[Bf-blender-cvs] [b2cb2a703a2] greasepencil-refactor: Merge branch 'greasepencil-object' into greasepencil-refactor
Commit: b2cb2a703a222d76ea18d8e15dc5229ae6a19747 Author: Antonio Vazquez Date: Thu Dec 19 08:57:38 2019 +0100 Branches: greasepencil-refactor https://developer.blender.org/rBb2cb2a703a222d76ea18d8e15dc5229ae6a19747 Merge branch 'greasepencil-object' into greasepencil-refactor === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [408565a8ddf] greasepencil-object: Merge branch 'master' into greasepencil-object
Commit: 408565a8ddfaed0a8034f7c916b26e0222173523 Author: Antonio Vazquez Date: Thu Dec 19 08:57:01 2019 +0100 Branches: greasepencil-object https://developer.blender.org/rB408565a8ddfaed0a8034f7c916b26e0222173523 Merge branch 'master' into greasepencil-object === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [96a3029ab9f] greasepencil-refactor: GPencil: Fix missing mask icon in Dopesheet
Commit: 96a3029ab9f0bb977cbc87d0853e542dd7ae5a5d Author: Antonio Vazquez Date: Thu Dec 19 08:55:41 2019 +0100 Branches: greasepencil-refactor https://developer.blender.org/rB96a3029ab9f0bb977cbc87d0853e542dd7ae5a5d GPencil: Fix missing mask icon in Dopesheet The new mask icon was not displayed in Dopesheet channel. === M source/blender/editors/animation/anim_channels_defines.c === diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index a3d8695d186..ec56b1d9d24 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -5092,7 +5092,15 @@ void ANIM_channel_draw_widgets(const bContext *C, prop = RNA_struct_find_property(, "mask_layer"); gp_rna_path = RNA_path_from_ID_to_property(, prop); if (RNA_path_resolve_property(_ptr, gp_rna_path, , )) { -icon = (gpl->flag & GP_LAYER_USE_MASK) ? ICON_MOD_MASK : ICON_LAYER_ACTIVE; +icon = ICON_LAYER_ACTIVE; +if (gpl->flag & GP_LAYER_USE_MASK) { + if (gpl->flag & GP_LAYER_MASK_INVERT) { +icon = ICON_HOLDOUT_ON; + } + else { +icon = ICON_MOD_MASK; + } +} uiDefAutoButR(block, , prop, ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [4440739699b] master: Fix T72236: UV Stretching Overlay
Commit: 4440739699bb237da8126168117e501aec770e89 Author: Jeroen Bakker Date: Wed Dec 18 16:10:01 2019 +0100 Branches: master https://developer.blender.org/rB4440739699bb237da8126168117e501aec770e89 Fix T72236: UV Stretching Overlay The ratio for area stretching was packed into an unsigned int, but could contain negative numbers. This flipped the negative numbers to high positive numbers and rendered the wrong color in the stretching overlay. I can remember during {T63755} I had to flip the sign to get the correct result, but couldn't find out why that was needed. Now I know. Reviewed By: fclem, mano-wii Differential Revision: https://developer.blender.org/D6440 === M source/blender/draw/intern/draw_cache_extract_mesh.c M source/blender/gpu/shaders/gpu_shader_2D_edituvs_stretch_vert.glsl === diff --git a/source/blender/draw/intern/draw_cache_extract_mesh.c b/source/blender/draw/intern/draw_cache_extract_mesh.c index 7d0cb7c7076..4bd0aac1ecc 100644 --- a/source/blender/draw/intern/draw_cache_extract_mesh.c +++ b/source/blender/draw/intern/draw_cache_extract_mesh.c @@ -2721,7 +2721,7 @@ static void *extract_stretch_area_init(const MeshRenderData *mr, void *buf) { static GPUVertFormat format = {0}; if (format.attr_len == 0) { -GPU_vertformat_attr_add(, "ratio", GPU_COMP_U16, 1, GPU_FETCH_INT_TO_FLOAT_UNIT); +GPU_vertformat_attr_add(, "ratio", GPU_COMP_I16, 1, GPU_FETCH_INT_TO_FLOAT_UNIT); } GPUVertBuf *vbo = buf; @@ -2788,7 +2788,7 @@ static void mesh_stretch_area_finish(const MeshRenderData *mr, void *buf, void * /* Convert in place to avoid an extra allocation */ uint16_t *poly_stretch = (uint16_t *)area_ratio; for (int p = 0; p < mr->poly_len; p++) { -poly_stretch[p] = area_ratio[p] * 65534.0f; +poly_stretch[p] = area_ratio[p] * SHRT_MAX; } /* Copy face data for each loop. */ diff --git a/source/blender/gpu/shaders/gpu_shader_2D_edituvs_stretch_vert.glsl b/source/blender/gpu/shaders/gpu_shader_2D_edituvs_stretch_vert.glsl index b0fa9eaed21..3254a7e1508 100644 --- a/source/blender/gpu/shaders/gpu_shader_2D_edituvs_stretch_vert.glsl +++ b/source/blender/gpu/shaders/gpu_shader_2D_edituvs_stretch_vert.glsl @@ -90,7 +90,7 @@ void main() stretch = stretch; stretch = 1.0 - stretch * stretch; #else - float stretch = 1.0 - area_ratio_to_stretch(ratio, totalAreaRatio, -totalAreaRatioInv); + float stretch = 1.0 - area_ratio_to_stretch(ratio, totalAreaRatio, totalAreaRatioInv); #endif ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [0971f56bac2] master: UI: use DPI scale for transform cursors
Commit: 0971f56bac242e983db4e089f11b2fd818a0b904 Author: Campbell Barton Date: Thu Dec 19 16:36:54 2019 +1100 Branches: master https://developer.blender.org/rB0971f56bac242e983db4e089f11b2fd818a0b904 UI: use DPI scale for transform cursors === M source/blender/editors/transform/transform.c === diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 42adf1ee456..719064ba1d6 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -1700,6 +1700,10 @@ static void drawArrow(ArrowDirection d, short offset, short length, short size) { immBegin(GPU_PRIM_LINES, 6); + offset = round_fl_to_short(UI_DPI_FAC * offset); + length = round_fl_to_short(UI_DPI_FAC * length); + size = round_fl_to_short(UI_DPI_FAC * size); + switch (d) { case LEFT: offset = -offset; @@ -1735,6 +1739,8 @@ static void drawArrow(ArrowDirection d, short offset, short length, short size) static void drawArrowHead(ArrowDirection d, short size) { + size = round_fl_to_short(UI_DPI_FAC * size); + immBegin(GPU_PRIM_LINES, 4); switch (d) { @@ -1762,8 +1768,10 @@ static void drawArrowHead(ArrowDirection d, short size) immEnd(); } -static void drawArc(float size, float angle_start, float angle_end, int segments) +static void drawArc(float angle_start, float angle_end, int segments, float size) { + segments = round_fl_to_int(segments * UI_DPI_FAC); + float delta = (angle_end - angle_start) / segments; float angle; int a; @@ -1816,6 +1824,9 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata) tmval[i] += offset[i]; } +GPU_line_smooth(true); +GPU_blend(true); + GPU_matrix_push(); /* Dashed lines first. */ @@ -1835,8 +1846,8 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata) immUniform2f("viewport_size", viewport_size[2], viewport_size[3]); immUniform1i("colors_len", 0); /* "simple" mode */ - immUniformThemeColor(TH_VIEW_OVERLAY); - immUniform1f("dash_width", 6.0f); + immUniformThemeColor3(TH_VIEW_OVERLAY); + immUniform1f("dash_width", 6.0f * UI_DPI_FAC); immUniform1f("dash_factor", 0.5f); immBegin(GPU_PRIM_LINES, 2); @@ -1855,7 +1866,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata) switch (t->helpline) { case HLP_SPRING: -immUniformThemeColor(TH_VIEW_OVERLAY); +immUniformThemeColor3(TH_VIEW_OVERLAY); GPU_matrix_translate_3fv(mval); GPU_matrix_rotate_axis(-RAD2DEGF(atan2f(cent[0] - tmval[0], cent[1] - tmval[1])), 'Z'); @@ -1865,7 +1876,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata) drawArrow(DOWN, 5, 10, 5); break; case HLP_HARROW: -immUniformThemeColor(TH_VIEW_OVERLAY); +immUniformThemeColor3(TH_VIEW_OVERLAY); GPU_matrix_translate_3fv(mval); GPU_line_width(3.0f); @@ -1873,7 +1884,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata) drawArrow(LEFT, 5, 10, 5); break; case HLP_VARROW: -immUniformThemeColor(TH_VIEW_OVERLAY); +immUniformThemeColor3(TH_VIEW_OVERLAY); GPU_matrix_translate_3fv(mval); @@ -1883,7 +1894,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata) break; case HLP_CARROW: { /* Draw arrow based on direction defined by custom-points. */ -immUniformThemeColor(TH_VIEW_OVERLAY); +immUniformThemeColor3(TH_VIEW_OVERLAY); GPU_matrix_translate_3fv(mval); @@ -1907,16 +1918,16 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata) float dx = tmval[0] - cent[0], dy = tmval[1] - cent[1]; float angle = atan2f(dy, dx); float dist = hypotf(dx, dy); -float delta_angle = min_ff(15.0f / dist, (float)M_PI / 4.0f); -float spacing_angle = min_ff(5.0f / dist, (float)M_PI / 12.0f); +float delta_angle = min_ff(15.0f / (dist / UI_DPI_FAC), (float)M_PI / 4.0f); +float spacing_angle = min_ff(5.0f / (dist / UI_DPI_FAC), (float)M_PI / 12.0f); -immUniformThemeColor(TH_VIEW_OVERLAY); +immUniformThemeColor3(TH_VIEW_OVERLAY); 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); +drawArc(angle - delta_angle, angle - spacing_angle, 10, dist); +drawArc(angle + spacing_angle, angle + delta_angle, 10, dist); GPU_matrix_push(); @@
[Bf-blender-cvs] [c14e352d2ce] master: Fix error in recent gizmo tweak workaround
Commit: c14e352d2ceb62288349bfc7afa4453d6cf38646 Author: Campbell Barton Date: Thu Dec 19 15:48:33 2019 +1100 Branches: master https://developer.blender.org/rBc14e352d2ceb62288349bfc7afa4453d6cf38646 Fix error in recent gizmo tweak workaround === M source/blender/windowmanager/gizmo/WM_gizmo_types.h M source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c === diff --git a/source/blender/windowmanager/gizmo/WM_gizmo_types.h b/source/blender/windowmanager/gizmo/WM_gizmo_types.h index fc876b56de7..c667dd564f7 100644 --- a/source/blender/windowmanager/gizmo/WM_gizmo_types.h +++ b/source/blender/windowmanager/gizmo/WM_gizmo_types.h @@ -461,12 +461,12 @@ typedef struct wmGizmoGroup { struct ReportList *reports; /** Has the same result as hiding all gizmos individually. */ - struct { -/* Reasons for hiding. */ -union { + union { +/** Reasons for hiding. */ +struct { uint delay_refresh_for_tweak : 1; }; -/* All, when we only want to check. */ +/** All, when we only want to check if any are hidden. */ uint any; } hide; diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c index f176f0e5df4..c3dfdd9a419 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c @@ -407,7 +407,7 @@ static void gizmomap_prepare_drawing(wmGizmoMap *gzmap, for (wmGizmoGroup *gzgroup = gzmap->groups.first; gzgroup; gzgroup = gzgroup->next) { /* check group visibility - drawstep first to avoid unnecessary call of group poll callback */ -if ((gzgroup->hide.any != 0) || !wm_gizmogroup_is_visible_in_drawstep(gzgroup, drawstep) || +if (!wm_gizmogroup_is_visible_in_drawstep(gzgroup, drawstep) || !WM_gizmo_group_type_poll(C, gzgroup->type)) { continue; } @@ -422,6 +422,11 @@ static void gizmomap_prepare_drawing(wmGizmoMap *gzmap, /* Calls `setup`, `setup_keymap` and `refresh` if they're defined. */ WM_gizmogroup_ensure_init(C, gzgroup); +/* Check after ensure which can run refresh and update this value. */ +if (gzgroup->hide.any != 0) { + continue; +} + /* prepare drawing */ if (gzgroup->type->draw_prepare) { gzgroup->type->draw_prepare(C, gzgroup); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [7ba1489bd72] master: Cleanup: use 'context' to make panels show in their section
Commit: 7ba1489bd7235a333a4f99040b3c9e7501bf346c Author: Campbell Barton Date: Thu Dec 19 13:21:41 2019 +1100 Branches: master https://developer.blender.org/rB7ba1489bd7235a333a4f99040b3c9e7501bf346c Cleanup: use 'context' to make panels show in their section All panels were calling poll to draw in their section causing a lot of repeated boiler plate poll functions. Also rename 'PreferencePanel' to 'CenterAlignMixIn' since this is it's purpose. === M release/scripts/startup/bl_ui/space_userpref.py M source/blender/editors/space_userpref/space_userpref.c M source/blender/makesrna/RNA_enum_types.h M source/blender/makesrna/intern/rna_userdef.c === diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py index fec76b045a4..9527c7f4de8 100644 --- a/release/scripts/startup/bl_ui/space_userpref.py +++ b/release/scripts/startup/bl_ui/space_userpref.py @@ -138,49 +138,49 @@ class USERPREF_PT_save_preferences(Panel): # Min-In Helpers # Panel mix-in. -class PreferencePanel: +class CenterAlignMixIn: """ Base class for panels to center align contents with some horizontal margin. -Deriving classes need to implement a ``draw_props(context, layout)`` function. +Deriving classes need to implement a ``draw_centered(context, layout)`` function. """ -bl_space_type = 'PREFERENCES' -bl_region_type = 'WINDOW' - def draw(self, context): layout = self.layout width = context.region.width ui_scale = context.preferences.system.ui_scale +# No horizontal margin if region is rather small. +is_wide = width > (350 * ui_scale) layout.use_property_split = True layout.use_property_decorate = False # No animation. row = layout.row() -if width > (350 * ui_scale): # No horizontal margin if region is rather small. +if is_wide: row.label() # Needed so col below is centered. col = row.column() col.ui_units_x = 50 -# draw_props implemented by deriving classes. -self.draw_props(context, col) +# Implemented by sub-classes. +self.draw_centered(context, col) -if width > (350 * ui_scale): # No horizontal margin if region is rather small. +if is_wide: row.label() # Needed so col above is centered. # - # Interface Panels -class USERPREF_PT_interface_display(PreferencePanel, Panel): -bl_label = "Display" +class InterfacePanel: +bl_space_type = 'PREFERENCES' +bl_region_type = 'WINDOW' +bl_context = "interface" -@classmethod -def poll(cls, context): -prefs = context.preferences -return (prefs.active_section == 'INTERFACE') -def draw_props(self, context, layout): +class USERPREF_PT_interface_display(InterfacePanel, CenterAlignMixIn, Panel): +bl_label = "Display" + +def draw_centered(self, context, layout): prefs = context.preferences view = prefs.view @@ -200,16 +200,11 @@ class USERPREF_PT_interface_display(PreferencePanel, Panel): flow.prop(view, "show_large_cursors") -class USERPREF_PT_interface_text(PreferencePanel, Panel): +class USERPREF_PT_interface_text(InterfacePanel, CenterAlignMixIn, Panel): bl_label = "Text Rendering" bl_options = {'DEFAULT_CLOSED'} -@classmethod -def poll(cls, context): -prefs = context.preferences -return (prefs.active_section == 'INTERFACE') - -def draw_props(self, context, layout): +def draw_centered(self, context, layout): prefs = context.preferences view = prefs.view @@ -224,14 +219,13 @@ class USERPREF_PT_interface_text(PreferencePanel, Panel): flow.prop(view, "font_path_ui_mono") -class USERPREF_PT_interface_translation(PreferencePanel, Panel): +class USERPREF_PT_interface_translation(InterfacePanel, CenterAlignMixIn, Panel): bl_label = "Translation" bl_translation_context = i18n_contexts.id_windowmanager @classmethod def poll(cls, context): -prefs = context.preferences -return (prefs.active_section == 'INTERFACE') and bpy.app.build_options.international +return bpy.app.build_options.international def draw_header(self, context): prefs = context.preferences @@ -239,7 +233,7 @@ class USERPREF_PT_interface_translation(PreferencePanel, Panel): self.layout.prop(view, "use_international_fonts", text="") -def draw_props(self, context, layout): +def draw_centered(self, context, layout): prefs = context.preferences view = prefs.view @@ -254,15 +248,10 @@ class USERPREF_PT_interface_translation(PreferencePanel, Panel):
[Bf-blender-cvs] [f98e2c0427c] master: Cleanup: add sections to preferences UI script
Commit: f98e2c0427c1dc5e2f1cac58cfb43b464013a33b Author: Campbell Barton Date: Thu Dec 19 13:20:37 2019 +1100 Branches: master https://developer.blender.org/rBf98e2c0427c1dc5e2f1cac58cfb43b464013a33b Cleanup: add sections to preferences UI script Makes navigating between sections easier, order some classes which were in the wrong section. === M release/scripts/startup/bl_ui/space_userpref.py === diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py index b670376c453..fec76b045a4 100644 --- a/release/scripts/startup/bl_ui/space_userpref.py +++ b/release/scripts/startup/bl_ui/space_userpref.py @@ -27,6 +27,9 @@ from bpy.app.translations import pgettext_iface as iface_ from bpy.app.translations import contexts as i18n_contexts +# - +# Main Header + class USERPREF_HT_header(Header): bl_space_type = 'PREFERENCES' @@ -60,6 +63,9 @@ class USERPREF_HT_header(Header): self.draw_buttons(layout, context) +# - +# Main Navigation Bar + class USERPREF_PT_navigation_bar(Panel): bl_label = "Preferences Navigation" bl_space_type = 'PREFERENCES' @@ -128,6 +134,9 @@ class USERPREF_PT_save_preferences(Panel): USERPREF_HT_header.draw_buttons(layout, context) +# - +# Min-In Helpers + # Panel mix-in. class PreferencePanel: """ @@ -160,6 +169,9 @@ class PreferencePanel: row.label() # Needed so col above is centered. +# - +# Interface Panels + class USERPREF_PT_interface_display(PreferencePanel, Panel): bl_label = "Display" @@ -340,6 +352,9 @@ class USERPREF_PT_interface_menus_pie(PreferencePanel, Panel): flow.prop(view, "pie_menu_confirm") +# - +# Editing Panels + class USERPREF_PT_edit_objects(Panel): bl_label = "Objects" bl_space_type = 'PREFERENCES' @@ -492,6 +507,9 @@ class USERPREF_PT_edit_misc(PreferencePanel, Panel): flow.prop(edit, "node_margin", text="Node Auto-offset Margin") +# - +# Animation Panels + class USERPREF_PT_animation_timeline(PreferencePanel, Panel): bl_label = "Timeline" @@ -575,6 +593,9 @@ class USERPREF_PT_animation_fcurves(PreferencePanel, Panel): flow.prop(edit, "use_insertkey_xyz_to_rgb", text="XYZ to RGB") +# - +# System Panels + class USERPREF_PT_system_sound(PreferencePanel, Panel): bl_label = "Sound" @@ -624,6 +645,50 @@ class USERPREF_PT_system_cycles_devices(PreferencePanel, Panel): # col.row().prop(system, "opensubdiv_compute_type", text="") +class USERPREF_PT_system_memory(PreferencePanel, Panel): +bl_label = "Memory & Limits" + +@classmethod +def poll(cls, context): +prefs = context.preferences +return (prefs.active_section == 'SYSTEM') + +def draw_props(self, context, layout): +prefs = context.preferences +system = prefs.system +edit = prefs.edit + +flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False) + +flow.prop(edit, "undo_steps", text="Undo Steps") +flow.prop(edit, "undo_memory_limit", text="Undo Memory Limit") +flow.prop(edit, "use_global_undo") + +layout.separator() + +flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False) + +flow.prop(system, "memory_cache_limit", text="Sequencer Cache Limit") +flow.prop(system, "scrollback", text="Console Scrollback Lines") + +layout.separator() + +flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False) + +flow.prop(system, "texture_time_out", text="Texture Time Out") +flow.prop(system, "texture_collection_rate", text="Garbage Collection Rate") + +layout.separator() + +flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False) + +flow.prop(system, "vbo_time_out", text="Vbo Time Out") +flow.prop(system, "vbo_collection_rate", text="Garbage Collection Rate") + + +# - +# Viewport Panels + class USERPREF_PT_viewport_display(PreferencePanel, Panel): bl_label = "Display" @@ -718,46 +783,8 @@ class
[Bf-blender-cvs] [27fa133435f] greasepencil-refactor: GPencil: Refactor: Add Flip FX
Commit: 27fa133435f7e3b6a96485225f7079bf423c9282 Author: Clément Foucault Date: Wed Dec 18 23:23:46 2019 +0100 Branches: greasepencil-refactor https://developer.blender.org/rB27fa133435f7e3b6a96485225f7079bf423c9282 GPencil: Refactor: Add Flip FX === M source/blender/draw/engines/gpencil/gpencil_engine.c M source/blender/draw/engines/gpencil/gpencil_engine.h M source/blender/draw/engines/gpencil/gpencil_shader.c M source/blender/draw/engines/gpencil/gpencil_shader_fx.c M source/blender/draw/engines/gpencil/shaders/gpencil_vfx_frag.glsl === diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c index 4fd6ca82a54..e66a77817b9 100644 --- a/source/blender/draw/engines/gpencil/gpencil_engine.c +++ b/source/blender/draw/engines/gpencil/gpencil_engine.c @@ -362,6 +362,7 @@ static void GPENCIL_engine_free(void) DRW_SHADER_FREE_SAFE(e_data.fx_blur_sh); DRW_SHADER_FREE_SAFE(e_data.fx_colorize_sh); DRW_SHADER_FREE_SAFE(e_data.fx_composite_sh); + DRW_SHADER_FREE_SAFE(e_data.fx_flip_sh); DRW_SHADER_FREE_SAFE(e_data.fx_glow_sh); DRW_SHADER_FREE_SAFE(e_data.fx_pixel_sh); DRW_SHADER_FREE_SAFE(e_data.fx_rim_sh); diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.h b/source/blender/draw/engines/gpencil/gpencil_engine.h index be5be0f2861..bc5196f5bae 100644 --- a/source/blender/draw/engines/gpencil/gpencil_engine.h +++ b/source/blender/draw/engines/gpencil/gpencil_engine.h @@ -472,6 +472,7 @@ typedef struct GPENCIL_e_data { /* Effects. */ struct GPUShader *fx_composite_sh; struct GPUShader *fx_colorize_sh; + struct GPUShader *fx_flip_sh; struct GPUShader *fx_blur_sh; struct GPUShader *fx_glow_sh; struct GPUShader *fx_pixel_sh; @@ -717,6 +718,7 @@ struct GPUShader *GPENCIL_shader_depth_merge_get(GPENCIL_e_data *e_data); struct GPUShader *GPENCIL_shader_fx_blur_get(GPENCIL_e_data *e_data); struct GPUShader *GPENCIL_shader_fx_colorize_get(GPENCIL_e_data *e_data); struct GPUShader *GPENCIL_shader_fx_composite_get(GPENCIL_e_data *e_data); +struct GPUShader *GPENCIL_shader_fx_flip_get(GPENCIL_e_data *e_data); struct GPUShader *GPENCIL_shader_fx_glow_get(GPENCIL_e_data *e_data); struct GPUShader *GPENCIL_shader_fx_pixelize_get(GPENCIL_e_data *e_data); struct GPUShader *GPENCIL_shader_fx_rim_get(GPENCIL_e_data *e_data); diff --git a/source/blender/draw/engines/gpencil/gpencil_shader.c b/source/blender/draw/engines/gpencil/gpencil_shader.c index 8f29c288cd8..20f81a16b16 100644 --- a/source/blender/draw/engines/gpencil/gpencil_shader.c +++ b/source/blender/draw/engines/gpencil/gpencil_shader.c @@ -175,6 +175,15 @@ struct GPUShader *GPENCIL_shader_fx_composite_get(GPENCIL_e_data *e_data) return e_data->fx_composite_sh; } +struct GPUShader *GPENCIL_shader_fx_flip_get(GPENCIL_e_data *e_data) +{ + if (!e_data->fx_flip_sh) { +e_data->fx_flip_sh = DRW_shader_create_fullscreen(datatoc_gpencil_vfx_frag_glsl, + "#define FLIP\n"); + } + return e_data->fx_flip_sh; +} + struct GPUShader *GPENCIL_shader_fx_glow_get(GPENCIL_e_data *e_data) { if (!e_data->fx_glow_sh) { diff --git a/source/blender/draw/engines/gpencil/gpencil_shader_fx.c b/source/blender/draw/engines/gpencil/gpencil_shader_fx.c index 38f4e831dd7..b96a291eb5f 100644 --- a/source/blender/draw/engines/gpencil/gpencil_shader_fx.c +++ b/source/blender/draw/engines/gpencil/gpencil_shader_fx.c @@ -1135,6 +1135,22 @@ static void gpencil_vfx_colorize(ColorizeShaderFxData *fx, Object *UNUSED(ob), g DRW_shgroup_call_procedural_triangles(grp, NULL, 1); } +static void gpencil_vfx_flip(FlipShaderFxData *fx, Object *UNUSED(ob), gpIterVfxData *iter) +{ + DRWShadingGroup *grp; + + float axis_flip[2]; + axis_flip[0] = (fx->flag & FX_FLIP_HORIZONTAL) ? -1.0f : 1.0f; + axis_flip[1] = (fx->flag & FX_FLIP_VERTICAL) ? -1.0f : 1.0f; + + GPUShader *sh = GPENCIL_shader_fx_flip_get(_data); + + DRWState state = DRW_STATE_WRITE_COLOR; + grp = gpencil_vfx_pass_create("Fx Flip", state, iter, sh); + DRW_shgroup_uniform_vec2_copy(grp, "axisFlip", axis_flip); + DRW_shgroup_call_procedural_triangles(grp, NULL, 1); +} + static void gpencil_vfx_rim(RimShaderFxData *fx, Object *ob, gpIterVfxData *iter) { DRWShadingGroup *grp; @@ -1437,6 +1453,7 @@ void gpencil_vfx_cache_populate(GPENCIL_Data *vedata, Object *ob, GPENCIL_tObjec gpencil_vfx_colorize((ColorizeShaderFxData *)fx, ob, ); break; case eShaderFxType_Flip: + gpencil_vfx_flip((FlipShaderFxData *)fx, ob, ); break; case eShaderFxType_Light: break; @@ -1455,6 +1472,7 @@ void gpencil_vfx_cache_populate(GPENCIL_Data *vedata, Object *ob, GPENCIL_tObjec case eShaderFxType_Swirl: break;
[Bf-blender-cvs] [0509f4149ea] greasepencil-refactor: GPencil: Refactor: Add Wave FX
Commit: 0509f4149ead4dde896089de9a66b91c7c07612c Author: Clément Foucault Date: Thu Dec 19 00:03:30 2019 +0100 Branches: greasepencil-refactor https://developer.blender.org/rB0509f4149ead4dde896089de9a66b91c7c07612c GPencil: Refactor: Add Wave FX Use the same shader as flip fx because we only transform the uvs and sample once. === M source/blender/draw/engines/gpencil/gpencil_engine.c M source/blender/draw/engines/gpencil/gpencil_engine.h M source/blender/draw/engines/gpencil/gpencil_shader.c M source/blender/draw/engines/gpencil/gpencil_shader_fx.c M source/blender/draw/engines/gpencil/shaders/gpencil_vfx_frag.glsl === diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c index e66a77817b9..5e5960c536b 100644 --- a/source/blender/draw/engines/gpencil/gpencil_engine.c +++ b/source/blender/draw/engines/gpencil/gpencil_engine.c @@ -362,11 +362,11 @@ static void GPENCIL_engine_free(void) DRW_SHADER_FREE_SAFE(e_data.fx_blur_sh); DRW_SHADER_FREE_SAFE(e_data.fx_colorize_sh); DRW_SHADER_FREE_SAFE(e_data.fx_composite_sh); - DRW_SHADER_FREE_SAFE(e_data.fx_flip_sh); DRW_SHADER_FREE_SAFE(e_data.fx_glow_sh); DRW_SHADER_FREE_SAFE(e_data.fx_pixel_sh); DRW_SHADER_FREE_SAFE(e_data.fx_rim_sh); DRW_SHADER_FREE_SAFE(e_data.fx_shadow_sh); + DRW_SHADER_FREE_SAFE(e_data.fx_transform_sh); DRW_TEXTURE_FREE_SAFE(e_data.gpencil_blank_texture); diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.h b/source/blender/draw/engines/gpencil/gpencil_engine.h index bc5196f5bae..a03897c4413 100644 --- a/source/blender/draw/engines/gpencil/gpencil_engine.h +++ b/source/blender/draw/engines/gpencil/gpencil_engine.h @@ -472,12 +472,12 @@ typedef struct GPENCIL_e_data { /* Effects. */ struct GPUShader *fx_composite_sh; struct GPUShader *fx_colorize_sh; - struct GPUShader *fx_flip_sh; struct GPUShader *fx_blur_sh; struct GPUShader *fx_glow_sh; struct GPUShader *fx_pixel_sh; struct GPUShader *fx_rim_sh; struct GPUShader *fx_shadow_sh; + struct GPUShader *fx_transform_sh; /* general drawing shaders */ struct GPUShader *gpencil_fill_sh; @@ -718,7 +718,7 @@ struct GPUShader *GPENCIL_shader_depth_merge_get(GPENCIL_e_data *e_data); struct GPUShader *GPENCIL_shader_fx_blur_get(GPENCIL_e_data *e_data); struct GPUShader *GPENCIL_shader_fx_colorize_get(GPENCIL_e_data *e_data); struct GPUShader *GPENCIL_shader_fx_composite_get(GPENCIL_e_data *e_data); -struct GPUShader *GPENCIL_shader_fx_flip_get(GPENCIL_e_data *e_data); +struct GPUShader *GPENCIL_shader_fx_transform_get(GPENCIL_e_data *e_data); struct GPUShader *GPENCIL_shader_fx_glow_get(GPENCIL_e_data *e_data); struct GPUShader *GPENCIL_shader_fx_pixelize_get(GPENCIL_e_data *e_data); struct GPUShader *GPENCIL_shader_fx_rim_get(GPENCIL_e_data *e_data); diff --git a/source/blender/draw/engines/gpencil/gpencil_shader.c b/source/blender/draw/engines/gpencil/gpencil_shader.c index 20f81a16b16..10ef5e193ba 100644 --- a/source/blender/draw/engines/gpencil/gpencil_shader.c +++ b/source/blender/draw/engines/gpencil/gpencil_shader.c @@ -141,31 +141,6 @@ struct GPUShader *GPENCIL_shader_fx_colorize_get(GPENCIL_e_data *e_data) return e_data->fx_colorize_sh; } -struct GPUShader *GPENCIL_shader_fx_rim_get(GPENCIL_e_data *e_data) -{ - if (!e_data->fx_rim_sh) { -e_data->fx_rim_sh = GPU_shader_create_from_arrays({ -.vert = -(const char *[]){ -datatoc_common_fullscreen_vert_glsl, -NULL, -}, -.frag = -(const char *[]){ -datatoc_gpencil_common_lib_glsl, -datatoc_gpencil_vfx_frag_glsl, -NULL, -}, -.defs = -(const char *[]){ -"#define RIM\n", -NULL, -}, -}); - } - return e_data->fx_rim_sh; -} - struct GPUShader *GPENCIL_shader_fx_composite_get(GPENCIL_e_data *e_data) { if (!e_data->fx_composite_sh) { @@ -175,15 +150,6 @@ struct GPUShader *GPENCIL_shader_fx_composite_get(GPENCIL_e_data *e_data) return e_data->fx_composite_sh; } -struct GPUShader *GPENCIL_shader_fx_flip_get(GPENCIL_e_data *e_data) -{ - if (!e_data->fx_flip_sh) { -e_data->fx_flip_sh = DRW_shader_create_fullscreen(datatoc_gpencil_vfx_frag_glsl, - "#define FLIP\n"); - } - return e_data->fx_flip_sh; -} - struct GPUShader *GPENCIL_shader_fx_glow_get(GPENCIL_e_data *e_data) { if (!e_data->fx_glow_sh) { @@ -202,6 +168,31 @@ struct GPUShader *GPENCIL_shader_fx_pixelize_get(GPENCIL_e_data *e_data) return e_data->fx_pixel_sh; } +struct GPUShader *GPENCIL_shader_fx_rim_get(GPENCIL_e_data *e_data) +{ + if (!e_data->fx_rim_sh) { +e_data->fx_rim_sh =
[Bf-blender-cvs] [0cc5a2bfd19] greasepencil-refactor: GPencil: Refactor: Add Swirl FX
Commit: 0cc5a2bfd19578a57209b4513b44321bbe309982 Author: Clément Foucault Date: Thu Dec 19 01:17:27 2019 +0100 Branches: greasepencil-refactor https://developer.blender.org/rB0cc5a2bfd19578a57209b4513b44321bbe309982 GPencil: Refactor: Add Swirl FX The angle is no longer mulitplied by 8. We need to change the UI and patch old files to preserve an appropriate slider feeling. The Swirl FX (like others) is now affected by distance of the source object. Transparent option has not been reimplemented as you can use masking for that. === M source/blender/draw/engines/gpencil/gpencil_shader_fx.c M source/blender/draw/engines/gpencil/shaders/gpencil_vfx_frag.glsl === diff --git a/source/blender/draw/engines/gpencil/gpencil_shader_fx.c b/source/blender/draw/engines/gpencil/gpencil_shader_fx.c index e6de1c2c030..8d50d279a81 100644 --- a/source/blender/draw/engines/gpencil/gpencil_shader_fx.c +++ b/source/blender/draw/engines/gpencil/gpencil_shader_fx.c @@ -1149,6 +1149,7 @@ static void gpencil_vfx_flip(FlipShaderFxData *fx, Object *UNUSED(ob), gpIterVfx grp = gpencil_vfx_pass_create("Fx Flip", state, iter, sh); DRW_shgroup_uniform_vec2_copy(grp, "axisFlip", axis_flip); DRW_shgroup_uniform_vec2_copy(grp, "waveOffset", (float[2]){0.0f, 0.0f}); + DRW_shgroup_uniform_float_copy(grp, "swirlRadius", 0.0f); DRW_shgroup_call_procedural_triangles(grp, NULL, 1); } @@ -1437,12 +1438,9 @@ static void gpencil_vfx_wave(WaveShaderFxData *fx, Object *ob, gpIterVfxData *it DRW_view_persmat_get(NULL, persmat, false); const float *vp_size = DRW_viewport_size_get(); const float *vp_size_inv = DRW_viewport_invert_size_get(); - const float ratio = vp_size_inv[1] / vp_size_inv[0]; - - copy_v3_v3(wave_center, ob->obmat[3]); - const float w = fabsf(mul_project_m4_v3_zfac(persmat, wave_center)); - mul_v3_m4v3(wave_center, persmat, wave_center); + const float w = fabsf(mul_project_m4_v3_zfac(persmat, ob->obmat[3])); + mul_v3_m4v3(wave_center, persmat, ob->obmat[3]); mul_v3_fl(wave_center, 1.0f / w); /* Modify by distance to camera and object scale. */ @@ -1481,6 +1479,52 @@ static void gpencil_vfx_wave(WaveShaderFxData *fx, Object *ob, gpIterVfxData *it DRW_shgroup_uniform_vec2_copy(grp, "waveDir", wave_dir); DRW_shgroup_uniform_vec2_copy(grp, "waveOffset", wave_ofs); DRW_shgroup_uniform_float_copy(grp, "wavePhase", wave_phase); + DRW_shgroup_uniform_float_copy(grp, "swirlRadius", 0.0f); + DRW_shgroup_call_procedural_triangles(grp, NULL, 1); +} + +static void gpencil_vfx_swirl(SwirlShaderFxData *fx, Object *UNUSED(ob), gpIterVfxData *iter) +{ + DRWShadingGroup *grp; + + if (fx->object == NULL) { +return; + } + + float winmat[4][4], persmat[4][4], swirl_center[3]; + DRW_view_winmat_get(NULL, winmat, false); + DRW_view_persmat_get(NULL, persmat, false); + const float *vp_size = DRW_viewport_size_get(); + + copy_v3_v3(swirl_center, fx->object->obmat[3]); + + const float w = fabsf(mul_project_m4_v3_zfac(persmat, swirl_center)); + mul_v3_m4v3(swirl_center, persmat, swirl_center); + mul_v3_fl(swirl_center, 1.0f / w); + + /* Modify by distance to camera and object scale. */ + float world_pixel_scale = 1.0f / 2000.0f; + float scale = mat4_to_scale(fx->object->obmat); + float distance_factor = (world_pixel_scale * scale * winmat[1][1] * vp_size[1]) / w; + + mul_v2_fl(swirl_center, 0.5f); + add_v2_fl(swirl_center, 0.5f); + mul_v2_v2(swirl_center, vp_size); + + float radius = fx->radius * distance_factor; + if (radius < 1.0f) { +return; + } + + GPUShader *sh = GPENCIL_shader_fx_transform_get(_data); + + DRWState state = DRW_STATE_WRITE_COLOR; + grp = gpencil_vfx_pass_create("Fx Flip", state, iter, sh); + DRW_shgroup_uniform_vec2_copy(grp, "axisFlip", (float[2]){1.0f, 1.0f}); + DRW_shgroup_uniform_vec2_copy(grp, "waveOffset", (float[2]){0.0f, 0.0f}); + DRW_shgroup_uniform_vec2_copy(grp, "swirlCenter", swirl_center); + DRW_shgroup_uniform_float_copy(grp, "swirlAngle", fx->angle); + DRW_shgroup_uniform_float_copy(grp, "swirlRadius", radius); DRW_shgroup_call_procedural_triangles(grp, NULL, 1); } @@ -1528,6 +1572,7 @@ void gpencil_vfx_cache_populate(GPENCIL_Data *vedata, Object *ob, GPENCIL_tObjec gpencil_vfx_glow((GlowShaderFxData *)fx, ob, ); break; case eShaderFxType_Swirl: + gpencil_vfx_swirl((SwirlShaderFxData *)fx, ob, ); break; case eShaderFxType_Wave: gpencil_vfx_wave((WaveShaderFxData *)fx, ob, ); diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_vfx_frag.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_vfx_frag.glsl index ce6987cd6f6..860dae08dde 100644 --- a/source/blender/draw/engines/gpencil/shaders/gpencil_vfx_frag.glsl +++ b/source/blender/draw/engines/gpencil/shaders/gpencil_vfx_frag.glsl @@ -112,6
[Bf-blender-cvs] [d56f1a5f446] greasepencil-refactor: GPencil: Refactor: Add Rim FX
Commit: d56f1a5f446cad754382b98bafb621a34c0199a1 Author: Clément Foucault Date: Wed Dec 18 23:08:57 2019 +0100 Branches: greasepencil-refactor https://developer.blender.org/rBd56f1a5f446cad754382b98bafb621a34c0199a1 GPencil: Refactor: Add Rim FX Nothing has changed functionality wise. === M source/blender/draw/engines/gpencil/gpencil_engine.c M source/blender/draw/engines/gpencil/gpencil_engine.h M source/blender/draw/engines/gpencil/gpencil_shader.c M source/blender/draw/engines/gpencil/gpencil_shader_fx.c M source/blender/draw/engines/gpencil/shaders/gpencil_vfx_frag.glsl === diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c index 39fab08dae8..4fd6ca82a54 100644 --- a/source/blender/draw/engines/gpencil/gpencil_engine.c +++ b/source/blender/draw/engines/gpencil/gpencil_engine.c @@ -364,6 +364,7 @@ static void GPENCIL_engine_free(void) DRW_SHADER_FREE_SAFE(e_data.fx_composite_sh); DRW_SHADER_FREE_SAFE(e_data.fx_glow_sh); DRW_SHADER_FREE_SAFE(e_data.fx_pixel_sh); + DRW_SHADER_FREE_SAFE(e_data.fx_rim_sh); DRW_SHADER_FREE_SAFE(e_data.fx_shadow_sh); DRW_TEXTURE_FREE_SAFE(e_data.gpencil_blank_texture); diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.h b/source/blender/draw/engines/gpencil/gpencil_engine.h index 2df8688f0d1..be5be0f2861 100644 --- a/source/blender/draw/engines/gpencil/gpencil_engine.h +++ b/source/blender/draw/engines/gpencil/gpencil_engine.h @@ -475,6 +475,7 @@ typedef struct GPENCIL_e_data { struct GPUShader *fx_blur_sh; struct GPUShader *fx_glow_sh; struct GPUShader *fx_pixel_sh; + struct GPUShader *fx_rim_sh; struct GPUShader *fx_shadow_sh; /* general drawing shaders */ @@ -718,6 +719,7 @@ struct GPUShader *GPENCIL_shader_fx_colorize_get(GPENCIL_e_data *e_data); struct GPUShader *GPENCIL_shader_fx_composite_get(GPENCIL_e_data *e_data); struct GPUShader *GPENCIL_shader_fx_glow_get(GPENCIL_e_data *e_data); struct GPUShader *GPENCIL_shader_fx_pixelize_get(GPENCIL_e_data *e_data); +struct GPUShader *GPENCIL_shader_fx_rim_get(GPENCIL_e_data *e_data); struct GPUShader *GPENCIL_shader_fx_shadow_get(GPENCIL_e_data *e_data); /* main functions */ diff --git a/source/blender/draw/engines/gpencil/gpencil_shader.c b/source/blender/draw/engines/gpencil/gpencil_shader.c index 60bfdf9ccce..8f29c288cd8 100644 --- a/source/blender/draw/engines/gpencil/gpencil_shader.c +++ b/source/blender/draw/engines/gpencil/gpencil_shader.c @@ -141,6 +141,31 @@ struct GPUShader *GPENCIL_shader_fx_colorize_get(GPENCIL_e_data *e_data) return e_data->fx_colorize_sh; } +struct GPUShader *GPENCIL_shader_fx_rim_get(GPENCIL_e_data *e_data) +{ + if (!e_data->fx_rim_sh) { +e_data->fx_rim_sh = GPU_shader_create_from_arrays({ +.vert = +(const char *[]){ +datatoc_common_fullscreen_vert_glsl, +NULL, +}, +.frag = +(const char *[]){ +datatoc_gpencil_common_lib_glsl, +datatoc_gpencil_vfx_frag_glsl, +NULL, +}, +.defs = +(const char *[]){ +"#define RIM\n", +NULL, +}, +}); + } + return e_data->fx_rim_sh; +} + struct GPUShader *GPENCIL_shader_fx_composite_get(GPENCIL_e_data *e_data) { if (!e_data->fx_composite_sh) { diff --git a/source/blender/draw/engines/gpencil/gpencil_shader_fx.c b/source/blender/draw/engines/gpencil/gpencil_shader_fx.c index fe33113bd6f..95f69b1467e 100644 --- a/source/blender/draw/engines/gpencil/gpencil_shader_fx.c +++ b/source/blender/draw/engines/gpencil/gpencil_shader_fx.c @@ -1135,6 +1135,78 @@ static void gpencil_vfx_colorize(ColorizeShaderFxData *fx, Object *UNUSED(ob), g DRW_shgroup_call_procedural_triangles(grp, NULL, 1); } +static void gpencil_vfx_rim(RimShaderFxData *fx, Object *ob, gpIterVfxData *iter) +{ + DRWShadingGroup *grp; + + float winmat[4][4], persmat[4][4]; + float offset[2] = {fx->offset[0], fx->offset[1]}; + float blur_size[2] = {fx->blur[0], fx->blur[1]}; + DRW_view_winmat_get(NULL, winmat, false); + DRW_view_persmat_get(NULL, persmat, false); + const float *vp_size = DRW_viewport_size_get(); + const float *vp_size_inv = DRW_viewport_invert_size_get(); + + const float w = fabsf(mul_project_m4_v3_zfac(persmat, ob->obmat[3])); + + /* Modify by distance to camera and object scale. */ + float world_pixel_scale = 1.0f / 2000.0f; + float scale = mat4_to_scale(ob->obmat); + float distance_factor = (world_pixel_scale * scale * winmat[1][1] * vp_size[1]) / w; + mul_v2_fl(offset, distance_factor); + mul_v2_v2(offset, vp_size_inv); + mul_v2_fl(blur_size, distance_factor); + + GPUShader *sh = GPENCIL_shader_fx_rim_get(_data); + + DRWState state =
[Bf-blender-cvs] [7359bec21b2] greasepencil-refactor: GPencil: Refactor: Add Colorize FX
Commit: 7359bec21b2be5d284ba8a5630bfa2642ba55cad Author: Clément Foucault Date: Wed Dec 18 19:50:58 2019 +0100 Branches: greasepencil-refactor https://developer.blender.org/rB7359bec21b2be5d284ba8a5630bfa2642ba55cad GPencil: Refactor: Add Colorize FX The behavior has been changed quite a bit to work with separated transparency layer. - The custom mode now just blend between the original image and the same image with the color changed and luma kept as is. - Grayscale & Sepia mode now blend with the original image using the factor. - The duo tone do not do a sharp separation of colors. It just color the original in 2 different color using a hard separation threshold. === M source/blender/draw/engines/gpencil/gpencil_engine.c M source/blender/draw/engines/gpencil/gpencil_engine.h M source/blender/draw/engines/gpencil/gpencil_shader.c M source/blender/draw/engines/gpencil/gpencil_shader_fx.c M source/blender/draw/engines/gpencil/shaders/gpencil_vfx_frag.glsl === diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c index 85b125d0783..39fab08dae8 100644 --- a/source/blender/draw/engines/gpencil/gpencil_engine.c +++ b/source/blender/draw/engines/gpencil/gpencil_engine.c @@ -360,6 +360,7 @@ static void GPENCIL_engine_free(void) DRW_SHADER_FREE_SAFE(e_data.depth_merge_sh); DRW_SHADER_FREE_SAFE(e_data.fx_blur_sh); + DRW_SHADER_FREE_SAFE(e_data.fx_colorize_sh); DRW_SHADER_FREE_SAFE(e_data.fx_composite_sh); DRW_SHADER_FREE_SAFE(e_data.fx_glow_sh); DRW_SHADER_FREE_SAFE(e_data.fx_pixel_sh); diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.h b/source/blender/draw/engines/gpencil/gpencil_engine.h index 8c5393a40d0..2df8688f0d1 100644 --- a/source/blender/draw/engines/gpencil/gpencil_engine.h +++ b/source/blender/draw/engines/gpencil/gpencil_engine.h @@ -471,6 +471,7 @@ typedef struct GPENCIL_e_data { struct GPUShader *depth_merge_sh; /* Effects. */ struct GPUShader *fx_composite_sh; + struct GPUShader *fx_colorize_sh; struct GPUShader *fx_blur_sh; struct GPUShader *fx_glow_sh; struct GPUShader *fx_pixel_sh; @@ -713,6 +714,7 @@ struct GPUShader *GPENCIL_shader_layer_blend_get(GPENCIL_e_data *e_data); struct GPUShader *GPENCIL_shader_layer_mask_get(GPENCIL_e_data *e_data); struct GPUShader *GPENCIL_shader_depth_merge_get(GPENCIL_e_data *e_data); struct GPUShader *GPENCIL_shader_fx_blur_get(GPENCIL_e_data *e_data); +struct GPUShader *GPENCIL_shader_fx_colorize_get(GPENCIL_e_data *e_data); struct GPUShader *GPENCIL_shader_fx_composite_get(GPENCIL_e_data *e_data); struct GPUShader *GPENCIL_shader_fx_glow_get(GPENCIL_e_data *e_data); struct GPUShader *GPENCIL_shader_fx_pixelize_get(GPENCIL_e_data *e_data); diff --git a/source/blender/draw/engines/gpencil/gpencil_shader.c b/source/blender/draw/engines/gpencil/gpencil_shader.c index 0590ea2824f..7533ebff48f 100644 --- a/source/blender/draw/engines/gpencil/gpencil_shader.c +++ b/source/blender/draw/engines/gpencil/gpencil_shader.c @@ -121,6 +121,15 @@ struct GPUShader *GPENCIL_shader_fx_blur_get(GPENCIL_e_data *e_data) return e_data->fx_blur_sh; } +struct GPUShader *GPENCIL_shader_fx_colorize_get(GPENCIL_e_data *e_data) +{ + if (!e_data->fx_colorize_sh) { +e_data->fx_colorize_sh = DRW_shader_create_fullscreen(datatoc_gpencil_vfx_frag_glsl, + "#define COLORIZE\n"); + } + return e_data->fx_colorize_sh; +} + struct GPUShader *GPENCIL_shader_fx_composite_get(GPENCIL_e_data *e_data) { if (!e_data->fx_composite_sh) { diff --git a/source/blender/draw/engines/gpencil/gpencil_shader_fx.c b/source/blender/draw/engines/gpencil/gpencil_shader_fx.c index 16917593242..fe33113bd6f 100644 --- a/source/blender/draw/engines/gpencil/gpencil_shader_fx.c +++ b/source/blender/draw/engines/gpencil/gpencil_shader_fx.c @@ -1120,6 +1120,21 @@ static void gpencil_vfx_blur(BlurShaderFxData *fx, Object *UNUSED(ob), gpIterVfx DRW_shgroup_call_procedural_triangles(grp, NULL, 1); } +static void gpencil_vfx_colorize(ColorizeShaderFxData *fx, Object *UNUSED(ob), gpIterVfxData *iter) +{ + DRWShadingGroup *grp; + + GPUShader *sh = GPENCIL_shader_fx_colorize_get(_data); + + DRWState state = DRW_STATE_WRITE_COLOR; + grp = gpencil_vfx_pass_create("Fx Colorize", state, iter, sh); + DRW_shgroup_uniform_vec3_copy(grp, "low_color", fx->low_color); + DRW_shgroup_uniform_vec3_copy(grp, "high_color", fx->high_color); + DRW_shgroup_uniform_float_copy(grp, "factor", fx->factor); + DRW_shgroup_uniform_int_copy(grp, "mode", fx->mode); + DRW_shgroup_call_procedural_triangles(grp, NULL, 1); +} + static void gpencil_vfx_pixelize(PixelShaderFxData *fx, Object *ob, gpIterVfxData *iter) { DRWShadingGroup *grp; @@ -1347,6 +1362,7 @@ void
[Bf-blender-cvs] [c2d56d7caa5] greasepencil-refactor: Cleanup: GPencil: CamelCase for uniform and fix a wrong comparison
Commit: c2d56d7caa595df771f5fd74d6286b64cb51217d Author: Clément Foucault Date: Wed Dec 18 23:09:51 2019 +0100 Branches: greasepencil-refactor https://developer.blender.org/rBc2d56d7caa595df771f5fd74d6286b64cb51217d Cleanup: GPencil: CamelCase for uniform and fix a wrong comparison === M source/blender/draw/engines/gpencil/gpencil_shader_fx.c M source/blender/draw/engines/gpencil/shaders/gpencil_vfx_frag.glsl === diff --git a/source/blender/draw/engines/gpencil/gpencil_shader_fx.c b/source/blender/draw/engines/gpencil/gpencil_shader_fx.c index 95f69b1467e..38f4e831dd7 100644 --- a/source/blender/draw/engines/gpencil/gpencil_shader_fx.c +++ b/source/blender/draw/engines/gpencil/gpencil_shader_fx.c @@ -1128,8 +1128,8 @@ static void gpencil_vfx_colorize(ColorizeShaderFxData *fx, Object *UNUSED(ob), g DRWState state = DRW_STATE_WRITE_COLOR; grp = gpencil_vfx_pass_create("Fx Colorize", state, iter, sh); - DRW_shgroup_uniform_vec3_copy(grp, "low_color", fx->low_color); - DRW_shgroup_uniform_vec3_copy(grp, "high_color", fx->high_color); + DRW_shgroup_uniform_vec3_copy(grp, "lowColor", fx->low_color); + DRW_shgroup_uniform_vec3_copy(grp, "highColor", fx->high_color); DRW_shgroup_uniform_float_copy(grp, "factor", fx->factor); DRW_shgroup_uniform_int_copy(grp, "mode", fx->mode); DRW_shgroup_call_procedural_triangles(grp, NULL, 1); diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_vfx_frag.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_vfx_frag.glsl index a7a3c4a6a27..3449e439c99 100644 --- a/source/blender/draw/engines/gpencil/shaders/gpencil_vfx_frag.glsl +++ b/source/blender/draw/engines/gpencil/shaders/gpencil_vfx_frag.glsl @@ -35,8 +35,8 @@ void main() #elif defined(COLORIZE) -uniform vec3 low_color; -uniform vec3 high_color; +uniform vec3 lowColor; +uniform vec3 highColor; uniform float factor; uniform int mode; @@ -65,10 +65,10 @@ void main() fragColor.rgb = mix(fragColor.rgb, sepia_mat * fragColor.rgb, factor); break; case MODE_DUOTONE: - fragColor.rgb = luma * ((luma <= factor) ? low_color : high_color); + fragColor.rgb = luma * ((luma <= factor) ? lowColor : highColor); break; case MODE_CUSTOM: - fragColor.rgb = mix(fragColor.rgb, luma * low_color, factor); + fragColor.rgb = mix(fragColor.rgb, luma * lowColor, factor); break; case MODE_TRANSPARENT: default: @@ -133,7 +133,7 @@ void main() vec3 col = texture(colorBuf, uv).rgb; if (threshold.x > -1.0) { if (threshold.y > -1.0) { -if (all(lessThan(vec3(0.05), abs(col - threshold { +if (all(lessThan(abs(col - threshold), vec3(0.05 { weight = 0.0; } } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [c42ceb93c93] greasepencil-refactor: GPencil: Refactor: Put blend mode shader code into gpencil_common_lib.glsl
Commit: c42ceb93c93fcc2692733954d895e1b14955fb74 Author: Clément Foucault Date: Wed Dec 18 23:07:38 2019 +0100 Branches: greasepencil-refactor https://developer.blender.org/rBc42ceb93c93fcc2692733954d895e1b14955fb74 GPencil: Refactor: Put blend mode shader code into gpencil_common_lib.glsl This is because the rim fx needs the same code. === M source/blender/draw/engines/gpencil/gpencil_shader.c M source/blender/draw/engines/gpencil/shaders/gpencil_common_lib.glsl M source/blender/draw/engines/gpencil/shaders/gpencil_layer_blend_frag.glsl === diff --git a/source/blender/draw/engines/gpencil/gpencil_shader.c b/source/blender/draw/engines/gpencil/gpencil_shader.c index 7533ebff48f..60bfdf9ccce 100644 --- a/source/blender/draw/engines/gpencil/gpencil_shader.c +++ b/source/blender/draw/engines/gpencil/gpencil_shader.c @@ -75,8 +75,19 @@ struct GPUShader *GPENCIL_shader_composite_get(GPENCIL_e_data *e_data) struct GPUShader *GPENCIL_shader_layer_blend_get(GPENCIL_e_data *e_data) { if (!e_data->layer_blend_sh) { -e_data->layer_blend_sh = DRW_shader_create_fullscreen(datatoc_gpencil_layer_blend_frag_glsl, - NULL); +e_data->layer_blend_sh = GPU_shader_create_from_arrays({ +.vert = +(const char *[]){ +datatoc_common_fullscreen_vert_glsl, +NULL, +}, +.frag = +(const char *[]){ +datatoc_gpencil_common_lib_glsl, +datatoc_gpencil_layer_blend_frag_glsl, +NULL, +}, +}); } return e_data->layer_blend_sh; } diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_common_lib.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_common_lib.glsl index 319bf7cbb07..690cbb2298c 100644 --- a/source/blender/draw/engines/gpencil/shaders/gpencil_common_lib.glsl +++ b/source/blender/draw/engines/gpencil/shaders/gpencil_common_lib.glsl @@ -35,7 +35,71 @@ struct gpMaterial { #define GP_FLAG_TEST(flag, val) (((flag) & (val)) != 0) +#ifdef GPENCIL_MATERIAL_BUFFER_LEN + layout(std140) uniform gpMaterialBlock { gpMaterial materials[GPENCIL_MATERIAL_BUFFER_LEN]; }; + +#endif + +/* Must match eGPLayerBlendModes */ +#define MODE_REGULAR 0 +#define MODE_OVERLAY 1 +#define MODE_ADD 2 +#define MODE_SUB 3 +#define MODE_MULTIPLY 4 +#define MODE_DIVIDE 5 +#define MODE_OVERLAY_SECOND_PASS 999 + +void blend_mode_output( +int blend_mode, vec4 color, float opacity, out vec4 frag_color, out vec4 frag_revealage) +{ + switch (blend_mode) { +case MODE_REGULAR: + /* Reminder: Blending func is premult alpha blend (dst.rgba * (1 - src.a) + src.rgb).*/ + color *= opacity; + frag_color = color; + frag_revealage = vec4(0.0, 0.0, 0.0, color.a); + break; +case MODE_MULTIPLY: + /* Reminder: Blending func is multiply blend (dst.rgba * src.rgba).*/ + color.a *= opacity; + frag_revealage = frag_color = (1.0 - color.a) + color.a * color; + break; +case MODE_DIVIDE: + /* Reminder: Blending func is multiply blend (dst.rgba * src.rgba).*/ + color.a *= opacity; + frag_revealage = frag_color = clamp(1.0 / (1.0 - color * color.a), 0.0, 1e18); + break; +case MODE_OVERLAY: + /* Reminder: Blending func is multiply blend (dst.rgba * src.rgba).*/ + /** + * We need to separate the overlay equation into 2 term (one mul and one add). + * This is the standard overlay equation (per channel): + * rtn = (src < 0.5) ? (2.0 * src * dst) : (1.0 - 2.0 * (1.0 - src) * (1.0 - dst)); + * We rewrite the second branch like this: + * rtn = 1 - 2 * (1 - src) * (1 - dst); + * rtn = 1 - 2 (1 - dst + src * dst - src); + * rtn = 1 - 2 (1 - dst * (1 - src) - src); + * rtn = 1 - 2 + dst * (2 - 2 * src) + 2 * src; + * rtn = (- 1 + 2 * src) + dst * (2 - 2 * src); + **/ + color = mix(vec4(0.5), color, color.a * opacity); + vec4 s = step(-0.5, -color); + frag_revealage = frag_color = 2.0 * s + 2.0 * color * (1.0 - s * 2.0); + break; +case MODE_OVERLAY_SECOND_PASS: + /* Reminder: Blending func is additive blend (dst.rgba + src.rgba).*/ + color = mix(vec4(0.5), color, color.a * opacity); + frag_revealage = frag_color = (-1.0 + 2.0 * color) * step(-0.5, -color); + break; +case MODE_SUB: +case MODE_ADD: + /* Reminder: Blending func is additive / subtractive blend (dst.rgba +/- src.rgba).*/ + frag_color = color * color.a * opacity; + frag_revealage = vec4(0.0); + break; + } +} \ No newline at end of file diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_layer_blend_frag.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_layer_blend_frag.glsl index
[Bf-blender-cvs] [da6929488a6] master: Fix panel for USD experimental showing for all sections
Commit: da6929488a6494d85d7d9035063c279c3f03765a Author: Campbell Barton Date: Thu Dec 19 09:47:13 2019 +1100 Branches: master https://developer.blender.org/rBda6929488a6494d85d7d9035063c279c3f03765a Fix panel for USD experimental showing for all sections === M release/scripts/startup/bl_ui/space_userpref.py === diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py index ae77b9df01b..b670376c453 100644 --- a/release/scripts/startup/bl_ui/space_userpref.py +++ b/release/scripts/startup/bl_ui/space_userpref.py @@ -2227,8 +2227,10 @@ class USERPREF_PT_experimental_usd(ExperimentalPanel, Panel): @classmethod def poll(cls, context): +if not super().poll(context): +return False # Only show the panel if Blender was actually built with USD support. -return getattr(bpy.app.build_options, 'usd', False) +return getattr(bpy.app.build_options, "usd", False) def draw_props(self, context, layout): prefs = context.preferences ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [6f6c25c681b] greasepencil-refactor: GPencil: Set default VFX Shadow color to Gray
Commit: 6f6c25c681bbce5769e826d74e910c6bce9c8445 Author: Antonio Vazquez Date: Wed Dec 18 19:16:14 2019 +0100 Branches: greasepencil-refactor https://developer.blender.org/rB6f6c25c681bbce5769e826d74e910c6bce9c8445 GPencil: Set default VFX Shadow color to Gray === M source/blender/shader_fx/intern/FX_shader_shadow.c === diff --git a/source/blender/shader_fx/intern/FX_shader_shadow.c b/source/blender/shader_fx/intern/FX_shader_shadow.c index 04160f618eb..68d23d65181 100644 --- a/source/blender/shader_fx/intern/FX_shader_shadow.c +++ b/source/blender/shader_fx/intern/FX_shader_shadow.c @@ -44,7 +44,7 @@ static void initData(ShaderFxData *md) gpfx->rotation = 0.0f; ARRAY_SET_ITEMS(gpfx->offset, 15, 20); ARRAY_SET_ITEMS(gpfx->scale, 1.0f, 1.0f); - ARRAY_SET_ITEMS(gpfx->shadow_rgba, 0.54f, 0.62f, 1.0f, 0.9f); + ARRAY_SET_ITEMS(gpfx->shadow_rgba, 0.0f, 0.0f, 0.0f, 0.8f); gpfx->amplitude = 10.0f; gpfx->period = 20.0f; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [9ae097e239a] master: Animation: Clarified tooltip for Viewport Render Animation
Commit: 9ae097e239a943a9b409155b943bc5510d14d9c8 Author: Sybren A. Stüvel Date: Wed Dec 18 15:17:51 2019 +0100 Branches: master https://developer.blender.org/rB9ae097e239a943a9b409155b943bc5510d14d9c8 Animation: Clarified tooltip for Viewport Render Animation The tooltip was static, so it was the same for viewport-rendering the current frame and for the entire animation. It is now different for those two. The structure of `screen_opengl_render_description()` is such that it allows for adding a new description for a soon-to-come feature (T72229). === M source/blender/editors/render/render_opengl.c === diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c index 10244cfa3fd..b46b8cdda89 100644 --- a/source/blender/editors/render/render_opengl.c +++ b/source/blender/editors/render/render_opengl.c @@ -1124,6 +1124,17 @@ static int screen_opengl_render_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } +static char *screen_opengl_render_description(struct bContext *UNUSED(C), + struct wmOperatorType *UNUSED(ot), + struct PointerRNA *ptr) +{ + if (!RNA_boolean_get(ptr, "animation")) { +return NULL; + } + + return BLI_strdup("Render the viewport for the animation range of this scene"); +} + void RENDER_OT_opengl(wmOperatorType *ot) { PropertyRNA *prop; @@ -1134,6 +1145,7 @@ void RENDER_OT_opengl(wmOperatorType *ot) ot->idname = "RENDER_OT_opengl"; /* api callbacks */ + ot->get_description = screen_opengl_render_description; ot->invoke = screen_opengl_render_invoke; ot->exec = screen_opengl_render_exec; /* blocking */ ot->modal = screen_opengl_render_modal; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [d591c8a3503] master: Gizmo: add the ability to postpone refreshing while tweaking
Commit: d591c8a350310e69d4db23759847fb0df2ff23ae Author: Campbell Barton Date: Thu Dec 19 01:27:23 2019 +1100 Branches: master https://developer.blender.org/rBd591c8a350310e69d4db23759847fb0df2ff23ae Gizmo: add the ability to postpone refreshing while tweaking This resolves a logical problem using tweak as a fallback tool. See: T66304#828742 The select action would immediately show the gizmo underneath it, then the tweak would be handled by the gizmo instead of moving the item under the cursor. Currently this works by hiding the gizmo until the tweak event ends. While it's simpler to check if the gizmo received a mouse-down event, it causes flickering before each drag event which feels like a glitch. This is optional for each gizmo type because there are cases where this can be useful to activate the gizmo immediately (mesh rip for example). === M source/blender/editors/space_image/space_image.c M source/blender/editors/space_view3d/view3d_gizmo_tool_generic.c M source/blender/editors/transform/transform_gizmo_3d.c M source/blender/editors/transform/transform_gizmo_extrude_3d.c M source/blender/windowmanager/gizmo/WM_gizmo_api.h M source/blender/windowmanager/gizmo/WM_gizmo_types.h M source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c M source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c M source/blender/windowmanager/intern/wm_event_system.c === diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index c0cdce1b000..2f93be8ae38 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -464,7 +464,8 @@ static void IMAGE_GGT_gizmo2d(wmGizmoGroupType *gzgt) gzgt->name = "UV Transform Gizmo"; gzgt->idname = "IMAGE_GGT_gizmo2d"; - gzgt->flag |= WM_GIZMOGROUPTYPE_TOOL_FALLBACK_KEYMAP; + gzgt->flag |= (WM_GIZMOGROUPTYPE_TOOL_FALLBACK_KEYMAP | + WM_GIZMOGROUPTYPE_DELAY_REFRESH_FOR_TWEAK); gzgt->gzmap_params.spaceid = SPACE_IMAGE; gzgt->gzmap_params.regionid = RGN_TYPE_WINDOW; @@ -481,7 +482,8 @@ static void IMAGE_GGT_gizmo2d_translate(wmGizmoGroupType *gzgt) gzgt->name = "UV Translate Gizmo"; gzgt->idname = "IMAGE_GGT_gizmo2d_translate"; - gzgt->flag |= WM_GIZMOGROUPTYPE_TOOL_FALLBACK_KEYMAP; + gzgt->flag |= (WM_GIZMOGROUPTYPE_TOOL_FALLBACK_KEYMAP | + WM_GIZMOGROUPTYPE_DELAY_REFRESH_FOR_TWEAK); gzgt->gzmap_params.spaceid = SPACE_IMAGE; gzgt->gzmap_params.regionid = RGN_TYPE_WINDOW; @@ -498,7 +500,8 @@ static void IMAGE_GGT_gizmo2d_resize(wmGizmoGroupType *gzgt) gzgt->name = "UV Transform Gizmo Resize"; gzgt->idname = "IMAGE_GGT_gizmo2d_resize"; - gzgt->flag |= WM_GIZMOGROUPTYPE_TOOL_FALLBACK_KEYMAP; + gzgt->flag |= (WM_GIZMOGROUPTYPE_TOOL_FALLBACK_KEYMAP | + WM_GIZMOGROUPTYPE_DELAY_REFRESH_FOR_TWEAK); gzgt->gzmap_params.spaceid = SPACE_IMAGE; gzgt->gzmap_params.regionid = RGN_TYPE_WINDOW; @@ -515,7 +518,8 @@ static void IMAGE_GGT_gizmo2d_rotate(wmGizmoGroupType *gzgt) gzgt->name = "UV Transform Gizmo Resize"; gzgt->idname = "IMAGE_GGT_gizmo2d_rotate"; - gzgt->flag |= WM_GIZMOGROUPTYPE_TOOL_FALLBACK_KEYMAP; + gzgt->flag |= (WM_GIZMOGROUPTYPE_TOOL_FALLBACK_KEYMAP | + WM_GIZMOGROUPTYPE_DELAY_REFRESH_FOR_TWEAK); gzgt->gzmap_params.spaceid = SPACE_IMAGE; gzgt->gzmap_params.regionid = RGN_TYPE_WINDOW; diff --git a/source/blender/editors/space_view3d/view3d_gizmo_tool_generic.c b/source/blender/editors/space_view3d/view3d_gizmo_tool_generic.c index f761a44fe16..8cd5ed7a478 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_tool_generic.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_tool_generic.c @@ -195,7 +195,8 @@ void VIEW3D_GGT_tool_generic_handle_normal(wmGizmoGroupType *gzgt) gzgt->name = "Generic Tool Widget Normal"; gzgt->idname = handle_normal_id; - gzgt->flag |= (WM_GIZMOGROUPTYPE_3D | WM_GIZMOGROUPTYPE_TOOL_FALLBACK_KEYMAP); + gzgt->flag |= (WM_GIZMOGROUPTYPE_3D | WM_GIZMOGROUPTYPE_TOOL_FALLBACK_KEYMAP | + WM_GIZMOGROUPTYPE_DELAY_REFRESH_FOR_TWEAK); gzgt->gzmap_params.spaceid = SPACE_VIEW3D; gzgt->gzmap_params.regionid = RGN_TYPE_WINDOW; @@ -211,6 +212,8 @@ void VIEW3D_GGT_tool_generic_handle_free(wmGizmoGroupType *gzgt) gzgt->name = "Generic Tool Widget Free"; gzgt->idname = handle_free_id; + /* Don't use 'WM_GIZMOGROUPTYPE_DELAY_REFRESH_FOR_TWEAK' here since this style of gizmo + * is better suited to being activated immediately. */ gzgt->flag |= (WM_GIZMOGROUPTYPE_3D | WM_GIZMOGROUPTYPE_TOOL_FALLBACK_KEYMAP); gzgt->gzmap_params.spaceid = SPACE_VIEW3D; diff --git a/source/blender/editors/transform/transform_gizmo_3d.c
[Bf-blender-cvs] [ce5e4f76dc1] greasepencil-refactor: Merge branch 'greasepencil-object' into greasepencil-refactor
Commit: ce5e4f76dc19d1cc5b12648e9ef86582ff0742e0 Author: Antonio Vazquez Date: Wed Dec 18 15:51:13 2019 +0100 Branches: greasepencil-refactor https://developer.blender.org/rBce5e4f76dc19d1cc5b12648e9ef86582ff0742e0 Merge branch 'greasepencil-object' into greasepencil-refactor === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [b6dc2e4ba02] greasepencil-object: Merge branch 'master' into greasepencil-object
Commit: b6dc2e4ba023750acba664a29a961524b7f0343c Author: Antonio Vazquez Date: Wed Dec 18 15:50:38 2019 +0100 Branches: greasepencil-object https://developer.blender.org/rBb6dc2e4ba023750acba664a29a961524b7f0343c Merge branch 'master' into greasepencil-object === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [b4b08e37f0f] greasepencil-refactor: GPencil: Remove arbitrary limit to only one VFX
Commit: b4b08e37f0f01de200a5d1b0516dd1d980173122 Author: Antonio Vazquez Date: Wed Dec 18 15:31:30 2019 +0100 Branches: greasepencil-refactor https://developer.blender.org/rBb4b08e37f0f01de200a5d1b0516dd1d980173122 GPencil: Remove arbitrary limit to only one VFX === M source/blender/shader_fx/intern/FX_shader_flip.c M source/blender/shader_fx/intern/FX_shader_pixel.c M source/blender/shader_fx/intern/FX_shader_wave.c === diff --git a/source/blender/shader_fx/intern/FX_shader_flip.c b/source/blender/shader_fx/intern/FX_shader_flip.c index 804b194ed68..41ca903ee08 100644 --- a/source/blender/shader_fx/intern/FX_shader_flip.c +++ b/source/blender/shader_fx/intern/FX_shader_flip.c @@ -47,7 +47,7 @@ ShaderFxTypeInfo shaderfx_Type_Flip = { /* structName */ "FlipShaderFxData", /* structSize */ sizeof(FlipShaderFxData), /* type */ eShaderFxType_GpencilType, -/* flags */ eShaderFxTypeFlag_Single, +/* flags */ 0, /* copyData */ copyData, diff --git a/source/blender/shader_fx/intern/FX_shader_pixel.c b/source/blender/shader_fx/intern/FX_shader_pixel.c index e0ea111d121..f39649bba07 100644 --- a/source/blender/shader_fx/intern/FX_shader_pixel.c +++ b/source/blender/shader_fx/intern/FX_shader_pixel.c @@ -44,7 +44,7 @@ ShaderFxTypeInfo shaderfx_Type_Pixel = { /* structName */ "PixelShaderFxData", /* structSize */ sizeof(PixelShaderFxData), /* type */ eShaderFxType_GpencilType, -/* flags */ eShaderFxTypeFlag_Single, +/* flags */ 0, /* copyData */ copyData, diff --git a/source/blender/shader_fx/intern/FX_shader_wave.c b/source/blender/shader_fx/intern/FX_shader_wave.c index 334024bbd3f..35d2e515f76 100644 --- a/source/blender/shader_fx/intern/FX_shader_wave.c +++ b/source/blender/shader_fx/intern/FX_shader_wave.c @@ -50,7 +50,7 @@ ShaderFxTypeInfo shaderfx_Type_Wave = { /* structName */ "WaveShaderFxData", /* structSize */ sizeof(WaveShaderFxData), /* type */ eShaderFxType_GpencilType, -/* flags */ eShaderFxTypeFlag_Single, +/* flags */ 0, /* copyData */ copyData, ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [426c04b9217] greasepencil-refactor: GPencil: Change default values for Blur VFX
Commit: 426c04b92179e4e360b549fff26a8f4d030f26b8 Author: Antonio Vazquez Date: Wed Dec 18 15:28:01 2019 +0100 Branches: greasepencil-refactor https://developer.blender.org/rB426c04b92179e4e360b549fff26a8f4d030f26b8 GPencil: Change default values for Blur VFX === M source/blender/shader_fx/intern/FX_shader_blur.c === diff --git a/source/blender/shader_fx/intern/FX_shader_blur.c b/source/blender/shader_fx/intern/FX_shader_blur.c index 0d41c316b69..70f53995201 100644 --- a/source/blender/shader_fx/intern/FX_shader_blur.c +++ b/source/blender/shader_fx/intern/FX_shader_blur.c @@ -30,8 +30,8 @@ static void initData(ShaderFxData *fx) { BlurShaderFxData *gpfx = (BlurShaderFxData *)fx; - ARRAY_SET_ITEMS(gpfx->radius, 1, 1); - gpfx->samples = 4; + ARRAY_SET_ITEMS(gpfx->radius, 5, 5); + gpfx->samples = 2; gpfx->coc = 0.025f; } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [15c15d95e9d] functions: fix missing include
Commit: 15c15d95e9d5746aec4821655f423af9ce200f9c Author: Jacques Lucke Date: Wed Dec 18 15:21:26 2019 +0100 Branches: functions https://developer.blender.org/rB15c15d95e9d5746aec4821655f423af9ce200f9c fix missing include === M source/blender/blenlib/BLI_monotonic_allocator.h === diff --git a/source/blender/blenlib/BLI_monotonic_allocator.h b/source/blender/blenlib/BLI_monotonic_allocator.h index a18369dfbdc..04d3f7218ff 100644 --- a/source/blender/blenlib/BLI_monotonic_allocator.h +++ b/source/blender/blenlib/BLI_monotonic_allocator.h @@ -27,6 +27,7 @@ #include "BLI_vector.h" #include "BLI_utility_mixins.h" #include "BLI_timeit.h" +#include "BLI_string_ref.h" namespace BLI { ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [f72a4ab0aff] functions: Remove Explode Particle node
Commit: f72a4ab0affac9dc78fc1ebbb2db5df99347edf2 Author: Jacques Lucke Date: Wed Dec 18 15:03:15 2019 +0100 Branches: functions https://developer.blender.org/rBf72a4ab0affac9dc78fc1ebbb2db5df99347edf2 Remove Explode Particle node === D release/scripts/startup/nodes/bparticle_nodes/explode_particle.py M release/scripts/startup/nodes/menu.py M source/blender/simulations/bparticles/actions.cpp M source/blender/simulations/bparticles/actions.hpp M source/blender/simulations/bparticles/node_frontend.cpp === diff --git a/release/scripts/startup/nodes/bparticle_nodes/explode_particle.py b/release/scripts/startup/nodes/bparticle_nodes/explode_particle.py deleted file mode 100644 index 5dd271dc5b3..000 --- a/release/scripts/startup/nodes/bparticle_nodes/explode_particle.py +++ /dev/null @@ -1,18 +0,0 @@ -import bpy -from bpy.props import * -from .. base import SimulationNode -from .. node_builder import NodeBuilder - -class ExplodeParticleNode(bpy.types.Node, SimulationNode): -bl_idname = "fn_ExplodeParticleNode" -bl_label = "Explode Particle" - -execute_on_birth__prop: NodeBuilder.ExecuteInputProperty() - -def declaration(self, builder: NodeBuilder): -builder.fixed_input("amount", "Amount", "Integer", default=10) -builder.fixed_input("speed", "Speed", "Float", default=2) -builder.execute_input("execute_on_birth", "Execute on Birth", "execute_on_birth__prop") - -builder.execute_output("execute", "Execute") -builder.influences_output("explode_system", "Explode System") diff --git a/release/scripts/startup/nodes/menu.py b/release/scripts/startup/nodes/menu.py index 6e80c966565..19fc6895b86 100644 --- a/release/scripts/startup/nodes/menu.py +++ b/release/scripts/startup/nodes/menu.py @@ -84,7 +84,6 @@ class ActionNodesMenu(bpy.types.Menu): insert_node(layout, "fn_ChangeParticleSizeNode", "Change Size") insert_node(layout, "fn_ChangeParticlePositionNode", "Change Position") layout.separator() -insert_node(layout, "fn_ExplodeParticleNode", "Explode Particle") insert_node(layout, "fn_KillParticleNode", "Kill Particle") insert_node(layout, "fn_ParticleConditionNode", "Condition") diff --git a/source/blender/simulations/bparticles/actions.cpp b/source/blender/simulations/bparticles/actions.cpp index 9d2a10aa4e2..33f182fe61a 100644 --- a/source/blender/simulations/bparticles/actions.cpp +++ b/source/blender/simulations/bparticles/actions.cpp @@ -125,41 +125,6 @@ void KillAction::execute(ActionInterface ) interface.kill(interface.pindices()); } -void ExplodeAction::execute(ActionInterface ) -{ - auto positions = interface.attributes().get("Position"); - - Vector new_positions; - Vector new_velocities; - Vector new_birth_times; - - auto inputs = ParticleFunctionResult::Compute( - *m_inputs_fn, interface.pindices(), interface.attributes()); - - for (uint pindex : interface.pindices()) { -uint parts_amount = std::max(0, inputs.get_single("Amount", 0, pindex)); -float speed = inputs.get_single("Speed", 1, pindex); - -new_positions.append_n_times(positions[pindex], parts_amount); -new_birth_times.append_n_times(interface.current_times()[pindex], parts_amount); - -for (uint j = 0; j < parts_amount; j++) { - new_velocities.append(random_direction() * speed); -} - } - - for (StringRef system_name : m_systems_to_emit) { -auto new_particles = interface.particle_allocator().request(system_name, - new_birth_times.size()); -new_particles.set("Position", new_positions); -new_particles.set("Velocity", new_velocities); -new_particles.fill("Size", 0.1f); -new_particles.set("Birth Time", new_birth_times); - -m_on_birth_action.execute_for_new_particles(new_particles, interface); - } -} - void ConditionAction::execute(ActionInterface ) { auto inputs = ParticleFunctionResult::Compute( diff --git a/source/blender/simulations/bparticles/actions.hpp b/source/blender/simulations/bparticles/actions.hpp index e92f2a01a0b..494dc79e0d4 100644 --- a/source/blender/simulations/bparticles/actions.hpp +++ b/source/blender/simulations/bparticles/actions.hpp @@ -87,25 +87,6 @@ class ChangePositionAction : public Action { void execute(ActionInterface ) override; }; -class ExplodeAction : public Action { - private: - ArrayRef m_systems_to_emit; - ParticleFunction *m_inputs_fn; - Action _on_birth_action; - - public: - ExplodeAction(ArrayRef systems_to_emit, -ParticleFunction *inputs_fn, -Action _birth_action) - : m_systems_to_emit(systems_to_emit), -m_inputs_fn(inputs_fn), -m_on_birth_action(on_birth_action) - { - } - - void execute(ActionInterface ) override; -}; -
[Bf-blender-cvs] [a7ce3fc3244] functions: use Tab to open/close groups
Commit: a7ce3fc324462ae5530e2659cafc5a198df4acce Author: Jacques Lucke Date: Wed Dec 18 14:59:27 2019 +0100 Branches: functions https://developer.blender.org/rBa7ce3fc324462ae5530e2659cafc5a198df4acce use Tab to open/close groups === M release/scripts/startup/nodes/function_nodes/groups.py === diff --git a/release/scripts/startup/nodes/function_nodes/groups.py b/release/scripts/startup/nodes/function_nodes/groups.py index 4662f6ac1cd..7b5a50229e2 100644 --- a/release/scripts/startup/nodes/function_nodes/groups.py +++ b/release/scripts/startup/nodes/function_nodes/groups.py @@ -473,6 +473,26 @@ class CreateGroupOutputForSocket(bpy.types.Operator): return {"FINISHED"} +class OpenCloseGroupOperator(bpy.types.Operator): +bl_idname = "fn.open_close_group" +bl_label = "Open/Close Group" +bl_options = {"INTERNAL"} + +@classmethod +def poll(cls, context): +try: return context.space_data.node_tree.bl_idname == "FunctionTree" +except: return False + +def invoke(self, context, event): +space_data = context.space_data +active_node = context.active_node +if isinstance(active_node, GroupNode) and active_node.node_group is not None: +space_data.path.append(active_node.node_group, node=active_node) +else: +space_data.path.pop() +return {"FINISHED"} + + def socket_can_become_group_input(socket): return socket.bl_idname != "fn_OperatorSocket" and not socket.is_linked @@ -491,6 +511,8 @@ def register(): kmi = keymap.keymap_items.new("wm.call_menu_pie", type="V", value="PRESS") kmi.properties.name = "FN_MT_manage_group_pie" +keymap.keymap_items.new("fn.open_close_group", type="TAB", value="PRESS") + def unregister(): global keymap ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [7329734ec2f] functions: fix file load error
Commit: 7329734ec2f90b45975464847f96ebd33cd0d221 Author: Jacques Lucke Date: Wed Dec 18 14:59:09 2019 +0100 Branches: functions https://developer.blender.org/rB7329734ec2f90b45975464847f96ebd33cd0d221 fix file load error === M release/scripts/startup/nodes/file_load.py === diff --git a/release/scripts/startup/nodes/file_load.py b/release/scripts/startup/nodes/file_load.py index bf04de0d02d..6783756c7f5 100644 --- a/release/scripts/startup/nodes/file_load.py +++ b/release/scripts/startup/nodes/file_load.py @@ -4,7 +4,7 @@ from bpy.app.handlers import persistent @persistent def file_load_handler(dummy): from . sync import sync_trees_and_dependent_trees -node_trees = set(bpy.data.node_groups) +node_trees = set(tree for tree in bpy.data.node_groups if tree.bl_idname == "FunctionTree") sync_trees_and_dependent_trees(node_trees) def register(): ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [5467f3de3a4] master: Cleanup: use wrapper function for gizmo group refresh
Commit: 5467f3de3a4aca99e678f16356c1d54cda5fb42f Author: Campbell Barton Date: Thu Dec 19 00:42:54 2019 +1100 Branches: master https://developer.blender.org/rB5467f3de3a4aca99e678f16356c1d54cda5fb42f Cleanup: use wrapper function for gizmo group refresh Allows for adding checks before/after refresh, not yet added. === M source/blender/windowmanager/gizmo/WM_gizmo_api.h M source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c M source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c === diff --git a/source/blender/windowmanager/gizmo/WM_gizmo_api.h b/source/blender/windowmanager/gizmo/WM_gizmo_api.h index 5896424d5fe..a81a4596733 100644 --- a/source/blender/windowmanager/gizmo/WM_gizmo_api.h +++ b/source/blender/windowmanager/gizmo/WM_gizmo_api.h @@ -371,7 +371,6 @@ void WM_gizmo_group_type_reinit(struct Main *bmain, 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 *gzgt); void WM_gizmo_group_remove_by_tool(struct bContext *C, struct Main *bmain, const struct wmGizmoGroupType *gzgt, @@ -379,4 +378,8 @@ void WM_gizmo_group_remove_by_tool(struct bContext *C, void WM_gizmo_group_tag_remove(struct wmGizmoGroup *gzgroup); +/* Wrap Group Type Callbacks. */ +bool WM_gizmo_group_type_poll(const struct bContext *C, const struct wmGizmoGroupType *gzgt); +void WM_gizmo_group_refresh(const struct bContext *C, struct wmGizmoGroup *gzgroup); + #endif /* __WM_GIZMO_API_H__ */ diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c index 77950c11c63..d2638ae148e 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c @@ -284,27 +284,11 @@ void WM_gizmogroup_ensure_init(const bContext *C, wmGizmoGroup *gzgroup) /* Refresh may be called multiple times, * this just ensures its called at least once before we draw. */ if (UNLIKELY((gzgroup->init_flag & WM_GIZMOGROUP_INIT_REFRESH) == 0)) { -if (gzgroup->type->refresh) { - gzgroup->type->refresh(C, gzgroup); -} +WM_gizmo_group_refresh(C, gzgroup); gzgroup->init_flag |= WM_GIZMOGROUP_INIT_REFRESH; } } -bool WM_gizmo_group_type_poll(const bContext *C, const struct wmGizmoGroupType *gzgt) -{ - /* If we're tagged, only use compatible. */ - if (gzgt->owner_id[0] != '\0') { -const WorkSpace *workspace = CTX_wm_workspace(C); -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 (!gzgt->poll || gzgt->poll(C, (wmGizmoGroupType *)gzgt)); -} - void WM_gizmo_group_remove_by_tool(bContext *C, Main *bmain, const wmGizmoGroupType *gzgt, @@ -1140,3 +1124,32 @@ void WM_gizmo_group_unlink_delayed_ptr_from_space(wmGizmoGroupType *gzgt, } /** \} */ + +/* */ +/** \name Gizmo Group Type Callback Wrappers + * + * \{ */ + +bool WM_gizmo_group_type_poll(const bContext *C, const wmGizmoGroupType *gzgt) +{ + /* If we're tagged, only use compatible. */ + if (gzgt->owner_id[0] != '\0') { +const WorkSpace *workspace = CTX_wm_workspace(C); +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 (!gzgt->poll || gzgt->poll(C, (wmGizmoGroupType *)gzgt)); +} + +void WM_gizmo_group_refresh(const bContext *C, wmGizmoGroup *gzgroup) +{ + const wmGizmoGroupType *gzgt = gzgroup->type; + if (gzgt->refresh) { +gzgt->refresh(C, gzgroup); + } +} + +/** \} */ diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c index ef4d8174718..97bb203bcf6 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c @@ -730,9 +730,8 @@ wmGizmo *wm_gizmomap_highlight_find(wmGizmoMap *gzmap, } if (do_step[step]) { -if ((gzmap->update_flag[step] & GIZMOMAP_IS_REFRESH_CALLBACK) && -(gzgroup->type->refresh != NULL)) { - gzgroup->type->refresh(C, gzgroup); +if (gzmap->update_flag[step] & GIZMOMAP_IS_REFRESH_CALLBACK) { + WM_gizmo_group_refresh(C, gzgroup); /* cleared below */ } if
[Bf-blender-cvs] [838dc349caa] master: Cleanup: const warning, unused var
Commit: 838dc349caa49ba65a1a5fb7bbb58f416fb933e6 Author: Campbell Barton Date: Thu Dec 19 00:19:01 2019 +1100 Branches: master https://developer.blender.org/rB838dc349caa49ba65a1a5fb7bbb58f416fb933e6 Cleanup: const warning, unused var === M source/blender/blenkernel/intern/particle_system.c M source/blender/blenlib/BLI_math_geom.h M source/blender/blenlib/intern/math_geom.c === diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 17195d8c6c3..34f2aa73817 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -4148,7 +4148,9 @@ static void particles_fluid_step(ParticleSimulationData *sim, psys->totpart = 0; } -#ifdef WITH_FLUID +#ifndef WITH_FLUID + UNUSED_VARS(use_render_params, cfra); +#else { Object *ob = sim->ob; FluidModifierData *mmd = (FluidModifierData *)modifiers_findByType(ob, eModifierType_Fluid); @@ -4400,9 +4402,7 @@ static void particles_fluid_step(ParticleSimulationData *sim, } /* Fluid sim particles done. */ } -#else - UNUSED_VARS(use_render_params); -#endif // WITH_FLUID +#endif /* WITH_FLUID */ } static int emit_particles(ParticleSimulationData *sim, PTCacheID *pid, float UNUSED(cfra)) diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h index 4f8810d50e1..534c25f6e01 100644 --- a/source/blender/blenlib/BLI_math_geom.h +++ b/source/blender/blenlib/BLI_math_geom.h @@ -645,7 +645,7 @@ void orthographic_m4(float mat[4][4], const float farClip); void window_translate_m4(float winmat[4][4], float perspmat[4][4], const float x, const float y); -void planes_from_projmat(float mat[4][4], +void planes_from_projmat(const float mat[4][4], float left[4], float right[4], float top[4], diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c index ba2a8605dec..a17fecca303 100644 --- a/source/blender/blenlib/intern/math_geom.c +++ b/source/blender/blenlib/intern/math_geom.c @@ -4711,7 +4711,7 @@ void window_translate_m4(float winmat[4][4], float perspmat[4][4], const float x * * plane parameters can be NULL if you do not need them. */ -void planes_from_projmat(float mat[4][4], +void planes_from_projmat(const float mat[4][4], float left[4], float right[4], float top[4], ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [545e1b60f16] functions: implement start-stop mode in Float Range node
Commit: 545e1b60f1609a072f1d8a2f87154328ac5816b9 Author: Jacques Lucke Date: Wed Dec 18 13:53:16 2019 +0100 Branches: functions https://developer.blender.org/rB545e1b60f1609a072f1d8a2f87154328ac5816b9 implement start-stop mode in Float Range node === M release/scripts/startup/nodes/function_nodes/float_range.py M source/blender/functions/intern/inlined_tree_multi_function_network/mappings_nodes.cc M source/blender/functions/intern/multi_functions/mixed.cc M source/blender/functions/intern/multi_functions/mixed.h === diff --git a/release/scripts/startup/nodes/function_nodes/float_range.py b/release/scripts/startup/nodes/function_nodes/float_range.py index e5fb64db2eb..cfd9b9cd311 100644 --- a/release/scripts/startup/nodes/function_nodes/float_range.py +++ b/release/scripts/startup/nodes/function_nodes/float_range.py @@ -1,4 +1,5 @@ import bpy +from bpy.props import * from .. base import FunctionNode from .. node_builder import NodeBuilder @@ -6,9 +7,25 @@ class FloatRangeNode(bpy.types.Node, FunctionNode): bl_idname = "fn_FloatRangeNode" bl_label = "Float Range" +mode: EnumProperty( +name="Mode", +items=[ +("AMOUNT_START_STEP", "Amount / Start / Step", "", "NONE", 0), +("AMOUNT_START_STOP", "Amount / Start / Stop", "", "NONE", 1), +], +default="AMOUNT_START_STOP", +update=FunctionNode.sync_tree, +) + def declaration(self, builder: NodeBuilder): -builder.fixed_input("amount", "Amount", "Integer") +builder.fixed_input("amount", "Amount", "Integer", default=10) builder.fixed_input("start", "Start", "Float") -builder.fixed_input("step", "Step", "Float") +if self.mode == "AMOUNT_START_STEP": +builder.fixed_input("step", "Step", "Float") +elif self.mode == "AMOUNT_START_STOP": +builder.fixed_input("stop", "Stop", "Float", default=1) builder.fixed_output("list", "List", "Float List") + +def draw(self, layout): +layout.prop(self, "mode", text="") diff --git a/source/blender/functions/intern/inlined_tree_multi_function_network/mappings_nodes.cc b/source/blender/functions/intern/inlined_tree_multi_function_network/mappings_nodes.cc index e738cab2698..1891352efeb 100644 --- a/source/blender/functions/intern/inlined_tree_multi_function_network/mappings_nodes.cc +++ b/source/blender/functions/intern/inlined_tree_multi_function_network/mappings_nodes.cc @@ -145,7 +145,19 @@ static void INSERT_vertex_info(VNodeMFNetworkBuilder ) static void INSERT_float_range(VNodeMFNetworkBuilder ) { - builder.set_constructed_matching_fn(); + int mode = RNA_enum_get(builder.rna(), "mode"); + switch (mode) { +case 0: { + builder.set_constructed_matching_fn(); + break; +} +case 1: { + builder.set_constructed_matching_fn(); + break; +} +default: + BLI_assert(false); + } } static void INSERT_time_info(VNodeMFNetworkBuilder ) diff --git a/source/blender/functions/intern/multi_functions/mixed.cc b/source/blender/functions/intern/multi_functions/mixed.cc index 2ee45d2bc83..e3565d7e505 100644 --- a/source/blender/functions/intern/multi_functions/mixed.cc +++ b/source/blender/functions/intern/multi_functions/mixed.cc @@ -172,7 +172,7 @@ void MF_FloatArraySum::call(MFMask mask, MFParams params, MFContext UNUSED(conte } } -MF_FloatRange::MF_FloatRange() +MF_FloatRange_Amount_Start_Step::MF_FloatRange_Amount_Start_Step() { MFSignatureBuilder signature = this->get_builder("Float Range"); signature.single_input("Amount"); @@ -181,23 +181,66 @@ MF_FloatRange::MF_FloatRange() signature.vector_output("Range"); } -void MF_FloatRange::call(MFMask mask, MFParams params, MFContext UNUSED(context)) const +void MF_FloatRange_Amount_Start_Step::call(MFMask mask, + MFParams params, + MFContext UNUSED(context)) const { VirtualListRef amounts = params.readonly_single_input(0, "Amount"); VirtualListRef starts = params.readonly_single_input(1, "Start"); VirtualListRef steps = params.readonly_single_input(2, "Step"); auto r_ranges = params.vector_output(3, "Range"); - for (uint i : mask.indices()) { -int amount = amounts[i]; -float start = starts[i]; -float step = steps[i]; + for (uint index : mask.indices()) { +uint amount = std::max(0, amounts[index]); +float start = starts[index]; +float step = steps[index]; + +MutableArrayRef range = r_ranges.allocate(index, amount); + +for (int i = 0; i < amount; i++) { + float value = start + i * step; + range[i] = value; +} + } +} + +MF_FloatRange_Amount_Start_Stop::MF_FloatRange_Amount_Start_Stop() +{ + MFSignatureBuilder signature =
[Bf-blender-cvs] [1c7e0b1755e] functions: improve node layout of group nodes
Commit: 1c7e0b1755ec0e875fa5e6b23ed2cf4e523ec6ff Author: Jacques Lucke Date: Wed Dec 18 13:11:48 2019 +0100 Branches: functions https://developer.blender.org/rB1c7e0b1755ec0e875fa5e6b23ed2cf4e523ec6ff improve node layout of group nodes === M release/scripts/startup/nodes/function_nodes/groups.py === diff --git a/release/scripts/startup/nodes/function_nodes/groups.py b/release/scripts/startup/nodes/function_nodes/groups.py index 8165989b3bb..4662f6ac1cd 100644 --- a/release/scripts/startup/nodes/function_nodes/groups.py +++ b/release/scripts/startup/nodes/function_nodes/groups.py @@ -133,6 +133,7 @@ class GroupOutputNode(bpy.types.Node, BaseNode): class GroupNode(bpy.types.Node, FunctionNode): bl_idname = "fn_GroupNode" bl_label = "Group" +bl_icon = "NODETREE" node_group: PointerProperty( type=bpy.types.NodeTree, @@ -171,12 +172,21 @@ class GroupNode(bpy.types.Node, FunctionNode): assert False def draw(self, layout): +if self.node_group is None: +layout.scale_y = 1.3 +self.invoke_group_selector(layout, "set_group", "Select Group", icon="NODETREE") + +def draw_advanced(self, layout): +col = layout.column() text = "Select Group" if self.node_group is None else self.node_group.name -layout.scale_y = 1.3 -self.invoke_group_selector(layout, "set_group", text, icon="NODETREE") +col.scale_y = 1.3 +self.invoke_group_selector(col, "set_group", text, icon="NODETREE") -def draw_closed_label(self): -return self.node_group.name +def draw_label(self): +if self.node_group is None: +return "(G) -" +else: +return "(G) " + self.node_group.name def set_group(self, group): self.node_group = group ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [ec6fc1aaecb] functions: support for inserting group nodes from search
Commit: ec6fc1aaecbefa7f4bc95bd9e2f4f1867241bf23 Author: Jacques Lucke Date: Wed Dec 18 13:34:26 2019 +0100 Branches: functions https://developer.blender.org/rBec6fc1aaecbefa7f4bc95bd9e2f4f1867241bf23 support for inserting group nodes from search === M release/scripts/startup/nodes/search.py === diff --git a/release/scripts/startup/nodes/search.py b/release/scripts/startup/nodes/search.py index cd2bdd21343..1bd27ff2030 100644 --- a/release/scripts/startup/nodes/search.py +++ b/release/scripts/startup/nodes/search.py @@ -18,7 +18,15 @@ class NodeSearch(bpy.types.Operator): for search_term, settings in node_cls.get_search_terms(): item = encode_search_item(node_cls.bl_idname, search_term, settings) items.append(item) -return items + +current_tree = context.space_data.node_tree +for tree in current_tree.find_callable_trees(): +name = "(G) " + tree.name +item = encode_search_item(name, name, {}) +items.append(item) + +sorted_items = list(sorted(items, key=lambda item: item[1])) +return sorted_items item: EnumProperty(items=cache_enum_items(get_search_items)) @@ -32,12 +40,24 @@ class NodeSearch(bpy.types.Operator): return {'CANCELLED'} def execute(self, context): +tree = context.space_data.node_tree +for node in tree.nodes: +node.select = False + idname, settings = decode_search_item(self.item) -op_settings = [] +if idname.startswith("(G) "): +group_name = idname[len("(G) "):] +idname = "fn_GroupNode" +node_group = bpy.data.node_groups[group_name] +settings = {"node_group" : node_group} + +bpy.ops.node.add_node('INVOKE_DEFAULT', type=idname) +new_node = context.active_node +new_node.select = True for key, value in settings.items(): -item = {"name" : key, "value" : repr(value)} -op_settings.append(item) -bpy.ops.node.add_node('INVOKE_DEFAULT', type=idname, use_transform=True, settings=op_settings) +setattr(new_node, key, value) + +bpy.ops.node.translate_attach("INVOKE_DEFAULT") return {'FINISHED'} ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [5c90bec61e7] functions: simplify socket identifiers
Commit: 5c90bec61e728aa40d2b72e28af086fdd214540a Author: Jacques Lucke Date: Wed Dec 18 13:38:51 2019 +0100 Branches: functions https://developer.blender.org/rB5c90bec61e728aa40d2b72e28af086fdd214540a simplify socket identifiers === M release/scripts/startup/nodes/declaration/base_list_variadic.py M release/scripts/startup/nodes/declaration/bparticles.py M release/scripts/startup/nodes/declaration/vectorized.py === diff --git a/release/scripts/startup/nodes/declaration/base_list_variadic.py b/release/scripts/startup/nodes/declaration/base_list_variadic.py index 35e74c0e6c4..e1e2cd02ce2 100644 --- a/release/scripts/startup/nodes/declaration/base_list_variadic.py +++ b/release/scripts/startup/nodes/declaration/base_list_variadic.py @@ -20,7 +20,7 @@ class BaseListVariadic(SocketDeclBase): for _ in range(self.default_amount): item = collection.add() item.state = "BASE" -item.identifier_prefix = str(uuid.uuid4()) +item.identifier = str(uuid.uuid4()) def build(self, node_sockets): return list(self._build(node_sockets)) @@ -32,7 +32,7 @@ class BaseListVariadic(SocketDeclBase): data_type, node_sockets, "", -item.identifier_prefix + self.identifier_suffix) +item.identifier) yield node_sockets.new("fn_OperatorSocket", "Operator") def validate(self, sockets): @@ -42,8 +42,7 @@ class BaseListVariadic(SocketDeclBase): for socket, item in zip(sockets[:-1], collection): data_type = self.base_type if item.state == "BASE" else self.list_type -identifier = item.identifier_prefix + self.identifier_suffix -if not self._data_socket_test(socket, "", data_type, identifier): +if not self._data_socket_test(socket, "", data_type, item.identifier): return False if sockets[-1].bl_idname != "fn_OperatorSocket": @@ -86,12 +85,11 @@ class BaseListVariadic(SocketDeclBase): collection = self.get_collection() item = collection.add() item.state = state -item.identifier_prefix = str(uuid.uuid4()) +item.identifier = str(uuid.uuid4()) self.node.rebuild() -identifier = item.identifier_prefix + self.identifier_suffix -new_socket = self.node.find_socket(identifier, is_output) +new_socket = self.node.find_socket(item.identifier, is_output) self.node.tree.new_link(linked_socket, new_socket) def amount(self): @@ -112,7 +110,7 @@ class BaseListVariadicPropertyGroup(bpy.types.PropertyGroup): items=[ ("BASE", "Base", "", "NONE", 0), ("LIST", "Base", "", "NONE", 1)]) -identifier_prefix: StringProperty() +identifier: StringProperty() class NewBaseListVariadicInputOperator(bpy.types.Operator): bl_idname = "fn.new_base_list_variadic_input" @@ -130,7 +128,7 @@ class NewBaseListVariadicInputOperator(bpy.types.Operator): item = collection.add() item.state = "BASE" -item.identifier_prefix = str(uuid.uuid4()) +item.identifier = str(uuid.uuid4()) tree.sync() return {'FINISHED'} diff --git a/release/scripts/startup/nodes/declaration/bparticles.py b/release/scripts/startup/nodes/declaration/bparticles.py index 3095a9d12f3..425569648e8 100644 --- a/release/scripts/startup/nodes/declaration/bparticles.py +++ b/release/scripts/startup/nodes/declaration/bparticles.py @@ -85,7 +85,7 @@ class ExecuteInputDecl(SocketDeclBase): class ExecuteInputListDecl(SocketDeclBase): def __init__(self, node, identifier: str, prop_name: str, display_name: str): self.node = node -self.identifier_prefix = identifier +self.identifier = identifier self.display_name = display_name self.prop_name = prop_name @@ -103,8 +103,7 @@ class ExecuteInputListDecl(SocketDeclBase): yield socket socket = node_sockets.new( "fn_OperatorSocket", -self.display_name, -identifier=self.identifier_prefix + "(Operator)") +self.display_name) socket.display_shape = 'SQUARE' yield socket @@ -128,8 +127,6 @@ class ExecuteInputListDecl(SocketDeclBase): return False if not sockets[-1].name == self.display_name: return False -if not sockets[-1].identifier == self.identifier_prefix + "(Operator)": -return False return True diff --git a/release/scripts/startup/nodes/declaration/vectorized.py b/release/scripts/startup/nodes/declaration/vectorized.py index 250d54bf811..27e608ccce8 100644 --- a/release/scripts/startup/nodes/declaration/vectorized.py +++
[Bf-blender-cvs] [17d18351c66] functions: extract method to find callable trees
Commit: 17d18351c66fcee64d23c503fbefc933d9b8e1e6 Author: Jacques Lucke Date: Wed Dec 18 13:17:49 2019 +0100 Branches: functions https://developer.blender.org/rB17d18351c66fcee64d23c503fbefc933d9b8e1e6 extract method to find callable trees === M release/scripts/startup/nodes/function_tree.py M release/scripts/startup/nodes/node_operators.py === diff --git a/release/scripts/startup/nodes/function_tree.py b/release/scripts/startup/nodes/function_tree.py index 227c6d8b8e8..ce53bd3d76a 100644 --- a/release/scripts/startup/nodes/function_tree.py +++ b/release/scripts/startup/nodes/function_tree.py @@ -26,6 +26,12 @@ class FunctionTree(bpy.types.NodeTree, BaseTree): trees.update(node.iter_directly_used_trees()) return trees +def find_callable_trees(self): +used_by_trees = FunctionTree.BuildInvertedCallGraph().reachable(self) +trees = [tree for tree in bpy.data.node_groups + if isinstance(tree, FunctionTree) and tree not in used_by_trees] +return trees + @staticmethod def BuildTreeCallGraph() -> DirectedGraph: ''' diff --git a/release/scripts/startup/nodes/node_operators.py b/release/scripts/startup/nodes/node_operators.py index 8463ed37341..05a8b362fee 100644 --- a/release/scripts/startup/nodes/node_operators.py +++ b/release/scripts/startup/nodes/node_operators.py @@ -70,13 +70,11 @@ class NodeGroupSelector(bpy.types.Operator, NodeOperatorBase): def get_items(self, context): tree = bpy.data.node_groups.get(self.tree_name) -used_by_trees = FunctionTree.BuildInvertedCallGraph().reachable(tree) +possible_trees = tree.find_callable_trees() items = [] -for tree in bpy.data.node_groups: -if isinstance(tree, FunctionTree): -if tree not in used_by_trees: -items.append((tree.name, tree.name, "")) +for tree in possible_trees: +items.append((tree.name, tree.name, "")) items.append(("NONE", "None", "")) return items ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [4c5332cae70] functions: new Random Vectors node
Commit: 4c5332cae7024eb3594b09c2b001cc30652a8527 Author: Jacques Lucke Date: Wed Dec 18 12:31:19 2019 +0100 Branches: functions https://developer.blender.org/rB4c5332cae7024eb3594b09c2b001cc30652a8527 new Random Vectors node === M release/scripts/startup/nodes/function_nodes/noise.py M source/blender/blenlib/BLI_math_cxx.h M source/blender/functions/intern/inlined_tree_multi_function_network/mappings_nodes.cc M source/blender/functions/intern/multi_functions/mixed.cc M source/blender/functions/intern/multi_functions/mixed.h === diff --git a/release/scripts/startup/nodes/function_nodes/noise.py b/release/scripts/startup/nodes/function_nodes/noise.py index 4c7dbb78bc2..b438ea88efa 100644 --- a/release/scripts/startup/nodes/function_nodes/noise.py +++ b/release/scripts/startup/nodes/function_nodes/noise.py @@ -104,5 +104,39 @@ class RandomVectorNode(bpy.types.Node, FunctionNode): def duplicate(self, src_node): self.node_seed = new_node_seed() + +class RandomVectorsNode(bpy.types.Node, FunctionNode): +bl_idname = "fn_RandomVectorsNode" +bl_label = "Random Vectors" + +node_seed: IntProperty( +name="Node Seed", +) + +mode: EnumProperty( +name="Mode", +items=random_vector_mode_items, +default="UNIFORM_IN_CUBE", +) + +def init_props(self): +self.node_seed = new_node_seed() + +def declaration(self, builder: NodeBuilder): +builder.fixed_input("amount", "Amount", "Integer", default=10) +builder.fixed_input("factor", "Factor", "Vector", default=(1, 1, 1)) +builder.fixed_input("seed", "Seed", "Integer") +builder.fixed_output("vectors", "Vectors", "Vector List") + +def draw(self, layout): +layout.prop(self, "mode", text="") + +def draw_advanced(self, layout): +layout.prop(self, "node_seed") + +def duplicate(self, src_node): +self.node_seed = new_node_seed() + + def new_node_seed(): return random.randint(0, 1) diff --git a/source/blender/blenlib/BLI_math_cxx.h b/source/blender/blenlib/BLI_math_cxx.h index 0c10a87665d..f5fdae2d0be 100644 --- a/source/blender/blenlib/BLI_math_cxx.h +++ b/source/blender/blenlib/BLI_math_cxx.h @@ -225,6 +225,13 @@ struct float3 { this->z *= scalar; } + void operator*=(float3 other) + { +this->x *= other.x; +this->y *= other.y; +this->z *= other.z; + } + friend float3 operator*(float3 a, float3 b) { return {a.x * b.x, a.y * b.y, a.z * b.z}; diff --git a/source/blender/functions/intern/inlined_tree_multi_function_network/mappings_nodes.cc b/source/blender/functions/intern/inlined_tree_multi_function_network/mappings_nodes.cc index 034025d9243..03296564076 100644 --- a/source/blender/functions/intern/inlined_tree_multi_function_network/mappings_nodes.cc +++ b/source/blender/functions/intern/inlined_tree_multi_function_network/mappings_nodes.cc @@ -485,6 +485,13 @@ static void INSERT_random_vector(VNodeMFNetworkBuilder ) {"use_list__factor", "use_list__seed"}, node_seed, mode); } +static void INSERT_random_vectors(VNodeMFNetworkBuilder ) +{ + uint node_seed = (uint)RNA_int_get(builder.rna(), "node_seed"); + RandomVectorMode::Enum mode = (RandomVectorMode::Enum)RNA_enum_get(builder.rna(), "mode"); + builder.set_constructed_matching_fn(node_seed, mode); +} + static void INSERT_value(VNodeMFNetworkBuilder ) { const XOutputSocket = builder.xnode().output(0); @@ -551,6 +558,7 @@ void add_inlined_tree_node_mapping_info(VTreeMultiFunctionMappings ) mappings.xnode_inserters.add_new("fn_RandomFloatNode", INSERT_random_float); mappings.xnode_inserters.add_new("fn_RandomFloatsNode", INSERT_random_floats); mappings.xnode_inserters.add_new("fn_RandomVectorNode", INSERT_random_vector); + mappings.xnode_inserters.add_new("fn_RandomVectorsNode", INSERT_random_vectors); mappings.xnode_inserters.add_new("fn_ValueNode", INSERT_value); mappings.xnode_inserters.add_new("fn_EmitterTimeInfoNode", INSERT_emitter_time_info); mappings.xnode_inserters.add_new("fn_SampleObjectSurfaceNode", INSERT_sample_object_surface); diff --git a/source/blender/functions/intern/multi_functions/mixed.cc b/source/blender/functions/intern/multi_functions/mixed.cc index 722fc123411..6ee1684001b 100644 --- a/source/blender/functions/intern/multi_functions/mixed.cc +++ b/source/blender/functions/intern/multi_functions/mixed.cc @@ -585,7 +585,8 @@ void MF_RandomFloats::call(MFMask mask, MFParams params, MFContext UNUSED(contex RNG *rng = BLI_rng_new(0); for (uint i : mask.indices()) { -MutableArrayRef r_array = r_values.allocate(i, amounts[i]); +uint amount = std::max(0, amounts[i]); +MutableArrayRef r_array = r_values.allocate(i, amount); BLI_rng_srandom(rng, seeds[i] + m_seed); float range =
[Bf-blender-cvs] [68b8979137e] functions: new Vector from Value node
Commit: 68b8979137ef252d4c25b2c8ecb3ec3cdc396559 Author: Jacques Lucke Date: Wed Dec 18 12:39:02 2019 +0100 Branches: functions https://developer.blender.org/rB68b8979137ef252d4c25b2c8ecb3ec3cdc396559 new Vector from Value node === M release/scripts/startup/nodes/function_nodes/vector.py M source/blender/functions/intern/inlined_tree_multi_function_network/mappings_nodes.cc M source/blender/functions/intern/multi_functions/mixed.cc M source/blender/functions/intern/multi_functions/mixed.h === diff --git a/release/scripts/startup/nodes/function_nodes/vector.py b/release/scripts/startup/nodes/function_nodes/vector.py index 70ccc055964..34c99a0d333 100644 --- a/release/scripts/startup/nodes/function_nodes/vector.py +++ b/release/scripts/startup/nodes/function_nodes/vector.py @@ -4,6 +4,17 @@ from .. base import FunctionNode from .. node_builder import NodeBuilder +class VectorFromValueNode(bpy.types.Node, FunctionNode): +bl_idname = "fn_VectorFromValueNode" +bl_label = "Vector from Value" + +use_list__value: NodeBuilder.VectorizedProperty() + +def declaration(self, builder: NodeBuilder): +builder.vectorized_input("value", "use_list__value", "Value", "Values", "Float") +builder.vectorized_output("vector", ["use_list__value"], "Vector", "Vectors", "Vector") + + class CombineVectorNode(bpy.types.Node, FunctionNode): bl_idname = "fn_CombineVectorNode" bl_label = "Combine Vector" diff --git a/source/blender/functions/intern/inlined_tree_multi_function_network/mappings_nodes.cc b/source/blender/functions/intern/inlined_tree_multi_function_network/mappings_nodes.cc index 03296564076..a77b90bf9a8 100644 --- a/source/blender/functions/intern/inlined_tree_multi_function_network/mappings_nodes.cc +++ b/source/blender/functions/intern/inlined_tree_multi_function_network/mappings_nodes.cc @@ -33,6 +33,11 @@ static void INSERT_separate_vector(VNodeMFNetworkBuilder ) builder.set_vectorized_constructed_matching_fn({"use_list__vector"}); } +static void INSERT_vector_from_value(VNodeMFNetworkBuilder ) +{ + builder.set_vectorized_constructed_matching_fn({"use_list__value"}); +} + static void INSERT_list_length(VNodeMFNetworkBuilder ) { const CPPType = builder.cpp_type_from_property("active_type"); @@ -529,6 +534,7 @@ void add_inlined_tree_node_mapping_info(VTreeMultiFunctionMappings ) mappings.xnode_inserters.add_new("fn_SeparateColorNode", INSERT_separate_color); mappings.xnode_inserters.add_new("fn_CombineVectorNode", INSERT_combine_vector); mappings.xnode_inserters.add_new("fn_SeparateVectorNode", INSERT_separate_vector); + mappings.xnode_inserters.add_new("fn_VectorFromValueNode", INSERT_vector_from_value); mappings.xnode_inserters.add_new("fn_SwitchNode", INSERT_switch); mappings.xnode_inserters.add_new("fn_SelectNode", INSERT_select); mappings.xnode_inserters.add_new("fn_ListLengthNode", INSERT_list_length); diff --git a/source/blender/functions/intern/multi_functions/mixed.cc b/source/blender/functions/intern/multi_functions/mixed.cc index 6ee1684001b..bef1d2bed5c 100644 --- a/source/blender/functions/intern/multi_functions/mixed.cc +++ b/source/blender/functions/intern/multi_functions/mixed.cc @@ -132,6 +132,24 @@ void MF_SeparateVector::call(MFMask mask, MFParams params, MFContext UNUSED(cont } } +MF_VectorFromValue::MF_VectorFromValue() +{ + MFSignatureBuilder signature = this->get_builder("Vector from Value"); + signature.single_input("Value"); + signature.single_output("Vector"); +} + +void MF_VectorFromValue::call(MFMask mask, MFParams params, MFContext UNUSED(context)) const +{ + VirtualListRef values = params.readonly_single_input(0, "Value"); + MutableArrayRef r_vectors = params.uninitialized_single_output(1, "Vector"); + + for (uint i : mask.indices()) { +float value = values[i]; +r_vectors[i] = {value, value, value}; + } +} + MF_FloatArraySum::MF_FloatArraySum() { MFSignatureBuilder signature = this->get_builder("Float Array Sum"); diff --git a/source/blender/functions/intern/multi_functions/mixed.h b/source/blender/functions/intern/multi_functions/mixed.h index 89b73faf634..479f1592fd1 100644 --- a/source/blender/functions/intern/multi_functions/mixed.h +++ b/source/blender/functions/intern/multi_functions/mixed.h @@ -30,6 +30,12 @@ class MF_SeparateVector final : public MultiFunction { void call(MFMask mask, MFParams params, MFContext context) const override; }; +class MF_VectorFromValue final : public MultiFunction { + public: + MF_VectorFromValue(); + void call(MFMask mask, MFParams params, MFContext context) const override; +}; + class MF_FloatArraySum final : public MultiFunction { public: MF_FloatArraySum(); ___ Bf-blender-cvs mailing list
[Bf-blender-cvs] [c6cf1082cb2] functions: new Multiply Vector with Float node
Commit: c6cf1082cb2e206bf4a7feb87385d7849e96d662 Author: Jacques Lucke Date: Wed Dec 18 12:53:02 2019 +0100 Branches: functions https://developer.blender.org/rBc6cf1082cb2e206bf4a7feb87385d7849e96d662 new Multiply Vector with Float node === M release/scripts/startup/nodes/function_nodes/math.py M source/blender/functions/intern/inlined_tree_multi_function_network/mappings_nodes.cc === diff --git a/release/scripts/startup/nodes/function_nodes/math.py b/release/scripts/startup/nodes/function_nodes/math.py index 8b921a5a360..6ec549e9b54 100644 --- a/release/scripts/startup/nodes/function_nodes/math.py +++ b/release/scripts/startup/nodes/function_nodes/math.py @@ -21,36 +21,35 @@ def create_variadic_math_node(data_type, idname, label): return MathNode -def create_two_inputs_math_node(data_type, idname, label): -return create_two_inputs_other_output_math_node(data_type, data_type, idname, label) - -def create_single_input_math_node(data_type, idname, label): +def create_single_type_two_inputs_math_node(data_type, idname, label): +return create_two_inputs_math_node(data_type, data_type, data_type, idname, label) +def create_two_inputs_math_node(input_type1, input_type2, output_type, idname, label): class MathNode(bpy.types.Node, FunctionNode): bl_idname = idname bl_label = label -use_list: NodeBuilder.VectorizedProperty() +use_list__a: NodeBuilder.VectorizedProperty() +use_list__b: NodeBuilder.VectorizedProperty() def declaration(self, builder: NodeBuilder): -builder.vectorized_input("input", "use_list", "Value", "Values", data_type) -builder.vectorized_output("output", ["use_list"], "Result", "Result", data_type) +builder.vectorized_input("a", "use_list__a", "A", "A", input_type1) +builder.vectorized_input("b", "use_list__b", "B", "B", input_type2) +builder.vectorized_output("result", ["use_list__a", "use_list__b"], "Result", "Result", output_type) return MathNode -def create_two_inputs_other_output_math_node(input_type, output_type, idname, label): +def create_single_input_math_node(data_type, idname, label): class MathNode(bpy.types.Node, FunctionNode): bl_idname = idname bl_label = label -use_list__a: NodeBuilder.VectorizedProperty() -use_list__b: NodeBuilder.VectorizedProperty() +use_list: NodeBuilder.VectorizedProperty() def declaration(self, builder: NodeBuilder): -builder.vectorized_input("a", "use_list__a", "A", "A", input_type) -builder.vectorized_input("b", "use_list__b", "B", "B", input_type) -builder.vectorized_output("result", ["use_list__a", "use_list__b"], "Result", "Result", output_type) +builder.vectorized_input("input", "use_list", "Value", "Values", data_type) +builder.vectorized_output("output", ["use_list"], "Result", "Result", data_type) return MathNode @@ -59,9 +58,9 @@ MultiplyFloatsNode = create_variadic_math_node("Float", "fn_MultiplyFloatsNode", MinimumFloatsNode = create_variadic_math_node("Float", "fn_MinimumFloatsNode", "Minimum Floats") MaximumFloatsNode = create_variadic_math_node("Float", "fn_MaximumFloatsNode", "Maximum Floats") -SubtractFloatsNode = create_two_inputs_math_node("Float", "fn_SubtractFloatsNode", "Subtract Floats") -DivideFloatsNode = create_two_inputs_math_node("Float", "fn_DivideFloatsNode", "Divide Floats") -PowerFloatsNode = create_two_inputs_math_node("Float", "fn_PowerFloatsNode", "Power Floats") +SubtractFloatsNode = create_single_type_two_inputs_math_node("Float", "fn_SubtractFloatsNode", "Subtract Floats") +DivideFloatsNode = create_single_type_two_inputs_math_node("Float", "fn_DivideFloatsNode", "Divide Floats") +PowerFloatsNode = create_single_type_two_inputs_math_node("Float", "fn_PowerFloatsNode", "Power Floats") SqrtFloatNode = create_single_input_math_node("Float", "fn_SqrtFloatNode", "Sqrt Float") AbsFloatNode = create_single_input_math_node("Float", "fn_AbsoluteFloatNode", "Absolute Float") @@ -69,15 +68,16 @@ SineFloatNode = create_single_input_math_node("Float", "fn_SineFloatNode", "Sine CosineFloatNode = create_single_input_math_node("Float", "fn_CosineFloatNode", "Cosine") AddVectorsNode = create_variadic_math_node("Vector", "fn_AddVectorsNode", "Add Vectors") -SubtractVectorsNode = create_two_inputs_math_node("Vector", "fn_SubtractVectorsNode", "Subtract Vectors") +SubtractVectorsNode = create_single_type_two_inputs_math_node("Vector", "fn_SubtractVectorsNode", "Subtract Vectors") MultiplyVectorsNode = create_variadic_math_node("Vector", "fn_MultiplyVectorsNode", "Multiply Vectors") -DivideVectorsNode = create_two_inputs_math_node("Vector", "fn_DivideVectorsNode", "Divide
[Bf-blender-cvs] [9fa91b87195] functions: support for sampling random vectors in a sphere
Commit: 9fa91b871956f471bb45f9741fef5f12b95cf3d1 Author: Jacques Lucke Date: Wed Dec 18 13:04:45 2019 +0100 Branches: functions https://developer.blender.org/rB9fa91b871956f471bb45f9741fef5f12b95cf3d1 support for sampling random vectors in a sphere === M release/scripts/startup/nodes/function_nodes/noise.py M source/blender/functions/intern/multi_functions/mixed.cc M source/blender/functions/intern/multi_functions/mixed.h === diff --git a/release/scripts/startup/nodes/function_nodes/noise.py b/release/scripts/startup/nodes/function_nodes/noise.py index b438ea88efa..5be3becf899 100644 --- a/release/scripts/startup/nodes/function_nodes/noise.py +++ b/release/scripts/startup/nodes/function_nodes/noise.py @@ -66,8 +66,9 @@ class RandomFloatsNode(bpy.types.Node, FunctionNode): self.node_seed = new_node_seed() random_vector_mode_items = [ -("UNIFORM_IN_CUBE", "Uniform in Cube", "Generate a vector that is somewhere in a cube", "NONE", 0), -("UNIFORM_ON_SPHERE", "Uniform on Sphere", "Generate a vector that is somehwere on the surface of a sphere", 1), +("UNIFORM_IN_CUBE", "Uniform in Cube", "Generate a vector that is somewhere in the volume of a cube", "NONE", 0), +("UNIFORM_ON_SPHERE", "Uniform on Sphere", "Generate a vector that is somewhere on the surface of a sphere", 1), +("UNIFORM_IN_SPHERE", "Uniform in Sphere", "Generate a vector that is somewhere in the volume of a sphere", 2), ] class RandomVectorNode(bpy.types.Node, FunctionNode): diff --git a/source/blender/functions/intern/multi_functions/mixed.cc b/source/blender/functions/intern/multi_functions/mixed.cc index bef1d2bed5c..2ee45d2bc83 100644 --- a/source/blender/functions/intern/multi_functions/mixed.cc +++ b/source/blender/functions/intern/multi_functions/mixed.cc @@ -627,6 +627,19 @@ MF_RandomVector::MF_RandomVector(uint seed, RandomVectorMode::Enum mode) signature.single_output("Vector"); } +static float3 rng_get_float3_01(RNG *rng) +{ + float x = BLI_rng_get_float(rng); + float y = BLI_rng_get_float(rng); + float z = BLI_rng_get_float(rng); + return {x, y, z}; +} + +static float3 rng_get_float3_neg1_1(RNG *rng) +{ + return rng_get_float3_01(rng) * 2 - float3(1.0f, 1.0f, 1.0f); +} + void MF_RandomVector::call(MFMask mask, MFParams params, MFContext UNUSED(context)) const { VirtualListRef factors = params.readonly_single_input(0, "Factor"); @@ -636,20 +649,16 @@ void MF_RandomVector::call(MFMask mask, MFParams params, MFContext UNUSED(contex RNG *rng = BLI_rng_new(0); switch (m_mode) { -case RandomVectorMode::SampleInCube: { +case RandomVectorMode::UniformInCube: { for (uint i : mask.indices()) { uint seed = seeds[i] ^ m_seed; BLI_rng_srandom(rng, seed); -float x = BLI_rng_get_float(rng) - 0.5f; -float y = BLI_rng_get_float(rng) - 0.5f; -float z = BLI_rng_get_float(rng) - 0.5f; -float3 factor = factors[i]; -float3 vector = float3(x, y, z) * factor; -r_vectors[i] = vector; +float3 vector = rng_get_float3_neg1_1(rng); +r_vectors[i] = vector * factors[i]; } break; } -case RandomVectorMode::SampleOnSphere: { +case RandomVectorMode::UniformOnSphere: { for (uint i : mask.indices()) { uint seed = seeds[i] ^ m_seed; BLI_rng_srandom(rng, seed); @@ -659,6 +668,18 @@ void MF_RandomVector::call(MFMask mask, MFParams params, MFContext UNUSED(contex } break; } +case RandomVectorMode::UniformInSphere: { + for (uint i : mask.indices()) { +uint seed = seeds[i] ^ m_seed; +BLI_rng_srandom(rng, seed); +float3 vector; +do { + vector = rng_get_float3_neg1_1(rng); +} while (vector.length_squared() >= 1.0f); +r_vectors[i] = vector * factors[i]; + } + break; +} } BLI_rng_free(rng); @@ -694,16 +715,14 @@ void MF_RandomVectors::call(MFMask mask, MFParams params, MFContext UNUSED(conte BLI_rng_srandom(rng, seed); switch (m_mode) { - case RandomVectorMode::SampleInCube: { + case RandomVectorMode::UniformInCube: { for (uint i : IndexRange(amount)) { - float x = BLI_rng_get_float(rng) - 0.5f; - float y = BLI_rng_get_float(rng) - 0.5f; - float z = BLI_rng_get_float(rng) - 0.5f; - r_vectors[i] = {x, y, z}; + float3 vector = rng_get_float3_neg1_1(rng); + r_vectors[i] = vector; } break; } - case RandomVectorMode::SampleOnSphere: { + case RandomVectorMode::UniformOnSphere: { for (uint i : IndexRange(amount)) { float3 vector; BLI_rng_get_float_unit_v3(rng, vector); @@ -711,6 +730,16 @@ void MF_RandomVectors::call(MFMask mask, MFParams params, MFContext
[Bf-blender-cvs] [ceb54718840] functions: improve Random Vector node
Commit: ceb5471884011b860b228490d2ca04339ed47b18 Author: Jacques Lucke Date: Wed Dec 18 12:11:02 2019 +0100 Branches: functions https://developer.blender.org/rBceb5471884011b860b228490d2ca04339ed47b18 improve Random Vector node === M release/scripts/startup/nodes/function_nodes/noise.py M source/blender/functions/intern/inlined_tree_multi_function_network/mappings_nodes.cc M source/blender/functions/intern/multi_functions/mixed.cc M source/blender/functions/intern/multi_functions/mixed.h === diff --git a/release/scripts/startup/nodes/function_nodes/noise.py b/release/scripts/startup/nodes/function_nodes/noise.py index c2c9ed64c4b..4c7dbb78bc2 100644 --- a/release/scripts/startup/nodes/function_nodes/noise.py +++ b/release/scripts/startup/nodes/function_nodes/noise.py @@ -65,6 +65,10 @@ class RandomFloatsNode(bpy.types.Node, FunctionNode): def duplicate(self, src_node): self.node_seed = new_node_seed() +random_vector_mode_items = [ +("UNIFORM_IN_CUBE", "Uniform in Cube", "Generate a vector that is somewhere in a cube", "NONE", 0), +("UNIFORM_ON_SPHERE", "Uniform on Sphere", "Generate a vector that is somehwere on the surface of a sphere", 1), +] class RandomVectorNode(bpy.types.Node, FunctionNode): bl_idname = "fn_RandomVectorNode" @@ -74,13 +78,25 @@ class RandomVectorNode(bpy.types.Node, FunctionNode): name="Node Seed", ) +mode: EnumProperty( +name="Mode", +items=random_vector_mode_items, +default="UNIFORM_IN_CUBE", +) + +use_list__factor: NodeBuilder.VectorizedProperty() +use_list__seed: NodeBuilder.VectorizedProperty() + def init_props(self): self.node_seed = new_node_seed() def declaration(self, builder: NodeBuilder): -builder.fixed_input("amplitude", "Amplitude", "Vector", default=(1, 1, 1)) -builder.fixed_input("seed", "Seed", "Integer") -builder.fixed_output("vector", "Vector", "Vector") +builder.vectorized_input("factor", "use_list__factor", "Factor", "Factors", "Vector", default=(1, 1, 1)) +builder.vectorized_input("seed", "use_list__seed", "Seed", "Seeds", "Integer") +builder.vectorized_output("vector", ["use_list__factor", "use_list__seed"], "Vector", "Vectors", "Vector") + +def draw(self, layout): +layout.prop(self, "mode", text="") def draw_advanced(self, layout): layout.prop(self, "node_seed") @@ -88,6 +104,5 @@ class RandomVectorNode(bpy.types.Node, FunctionNode): def duplicate(self, src_node): self.node_seed = new_node_seed() - def new_node_seed(): return random.randint(0, 1) diff --git a/source/blender/functions/intern/inlined_tree_multi_function_network/mappings_nodes.cc b/source/blender/functions/intern/inlined_tree_multi_function_network/mappings_nodes.cc index 2ccc6515f3f..034025d9243 100644 --- a/source/blender/functions/intern/inlined_tree_multi_function_network/mappings_nodes.cc +++ b/source/blender/functions/intern/inlined_tree_multi_function_network/mappings_nodes.cc @@ -480,7 +480,9 @@ static void INSERT_random_floats(VNodeMFNetworkBuilder ) static void INSERT_random_vector(VNodeMFNetworkBuilder ) { uint node_seed = (uint)RNA_int_get(builder.rna(), "node_seed"); - builder.set_constructed_matching_fn(node_seed); + RandomVectorMode::Enum mode = (RandomVectorMode::Enum)RNA_enum_get(builder.rna(), "mode"); + builder.set_vectorized_constructed_matching_fn( + {"use_list__factor", "use_list__seed"}, node_seed, mode); } static void INSERT_value(VNodeMFNetworkBuilder ) diff --git a/source/blender/functions/intern/multi_functions/mixed.cc b/source/blender/functions/intern/multi_functions/mixed.cc index a0c11f5f5c1..722fc123411 100644 --- a/source/blender/functions/intern/multi_functions/mixed.cc +++ b/source/blender/functions/intern/multi_functions/mixed.cc @@ -599,29 +599,50 @@ void MF_RandomFloats::call(MFMask mask, MFParams params, MFContext UNUSED(contex BLI_rng_free(rng); } -MF_RandomVector::MF_RandomVector(uint seed) : m_seed(seed * 56242361) +MF_RandomVector::MF_RandomVector(uint seed, RandomVectorMode::Enum mode) +: m_seed(seed * 56242361), m_mode(mode) { MFSignatureBuilder signature = this->get_builder("Random Vector"); - signature.single_input("Amplitude"); + signature.single_input("Factor"); signature.single_input("Seed"); signature.single_output("Vector"); } void MF_RandomVector::call(MFMask mask, MFParams params, MFContext UNUSED(context)) const { - VirtualListRef amplitudes = params.readonly_single_input(0, "Amplitude"); + VirtualListRef factors = params.readonly_single_input(0, "Factor"); VirtualListRef seeds = params.readonly_single_input(1, "Seed"); MutableArrayRef r_vectors = params.uninitialized_single_output(2, "Vector"); - for
[Bf-blender-cvs] [375ac4f37ae] functions: new Random Vector node
Commit: 375ac4f37ae1d8402dc0038e34a2edef866fd949 Author: Jacques Lucke Date: Wed Dec 18 11:42:42 2019 +0100 Branches: functions https://developer.blender.org/rB375ac4f37ae1d8402dc0038e34a2edef866fd949 new Random Vector node === M release/scripts/startup/nodes/function_nodes/noise.py M source/blender/functions/intern/inlined_tree_multi_function_network/mappings_nodes.cc M source/blender/functions/intern/multi_functions/mixed.cc M source/blender/functions/intern/multi_functions/mixed.h === diff --git a/release/scripts/startup/nodes/function_nodes/noise.py b/release/scripts/startup/nodes/function_nodes/noise.py index 46f3e4b827c..c2c9ed64c4b 100644 --- a/release/scripts/startup/nodes/function_nodes/noise.py +++ b/release/scripts/startup/nodes/function_nodes/noise.py @@ -4,6 +4,7 @@ from bpy.props import * from .. base import FunctionNode from .. node_builder import NodeBuilder + class PerlinNoiseNode(bpy.types.Node, FunctionNode): bl_idname = "fn_PerlinNoiseNode" bl_label = "Perlin Noise" @@ -20,12 +21,25 @@ class RandomFloatNode(bpy.types.Node, FunctionNode): bl_idname = "fn_RandomFloatNode" bl_label = "Random Float" +node_seed: IntProperty( +name="Node Seed", +) + +def init_props(self): +self.node_seed = new_node_seed() + def declaration(self, builder: NodeBuilder): builder.fixed_input("min", "Min", "Float", default=0) builder.fixed_input("max", "Max", "Float", default=1) builder.fixed_input("seed", "Seed", "Integer") builder.fixed_output("value", "Value", "Float") +def draw_advanced(self, layout): +layout.prop(self, "node_seed") + +def duplicate(self, src_node): +self.node_seed = new_node_seed() + class RandomFloatsNode(bpy.types.Node, FunctionNode): bl_idname = "fn_RandomFloatsNode" @@ -35,6 +49,9 @@ class RandomFloatsNode(bpy.types.Node, FunctionNode): name="Node Seed", ) +def init_props(self): +self.node_seed = new_node_seed() + def declaration(self, builder: NodeBuilder): builder.fixed_input("amount", "Amount", "Integer", default=10) builder.fixed_input("min", "Min", "Float") @@ -46,4 +63,31 @@ class RandomFloatsNode(bpy.types.Node, FunctionNode): layout.prop(self, "node_seed") def duplicate(self, src_node): -self.node_seed = random.randint(0, 1) +self.node_seed = new_node_seed() + + +class RandomVectorNode(bpy.types.Node, FunctionNode): +bl_idname = "fn_RandomVectorNode" +bl_label = "Random Vector" + +node_seed: IntProperty( +name="Node Seed", +) + +def init_props(self): +self.node_seed = new_node_seed() + +def declaration(self, builder: NodeBuilder): +builder.fixed_input("amplitude", "Amplitude", "Vector", default=(1, 1, 1)) +builder.fixed_input("seed", "Seed", "Integer") +builder.fixed_output("vector", "Vector", "Vector") + +def draw_advanced(self, layout): +layout.prop(self, "node_seed") + +def duplicate(self, src_node): +self.node_seed = new_node_seed() + + +def new_node_seed(): +return random.randint(0, 1) diff --git a/source/blender/functions/intern/inlined_tree_multi_function_network/mappings_nodes.cc b/source/blender/functions/intern/inlined_tree_multi_function_network/mappings_nodes.cc index 84c70cc9da7..2ccc6515f3f 100644 --- a/source/blender/functions/intern/inlined_tree_multi_function_network/mappings_nodes.cc +++ b/source/blender/functions/intern/inlined_tree_multi_function_network/mappings_nodes.cc @@ -467,7 +467,8 @@ static void INSERT_map_range(VNodeMFNetworkBuilder ) static void INSERT_random_float(VNodeMFNetworkBuilder ) { - builder.set_constructed_matching_fn(); + uint node_seed = (uint)RNA_int_get(builder.rna(), "node_seed"); + builder.set_constructed_matching_fn(node_seed); } static void INSERT_random_floats(VNodeMFNetworkBuilder ) @@ -476,6 +477,12 @@ static void INSERT_random_floats(VNodeMFNetworkBuilder ) builder.set_constructed_matching_fn(node_seed); } +static void INSERT_random_vector(VNodeMFNetworkBuilder ) +{ + uint node_seed = (uint)RNA_int_get(builder.rna(), "node_seed"); + builder.set_constructed_matching_fn(node_seed); +} + static void INSERT_value(VNodeMFNetworkBuilder ) { const XOutputSocket = builder.xnode().output(0); @@ -541,6 +548,7 @@ void add_inlined_tree_node_mapping_info(VTreeMultiFunctionMappings ) mappings.xnode_inserters.add_new("fn_FloatClampNode", INSERT_clamp_float); mappings.xnode_inserters.add_new("fn_RandomFloatNode", INSERT_random_float); mappings.xnode_inserters.add_new("fn_RandomFloatsNode", INSERT_random_floats); + mappings.xnode_inserters.add_new("fn_RandomVectorNode", INSERT_random_vector);
[Bf-blender-cvs] [06adff95b4e] functions: cleanup Spawn Particles node
Commit: 06adff95b4e7a4c4841dee6e4fd386da2ed80097 Author: Jacques Lucke Date: Wed Dec 18 11:18:55 2019 +0100 Branches: functions https://developer.blender.org/rB06adff95b4e7a4c4841dee6e4fd386da2ed80097 cleanup Spawn Particles node === M source/blender/simulations/bparticles/actions.cpp M source/blender/simulations/bparticles/actions.hpp M source/blender/simulations/bparticles/node_frontend.cpp M source/blender/simulations/bparticles/particle_function.hpp === diff --git a/source/blender/simulations/bparticles/actions.cpp b/source/blender/simulations/bparticles/actions.cpp index af5297a8a06..9d2a10aa4e2 100644 --- a/source/blender/simulations/bparticles/actions.cpp +++ b/source/blender/simulations/bparticles/actions.cpp @@ -226,47 +226,22 @@ using FN::MFParamType; void SpawnParticlesAction::execute(ActionInterface ) { - FN::MFMask mask(interface.pindices()); - uint min_array_size = mask.min_array_size(); - FN::MFParamsBuilder params_builder{m_spawn_function, min_array_size}; - - for (uint param_index : m_spawn_function.param_indices()) { -MFParamType param_type = m_spawn_function.param_type(param_index); -MFDataType data_type = param_type.data_type(); -BLI_assert(param_type.is_output()); -switch (param_type.data_type().category()) { - case MFDataType::Single: { -const FN::CPPType = data_type.single__cpp_type(); -void *buffer = MEM_malloc_arrayN(min_array_size, type.size(), __func__); -FN::GenericMutableArrayRef array{type, buffer, min_array_size}; -params_builder.add_single_output(array); -break; - } - case MFDataType::Vector: { -const FN::CPPType _type = data_type.vector__cpp_base_type(); -FN::GenericVectorArray *vector_array = new FN::GenericVectorArray(base_type, - min_array_size); -params_builder.add_vector_output(*vector_array); -break; - } -} + if (interface.pindices().size() == 0) { +return; } - FN::ParticleAttributesContext attributes_context = {interface.attributes()}; + uint array_size = interface.pindices().last() + 1; - FN::MFContextBuilder context_builder; - context_builder.add_global_context(m_id_data_cache); - context_builder.add_global_context(m_id_handle_lookup); - context_builder.add_element_context(attributes_context, IndexRange(min_array_size)); - - m_spawn_function.call(mask, params_builder, context_builder); + auto inputs = ParticleFunctionResult::Compute( + m_spawn_function, interface.pindices(), interface.attributes()); - LargeScopedArray particle_counts(min_array_size, -1); + LargeScopedArray particle_counts(array_size, -1); - for (uint param_index : m_spawn_function.param_indices()) { -MFParamType param_type = m_spawn_function.param_type(param_index); + const MultiFunction = m_spawn_function.fn(); + for (uint param_index : fn.param_indices()) { +MFParamType param_type = fn.param_type(param_index); if (param_type.is_vector_output()) { - FN::GenericVectorArray _array = params_builder.computed_vector_array(param_index); + FN::GenericVectorArray _array = inputs.computed_vector_array(param_index); for (uint i : interface.pindices()) { FN::GenericArrayRef array = vector_array[i]; particle_counts[i] = std::max(particle_counts[i], array.size()); @@ -293,8 +268,8 @@ void SpawnParticlesAction::execute(ActionInterface ) } attribute_arrays.add_new("Birth Time", new_birth_times.as_mutable_ref()); - for (uint param_index : m_spawn_function.param_indices()) { -MFParamType param_type = m_spawn_function.param_type(param_index); + for (uint param_index : fn.param_indices()) { +MFParamType param_type = fn.param_type(param_index); MFDataType data_type = param_type.data_type(); StringRef attribute_name = m_attribute_names[param_index]; @@ -303,7 +278,7 @@ void SpawnParticlesAction::execute(ActionInterface ) const FN::CPPType = data_type.single__cpp_type(); void *buffer = MEM_malloc_arrayN(total_spawn_amount, type.size(), __func__); GenericMutableArrayRef array(type, buffer, total_spawn_amount); -GenericMutableArrayRef computed_array = params_builder.computed_array(param_index); +GenericArrayRef computed_array = inputs.computed_array(param_index); uint current = 0; for (uint i : interface.pindices()) { @@ -313,17 +288,13 @@ void SpawnParticlesAction::execute(ActionInterface ) } attribute_arrays.add(attribute_name, array); - -computed_array.destruct_indices(interface.pindices()); -MEM_freeN(computed_array.buffer()); break; } case MFDataType::Vector: { const FN::CPPType _type =
[Bf-blender-cvs] [298b0cd863d] functions: Remove Action Context concept for now
Commit: 298b0cd863d5a8c1d3314e1b1047d9591dacf2c4 Author: Jacques Lucke Date: Wed Dec 18 10:04:53 2019 +0100 Branches: functions https://developer.blender.org/rB298b0cd863d5a8c1d3314e1b1047d9591dacf2c4 Remove Action Context concept for now === M source/blender/simulations/CMakeLists.txt D source/blender/simulations/bparticles/action_contexts.cpp D source/blender/simulations/bparticles/action_contexts.hpp M source/blender/simulations/bparticles/action_interface.cpp M source/blender/simulations/bparticles/action_interface.hpp M source/blender/simulations/bparticles/actions.cpp M source/blender/simulations/bparticles/emitters.cpp M source/blender/simulations/bparticles/events.cpp M source/blender/simulations/bparticles/particle_function.cpp M source/blender/simulations/bparticles/particle_function.hpp === diff --git a/source/blender/simulations/CMakeLists.txt b/source/blender/simulations/CMakeLists.txt index d536f124b82..dd2d3ff5b86 100644 --- a/source/blender/simulations/CMakeLists.txt +++ b/source/blender/simulations/CMakeLists.txt @@ -28,8 +28,6 @@ set(SRC bparticles/actions.cpp bparticles/action_interface.hpp bparticles/action_interface.cpp - bparticles/action_contexts.hpp - bparticles/action_contexts.cpp bparticles/events.hpp bparticles/events.cpp bparticles/emitter_interface.hpp diff --git a/source/blender/simulations/bparticles/action_contexts.cpp b/source/blender/simulations/bparticles/action_contexts.cpp deleted file mode 100644 index a62cbaaa033..000 --- a/source/blender/simulations/bparticles/action_contexts.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include "DNA_object_types.h" -#include "DNA_mesh_types.h" -#include "DNA_meshdata_types.h" - -#include "BKE_mesh_runtime.h" - -#include "BLI_math_geom.h" - -#include "action_contexts.hpp" - -namespace BParticles { - -void MeshSurfaceContext::compute_barycentric_coords(ArrayRef pindices) -{ - BLI_assert(m_object->type == OB_MESH); - uint size = m_local_positions.size(); - auto barycentric_coords = BLI::temporary_allocate_array(size); - - Mesh *mesh = (Mesh *)m_object->data; - const MLoopTri *triangles = BKE_mesh_runtime_looptri_ensure(mesh); - - for (uint pindex : pindices) { -uint triangle_index = m_looptri_indices[pindex]; -const MLoopTri = triangles[triangle_index]; -float3 position = m_local_positions[pindex]; - -float3 v1 = mesh->mvert[mesh->mloop[triangle.tri[0]].v].co; -float3 v2 = mesh->mvert[mesh->mloop[triangle.tri[1]].v].co; -float3 v3 = mesh->mvert[mesh->mloop[triangle.tri[2]].v].co; - -float3 weights; -interp_weights_tri_v3(weights, v1, v2, v3, position); - -barycentric_coords[pindex] = weights; - } - - m_barycentric_coords = barycentric_coords; - m_buffers_to_free.append(barycentric_coords.begin()); -} - -} // namespace BParticles diff --git a/source/blender/simulations/bparticles/action_contexts.hpp b/source/blender/simulations/bparticles/action_contexts.hpp deleted file mode 100644 index b4552b05a39..000 --- a/source/blender/simulations/bparticles/action_contexts.hpp +++ /dev/null @@ -1,129 +0,0 @@ -#pragma once - -#include "BLI_temporary_allocator_cxx.h" -#include "BLI_utility_mixins.h" - -#include "action_interface.hpp" - -struct Object; - -namespace BParticles { - -using BLI::float3; -using BLI::float4x4; - -class MeshSurfaceContext : public ActionContext, BLI::NonCopyable, BLI::NonMovable { - private: - Vector m_buffers_to_free; - Object *m_object; - ArrayRef m_world_transforms; - ArrayRef m_local_positions; - ArrayRef m_local_normals; - ArrayRef m_world_normals; - ArrayRef m_looptri_indices; - ArrayRef m_world_surface_velocities; - ArrayRef m_barycentric_coords; - - public: - MeshSurfaceContext(Object *object, - ArrayRef world_transforms, - ArrayRef local_positions, - ArrayRef local_normals, - ArrayRef world_normals, - ArrayRef looptri_indices, - ArrayRef world_surface_velocities) - : m_object(object), -m_world_transforms(world_transforms), -m_local_positions(local_positions), -m_local_normals(local_normals), -m_world_normals(world_normals), -m_looptri_indices(looptri_indices), -m_world_surface_velocities(world_surface_velocities) - { - this->compute_barycentric_coords(IndexRange(m_local_positions.size()).as_array_ref()); - } - - MeshSurfaceContext(Object *object, - float4x4 world_transform, - ArrayRef pindices, - ArrayRef local_positions, - ArrayRef local_normals, - ArrayRef looptri_indices) - : m_object(object), -m_local_positions(local_positions), -
[Bf-blender-cvs] [6bb09a50fbe] functions: support for computing vectors per particle
Commit: 6bb09a50fbed7759b0e6f2b8e6dcd87f0ab1e1b5 Author: Jacques Lucke Date: Wed Dec 18 11:06:55 2019 +0100 Branches: functions https://developer.blender.org/rB6bb09a50fbed7759b0e6f2b8e6dcd87f0ab1e1b5 support for computing vectors per particle === M source/blender/blenlib/BLI_monotonic_allocator.h M source/blender/simulations/bparticles/actions.cpp M source/blender/simulations/bparticles/events.cpp M source/blender/simulations/bparticles/forces.cpp M source/blender/simulations/bparticles/node_frontend.cpp M source/blender/simulations/bparticles/offset_handlers.cpp M source/blender/simulations/bparticles/particle_function.cpp M source/blender/simulations/bparticles/particle_function.hpp === diff --git a/source/blender/blenlib/BLI_monotonic_allocator.h b/source/blender/blenlib/BLI_monotonic_allocator.h index 16e46c85007..a18369dfbdc 100644 --- a/source/blender/blenlib/BLI_monotonic_allocator.h +++ b/source/blender/blenlib/BLI_monotonic_allocator.h @@ -90,8 +90,8 @@ class MonotonicAllocator : NonCopyable, NonMovable { StringRefNull copy_string(StringRef str) { -void *buffer = this->allocate(str.size() + 1, 1); -memcpy(buffer, str.data(), str.size() + 1); +char *buffer = (char *)this->allocate(str.size() + 1, 1); +str.copy_to__with_null(buffer); return StringRefNull((const char *)buffer); } diff --git a/source/blender/simulations/bparticles/actions.cpp b/source/blender/simulations/bparticles/actions.cpp index 7582d8ec1f2..af5297a8a06 100644 --- a/source/blender/simulations/bparticles/actions.cpp +++ b/source/blender/simulations/bparticles/actions.cpp @@ -54,10 +54,11 @@ void SetVelocityAction::execute(ActionInterface ) { auto velocities = interface.attributes().get("Velocity"); - auto inputs = m_inputs_fn->compute(interface); + auto inputs = ParticleFunctionResult::Compute( + *m_inputs_fn, interface.pindices(), interface.attributes()); for (uint pindex : interface.pindices()) { -float3 velocity = inputs->get("Velocity", 0, pindex); +float3 velocity = inputs.get_single("Velocity", 0, pindex); velocities[pindex] = velocity; } @@ -68,10 +69,11 @@ void RandomizeVelocityAction::execute(ActionInterface ) { auto velocities = interface.attributes().get("Velocity"); - auto inputs = m_inputs_fn->compute(interface); + auto inputs = ParticleFunctionResult::Compute( + *m_inputs_fn, interface.pindices(), interface.attributes()); for (uint pindex : interface.pindices()) { -float randomness = inputs->get("Randomness", 0, pindex); +float randomness = inputs.get_single("Randomness", 0, pindex); float3 old_velocity = velocities[pindex]; float old_speed = old_velocity.length(); @@ -86,9 +88,10 @@ void ChangeColorAction::execute(ActionInterface ) { auto colors = interface.attributes().get("Color"); - auto inputs = m_inputs_fn->compute(interface); + auto inputs = ParticleFunctionResult::Compute( + *m_inputs_fn, interface.pindices(), interface.attributes()); for (uint pindex : interface.pindices()) { -rgba_f color = inputs->get("Color", 0, pindex); +rgba_f color = inputs.get_single("Color", 0, pindex); colors[pindex] = color; } } @@ -97,9 +100,10 @@ void ChangeSizeAction::execute(ActionInterface ) { auto sizes = interface.attributes().get("Size"); - auto inputs = m_inputs_fn->compute(interface); + auto inputs = ParticleFunctionResult::Compute( + *m_inputs_fn, interface.pindices(), interface.attributes()); for (uint pindex : interface.pindices()) { -float size = inputs->get("Size", 0, pindex); +float size = inputs.get_single("Size", 0, pindex); sizes[pindex] = size; } } @@ -108,9 +112,10 @@ void ChangePositionAction::execute(ActionInterface ) { auto positions = interface.attributes().get("Position"); - auto inputs = m_inputs_fn->compute(interface); + auto inputs = ParticleFunctionResult::Compute( + *m_inputs_fn, interface.pindices(), interface.attributes()); for (uint pindex : interface.pindices()) { -float3 position = inputs->get("Position", 0, pindex); +float3 position = inputs.get_single("Position", 0, pindex); positions[pindex] = position; } } @@ -128,11 +133,12 @@ void ExplodeAction::execute(ActionInterface ) Vector new_velocities; Vector new_birth_times; - auto inputs = m_inputs_fn->compute(interface); + auto inputs = ParticleFunctionResult::Compute( + *m_inputs_fn, interface.pindices(), interface.attributes()); for (uint pindex : interface.pindices()) { -uint parts_amount = std::max(0, inputs->get("Amount", 0, pindex)); -float speed = inputs->get("Speed", 1, pindex); +uint parts_amount = std::max(0, inputs.get_single("Amount", 0, pindex)); +float speed = inputs.get_single("Speed", 1, pindex);
[Bf-blender-cvs] [61f4a7d1f59] master: Fix T72372: color picker is unreliable with large "clip end" values
Commit: 61f4a7d1f593e3870e7a0df4b32e95516b236eef Author: mano-wii Date: Wed Dec 18 09:41:03 2019 -0300 Branches: master https://developer.blender.org/rB61f4a7d1f593e3870e7a0df4b32e95516b236eef Fix T72372: color picker is unreliable with large "clip end" values By my tests, `planes_from_projmat` proved to be more accurate than the current solution. Differential Revision: https://developer.blender.org/D6434 === M source/blender/draw/intern/draw_manager_data.c === diff --git a/source/blender/draw/intern/draw_manager_data.c b/source/blender/draw/intern/draw_manager_data.c index 83b764317a9..98474c81209 100644 --- a/source/blender/draw/intern/draw_manager_data.c +++ b/source/blender/draw/intern/draw_manager_data.c @@ -1416,53 +1416,19 @@ static void draw_frustum_boundbox_calc(const float (*viewinv)[4], } } -static void draw_frustum_culling_planes_calc(const BoundBox *bbox, float (*frustum_planes)[4]) +static void draw_frustum_culling_planes_calc(const float (*persmat)[4], float (*frustum_planes)[4]) { - /* TODO See if planes_from_projmat cannot do the job. */ + planes_from_projmat(persmat, + frustum_planes[0], + frustum_planes[5], + frustum_planes[3], + frustum_planes[1], + frustum_planes[4], + frustum_planes[2]); - /* Compute clip planes using the world space frustum corners. */ + /* Normalize. */ for (int p = 0; p < 6; p++) { -int q, r, s; -switch (p) { - case 0: -q = 1; -r = 2; -s = 3; -break; /* -X */ - case 1: -q = 0; -r = 4; -s = 5; -break; /* -Y */ - case 2: -q = 1; -r = 5; -s = 6; -break; /* +Z (far) */ - case 3: -q = 2; -r = 6; -s = 7; -break; /* +Y */ - case 4: -q = 0; -r = 3; -s = 7; -break; /* -Z (near) */ - default: -q = 4; -r = 7; -s = 6; -break; /* +X */ -} - -normal_quad_v3(frustum_planes[p], bbox->vec[p], bbox->vec[q], bbox->vec[r], bbox->vec[s]); -/* Increase precision and use the mean of all 4 corners. */ -frustum_planes[p][3] = -dot_v3v3(frustum_planes[p], bbox->vec[p]); -frustum_planes[p][3] += -dot_v3v3(frustum_planes[p], bbox->vec[q]); -frustum_planes[p][3] += -dot_v3v3(frustum_planes[p], bbox->vec[r]); -frustum_planes[p][3] += -dot_v3v3(frustum_planes[p], bbox->vec[s]); -frustum_planes[p][3] *= 0.25f; +frustum_planes[p][3] /= normalize_v3(frustum_planes[p]); } } @@ -1720,7 +1686,7 @@ void DRW_view_update(DRWView *view, } draw_frustum_boundbox_calc(viewinv, winmat, >frustum_corners); - draw_frustum_culling_planes_calc(>frustum_corners, view->frustum_planes); + draw_frustum_culling_planes_calc(view->storage.persmat, view->frustum_planes); draw_frustum_bound_sphere_calc( >frustum_corners, viewinv, winmat, wininv, >frustum_bsphere); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [409d3f48809] master: Workbench: Force Vertex Colors in Paint Mode
Commit: 409d3f48809c1526a23c95f3ee568095100e7caa Author: Jeroen Bakker Date: Wed Dec 18 09:09:09 2019 +0100 Branches: master https://developer.blender.org/rB409d3f48809c1526a23c95f3ee568095100e7caa Workbench: Force Vertex Colors in Paint Mode Vertex colors behaved differently as the paint overlay mixed the colors in display mode and the results was multiplied on top of the original shading. This patch will align the implementation to texture painting where the colors are drawn by the workbench engine so the correct shading is applied. This also means that we don't show the vertex colors overlay when not in solid mode. Reviewed By: fclem Differential Revision: https://developer.blender.org/D6436 === M source/blender/draw/engines/overlay/overlay_paint.c M source/blender/draw/engines/workbench/workbench_deferred.c M source/blender/draw/engines/workbench/workbench_forward.c M source/blender/draw/engines/workbench/workbench_materials.c M source/blender/draw/engines/workbench/workbench_private.h M source/blender/makesrna/intern/rna_space.c === diff --git a/source/blender/draw/engines/overlay/overlay_paint.c b/source/blender/draw/engines/overlay/overlay_paint.c index 71e43b8..047659fbeee 100644 --- a/source/blender/draw/engines/overlay/overlay_paint.c +++ b/source/blender/draw/engines/overlay/overlay_paint.c @@ -159,23 +159,16 @@ void OVERLAY_paint_vertex_cache_populate(OVERLAY_Data *vedata, Object *ob) OVERLAY_PrivateData *pd = vedata->stl->pd; struct GPUBatch *geom = NULL; - const Mesh *me = ob->data; const Mesh *me_orig = DEG_get_original_object(ob)->data; const bool use_wire = (pd->overlay.paint_flag & V3D_OVERLAY_PAINT_WIRE) != 0; const bool use_face_sel = (me_orig->editflag & ME_EDIT_PAINT_FACE_SEL) != 0; const bool use_vert_sel = (me_orig->editflag & ME_EDIT_PAINT_VERT_SEL) != 0; if (pd->paint_surf_grp) { -if (ob->mode == OB_MODE_VERTEX_PAINT) { - if (me->mloopcol == NULL) { -return; - } - geom = DRW_cache_mesh_surface_vertpaint_get(ob); -} -else { +if (ob->mode == OB_MODE_WEIGHT_PAINT) { geom = DRW_cache_mesh_surface_weights_get(ob); + DRW_shgroup_call(pd->paint_surf_grp, geom, ob); } -DRW_shgroup_call(pd->paint_surf_grp, geom, ob); } if (use_face_sel || use_wire) { diff --git a/source/blender/draw/engines/workbench/workbench_deferred.c b/source/blender/draw/engines/workbench/workbench_deferred.c index a536132a1cf..02a3af7fa73 100644 --- a/source/blender/draw/engines/workbench/workbench_deferred.c +++ b/source/blender/draw/engines/workbench/workbench_deferred.c @@ -214,16 +214,16 @@ static GPUShader *workbench_cavity_shader_get(bool cavity, bool curvature) static GPUShader *ensure_deferred_prepass_shader(WORKBENCH_PrivateData *wpd, bool is_uniform_color, bool is_hair, - bool is_texture_painting, + const WORKBENCH_ColorOverride color_override, eGPUShaderConfig sh_cfg) { WORKBENCH_DEFERRED_Shaders *sh_data = _data.sh_data[sh_cfg]; int index = workbench_material_get_prepass_shader_index( - wpd, is_uniform_color, is_hair, is_texture_painting); + wpd, is_uniform_color, is_hair, color_override); if (sh_data->prepass_sh_cache[index] == NULL) { const GPUShaderConfigData *sh_cfg_data = _shader_cfg_data[sh_cfg]; char *defines = workbench_material_build_defines( -wpd, is_uniform_color, is_hair, is_texture_painting); +wpd, is_uniform_color, is_hair, color_override); char *prepass_vert = workbench_build_prepass_vert(is_hair); char *prepass_frag = workbench_build_prepass_frag(); sh_data->prepass_sh_cache[index] = GPU_shader_create_from_arrays({ @@ -242,7 +242,8 @@ static GPUShader *ensure_deferred_composite_shader(WORKBENCH_PrivateData *wpd) { int index = workbench_material_get_composite_shader_index(wpd); if (e_data.composite_sh_cache[index] == NULL) { -char *defines = workbench_material_build_defines(wpd, false, false, false); +char *defines = workbench_material_build_defines( +wpd, false, false, WORKBENCH_COLOR_OVERRIDE_OFF); char *composite_frag = workbench_build_composite_frag(wpd); e_data.composite_sh_cache[index] = DRW_shader_create_fullscreen(composite_frag, defines); MEM_freeN(composite_frag); @@ -269,11 +270,18 @@ static GPUShader *ensure_background_shader(WORKBENCH_PrivateData *wpd) static void select_deferred_shaders(WORKBENCH_PrivateData *wpd, eGPUShaderConfig sh_cfg) { - wpd->prepass_sh = ensure_deferred_prepass_shader(wpd, false, false, false, sh_cfg); - wpd->prepass_hair_sh =
[Bf-blender-cvs] [8bab8655393] master: Fix T72289: FreeStyle python error
Commit: 8bab8655393faf51a2a7ee3b267a745b38fc49e5 Author: Jeroen Bakker Date: Tue Dec 17 12:38:12 2019 +0100 Branches: master https://developer.blender.org/rB8bab8655393faf51a2a7ee3b267a745b38fc49e5 Fix T72289: FreeStyle python error Introduced by {T67981}. We changed the python API for curve evaluation. Freestyle still used the old call that failed. This patch updates FreeStyle to use the new API. I checked other areas in freestyle but it seemed to be the only `evaluate` for curves that is called directly. Reviewed By: zeddb Differential Revision: https://developer.blender.org/D6430 === M release/scripts/freestyle/modules/parameter_editor.py === diff --git a/release/scripts/freestyle/modules/parameter_editor.py b/release/scripts/freestyle/modules/parameter_editor.py index e74b61ced94..534ee7d65be 100644 --- a/release/scripts/freestyle/modules/parameter_editor.py +++ b/release/scripts/freestyle/modules/parameter_editor.py @@ -188,7 +188,7 @@ class CurveMappingModifier(ScalarBlendModifier): # deprecated: return evaluateCurveMappingF(self.curve, 0, t) curve = self.curve curve.initialize() -result = curve.curves[0].evaluate(t) +result = curve.evaluate(curve=curve.curves[0], position=t) # float precision errors in t can give a very weird result for evaluate. # therefore, bound the result by the curve's min and max values return bound(curve.clip_min_y, result, curve.clip_max_y) ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [2a35383bb0b] master: Fix T72353: Camera Limits Visibility
Commit: 2a35383bb0b49dd7a7ee0c507ec012372587f6e5 Author: Jeroen Bakker Date: Wed Dec 11 14:47:35 2019 +0100 Branches: master https://developer.blender.org/rB2a35383bb0b49dd7a7ee0c507ec012372587f6e5 Fix T72353: Camera Limits Visibility Due to recent refactoring of the overlay unification the camera limits were also visible when the overlays were turned off. This was because the `draw_extra` had an exception for when looking through the camera. This change also takes the global hide overlays into account. So now the camera limits will not be drawn when overlays are turned off. This also fixed other camera related overlay drawing. Reviewed By: fclem Differential Revision: https://developer.blender.org/D6394 === M source/blender/draw/engines/overlay/overlay_engine.c === diff --git a/source/blender/draw/engines/overlay/overlay_engine.c b/source/blender/draw/engines/overlay/overlay_engine.c index 06044ff92b3..fe39b8580e3 100644 --- a/source/blender/draw/engines/overlay/overlay_engine.c +++ b/source/blender/draw/engines/overlay/overlay_engine.c @@ -202,9 +202,10 @@ static void OVERLAY_cache_populate(void *vedata, Object *ob) const bool draw_bone_selection = (ob->type == OB_MESH) && pd->armature.do_pose_fade_geom && !is_select; const bool draw_extras = - ((pd->overlay.flag & V3D_OVERLAY_HIDE_OBJECT_XTRAS) == 0) || - /* Show if this is the camera we're looking through since it's useful for selecting. */ - ((draw_ctx->rv3d->persp == RV3D_CAMOB) && ((ID *)draw_ctx->v3d->camera == ob->id.orig_id)); + (!pd->hide_overlays) && + (((pd->overlay.flag & V3D_OVERLAY_HIDE_OBJECT_XTRAS) == 0) || + /* Show if this is the camera we're looking through since it's useful for selecting. */ + ((draw_ctx->rv3d->persp == RV3D_CAMOB) && ((ID *)draw_ctx->v3d->camera == ob->id.orig_id))); const bool draw_motion_paths = (pd->overlay.flag & V3D_OVERLAY_HIDE_MOTION_PATHS) == 0; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [b30a722f2d6] master: Fix T72124: LookDev Sphere Rendering
Commit: b30a722f2d6faecccd3b81efc1f0aa567064bb3a Author: Jeroen Bakker Date: Wed Dec 11 13:35:53 2019 +0100 Branches: master https://developer.blender.org/rBb30a722f2d6faecccd3b81efc1f0aa567064bb3a Fix T72124: LookDev Sphere Rendering Due to the refactoring of the overlay engine the draw caches were changed. The sphere batch used to have positions and normals. After the refactoring it didn't had the normals anymore. The normals are needed for shading. As they were not there the look dev spheres were rendered black. This change add the `nor` attribute to `DRW_cache_sphere_get` batch. Reviewed By: fclem Differential Revision: https://developer.blender.org/D6393 === M source/blender/draw/intern/draw_cache.c === diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c index 90b5e08f994..69135f8ade3 100644 --- a/source/blender/draw/intern/draw_cache.c +++ b/source/blender/draw/intern/draw_cache.c @@ -68,6 +68,12 @@ typedef struct Vert { int class; } Vert; +typedef struct VertShaded { + float pos[3]; + int class; + float nor[3]; +} VertShaded; + /* Batch's only (free'd as an array) */ static struct DRWShapeCache { GPUBatch *drw_procedural_verts; @@ -471,7 +477,7 @@ static void sphere_lat_lon_vert(GPUVertBuf *vbo, int *v_ofs, float lat, float lo float x = sinf(lat) * cosf(lon); float y = cosf(lat); float z = sinf(lat) * sinf(lon); - GPU_vertbuf_vert_set(vbo, *v_ofs, &(Vert){{x, y, z}, VCLASS_EMPTY_SCALED}); + GPU_vertbuf_vert_set(vbo, *v_ofs, &(VertShaded){{x, y, z}, VCLASS_EMPTY_SCALED, {x, y, z}}); (*v_ofs)++; } @@ -482,6 +488,8 @@ GPUBatch *DRW_cache_sphere_get(void) const int lon_res = 24; GPUVertFormat format = extra_vert_format(); +GPU_vertformat_attr_add(, "nor", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(); int v_len = (lat_res - 1) * lon_res * 6; GPU_vertbuf_data_alloc(vbo, v_len); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [f9023f51963] greasepencil-refactor: GPencil: Replace hardcoded factor by definition
Commit: f9023f519635611e97244713937677ee0a2b53fb Author: Antonio Vazquez Date: Wed Dec 18 10:54:44 2019 +0100 Branches: greasepencil-refactor https://developer.blender.org/rBf9023f519635611e97244713937677ee0a2b53fb GPencil: Replace hardcoded factor by definition === M source/blender/draw/engines/gpencil/gpencil_engine.c M source/blender/draw/engines/gpencil/gpencil_engine.h M source/blender/draw/engines/gpencil/gpencil_shader_fx.c === diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c index fe62d9ac824..85b125d0783 100644 --- a/source/blender/draw/engines/gpencil/gpencil_engine.c +++ b/source/blender/draw/engines/gpencil/gpencil_engine.c @@ -822,7 +822,7 @@ static void gp_layer_cache_populate(bGPDlayer *gpl, float object_scale = mat4_to_scale(iter->ob->obmat); /* Negate thickness sign to tag that strokes are in screen space. * Convert to world units (by default, 1 meter = 2000 px). */ - float thickness_scale = (is_screenspace) ? -1.0f : (gpd->pixfactor / 2000.0f); + float thickness_scale = (is_screenspace) ? -1.0f : (gpd->pixfactor / GPENCIL_PIXEL_FACTOR); struct GPUShader *sh = GPENCIL_shader_geometry_get(_data); iter->grp = DRW_shgroup_create(sh, tgp_layer->geom_ps); diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.h b/source/blender/draw/engines/gpencil/gpencil_engine.h index a88181a32b7..8c5393a40d0 100644 --- a/source/blender/draw/engines/gpencil/gpencil_engine.h +++ b/source/blender/draw/engines/gpencil/gpencil_engine.h @@ -44,6 +44,9 @@ struct GPUVertFormat; #define GPENCIL_MAX_SHGROUPS 65536 #define GPENCIL_GROUPS_BLOCK_SIZE 1024 +/* used to convert pixel scale. */ +#define GPENCIL_PIXEL_FACTOR 2000.0f + /* used to expand VBOs. Size has a big impact in the speed */ #define GPENCIL_VBO_BLOCK_SIZE 128 diff --git a/source/blender/draw/engines/gpencil/gpencil_shader_fx.c b/source/blender/draw/engines/gpencil/gpencil_shader_fx.c index e11549c7968..16917593242 100644 --- a/source/blender/draw/engines/gpencil/gpencil_shader_fx.c +++ b/source/blender/draw/engines/gpencil/gpencil_shader_fx.c @@ -1142,7 +1142,7 @@ static void gpencil_vfx_pixelize(PixelShaderFxData *fx, Object *ob, gpIterVfxDat add_v2_fl(ob_center, 0.5f); /* Modify by distance to camera and object scale. */ - float world_pixel_scale = 1.0f / 2000.0f; + float world_pixel_scale = 1.0f / GPENCIL_PIXEL_FACTOR; float scale = mat4_to_scale(ob->obmat); mul_v2_fl(pixel_size, (world_pixel_scale * scale * winmat[1][1] * vp_size[1]) / w); @@ -1198,7 +1198,7 @@ static void gpencil_vfx_shadow(ShadowShaderFxData *fx, Object *ob, gpIterVfxData mul_v3_fl(rot_center, 1.0f / w); /* Modify by distance to camera and object scale. */ - float world_pixel_scale = 1.0f / 2000.0f; + float world_pixel_scale = 1.0f / GPENCIL_PIXEL_FACTOR; float scale = mat4_to_scale(ob->obmat); float distance_factor = (world_pixel_scale * scale * winmat[1][1] * vp_size[1]) / w; mul_v2_fl(offset, distance_factor); @@ -1392,4 +1392,4 @@ void gpencil_vfx_cache_populate(GPENCIL_Data *vedata, Object *ob, GPENCIL_tObjec DRW_shgroup_uniform_int_copy(grp, "isFirstPass", false); DRW_shgroup_call_procedural_triangles(grp, NULL, 1); } -} \ No newline at end of file +} ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [fa6a26e3917] greasepencil-refactor: Merge branch 'greasepencil-object' into greasepencil-refactor
Commit: fa6a26e391729f4c8377bbc524286a295ebae878 Author: Antonio Vazquez Date: Wed Dec 18 10:38:21 2019 +0100 Branches: greasepencil-refactor https://developer.blender.org/rBfa6a26e391729f4c8377bbc524286a295ebae878 Merge branch 'greasepencil-object' into greasepencil-refactor === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [c5e3ee26e72] greasepencil-object: Merge branch 'master' into greasepencil-object
Commit: c5e3ee26e721c821d4179122a7e7209a80823315 Author: Antonio Vazquez Date: Wed Dec 18 10:37:40 2019 +0100 Branches: greasepencil-object https://developer.blender.org/rBc5e3ee26e721c821d4179122a7e7209a80823315 Merge branch 'master' into greasepencil-object === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [e810f4dd7b6] functions: Merge branch 'master' into functions
Commit: e810f4dd7b6c69513f52712cf273285b5ca1c11c Author: Jacques Lucke Date: Wed Dec 18 09:54:06 2019 +0100 Branches: functions https://developer.blender.org/rBe810f4dd7b6c69513f52712cf273285b5ca1c11c Merge branch 'master' into functions === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs