[Bf-blender-cvs] [8f548fd8564] property-search-ui: Merge branch 'master' into property-search-ui
Commit: 8f548fd8564e646b5797d30c8ee23ebbc1a4f8c2 Author: Hans Goudey Date: Mon Jul 27 16:32:49 2020 -0400 Branches: property-search-ui https://developer.blender.org/rB8f548fd8564e646b5797d30c8ee23ebbc1a4f8c2 Merge branch 'master' into property-search-ui === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [b4b2185da0b] property-search-ui: Property Search: Remove debugging information
Commit: b4b2185da0b4816007d1aee3fc8138a40c96 Author: Hans Goudey Date: Mon Jul 27 16:39:43 2020 -0400 Branches: property-search-ui https://developer.blender.org/rBb4b2185da0b4816007d1aee3fc8138a40c96 Property Search: Remove debugging information === M source/blender/editors/space_buttons/space_buttons.c === diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c index 63b91163125..6a173d2dea7 100644 --- a/source/blender/editors/space_buttons/space_buttons.c +++ b/source/blender/editors/space_buttons/space_buttons.c @@ -341,16 +341,6 @@ static void property_search_other_tabs(const bContext *C, UI_blocklist_free(C_copy, _copy->uiblocks); } - printf("\nPROPERTY_SEARCH_OTHER_TABS\n"); - for (int i = 0; i < tabs_tot; i++) { -if (context_tabs_array[i] == -1) { - printf("- - -\n"); -} -printf("tab value: %d, unfiltered: %s\n", - context_tabs_array[i], - (sbuts->context_search_filter_active & (1 << i)) ? "true" : "false"); - } - BKE_area_region_free(CTX_wm_area(C_copy)->type, region_copy); MEM_freeN(region_copy); MEM_freeN(sbuts_copy); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [634bf8e4fcb] property-search-ui: Merge branch 'master' into property-search-ui
Commit: 634bf8e4fcb73c1787e58f42bec380eda9b3df6e Author: Hans Goudey Date: Mon Jul 27 12:34:08 2020 -0400 Branches: property-search-ui https://developer.blender.org/rB634bf8e4fcb73c1787e58f42bec380eda9b3df6e Merge branch 'master' into property-search-ui === === diff --cc source/blender/editors/space_buttons/space_buttons.c index ac0baeb1a68,67efd8f4b8e..63b91163125 --- a/source/blender/editors/space_buttons/space_buttons.c +++ b/source/blender/editors/space_buttons/space_buttons.c @@@ -48,11 -48,8 +48,9 @@@ #include "RNA_define.h" #include "RNA_enum_types.h" +#include "UI_interface.h" #include "UI_resources.h" - #include "GPU_glew.h" - #include "buttons_intern.h" /* own include */ /* default callbacks for buttons space * */ ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [d42530824e4] master: Fix T78994: Clear selected pose doesn't work without animation
Commit: d42530824e434fcc4c8d5394dd65f44cf3e8c16f Author: Hans Goudey Date: Tue Jul 21 09:51:27 2020 -0400 Branches: master https://developer.blender.org/rBd42530824e434fcc4c8d5394dd65f44cf3e8c16f Fix T78994: Clear selected pose doesn't work without animation It looks like the code left this as a todo, but the basic solution is to add an extra parameter to BKE_bose_rest to check whether bones are selected before reseting them. I also corrected the operator description which said it acted on only selected bones even when there is an option to turn that off. The "act on selected" is generally implied for Blender's operators anyway. Differential Revision: https://developer.blender.org/D8319 === M source/blender/blenkernel/BKE_action.h M source/blender/blenkernel/intern/action.c M source/blender/blenkernel/intern/armature.c M source/blender/blenkernel/intern/object.c M source/blender/editors/armature/pose_transform.c === diff --git a/source/blender/blenkernel/BKE_action.h b/source/blender/blenkernel/BKE_action.h index 43071c2966d..b7904ce1879 100644 --- a/source/blender/blenkernel/BKE_action.h +++ b/source/blender/blenkernel/BKE_action.h @@ -209,8 +209,8 @@ void what_does_obaction(struct Object *ob, void BKE_pose_copy_pchan_result(struct bPoseChannel *pchanto, const struct bPoseChannel *pchanfrom); bool BKE_pose_copy_result(struct bPose *to, struct bPose *from); -/* clear all transforms */ -void BKE_pose_rest(struct bPose *pose); +/* Clear transforms. */ +void BKE_pose_rest(struct bPose *pose, bool selected_bones_only); /* Tag pose for recalc. Also tag all related data to be recalc. */ void BKE_pose_tag_recalc(struct Main *bmain, struct bPose *pose); diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index 0ee2fcb1963..fa7eee83a68 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -1512,8 +1512,10 @@ short action_get_item_transforms(bAction *act, Object *ob, bPoseChannel *pchan, /* ** Pose Management Tools ** */ -/* for do_all_pose_actions, clears the pose. Now also exported for proxy and tools */ -void BKE_pose_rest(bPose *pose) +/** + * Zero the pose transforms for the entire pose or only for selected bones. + */ +void BKE_pose_rest(bPose *pose, bool selected_bones_only) { bPoseChannel *pchan; @@ -1525,6 +1527,9 @@ void BKE_pose_rest(bPose *pose) memset(pose->cyclic_offset, 0, sizeof(pose->cyclic_offset)); for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) { +if (selected_bones_only && pchan->bone != NULL && (pchan->bone->flag & BONE_SELECTED) == 0) { + continue; +} zero_v3(pchan->loc); zero_v3(pchan->eul); unit_qt(pchan->quat); diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index e799fb16929..bf04603aa46 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -2164,7 +2164,7 @@ static void pose_proxy_sync(Object *ob, Object *from, int layer_protected) } /* clear all transformation values from library */ - BKE_pose_rest(frompose); + BKE_pose_rest(frompose, false); /* copy over all of the proxy's bone groups */ /* TODO for later diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index a344d2a163f..33c5343e410 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -2088,7 +2088,7 @@ void BKE_object_make_proxy(Main *bmain, Object *ob, Object *target, Object *cob) /* type conversions */ if (target->type == OB_ARMATURE) { copy_object_pose(ob, target, 0); /* data copy, object pointers in constraints */ -BKE_pose_rest(ob->pose); /* clear all transforms in channels */ +BKE_pose_rest(ob->pose, false); /* clear all transforms in channels */ BKE_pose_rebuild(bmain, ob, ob->data, true); /* set all internal links */ armature_set_id_extern(ob); diff --git a/source/blender/editors/armature/pose_transform.c b/source/blender/editors/armature/pose_transform.c index 615d59c3154..a6cf8552ca4 100644 --- a/source/blender/editors/armature/pose_transform.c +++ b/source/blender/editors/armature/pose_transform.c @@ -1262,10 +1262,8 @@ static int pose_clear_user_transforms_exec(bContext *C, wmOperator *op) MEM_freeN(dummyPose); } else { - /* no animation, so just reset whole pose to rest pose - * (cannot just restore for selected though) - */ - BKE_pose_rest(ob->pose); + /* No animation, so
[Bf-blender-cvs] [c2b0c648430] master: UI: Add an outer boundary for edge panning, use in outliner
Commit: c2b0c64843084b6e4189d289fd2d201257fd9448 Author: Hans Goudey Date: Tue Jul 21 10:12:35 2020 -0400 Branches: master https://developer.blender.org/rBc2b0c64843084b6e4189d289fd2d201257fd9448 UI: Add an outer boundary for edge panning, use in outliner Currently if you drag and drop an item from the outliner elsewhere in the Blender window, the outliner will scroll the entire time, even if the mouse is far away. This commit adds optional behavior for the edge pan operator that makes it only act if the mouse is close enough to the region. Differential Revision: https://developer.blender.org/D8193 === M source/blender/blenlib/BLI_rect.h M source/blender/blenlib/intern/rct.c M source/blender/editors/interface/view2d_ops.c M source/blender/editors/space_outliner/outliner_dragdrop.c === diff --git a/source/blender/blenlib/BLI_rect.h b/source/blender/blenlib/BLI_rect.h index b1faae03583..14d18308ed6 100644 --- a/source/blender/blenlib/BLI_rect.h +++ b/source/blender/blenlib/BLI_rect.h @@ -63,6 +63,7 @@ void BLI_rcti_translate(struct rcti *rect, int x, int y); void BLI_rcti_recenter(struct rcti *rect, int x, int y); void BLI_rctf_recenter(struct rctf *rect, float x, float y); void BLI_rcti_resize(struct rcti *rect, int x, int y); +void BLI_rcti_pad(struct rcti *rect, int pad_x, int pad_y); void BLI_rctf_resize(struct rctf *rect, float x, float y); void BLI_rcti_scale(rcti *rect, const float scale); void BLI_rctf_scale(rctf *rect, const float scale); diff --git a/source/blender/blenlib/intern/rct.c b/source/blender/blenlib/intern/rct.c index ad8443683f8..bf3c8730b01 100644 --- a/source/blender/blenlib/intern/rct.c +++ b/source/blender/blenlib/intern/rct.c @@ -635,6 +635,14 @@ void BLI_rcti_resize(rcti *rect, int x, int y) rect->ymax = rect->ymin + y; } +void BLI_rcti_pad(rcti *rect, int pad_x, int pad_y) +{ + rect->xmin -= pad_x; + rect->ymin -= pad_y; + rect->xmax += pad_x; + rect->ymax += pad_y; +} + void BLI_rctf_resize(rctf *rect, float x, float y) { rect->xmin = BLI_rctf_cent_x(rect) - (x * 0.5f); diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index c37a7279773..64cacd44e3d 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -475,20 +475,29 @@ static int view_edge_pan_modal(bContext *C, wmOperator *op, const wmEvent *event * On successful handling, always pass events on to other handlers. */ const int success_retval = OPERATOR_PASS_THROUGH; - /* Find whether the mouse is beyond X and Y edges. */ + int outside_padding = RNA_int_get(op->ptr, "outside_padding") * UI_UNIT_X; + rcti padding_rect; + if (outside_padding != 0) { +padding_rect = region->winrct; +BLI_rcti_pad(_rect, outside_padding, outside_padding); + } + int pan_dir_x = 0; int pan_dir_y = 0; - if (event->x > region->winrct.xmax - EDGE_PAN_REGION_PAD) { -pan_dir_x = 1; - } - else if (event->x < region->winrct.xmin + EDGE_PAN_REGION_PAD) { -pan_dir_x = -1; - } - if (event->y > region->winrct.ymax - EDGE_PAN_REGION_PAD) { -pan_dir_y = 1; - } - else if (event->y < region->winrct.ymin + EDGE_PAN_REGION_PAD) { -pan_dir_y = -1; + if ((outside_padding == 0) || BLI_rcti_isect_pt(_rect, event->x, event->y)) { +/* Find whether the mouse is beyond X and Y edges. */ +if (event->x > region->winrct.xmax - EDGE_PAN_REGION_PAD) { + pan_dir_x = 1; +} +else if (event->x < region->winrct.xmin + EDGE_PAN_REGION_PAD) { + pan_dir_x = -1; +} +if (event->y > region->winrct.ymax - EDGE_PAN_REGION_PAD) { + pan_dir_y = 1; +} +else if (event->y < region->winrct.ymin + EDGE_PAN_REGION_PAD) { + pan_dir_y = -1; +} } const double current_time = PIL_check_seconds_timer(); @@ -532,6 +541,16 @@ static void VIEW2D_OT_edge_pan(wmOperatorType *ot) /* operator is modal */ ot->flag = OPTYPE_INTERNAL; + RNA_def_int(ot->srna, + "outside_padding", + 0, + 0, + 100, + "Outside Padding", + "Padding around the region in UI units within which panning is activated (0 to " + "disable boundary)", + 0, + 100); } #undef EDGE_PAN_REGION_PAD diff --git a/source/blender/editors/space_outliner/outliner_dragdrop.c b/source/blender/editors/space_outliner/outliner_dragdrop.c index 09d7f889bde..5baaef958fa 100644 --- a/source/blender/editors/space_outliner/outliner_dragdrop.c +++ b/source/blender/editors/space_outliner/outliner_dragdrop.c @@ -858,6 +858,8 @@ void OUTLINER_OT_collection_drop(wmOper
[Bf-blender-cvs] [17ebbdf1c17] master: UI: Use consistent layout for custom operator UI
Commit: 17ebbdf1c17dab4872d2b3deea77a35524fe14b9 Author: Hans Goudey Date: Tue Jul 21 11:13:18 2020 -0400 Branches: master https://developer.blender.org/rB17ebbdf1c17dab4872d2b3deea77a35524fe14b9 UI: Use consistent layout for custom operator UI Operators are one of the last places in Blender to use older UI designs that don't fit in with recent style conventions. This commit updates these custom operator UI callbacks for consistency and clarity. Some of the code is also simplified a lot. Some of the older operator layouts were much more complex (in terms of code) than they needed to be. See the differential revision for a before and after screenshot of each operator. Differential Revision: https://developer.blender.org/D8326 === M source/blender/editors/io/io_alembic.c M source/blender/editors/io/io_collada.c M source/blender/editors/io/io_usd.c M source/blender/editors/mesh/editmesh_bevel.c M source/blender/editors/mesh/editmesh_tools.c M source/blender/editors/object/object_add.c M source/blender/editors/screen/screendump.c M source/blender/editors/sound/sound_ops.c M source/blender/editors/space_image/image_ops.c === diff --git a/source/blender/editors/io/io_alembic.c b/source/blender/editors/io/io_alembic.c index 9db1fe31494..238ebffe153 100644 --- a/source/blender/editors/io/io_alembic.c +++ b/source/blender/editors/io/io_alembic.c @@ -158,99 +158,78 @@ static int wm_alembic_export_exec(bContext *C, wmOperator *op) static void ui_alembic_export_settings(uiLayout *layout, PointerRNA *imfptr) { - uiLayout *box; - uiLayout *row; - uiLayout *col; + uiLayout *box, *row, *col, *sub; + + uiLayoutSetPropSep(layout, true); + uiLayoutSetPropDecorate(layout, false); box = uiLayoutBox(layout); - row = uiLayoutRow(box, false); - uiItemL(row, IFACE_("Manual Transform:"), ICON_NONE); + uiItemL(box, IFACE_("Manual Transform"), ICON_NONE); - row = uiLayoutRow(box, false); - uiItemR(row, imfptr, "global_scale", 0, NULL, ICON_NONE); + uiItemR(box, imfptr, "global_scale", 0, NULL, ICON_NONE); /* Scene Options */ box = uiLayoutBox(layout); row = uiLayoutRow(box, false); - uiItemL(row, IFACE_("Scene Options:"), ICON_SCENE_DATA); - - row = uiLayoutRow(box, false); - uiItemR(row, imfptr, "start", 0, NULL, ICON_NONE); - - row = uiLayoutRow(box, false); - uiItemR(row, imfptr, "end", 0, NULL, ICON_NONE); - - row = uiLayoutRow(box, false); - uiItemR(row, imfptr, "xsamples", 0, NULL, ICON_NONE); - - row = uiLayoutRow(box, false); - uiItemR(row, imfptr, "gsamples", 0, NULL, ICON_NONE); + uiItemL(row, IFACE_("Scene Options"), ICON_SCENE_DATA); - row = uiLayoutRow(box, false); - uiItemR(row, imfptr, "sh_open", 0, NULL, ICON_NONE); + col = uiLayoutColumn(box, false); - row = uiLayoutRow(box, false); - uiItemR(row, imfptr, "sh_close", 0, NULL, ICON_NONE); + sub = uiLayoutColumn(col, true); + uiItemR(sub, imfptr, "start", 0, IFACE_("Frame Start"), ICON_NONE); + uiItemR(sub, imfptr, "end", 0, IFACE_("End"), ICON_NONE); - row = uiLayoutRow(box, false); - uiItemR(row, imfptr, "selected", 0, NULL, ICON_NONE); + uiItemR(col, imfptr, "xsamples", 0, IFACE_("Samples Transform"), ICON_NONE); + uiItemR(col, imfptr, "gsamples", 0, IFACE_("Geometry"), ICON_NONE); - row = uiLayoutRow(box, false); - uiItemR(row, imfptr, "renderable_only", 0, NULL, ICON_NONE); + sub = uiLayoutColumn(col, true); + uiItemR(sub, imfptr, "sh_open", UI_ITEM_R_SLIDER, NULL, ICON_NONE); + uiItemR(sub, imfptr, "sh_close", UI_ITEM_R_SLIDER, IFACE_("Close"), ICON_NONE); - row = uiLayoutRow(box, false); - uiItemR(row, imfptr, "visible_objects_only", 0, NULL, ICON_NONE); + uiItemS(col); - row = uiLayoutRow(box, false); - uiItemR(row, imfptr, "flatten", 0, NULL, ICON_NONE); + uiItemR(col, imfptr, "flatten", 0, NULL, ICON_NONE); + sub = uiLayoutColumnWithHeading(col, true, IFACE_("Only")); + uiItemR(sub, imfptr, "selected", 0, IFACE_("Selected Objects"), ICON_NONE); + uiItemR(sub, imfptr, "renderable_only", 0, IFACE_("Renderable Objects"), ICON_NONE); + uiItemR(sub, imfptr, "visible_objects_only", 0, IFACE_("Visible Objects"), ICON_NONE); /* Object Data */ box = uiLayoutBox(layout); row = uiLayoutRow(box, false); - uiItemL(row, IFACE_("Object Options:"), ICON_OBJECT_DATA); + uiItemL(row, IFACE_("Object Options"), ICON_OBJECT_DATA); - row = uiLayoutRow(box, false); - uiItemR(row, imfptr, "uvs", 0, NULL, ICON_NONE);
[Bf-blender-cvs] [6c7e62ef9be] master: UI: Adjust Multiresolution Modifier Layout
Commit: 6c7e62ef9be564fbee279c7467c9b6adaf51b6c8 Author: Hans Goudey Date: Tue Jul 21 11:27:05 2020 -0400 Branches: master https://developer.blender.org/rB6c7e62ef9be564fbee279c7467c9b6adaf51b6c8 UI: Adjust Multiresolution Modifier Layout Adjusting the layout for this modifier is the final part of the modifier UI project for 2.90. This layout exposes the most important information, the levels and subdivision controls, by default, putting other contols in collapsed subpanels. Note that there is empty space for the "Delete Lower" button that is still planned for 2.90. And there will also eventually be more items added to the "Shape" panel, maybe for 2.90. Differential Revision: https://developer.blender.org/D8187 === M source/blender/modifiers/intern/MOD_multires.c === diff --git a/source/blender/modifiers/intern/MOD_multires.c b/source/blender/modifiers/intern/MOD_multires.c index 53e53315cfe..b05a42d 100644 --- a/source/blender/modifiers/intern/MOD_multires.c +++ b/source/blender/modifiers/intern/MOD_multires.c @@ -75,6 +75,9 @@ static void initData(ModifierData *md) mmd->uv_smooth = SUBSURF_UV_SMOOTH_PRESERVE_CORNERS; mmd->quality = 4; mmd->flags |= (eMultiresModifierFlag_UseCrease | eMultiresModifierFlag_ControlEdges); + + /* Open subdivision panels by default. */ + md->ui_expand_flag = (1 << 0) | (1 << 1); } static void copyData(const ModifierData *md_src, ModifierData *md_dst, const int flag) @@ -287,13 +290,37 @@ static void deformMatrices(ModifierData *md, static void panel_draw(const bContext *C, Panel *panel) { - uiLayout *row, *col, *split, *col2; + uiLayout *col; + uiLayout *layout = panel->layout; + + PointerRNA ptr; + modifier_panel_get_property_pointers(C, panel, NULL, ); + + uiLayoutSetPropSep(layout, true); + + col = uiLayoutColumn(layout, true); + uiItemR(col, , "levels", 0, IFACE_("Level Viewport"), ICON_NONE); + uiItemR(col, , "sculpt_levels", 0, IFACE_("Sculpt"), ICON_NONE); + uiItemR(col, , "render_levels", 0, IFACE_("Render"), ICON_NONE); + + uiItemR(layout, , "show_only_control_edges", 0, NULL, ICON_NONE); + + modifier_panel_end(layout, ); +} + +static void subdivisions_panel_draw(const bContext *C, Panel *panel) +{ + uiLayout *row; uiLayout *layout = panel->layout; PointerRNA ptr; PointerRNA ob_ptr; modifier_panel_get_property_pointers(C, panel, _ptr, ); + uiLayoutSetEnabled(layout, RNA_enum_get(_ptr, "mode") != OB_MODE_EDIT); + + MultiresModifierData *mmd = (MultiresModifierData *)ptr.data; + /** * Changing some of the properties can not be done once there is an * actual displacement stored for this multi-resolution modifier. @@ -304,33 +331,9 @@ static void panel_draw(const bContext *C, Panel *panel) * non-zero displacement, but such checks will be too slow to be done * on every redraw. */ - bool has_displacement = RNA_int_get(, "total_levels") != 0; - MultiresModifierData *mmd = (MultiresModifierData *)ptr.data; - - uiLayoutSetPropSep(layout, true); - - col = uiLayoutColumn(layout, false); - uiLayoutSetEnabled(col, !has_displacement); - uiItemR(col, , "subdivision_type", 0, NULL, ICON_NONE); - - col = uiLayoutColumn(layout, true); - uiItemR(col, , "sculpt_levels", 0, IFACE_("Levels Sculpt"), ICON_NONE); - uiItemR(col, , "levels", 0, IFACE_("Viewport"), ICON_NONE); - uiItemR(col, , "render_levels", 0, IFACE_("Render"), ICON_NONE); - uiItemR(layout, , "show_only_control_edges", 0, NULL, ICON_NONE); - - uiItemS(layout); - split = uiLayoutSplit(layout, 0.5f, false); - uiLayoutSetEnabled(split, RNA_enum_get(_ptr, "mode") != OB_MODE_EDIT); - col = uiLayoutColumn(split, false); - col2 = uiLayoutColumn(split, false); - - uiItemO(col, IFACE_("Unsubdivide"), ICON_NONE, "OBJECT_OT_multires_unsubdivide"); - - row = uiLayoutRow(col2, true); PointerRNA op_ptr; - uiItemFullO(row, + uiItemFullO(layout, "OBJECT_OT_multires_subdivide", IFACE_("Subdivide"), ICON_NONE, @@ -340,10 +343,12 @@ static void panel_draw(const bContext *C, Panel *panel) _ptr); RNA_enum_set(_ptr, "mode", MULTIRES_SUBDIVIDE_CATMULL_CLARK); RNA_string_set(_ptr, "modifier", ((ModifierData *)mmd)->name); + + row = uiLayoutRow(layout, false); uiItemFullO(row, "OBJECT_OT_multires_subdivide", IFACE_("Simple"), - ICON_NONE, /* TODO: Needs icon, remove text */ + ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, 0, @@ -3
[Bf-blender-cvs] [4b0a94661c0] property-search-ui: Property Search: Clean up some unecessary changes
Commit: 4b0a94661c058e0f0111e4cbdd50b50b02841648 Author: Hans Goudey Date: Thu Jul 23 11:36:40 2020 -0400 Branches: property-search-ui https://developer.blender.org/rB4b0a94661c058e0f0111e4cbdd50b50b02841648 Property Search: Clean up some unecessary changes === M release/scripts/startup/bl_ui/space_properties.py M source/blender/editors/interface/interface.c M source/blender/editors/interface/interface_layout.c M source/blender/makesrna/intern/rna_space.c === diff --git a/release/scripts/startup/bl_ui/space_properties.py b/release/scripts/startup/bl_ui/space_properties.py index 35a4e608785..c5b019d58bb 100644 --- a/release/scripts/startup/bl_ui/space_properties.py +++ b/release/scripts/startup/bl_ui/space_properties.py @@ -52,7 +52,7 @@ class PROPERTIES_PT_navigation_bar(Panel): layout.scale_x = 1.4 layout.scale_y = 1.4 -if (view.filter_text): +if view.filter_text: layout.prop_tabs_enum(view, "context", data_highlight=view, property_highlight="context_search_filter_active", icon_only=True) else: diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 05abc16fafd..aea24304127 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -3356,7 +3356,7 @@ uiBlock *UI_block_begin(const bContext *C, ARegion *region, const char *name, sh block->dt = dt; block->evil_C = (void *)C; /* XXX */ - /* Set the search filter int he properties area. */ + /* Set the search filter in the properties editor. */ if ((region && region->regiontype == RGN_TYPE_WINDOW) && (area && area->spacetype == SPACE_PROPERTIES)) { SpaceProperties *sbuts = CTX_wm_space_properties(C); diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index b83294a86ec..3ac38a4465e 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -2171,6 +2171,7 @@ void uiItemFullR(uiLayout *layout, /* Split the label / property. */ uiLayout *layout_parent = layout; + if (use_prop_sep) { uiLayout *layout_row = NULL; #ifdef UI_PROP_DECORATE @@ -5979,9 +5980,6 @@ void uiLayoutSetFunc(uiLayout *layout, uiMenuHandleFunc handlefunc, void *argv) layout->root->argv = argv; } -/** - * Finish the layout process and solve for the size of a block. - */ void UI_block_layout_resolve(uiBlock *block, int *r_x, int *r_y) { uiLayoutRoot *root; diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 5833ebffd29..dbad8a536d5 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -1806,27 +1806,6 @@ static const EnumPropertyItem *rna_SpaceProperties_context_itemf(bContext *UNUSE return item; } -// static const int rna_SpaceProperties_context_search_filter_active_get(PointerRNA *ptr) -// { -// SpaceProperties *sbuts = (SpaceProperties *)(ptr->data); - -// int context_tabs_array[32]; -// int totitem = ED_buttons_tabs_list(sbuts, context_tabs_array); - -// int retval = 0; -// for (int i = 0; i < totitem; i++) { -// if (context_tabs_array[i] == -1) { -// continue; -// } -// int tab_context = context_tabs_array[i]; -// if (sbuts->context_search_filter_active & (1 << tab_context)) { -// retval |= (1 << i); -// } -// } - -// return retval; -// } - static void rna_SpaceProperties_context_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [8eda823dbc2] property-search-ui: Merge branch 'master' into property-search-ui
Commit: 8eda823dbc242d4b8b9625dc11e4428f0c1d2278 Author: Hans Goudey Date: Thu Jul 23 11:04:11 2020 -0400 Branches: property-search-ui https://developer.blender.org/rB8eda823dbc242d4b8b9625dc11e4428f0c1d2278 Merge branch 'master' into property-search-ui === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [6f3c37a3ff8] master: UI: Move properties tab list creation from RNA to editor
Commit: 6f3c37a3ff83222bf8d2de8a888b63bdfb70c079 Author: Hans Goudey Date: Thu Jul 23 11:01:59 2020 -0400 Branches: master https://developer.blender.org/rB6f3c37a3ff83222bf8d2de8a888b63bdfb70c079 UI: Move properties tab list creation from RNA to editor This is a change I pulled from the property-search-ui branch, where I have to use the list of tabs to search the inactive tabs and it makes more sense to use the array directly. It is also an improvement to have this fundamental code to the properties editor in the editor code rather than an RNA callback. There are no functional changes. Differential Revision: https://developer.blender.org/D8368 === M source/blender/editors/include/ED_buttons.h M source/blender/editors/space_buttons/space_buttons.c M source/blender/makesrna/intern/rna_space.c === diff --git a/source/blender/editors/include/ED_buttons.h b/source/blender/editors/include/ED_buttons.h index 2eaef5e82e0..455eee8580d 100644 --- a/source/blender/editors/include/ED_buttons.h +++ b/source/blender/editors/include/ED_buttons.h @@ -27,6 +27,10 @@ extern "C" { #endif +struct SpaceProperties; + +int ED_buttons_tabs_list(struct SpaceProperties *sbuts, int *context_tabs_array); + #ifdef __cplusplus } #endif diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c index 88c2c6e82b6..8337c9b792a 100644 --- a/source/blender/editors/space_buttons/space_buttons.c +++ b/source/blender/editors/space_buttons/space_buttons.c @@ -35,6 +35,7 @@ #include "BKE_screen.h" #include "BKE_shader_fx.h" +#include "ED_buttons.h" #include "ED_screen.h" #include "ED_space_api.h" #include "ED_view3d.h" /* To draw toolbar UI. */ @@ -139,6 +140,98 @@ static void buttons_main_region_init(wmWindowManager *wm, ARegion *region) WM_event_add_keymap_handler(>handlers, keymap); } +/** + * Fills an array with the tab context values for the properties editor. -1 signals a separator. + * + * \return The total number of items in the array returned. + */ +int ED_buttons_tabs_list(SpaceProperties *sbuts, int *context_tabs_array) +{ + int length = 0; + if (sbuts->pathflag & (1 << BCONTEXT_TOOL)) { +context_tabs_array[length] = BCONTEXT_TOOL; +length++; + } + if (length != 0) { +context_tabs_array[length] = -1; +length++; + } + if (sbuts->pathflag & (1 << BCONTEXT_RENDER)) { +context_tabs_array[length] = BCONTEXT_RENDER; +length++; + } + if (sbuts->pathflag & (1 << BCONTEXT_OUTPUT)) { +context_tabs_array[length] = BCONTEXT_OUTPUT; +length++; + } + if (sbuts->pathflag & (1 << BCONTEXT_VIEW_LAYER)) { +context_tabs_array[length] = BCONTEXT_VIEW_LAYER; +length++; + } + if (sbuts->pathflag & (1 << BCONTEXT_SCENE)) { +context_tabs_array[length] = BCONTEXT_SCENE; +length++; + } + if (sbuts->pathflag & (1 << BCONTEXT_WORLD)) { +context_tabs_array[length] = BCONTEXT_WORLD; +length++; + } + if (length != 0) { +context_tabs_array[length] = -1; +length++; + } + if (sbuts->pathflag & (1 << BCONTEXT_OBJECT)) { +context_tabs_array[length] = BCONTEXT_OBJECT; +length++; + } + if (sbuts->pathflag & (1 << BCONTEXT_MODIFIER)) { +context_tabs_array[length] = BCONTEXT_MODIFIER; +length++; + } + if (sbuts->pathflag & (1 << BCONTEXT_SHADERFX)) { +context_tabs_array[length] = BCONTEXT_SHADERFX; +length++; + } + if (sbuts->pathflag & (1 << BCONTEXT_PARTICLE)) { +context_tabs_array[length] = BCONTEXT_PARTICLE; +length++; + } + if (sbuts->pathflag & (1 << BCONTEXT_PHYSICS)) { +context_tabs_array[length] = BCONTEXT_PHYSICS; +length++; + } + if (sbuts->pathflag & (1 << BCONTEXT_CONSTRAINT)) { +context_tabs_array[length] = BCONTEXT_CONSTRAINT; +length++; + } + if (sbuts->pathflag & (1 << BCONTEXT_DATA)) { +context_tabs_array[length] = BCONTEXT_DATA; +length++; + } + if (sbuts->pathflag & (1 << BCONTEXT_BONE)) { +context_tabs_array[length] = BCONTEXT_BONE; +length++; + } + if (sbuts->pathflag & (1 << BCONTEXT_BONE_CONSTRAINT)) { +context_tabs_array[length] = BCONTEXT_BONE_CONSTRAINT; +length++; + } + if (sbuts->pathflag & (1 << BCONTEXT_MATERIAL)) { +context_tabs_array[length] = BCONTEXT_MATERIAL; +length++; + } + if (length != 0) { +context_tabs_array[length] = -1; +length++; + } + if (sbuts->pathflag & (1 << BCONTEXT_TEXTURE)) { +context_tabs_array[length] = BCONTEXT_TEXTURE; +length++; + } + + return length; +} + static void buttons_main_
[Bf-blender-cvs] [af146e77454] property-search-ui: Use operator to toggle pin data-block
Commit: af146e774546d9c2b5ba1e425d3f42b9b4d35b0b Author: Hans Goudey Date: Thu Jul 23 12:16:49 2020 -0400 Branches: property-search-ui https://developer.blender.org/rBaf146e774546d9c2b5ba1e425d3f42b9b4d35b0b Use operator to toggle pin data-block === M release/scripts/startup/bl_ui/space_properties.py M source/blender/editors/space_buttons/buttons_intern.h M source/blender/editors/space_buttons/buttons_ops.c M source/blender/editors/space_buttons/space_buttons.c === diff --git a/release/scripts/startup/bl_ui/space_properties.py b/release/scripts/startup/bl_ui/space_properties.py index c5b019d58bb..a6cff0b2787 100644 --- a/release/scripts/startup/bl_ui/space_properties.py +++ b/release/scripts/startup/bl_ui/space_properties.py @@ -36,7 +36,7 @@ class PROPERTIES_HT_header(Header): # Note: pin ID doesn't properly work with this simple button in python yet. row = layout.row() row.emboss = 'NONE' -row.prop(view, "use_pin_id", icon=('PINNED' if view.use_pin_id else 'UNPINNED'), text="") +row.operator("buttons.toggle_pin", icon=('PINNED' if view.use_pin_id else 'UNPINNED'), text="") class PROPERTIES_PT_navigation_bar(Panel): diff --git a/source/blender/editors/space_buttons/buttons_intern.h b/source/blender/editors/space_buttons/buttons_intern.h index ce6490f6baa..459c0dc2448 100644 --- a/source/blender/editors/space_buttons/buttons_intern.h +++ b/source/blender/editors/space_buttons/buttons_intern.h @@ -92,6 +92,7 @@ void buttons_texture_context_compute(const struct bContext *C, struct SpacePrope /* buttons_ops.c */ void BUTTONS_OT_start_filter(struct wmOperatorType *ot); void BUTTONS_OT_clear_filter(struct wmOperatorType *ot); +void BUTTONS_OT_toggle_pin(struct wmOperatorType *ot); void BUTTONS_OT_file_browse(struct wmOperatorType *ot); void BUTTONS_OT_directory_browse(struct wmOperatorType *ot); void BUTTONS_OT_context_menu(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_buttons/buttons_ops.c b/source/blender/editors/space_buttons/buttons_ops.c index d0fc17aa6c2..9c2ef613ba4 100644 --- a/source/blender/editors/space_buttons/buttons_ops.c +++ b/source/blender/editors/space_buttons/buttons_ops.c @@ -108,6 +108,33 @@ void BUTTONS_OT_clear_filter(struct wmOperatorType *ot) ot->poll = ED_operator_buttons_active; } +/** pin id operator */ + +static int toggle_pin_exec(bContext *C, wmOperator *UNUSED(op)) +{ + SpaceProperties *sbuts = CTX_wm_space_properties(C); + + sbuts->pinid = (sbuts->flag & SB_PIN_CONTEXT) ? NULL : buttons_context_id_path(C); + + sbuts->flag ^= SB_PIN_CONTEXT; + + ED_area_tag_redraw(CTX_wm_area(C)); + + return OPERATOR_FINISHED; +} + +void BUTTONS_OT_toggle_pin(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Toggle Pin ID"; + ot->description = "Keep the current data-block displayed"; + ot->idname = "BUTTONS_OT_toggle_pin"; + + /* api callbacks */ + ot->exec = toggle_pin_exec; + ot->poll = ED_operator_buttons_active; +} + /** context_menu operator */ static int context_menu_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *UNUSED(event)) diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c index 56b693f9e2b..ac0baeb1a68 100644 --- a/source/blender/editors/space_buttons/space_buttons.c +++ b/source/blender/editors/space_buttons/space_buttons.c @@ -399,6 +399,7 @@ static void buttons_operatortypes(void) { WM_operatortype_append(BUTTONS_OT_start_filter); WM_operatortype_append(BUTTONS_OT_clear_filter); + WM_operatortype_append(BUTTONS_OT_toggle_pin); WM_operatortype_append(BUTTONS_OT_context_menu); WM_operatortype_append(BUTTONS_OT_file_browse); WM_operatortype_append(BUTTONS_OT_directory_browse); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [1afdc925113] property-search-ui: Merge branch 'master' into property-search-ui
Commit: 1afdc9251136de35acf9b58444a710bbe907d43d Author: Hans Goudey Date: Wed Jul 22 11:35:02 2020 -0400 Branches: property-search-ui https://developer.blender.org/rB1afdc9251136de35acf9b58444a710bbe907d43d Merge branch 'master' into property-search-ui === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [cc1201dce39] property-search-ui: Property Search: Improve debug printing
Commit: cc1201dce398417d5fcc9a64ebdad97599d38a21 Author: Hans Goudey Date: Wed Jul 22 12:09:54 2020 -0400 Branches: property-search-ui https://developer.blender.org/rBcc1201dce398417d5fcc9a64ebdad97599d38a21 Property Search: Improve debug printing === M source/blender/editors/space_buttons/space_buttons.c === diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c index 57d67e2acb6..74aad9c125e 100644 --- a/source/blender/editors/space_buttons/space_buttons.c +++ b/source/blender/editors/space_buttons/space_buttons.c @@ -343,7 +343,11 @@ static void property_search_other_tabs(const bContext *C, UI_blocklist_free(C_copy, _copy->uiblocks); } + printf("\nPROPERTY_SEARCH_OTHER_TABS\n"); for (int i = 0; i < tabs_tot; i++) { +if (context_tabs_array[i] == -1) { + printf("- - -\n"); +} printf("tab value: %d, unfiltered: %s\n", context_tabs_array[i], (sbuts->context_search_filter_active & (1 << i)) ? "true" : "else"); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [d219d0efa13] property-search-ui: Property Search: Fix graying out tabs with no results
Commit: d219d0efa13cc35c888df6f6bfe71035d1426cc4 Author: Hans Goudey Date: Wed Jul 22 15:14:06 2020 -0400 Branches: property-search-ui https://developer.blender.org/rBd219d0efa13cc35c888df6f6bfe71035d1426cc4 Property Search: Fix graying out tabs with no results === M release/scripts/startup/bl_ui/space_properties.py M source/blender/editors/include/UI_interface.h M source/blender/editors/interface/interface_layout.c M source/blender/editors/space_buttons/space_buttons.c M source/blender/makesrna/intern/rna_ui_api.c === diff --git a/release/scripts/startup/bl_ui/space_properties.py b/release/scripts/startup/bl_ui/space_properties.py index 311892cab15..35a4e608785 100644 --- a/release/scripts/startup/bl_ui/space_properties.py +++ b/release/scripts/startup/bl_ui/space_properties.py @@ -53,7 +53,8 @@ class PROPERTIES_PT_navigation_bar(Panel): layout.scale_x = 1.4 layout.scale_y = 1.4 if (view.filter_text): -layout.prop_tabs_enum(view, "context_search_filter_active", icon_only=True) +layout.prop_tabs_enum(view, "context", data_highlight=view, +property_highlight="context_search_filter_active", icon_only=True) else: layout.prop_tabs_enum(view, "context", icon_only=True) diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 945be665d82..903caab2f22 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -2420,6 +2420,8 @@ void uiItemTabsEnumR_prop(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, PropertyRNA *prop, + struct PointerRNA *ptr_highlight, + PropertyRNA *prop_highlight, bool icon_only); /* UI Operators */ diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 9e6b42d0858..b83294a86ec 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -920,6 +920,8 @@ static void ui_item_enum_expand_tabs(uiLayout *layout, uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, + PointerRNA *ptr_highlight, + PropertyRNA *prop_highlight, const char *uiname, const int h, const bool icon_only) @@ -928,8 +930,26 @@ static void ui_item_enum_expand_tabs(uiLayout *layout, ui_item_enum_expand_exec(layout, block, ptr, prop, uiname, h, UI_BTYPE_TAB, icon_only, NULL); BLI_assert(last != block->buttons.last); + + const bool use_custom_highlight = (prop_highlight != NULL); + + int custom_highlight_flag = 0; /* Max of 32 tabs. */ + if (use_custom_highlight) { +BLI_assert(prop_highlight != NULL); +BLI_assert(RNA_property_flag(prop_highlight) & PROP_ENUM_FLAG); +custom_highlight_flag = RNA_property_enum_get(ptr_highlight, prop_highlight); + } + + int i = 0; for (uiBut *tab = last ? last->next : block->buttons.first; tab; tab = tab->next) { UI_but_drawflag_enable(tab, ui_but_align_opposite_to_area_align_get(CTX_wm_region(C))); + +if (use_custom_highlight) { + if (!(custom_highlight_flag & (1 << i))) { +tab->flag |= UI_BUT_INACTIVE; + } +} +i++; } } @@ -3564,13 +3584,19 @@ void uiItemMenuEnumR( uiItemMenuEnumR_prop(layout, ptr, prop, name, icon); } -void uiItemTabsEnumR_prop( -uiLayout *layout, bContext *C, PointerRNA *ptr, PropertyRNA *prop, bool icon_only) +void uiItemTabsEnumR_prop(uiLayout *layout, + bContext *C, + PointerRNA *ptr, + PropertyRNA *prop, + PointerRNA *ptr_highlight, + PropertyRNA *prop_highlight, + bool icon_only) { uiBlock *block = layout->root->block; UI_block_layout_set_current(block, layout); - ui_item_enum_expand_tabs(layout, C, block, ptr, prop, NULL, UI_UNIT_Y, icon_only); + ui_item_enum_expand_tabs( + layout, C, block, ptr, prop, ptr_highlight, prop_highlight, NULL, UI_UNIT_Y, icon_only); } /** \} */ diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c index 74aad9c125e..56b693f9e2b 100644 --- a/source/blender/editors/space_buttons/space_but
[Bf-blender-cvs] [68df739bb19] property-search-ui-v2: Merge branch 'master' into property-search-ui-v2
Commit: 68df739bb195144189c303a59fbc46328e4ef55c Author: Hans Goudey Date: Wed Jul 29 17:21:13 2020 -0400 Branches: property-search-ui-v2 https://developer.blender.org/rB68df739bb195144189c303a59fbc46328e4ef55c Merge branch 'master' into property-search-ui-v2 === === diff --cc source/blender/editors/include/UI_interface.h index a3fc66484d0,2c42f3a5071..2cb4cca9f84 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@@ -676,10 -671,7 +676,10 @@@ enum }; void UI_block_theme_style_set(uiBlock *block, char theme_style); char UI_block_emboss_get(uiBlock *block); - void UI_block_emboss_set(uiBlock *block, char dt); + void UI_block_emboss_set(uiBlock *block, char emboss); +bool UI_block_has_search_filter(const uiBlock *block); +bool UI_block_is_search_only(const uiBlock *block); +void UI_block_set_search_only(uiBlock *block, bool search_only); void UI_block_free(const struct bContext *C, uiBlock *block); void UI_blocklist_free(const struct bContext *C, struct ListBase *lb); diff --cc source/blender/editors/interface/interface.c index b8c0199cd28,b28a6f530f6..c053f252a7a --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@@ -3366,16 -3365,9 +3366,16 @@@ uiBlock *UI_block_begin(const bContext block = MEM_callocN(sizeof(uiBlock), "uiBlock"); block->active = 1; - block->dt = dt; + block->emboss = emboss; block->evil_C = (void *)C; /* XXX */ + /* Set the search filter for the properties editor. */ + if ((region && region->regiontype == RGN_TYPE_WINDOW) && + (area && area->spacetype == SPACE_PROPERTIES)) { +SpaceProperties *sbuts = CTX_wm_space_properties(C); +block->search_filter = sbuts->search_string; + } + if (scn) { /* store display device name, don't lookup for transformations yet * block could be used for non-color displays where looking up for transformation ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [ba2eef2f6fb] property-search-ui-v2: Property Search: Remove code for changing to search layout
Commit: ba2eef2f6fb7cc0c48353081417a39699c8b4a1b Author: Hans Goudey Date: Thu Jul 30 12:29:14 2020 -0400 Branches: property-search-ui-v2 https://developer.blender.org/rBba2eef2f6fb7cc0c48353081417a39699c8b4a1b Property Search: Remove code for changing to search layout The design for this task has changed so that the layouts won't be changed to only list the matching properties. Instead we will use highlights to communicate matching properties. After this commit property search doesn't do anything visible. Functionality will be added back in future commits. === M release/scripts/startup/bl_ui/properties_constraint.py M release/scripts/startup/bl_ui/properties_data_modifier.py M source/blender/editors/include/UI_interface.h M source/blender/editors/interface/interface_layout.c M source/blender/editors/interface/interface_panel.c M source/blender/editors/screen/area.c M source/blender/makesrna/intern/rna_ui.c === diff --git a/release/scripts/startup/bl_ui/properties_constraint.py b/release/scripts/startup/bl_ui/properties_constraint.py index f5177b81c95..215c96a5975 100644 --- a/release/scripts/startup/bl_ui/properties_constraint.py +++ b/release/scripts/startup/bl_ui/properties_constraint.py @@ -44,7 +44,6 @@ class OBJECT_PT_constraints(ObjectConstraintPanel): def draw(self, context): layout = self.layout -layout.use_property_search = False layout.operator_menu_enum("object.constraint_add", "type", text="Add Object Constraint") @@ -59,7 +58,6 @@ class BONE_PT_constraints(BoneConstraintPanel): def draw(self, context): layout = self.layout -layout.use_property_search = False layout.operator_menu_enum("pose.constraint_add", "type", text="Add Bone Constraint") diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py index 10f954a604b..d464a3ffc6b 100644 --- a/release/scripts/startup/bl_ui/properties_data_modifier.py +++ b/release/scripts/startup/bl_ui/properties_data_modifier.py @@ -39,7 +39,6 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel): def draw(self, context): layout = self.layout -layout.use_property_search = False layout.operator_menu_enum("object.modifier_add", "type") layout.template_modifiers() diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 2cb4cca9f84..e62e84142ea 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -1907,7 +1907,6 @@ void uiLayoutSetUnitsY(uiLayout *layout, float unit); void uiLayoutSetEmboss(uiLayout *layout, char emboss); void uiLayoutSetPropSep(uiLayout *layout, bool is_sep); void uiLayoutSetPropDecorate(uiLayout *layout, bool is_sep); -void uiLayoutSetPropSearch(uiLayout *layout, bool is_searchable); int uiLayoutGetLocalDir(const uiLayout *layout); int uiLayoutGetOperatorContext(uiLayout *layout); diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 2608e4b5060..41bb7127c32 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -145,7 +145,6 @@ enum { * Enabled by default, depends on 'UI_ITEM_PROP_SEP'. */ UI_ITEM_PROP_DECORATE = 1 << 5, UI_ITEM_PROP_DECORATE_NO_PAD = 1 << 6, - UI_ITEM_USE_SEARCH_FILTER = 1 << 7, }; typedef struct uiButtonItem { @@ -182,8 +181,6 @@ struct uiLayout { char emboss; /** for fixed width or height to avoid UI size changes */ float units[2]; - - bool property_search_layout_temp_debug; }; typedef struct uiLayoutItemFlow { @@ -831,8 +828,7 @@ static void ui_item_enum_expand_exec(uiLayout *layout, * this doubles the icon_only parameter. * - we *never* draw (i.e. really use) the enum label uiname, it is just used as a mere flag! * - * Unfortunately, fixing this implies an API "soft break", so better to defer it for later... - * :/ + * Unfortunately, fixing this implies an API "soft break", so better to defer it for later... :/ * - mont29 */ @@ -1994,8 +1990,8 @@ static uiBut *ui_layout_heading_label_add(uiLayout *layout, */ static uiLayout *ui_item_prop_split_layout_hack(uiLayout *layout_parent, uiLayout *layout_split) { - /* Tag item as using property split layout, this is inherited to children so they can get - * special treatment if needed. */ + /* Tag item as using property split layout, this is inherited to children so they can get special + * treatment if needed. */ layout_parent->item.flag |= UI_ITEM
[Bf-blender-cvs] [fff7a298614] property-search-ui-v2: Merge branch 'master' into property-search-ui-v2
Commit: fff7a298614c39267a581110896d447fdb73645a Author: Hans Goudey Date: Thu Jul 30 11:53:59 2020 -0400 Branches: property-search-ui-v2 https://developer.blender.org/rBfff7a298614c39267a581110896d447fdb73645a Merge branch 'master' into property-search-ui-v2 === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [aa3a053f312] property-search-ui-v2: Property Search: Gray out buttons that don't match the search
Commit: aa3a053f31290852bf42971ee4f68fc2673e5631 Author: Hans Goudey Date: Thu Jul 30 14:49:59 2020 -0400 Branches: property-search-ui-v2 https://developer.blender.org/rBaa3a053f31290852bf42971ee4f68fc2673e5631 Property Search: Gray out buttons that don't match the search === M source/blender/editors/interface/interface_intern.h M source/blender/editors/interface/interface_layout.c M source/blender/editors/interface/interface_panel.c === diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 17e3385576b..7e07c87029a 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -80,7 +80,7 @@ enum { UI_HAS_ICON = (1 << 3), UI_HIDDEN = (1 << 4), UI_SELECT_DRAW = (1 << 5), /* Display selected, doesn't impact interaction. */ - UI_FILTERED = (1 << 12), /* Filtered by the search string, removed if in a layout. */ + UI_FILTERED = (1 << 12), /* Filtered by property search, displayed grayed out. */ /* warn: rest of uiBut->flag in UI_interface.h */ }; diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 41bb7127c32..a216e5fbad7 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -5156,7 +5156,7 @@ void uiLayoutRootSetSearchOnly(uiLayout *layout, bool search_only) static void ui_layout_free(uiLayout *layout); -static void ui_layout_free_hide_buttons(uiLayout *layout) +static void layout_free_and_hide_buttons(uiLayout *layout) { LISTBASE_FOREACH_MUTABLE (uiItem *, item, >items) { if (item->type == ITEM_BUTTON) { @@ -5166,14 +5166,14 @@ static void ui_layout_free_hide_buttons(uiLayout *layout) MEM_freeN(item); } else { - ui_layout_free_hide_buttons((uiLayout *)item); + layout_free_and_hide_buttons((uiLayout *)item); } } MEM_freeN(layout); } -static bool ui_button_search_tag(uiBut *but, char *search_filter) +static bool button_matches_search_filter(uiBut *but, char *search_filter) { if (but->optype != NULL) { if (BLI_strcasestr(but->optype->name, search_filter)) { @@ -5201,37 +5201,29 @@ static bool ui_button_search_tag(uiBut *but, char *search_filter) /** * Tag all buttons with whether they matched the search filter or not. - * - * \note This doesn't actually remove any buttons, and buttons that were tagged might - * not even be removed if they were in a layout with property search turned off. */ -static bool ui_block_search_filter_tag_buttons(uiBlock *block) +static bool block_search_filter_tag_buttons(uiBlock *block) { - bool has_result = false; LISTBASE_FOREACH (uiBut *, but, >buttons) { -/* Flag all label buttons, we don't want to re-display them. */ -if (but->type == UI_BTYPE_LABEL) { - but->flag |= UI_FILTERED; -} +but->flag |= UI_FILTERED; + } -if (ui_button_search_tag(but, block->search_filter)) { + bool has_result = false; + LISTBASE_FOREACH (uiBut *, but, >buttons) { +if (button_matches_search_filter(but, block->search_filter)) { has_result = true; - continue; + but->flag &= ~UI_FILTERED; } - -but->flag |= UI_FILTERED; } /* Remove filter from labels and decorators that correspond to un-filtered buttons. */ LISTBASE_FOREACH (uiBut *, but, >buttons) { if (!(but->flag & UI_FILTERED)) { - uiBut *label_but = but->label_but; - uiBut *decorator_but = but->decorator_but; - if (label_but != NULL) { -label_but->flag &= ~UI_FILTERED; + if (but->label_but != NULL) { +but->label_but->flag &= ~UI_FILTERED; } - if (decorator_but != NULL) { -decorator_but->flag &= ~UI_FILTERED; + if (but->decorator_but != NULL) { +but->decorator_but->flag &= ~UI_FILTERED; } } } @@ -5239,22 +5231,13 @@ static bool ui_block_search_filter_tag_buttons(uiBlock *block) return has_result; } -static void ui_block_search_layout(uiBlock *block) +static void block_search(uiBlock *block) { /* Only continue if the block has the search filter set. */ if (!(block->search_filter && block->search_filter[0])) { return; } -#ifdef DEBUG_LAYOUT_ROOTS - if (block->panel && (block->panel->flag & PNL_SELECT)) { -printf("\nBEFORE %s %p\n", block->name, block); -LISTBASE_FOREACH (uiLayoutRoot *, root, >layouts) { - debug_print_layout((uiItem *)root->layout, 0, false); -} - } -#endif - /* Also search based on panel labels. */ bool pane
[Bf-blender-cvs] [1836a979586] property-search-ui-v2: Property Search: Continued refactoring / cleanup
Commit: 1836a979586b18c29e855aa5cab611fbda030084 Author: Hans Goudey Date: Thu Jul 30 15:23:18 2020 -0400 Branches: property-search-ui-v2 https://developer.blender.org/rB1836a979586b18c29e855aa5cab611fbda030084 Property Search: Continued refactoring / cleanup === M source/blender/editors/include/UI_interface.h M source/blender/editors/interface/interface_intern.h M source/blender/editors/interface/interface_layout.c M source/blender/editors/interface/interface_panel.c M source/blender/editors/space_buttons/space_buttons.c === diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 65f770887fe..20bbc22dbfc 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -1692,7 +1692,7 @@ void UI_panels_scale(struct ARegion *region, float new_width); void UI_panel_label_offset(struct uiBlock *block, int *r_x, int *r_y); int UI_panel_size_y(const struct Panel *panel); bool UI_panel_is_dragging(const struct Panel *panel); -bool UI_panel_is_search_filtered(const struct Panel *panel); +bool UI_panel_matches_search_filter(const struct Panel *panel); bool UI_panel_is_active(const struct Panel *panel); bool UI_panel_category_is_visible(const struct ARegion *region); diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index d533035798a..fb01f265994 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -750,7 +750,7 @@ extern void ui_draw_aligned_panel(struct uiStyle *style, const rcti *rect, const bool show_pin, const bool show_background); -void ui_panel_set_search_filtered(struct Panel *panel, const bool value); +void ui_panel_set_search_filter_match(struct Panel *panel, const bool value); /* interface_draw.c */ extern void ui_draw_dropshadow( diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 23dcdefdf75..b8ad3c11a58 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -5153,8 +5153,6 @@ void uiLayoutRootSetSearchOnly(uiLayout *layout, bool search_only) // #define PROPERTY_SEARCH_USE_TOOLTIPS #define PROPERTY_SEARCH_USE_PANEL_LABELS -static void ui_layout_free(uiLayout *layout); - static void layout_free_and_hide_buttons(uiLayout *layout) { LISTBASE_FOREACH_MUTABLE (uiItem *, item, >items) { @@ -5248,6 +5246,9 @@ static void block_search(uiBlock *block) if (!panel_label_matches) { has_result = block_search_filter_tag_buttons(block); } + else { +has_result = true; + } /* Remove search only layout roots before the next step. */ LISTBASE_FOREACH_MUTABLE (uiLayoutRoot *, root, >layouts) { @@ -5268,7 +5269,21 @@ static void block_search(uiBlock *block) } if (block->panel != NULL) { -ui_panel_set_search_filtered(block->panel, !has_result); +ui_panel_set_search_filter_match(block->panel, !has_result); + } +} + +static void block_search_deactive_buttons(uiBlock *block) +{ + /* Only continue if the block has the search filter set. */ + if (!(block->search_filter && block->search_filter[0])) { +return; + } + + LISTBASE_FOREACH (uiBut *, but, >buttons) { +if ((but->flag & UI_SEARCH_FILTER_MATCHES)) { + but->flag |= UI_BUT_INACTIVE; +} } } @@ -5485,13 +5500,10 @@ static void ui_item_layout(uiItem *item) } } else { -uiButtonItem *bitem = (uiButtonItem *)item; if (item->flag & UI_ITEM_BOX_ITEM) { + uiButtonItem *bitem = (uiButtonItem *)item; bitem->but->drawflag |= UI_BUT_BOX_ITEM; } -if (!(bitem->but->flag & UI_SEARCH_FILTER_MATCHES)) { - bitem->but->flag |= UI_BUT_INACTIVE; -} } } @@ -5700,6 +5712,8 @@ void UI_block_layout_resolve(uiBlock *block, int *r_x, int *r_y) ui_layout_free(root->layout); } + block_search_deactive_buttons(block); + BLI_freelistN(>layouts); /* XXX silly trick, interface_templates.c doesn't get linked diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index 82331f68242..96e9713ccc2 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -75,8 +75,7 @@ #define PNL_ANIM_ALIGN (1 << 3) #define PNL_NEW_ADDED (1 << 4) #define PNL_FIRST (1 << 5) -#define PNL_SEARCH_FILTERED (1 << 6) -#define PNL_WAS_SEARCH_FILTERED (1 << 7) +#define PNL_SEARCH_FILTER
[Bf-blender-cvs] [b8601b64c7c] master: Correct Blender version after last commit
Commit: b8601b64c7cba366f97535d53470c539632c43c6 Author: Hans Goudey Date: Sat Jul 18 12:25:51 2020 -0400 Branches: master https://developer.blender.org/rBb8601b64c7cba366f97535d53470c539632c43c6 Correct Blender version after last commit c08d84748804 incremented the patch version instead of the file subversion for versioning code when adding new options. This commit resets the patch version and instead bumps the file subversion. === M source/blender/blenkernel/BKE_blender_version.h M source/blender/blenloader/intern/versioning_userdef.c === diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h index 14fb1091045..556c1c961dc 100644 --- a/source/blender/blenkernel/BKE_blender_version.h +++ b/source/blender/blenkernel/BKE_blender_version.h @@ -34,13 +34,13 @@ extern "C" { /* Blender major and minor version. */ #define BLENDER_VERSION 290 /* Blender patch version for bugfix releases. */ -#define BLENDER_VERSION_PATCH 1 +#define BLENDER_VERSION_PATCH 0 /** Blender release cycle stage: alpha/beta/rc/release. */ #define BLENDER_VERSION_CYCLE alpha /* Blender file format version. */ #define BLENDER_FILE_VERSION BLENDER_VERSION -#define BLENDER_FILE_SUBVERSION 6 +#define BLENDER_FILE_SUBVERSION 7 /* Minimum Blender version that supports reading file written with the current * version. Older Blender versions will test this and show a warning if the file diff --git a/source/blender/blenloader/intern/versioning_userdef.c b/source/blender/blenloader/intern/versioning_userdef.c index 9a3f4be6786..50e3b375166 100644 --- a/source/blender/blenloader/intern/versioning_userdef.c +++ b/source/blender/blenloader/intern/versioning_userdef.c @@ -753,7 +753,7 @@ void BLO_version_defaults_userpref_blend(Main *bmain, UserDef *userdef) userdef->transopts &= ~USER_DOTRANSLATE_DEPRECATED; } - if (!USER_VERSION_ATLEAST(290, 1)) { + if (!USER_VERSION_ATLEAST(290, 7)) { userdef->statusbar_flag = STATUSBAR_SHOW_VERSION; } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [19ff145e666] master: Clang-Tidy: Enable readability-redundant-control-flow
Commit: 19ff145e33cebeae97cf985c968d39044215 Author: Hans Goudey Date: Fri Jul 3 09:41:55 2020 -0400 Branches: master https://developer.blender.org/rB19ff145e33cebeae97cf985c968d39044215 Clang-Tidy: Enable readability-redundant-control-flow === M .clang-tidy M intern/guardedalloc/intern/mallocn_guarded_impl.c M source/blender/blenkernel/intern/material.c M source/blender/blenkernel/intern/softbody.c M source/blender/blenkernel/intern/studiolight.c M source/blender/blenloader/intern/readfile.c M source/blender/compositor/operations/COM_VectorBlurOperation.cpp M source/blender/draw/intern/draw_cache_impl_gpencil.c M source/blender/editors/gpencil/gpencil_vertex_paint.c M source/blender/editors/object/object_vgroup.c M source/blender/editors/sculpt_paint/paint_image_proj.c M source/blender/editors/sculpt_paint/sculpt_cloth.c M source/blender/editors/sculpt_paint/sculpt_uv.c M source/blender/editors/space_console/console_draw.c M source/blender/freestyle/intern/geometry/matrix_util.cpp M source/blender/gpu/intern/gpu_shader.c M source/blender/io/collada/AnimationImporter.cpp M source/blender/python/intern/bpy_driver.c M source/blender/windowmanager/intern/wm_playanim.c === diff --git a/.clang-tidy b/.clang-tidy index 7d8d4e9c3c0..385c7de7260 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -17,7 +17,6 @@ Checks: > -readability-inconsistent-declaration-parameter-name, -readability-non-const-parameter, -readability-redundant-preprocessor, - -readability-redundant-control-flow, -readability-named-parameter, -readability-function-size, -readability-function-size, diff --git a/intern/guardedalloc/intern/mallocn_guarded_impl.c b/intern/guardedalloc/intern/mallocn_guarded_impl.c index 20dcbed7235..305952c9503 100644 --- a/intern/guardedalloc/intern/mallocn_guarded_impl.c +++ b/intern/guardedalloc/intern/mallocn_guarded_impl.c @@ -906,8 +906,6 @@ void MEM_guarded_freeN(void *vmemh) totblock--; /* here a DUMP should happen */ - - return; } /* - */ diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index d4de04a9e98..0e2d8fcf4c7 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -1272,8 +1272,6 @@ void BKE_texpaint_slot_refresh_cache(Scene *scene, Material *ma) if (ma->paint_clone_slot >= count) { ma->paint_clone_slot = count - 1; } - - return; } void BKE_texpaint_slots_refresh_object(Scene *scene, struct Object *ob) diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index 9c7abbdf876..75da92a26b8 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -481,7 +481,6 @@ static void ccd_mesh_update(Object *ob, ccd_Mesh *pccd_M) mima->maxy = max_ff(mima->maxy, v[1] + hull); mima->maxz = max_ff(mima->maxz, v[2] + hull); } - return; } static void ccd_mesh_free(ccd_Mesh *ccdm) diff --git a/source/blender/blenkernel/intern/studiolight.c b/source/blender/blenkernel/intern/studiolight.c index 8455b60c894..46341652544 100644 --- a/source/blender/blenkernel/intern/studiolight.c +++ b/source/blender/blenkernel/intern/studiolight.c @@ -875,7 +875,6 @@ BLI_INLINE void studiolight_spherical_harmonics_eval(StudioLight *sl, color[i] = studiolight_spherical_harmonics_geomerics_eval( normal, sh[0][i], sh[1][i], sh[2][i], sh[3][i]); } - return; #else /* L0 */ mul_v3_v3fl(color, sl->spherical_harmonics_coefs[0], 0.282095f); diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 5a2b8da6ef9..4d411225be3 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -4908,7 +4908,6 @@ static void direct_link_particlesystems(BlendDataReader *reader, ListBase *parti psys->orig_psys = NULL; psys->batch_cache = NULL; } - return; } /** \} */ diff --git a/source/blender/compositor/operations/COM_VectorBlurOperation.cpp b/source/blender/compositor/operations/COM_VectorBlurOperation.cpp index ee1bb0739b9..56caa68fd35 100644 --- a/source/blender/compositor/operations/COM_VectorBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_VectorBlurOperation.cpp @@ -138,7 +138,6 @@ void VectorBlurOperation::generateVectorBlur(float *data, inputImage->getBuffer(), inputSpeed->getBuffer(), inputZ->getBuffer()); - return; } /* ** Spans *
[Bf-blender-cvs] [a33756d783a] master: Cleanup: Unused variables in non-debug build
Commit: a33756d783a99a29aa77373c726a598ec50af80a Author: Hans Goudey Date: Fri Jul 3 10:09:19 2020 -0400 Branches: master https://developer.blender.org/rBa33756d783a99a29aa77373c726a598ec50af80a Cleanup: Unused variables in non-debug build === M source/blender/bmesh/tools/bmesh_bevel.c === diff --git a/source/blender/bmesh/tools/bmesh_bevel.c b/source/blender/bmesh/tools/bmesh_bevel.c index b29d471d262..b109dc3199a 100644 --- a/source/blender/bmesh/tools/bmesh_bevel.c +++ b/source/blender/bmesh/tools/bmesh_bevel.c @@ -782,6 +782,7 @@ static bool contig_ldata_across_edge(BMesh *bm, BMEdge *e, BMFace *f1, BMFace *f BMLoop *lef1, *lef2; BMLoop *lv1f1, *lv1f2, *lv2f1, *lv2f2; BMVert *v1, *v2; + UNUSED_VARS_NDEBUG(v1, v2); int i; if (bm->ldata.totlayer == 0) { ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [f4fdb8efc58] master: Cleanup: Remove redundant logic
Commit: f4fdb8efc5806524740e91d9f44283057d27ec46 Author: Hans Goudey Date: Fri Jul 3 10:38:49 2020 -0400 Branches: master https://developer.blender.org/rBf4fdb8efc5806524740e91d9f44283057d27ec46 Cleanup: Remove redundant logic === M source/blender/modifiers/intern/MOD_ocean.c === diff --git a/source/blender/modifiers/intern/MOD_ocean.c b/source/blender/modifiers/intern/MOD_ocean.c index 0773a81127a..6374f081581 100644 --- a/source/blender/modifiers/intern/MOD_ocean.c +++ b/source/blender/modifiers/intern/MOD_ocean.c @@ -657,7 +657,7 @@ static void spray_panel_draw(const bContext *C, Panel *panel) modifier_panel_get_property_pointers(C, panel, NULL, ); bool use_foam = RNA_boolean_get(, "use_foam"); - bool use_spray = RNA_boolean_get(, "use_spray") && use_foam; + bool use_spray = RNA_boolean_get(, "use_spray"); uiLayoutSetPropSep(layout, true); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [f66aafa391b] master: Fix memory leak when dragging shaderfx
Commit: f66aafa391b18ae7dc7a20f8871ba29d03c4f7f6 Author: Hans Goudey Date: Fri Jul 3 10:37:58 2020 -0400 Branches: master https://developer.blender.org/rBf66aafa391b18ae7dc7a20f8871ba29d03c4f7f6 Fix memory leak when dragging shaderfx === M source/blender/shader_fx/intern/FX_ui_common.c === diff --git a/source/blender/shader_fx/intern/FX_ui_common.c b/source/blender/shader_fx/intern/FX_ui_common.c index 3a1df937c9f..e7dee920d3c 100644 --- a/source/blender/shader_fx/intern/FX_ui_common.c +++ b/source/blender/shader_fx/intern/FX_ui_common.c @@ -77,6 +77,7 @@ static void shaderfx_reorder(bContext *C, Panel *panel, int new_index) RNA_string_set(_ptr, "shaderfx", fx->name); RNA_int_set(_ptr, "index", new_index); WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, _ptr); + WM_operator_properties_free(_ptr); } /** ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [6a58e15548c] master: Cleanup: Remove obsolete code in interface_panel.c
Commit: 6a58e15548c33444fa1845a6fad080faff008cfd Author: Hans Goudey Date: Fri Jul 3 10:03:16 2020 -0400 Branches: master https://developer.blender.org/rB6a58e15548c33444fa1845a6fad080faff008cfd Cleanup: Remove obsolete code in interface_panel.c Some code delt with panel merging in earlier versions of Blender, which is no longer needed. Other code delt with controls that aren't used anymore, and in some cases have region-level equivalents. There's a surprising amount of this unused code in this file, so removing it will be helpful for the future. Differential Revision: https://developer.blender.org/D7938 === M source/blender/editors/include/UI_interface.h M source/blender/editors/interface/interface_panel.c M source/blender/makesdna/DNA_screen_types.h === diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index da3d06230e3..7fd45e06fbf 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -175,13 +175,6 @@ enum { UI_RETURN_POPUP_OK = 1 << 5, }; -/* panel controls */ -enum { - UI_PNL_SOLID = 1 << 1, - UI_PNL_CLOSE = 1 << 5, - UI_PNL_SCALE = 1 << 9, -}; - /* but->flag - general state flags. */ enum { /** Warning, the first 6 flags are internal. */ diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index 95c804eaccb..dd3074d6258 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -878,79 +878,8 @@ void UI_draw_icon_tri(float x, float y, char dir, const float color[4]) } } -static void ui_draw_anti_x(uint pos, float x1, float y1, float x2, float y2) -{ - - /* set antialias line */ - GPU_line_smooth(true); - GPU_blend(true); - - GPU_line_width(2.0); - - immBegin(GPU_PRIM_LINES, 4); - - immVertex2f(pos, x1, y1); - immVertex2f(pos, x2, y2); - - immVertex2f(pos, x1, y2); - immVertex2f(pos, x2, y1); - - immEnd(); - - GPU_line_smooth(false); - GPU_blend(false); -} - -/* x 'icon' for panel header */ -static void ui_draw_x_icon(uint pos, float x, float y) -{ - - ui_draw_anti_x(pos, x, y, x + 9.375f, y + 9.375f); -} - #define PNL_ICON UI_UNIT_X /* could be UI_UNIT_Y too */ -static void ui_draw_panel_scalewidget(uint pos, const rcti *rect) -{ - float xmin, xmax, dx; - float ymin, ymax, dy; - - xmin = rect->xmax - PNL_HEADER + 2; - xmax = rect->xmax - 3; - ymin = rect->ymin + 3; - ymax = rect->ymin + PNL_HEADER - 2; - - dx = 0.5f * (xmax - xmin); - dy = 0.5f * (ymax - ymin); - - GPU_blend(true); - immUniformColor4ub(255, 255, 255, 50); - - immBegin(GPU_PRIM_LINES, 4); - - immVertex2f(pos, xmin, ymin); - immVertex2f(pos, xmax, ymax); - - immVertex2f(pos, xmin + dx, ymin); - immVertex2f(pos, xmax, ymax - dy); - - immEnd(); - - immUniformColor4ub(0, 0, 0, 50); - - immBegin(GPU_PRIM_LINES, 4); - - immVertex2f(pos, xmin, ymin + 1); - immVertex2f(pos, xmax, ymax + 1); - - immVertex2f(pos, xmin + dx, ymin + 1); - immVertex2f(pos, xmax, ymax - dy + 1); - - immEnd(); - - GPU_blend(false); -} - /* For button layout next to label. */ void UI_panel_label_offset(uiBlock *block, int *r_x, int *r_y) { @@ -977,12 +906,7 @@ static void ui_draw_aligned_panel_header( uchar col_title[4]; /* + 0.001f to avoid flirting with float inaccuracy */ - if (panel->control & UI_PNL_CLOSE) { -pnl_icons = (panel->labelofs + (2.0f * PNL_ICON)) / block->aspect + 0.001f; - } - else { -pnl_icons = (panel->labelofs + (1.1f * PNL_ICON)) / block->aspect + 0.001f; - } + pnl_icons = (panel->labelofs + (1.1f * PNL_ICON)) / block->aspect + 0.001f; /* draw text label */ panel_title_color_get(show_background, col_title); @@ -1178,11 +1102,7 @@ void ui_draw_aligned_panel(uiStyle *style, /* in some occasions, draw a border */ if (panel->flag & PNL_SELECT && !is_subpanel) { float radius; - if (panel->control & UI_PNL_SOLID) { -UI_draw_roundbox_corner_set(UI_CNR_ALL); -radius = 8.0f; - } - else if (draw_box_style) { + if (draw_box_style) { UI_draw_roundbox_corner_set(UI_CNR_ALL); radius = box_wcol->roundness * U.widget_unit; } @@ -1233,26 +1153,12 @@ void ui_draw_aligned_panel(uiStyle *style, } } -if (panel->control & UI_PNL_SCALE) { - ui_draw_panel_scalewidget(pos, rect); -} - immUnbindProgram(); } uchar col_title[4]; panel_title_color_get(show_background, col_title); - /* draw optional close icon */ - - if (panel->control & UI_PNL_CLOSE) { -const int ofsx = 6; -immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); -immUniformColor
[Bf-blender-cvs] [53d41e1a6fc] master: UI: Use sliders and [0, 1] ranges in ocean modifier
Commit: 53d41e1a6fc4c521e412fba57913f93fadeb3735 Author: Hans Goudey Date: Fri Jul 3 10:28:13 2020 -0400 Branches: master https://developer.blender.org/rB53d41e1a6fc4c521e412fba57913f93fadeb3735 UI: Use sliders and [0, 1] ranges in ocean modifier The ocean modifier has two properties that use a [0, 10] hard min and hard max. The values act as factors though, so it makes more sense to use sliders and a 0 to 1 range. This commit also bumps the file subversion to avoid repeatedly applying the change to the properties' range. Differential Revision: https://developer.blender.org/D8186 === M source/blender/blenkernel/BKE_blender_version.h M source/blender/blenkernel/intern/ocean.c M source/blender/blenloader/intern/versioning_290.c M source/blender/makesrna/intern/rna_modifier.c M source/blender/modifiers/intern/MOD_ocean.c === diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h index 229b5193e9c..57f22a8d709 100644 --- a/source/blender/blenkernel/BKE_blender_version.h +++ b/source/blender/blenkernel/BKE_blender_version.h @@ -40,7 +40,7 @@ extern "C" { /* Blender file format version. */ #define BLENDER_FILE_VERSION BLENDER_VERSION -#define BLENDER_FILE_SUBVERSION 5 +#define BLENDER_FILE_SUBVERSION 6 /* Minimum Blender version that supports reading file written with the current * version. Older Blender versions will test this and show a warning if the file diff --git a/source/blender/blenkernel/intern/ocean.c b/source/blender/blenkernel/intern/ocean.c index 8957628c76a..609c5c1e580 100644 --- a/source/blender/blenkernel/intern/ocean.c +++ b/source/blender/blenkernel/intern/ocean.c @@ -831,7 +831,7 @@ void BKE_ocean_init(struct Ocean *o, o->_A = A; o->_w = w; o->_damp_reflections = 1.0f - damp; - o->_wind_alignment = alignment; + o->_wind_alignment = alignment * 10.0f; o->_depth = depth; o->_Lx = Lx; o->_Lz = Lz; @@ -845,7 +845,7 @@ void BKE_ocean_init(struct Ocean *o, /* Common JONSWAP parameters. */ o->_fetch_jonswap = fetch_jonswap; - o->_sharpen_peak_jonswap = sharpen_peak_jonswap; + o->_sharpen_peak_jonswap = sharpen_peak_jonswap * 10.0f; o->_do_disp_y = do_height_field; o->_do_normals = do_normals; diff --git a/source/blender/blenloader/intern/versioning_290.c b/source/blender/blenloader/intern/versioning_290.c index 2e93df09e1e..0d16b58d28f 100644 --- a/source/blender/blenloader/intern/versioning_290.c +++ b/source/blender/blenloader/intern/versioning_290.c @@ -257,18 +257,7 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain) } } - /** - * Versioning code until next subversion bump goes here. - * - * \note Be sure to check when bumping the version: - * - "versioning_userdef.c", #BLO_version_defaults_userpref_blend - * - "versioning_userdef.c", #do_versions_theme - * - * \note Keep this message at the bottom of the function. - */ - { -/* Keep this block, even when empty. */ - + if (!MAIN_VERSION_ATLEAST(bmain, 290, 6)) { /* Transition to saving expansion for all of a modifier's sub-panels. */ if (!DNA_struct_elem_find(fd->filesdna, "ModifierData", "short", "ui_expand_flag")) { for (Object *object = bmain->objects.first; object != NULL; object = object->id.next) { @@ -338,19 +327,43 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain) } } } - } - /* Refactor bevel profile type to use an enum. */ - if (!DNA_struct_elem_find(fd->filesdna, "BevelModifierData", "short", "profile_type")) { +/* Refactor bevel profile type to use an enum. */ +if (!DNA_struct_elem_find(fd->filesdna, "BevelModifierData", "short", "profile_type")) { + for (Object *object = bmain->objects.first; object != NULL; object = object->id.next) { +LISTBASE_FOREACH (ModifierData *, md, >modifiers) { + if (md->type == eModifierType_Bevel) { +BevelModifierData *bmd = (BevelModifierData *)md; +bool use_custom_profile = bmd->flags & MOD_BEVEL_CUSTOM_PROFILE_DEPRECATED; +bmd->profile_type = use_custom_profile ? MOD_BEVEL_PROFILE_CUSTOM : + MOD_BEVEL_PROFILE_SUPERELLIPSE; + } +} + } +} + +/* Change ocean modifier values from [0, 10] to [0, 1] ranges. */ for (Object *object = bmain->objects.first; object != NULL; object = object->id.next) { LISTBASE_FOREACH (ModifierData *, md, >modifiers) { -if (md->type == eModifierType_Bevel) { - BevelM
[Bf-blender-cvs] [99862a72b1e] property-search-ui-v2: Property Search: Miscellaneous cleanup
Commit: 99862a72b1e9c13b0556e29bf31943f355139092 Author: Hans Goudey Date: Thu Jul 30 14:59:47 2020 -0400 Branches: property-search-ui-v2 https://developer.blender.org/rB99862a72b1e9c13b0556e29bf31943f355139092 Property Search: Miscellaneous cleanup Mostly renaming UI_FILTERED to UI_SEARCH_FILTER_MATCHES and reversing its meaning. Also reverting some unrelated changes. === M source/blender/editors/include/UI_interface.h M source/blender/editors/interface/interface_intern.h M source/blender/editors/interface/interface_layout.c === diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index e62e84142ea..65f770887fe 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -157,8 +157,6 @@ enum { UI_BLOCK_POPOVER_ONCE = 1 << 22, /** Always show keymaps, even for non-menus. */ UI_BLOCK_SHOW_SHORTCUT_ALWAYS = 1 << 23, - /** All items have been removed from the block by the search filter. */ - UI_BLOCK_FILTERED_EMPTY = 1 << 24, /** The block is only used during the layout process and will not be drawn, * for the case of a subpanel of a closed panel. */ UI_BLOCK_SEARCH_ONLY = 1 << 25, diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 7e07c87029a..d533035798a 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -79,8 +79,8 @@ enum { UI_ACTIVE = (1 << 2), UI_HAS_ICON = (1 << 3), UI_HIDDEN = (1 << 4), - UI_SELECT_DRAW = (1 << 5), /* Display selected, doesn't impact interaction. */ - UI_FILTERED = (1 << 12), /* Filtered by property search, displayed grayed out. */ + UI_SELECT_DRAW = (1 << 5),/* Display selected, doesn't impact interaction. */ + UI_SEARCH_FILTER_MATCHES = (1 << 12), /* The button matches the search filter. */ /* warn: rest of uiBut->flag in UI_interface.h */ }; diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index a216e5fbad7..23dcdefdf75 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -2193,7 +2193,7 @@ void uiItemFullR(uiLayout *layout, else { uiLayout *layout_split = uiLayoutSplit( layout_row ? layout_row : layout, UI_ITEM_PROP_SEP_DIVIDE, true); - bool label_added = false; /* HANS-TODO: Replace with checking if label_but == NULL. */ + bool label_added = false; layout_split->space = 0; uiLayout *layout_sub = uiLayoutColumn(layout_split, true); layout_sub->space = 0; @@ -3271,8 +3271,7 @@ uiBut *uiItemL_respect_property_split(uiLayout *layout, if (layout->item.flag & UI_ITEM_PROP_SEP) { uiBlock *block = uiLayoutGetBlock(layout); uiPropertySplitWrapper split_wrapper = uiItemPropertySplitWrapperCreate(layout); -/* Further items added to 'layout' will automatically be added to split_wrapper.property_row - */ +/* Further items added to 'layout' will automatically be added to split_wrapper.property_row */ label_but = uiItemL_(split_wrapper.label_column, text, icon); UI_block_layout_set_current(block, split_wrapper.property_row); @@ -5152,7 +5151,7 @@ void uiLayoutRootSetSearchOnly(uiLayout *layout, bool search_only) * \{ */ // #define PROPERTY_SEARCH_USE_TOOLTIPS -// #define PROPERTY_SEARCH_USE_PANEL_LABELS +#define PROPERTY_SEARCH_USE_PANEL_LABELS static void ui_layout_free(uiLayout *layout); @@ -5204,26 +5203,22 @@ static bool button_matches_search_filter(uiBut *but, char *search_filter) */ static bool block_search_filter_tag_buttons(uiBlock *block) { - LISTBASE_FOREACH (uiBut *, but, >buttons) { -but->flag |= UI_FILTERED; - } - bool has_result = false; LISTBASE_FOREACH (uiBut *, but, >buttons) { if (button_matches_search_filter(but, block->search_filter)) { has_result = true; - but->flag &= ~UI_FILTERED; + but->flag |= UI_SEARCH_FILTER_MATCHES; } } /* Remove filter from labels and decorators that correspond to un-filtered buttons. */ LISTBASE_FOREACH (uiBut *, but, >buttons) { -if (!(but->flag & UI_FILTERED)) { +if (but->flag & UI_SEARCH_FILTER_MATCHES) { if (but->label_but != NULL) { -but->label_but->flag &= ~UI_FILTERED; +but->label_but->flag |= UI_SEARCH_FILTER_MATCHES; } if (but->decorator_but != NULL) { -but->decorator_but->flag &= ~UI_FILTERED; +but->decorator_but->flag |= UI_SEARCH_FILTER_M
[Bf-blender-cvs] [b02e8e35046] property-search-ui-v2: Property Search: Add "search match" theme color
Commit: b02e8e3504698e7a1c9a82e3ec30e7bede277222 Author: Hans Goudey Date: Thu Jul 30 17:42:42 2020 -0400 Branches: property-search-ui-v2 https://developer.blender.org/rBb02e8e3504698e7a1c9a82e3ec30e7bede277222 Property Search: Add "search match" theme color === M release/datafiles/userdef/userdef_default_theme.c M source/blender/blenloader/intern/versioning_userdef.c M source/blender/editors/include/UI_resources.h M source/blender/editors/interface/resources.c M source/blender/makesdna/DNA_userdef_types.h M source/blender/makesrna/intern/rna_userdef.c === diff --git a/release/datafiles/userdef/userdef_default_theme.c b/release/datafiles/userdef/userdef_default_theme.c index 4d48bb8eaac..7de5a18bd86 100644 --- a/release/datafiles/userdef/userdef_default_theme.c +++ b/release/datafiles/userdef/userdef_default_theme.c @@ -269,6 +269,7 @@ const bTheme U_theme_default = { .header = RGBA(0x424242ff), .header_text = RGBA(0xeeff), .header_text_hi = RGBA(0x), +.search_match_color = RGBA(0x5680c2ff), .tab_active = RGBA(0x4b4b4bff), .tab_inactive = RGBA(0x2b2b2bff), .tab_back = RGBA(0x232323ff), diff --git a/source/blender/blenloader/intern/versioning_userdef.c b/source/blender/blenloader/intern/versioning_userdef.c index e2dc27d7e88..8d934dc036f 100644 --- a/source/blender/blenloader/intern/versioning_userdef.c +++ b/source/blender/blenloader/intern/versioning_userdef.c @@ -227,6 +227,7 @@ static void do_versions_theme(const UserDef *userdef, bTheme *btheme) */ { /* Keep this block, even when empty. */ +FROM_DEFAULT_V4_UCHAR(space_properties.search_match_color); } #undef FROM_DEFAULT_V4_UCHAR diff --git a/source/blender/editors/include/UI_resources.h b/source/blender/editors/include/UI_resources.h index c5c4ca79f14..2da44a203fe 100644 --- a/source/blender/editors/include/UI_resources.h +++ b/source/blender/editors/include/UI_resources.h @@ -68,6 +68,7 @@ typedef enum ThemeColorID { TH_HEADERDESEL, TH_HEADER_TEXT, TH_HEADER_TEXT_HI, + TH_SEARCH_MATCH, /* panels */ TH_PANEL_HEADER, diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index 84fe3e13426..44bd42d6842 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -261,6 +261,9 @@ const uchar *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid) case TH_HEADER_TEXT_HI: cp = ts->header_text_hi; break; +case TH_SEARCH_MATCH: + cp = ts->search_match_color; + break; case TH_PANEL_HEADER: cp = ts->panelcolors.header; diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index d50c0055499..3d1d59d438c 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -265,6 +265,8 @@ typedef struct ThemeSpace { /* note, cannot use name 'panel' because of DNA mapping old files */ uiPanelColors panelcolors; + unsigned char search_match_color[4]; + unsigned char shade1[4]; unsigned char shade2[4]; @@ -328,7 +330,7 @@ typedef struct ThemeSpace { unsigned char syntaxd[4], syntaxr[4]; // in nodespace used for distort unsigned char line_numbers[4]; - char _pad6[7]; + char _pad6[3]; unsigned char nodeclass_output[4], nodeclass_filter[4]; unsigned char nodeclass_vector[4], nodeclass_texture[4]; diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 6ce6098d0c3..b762e08526c 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -1719,6 +1719,11 @@ static void rna_def_userdef_theme_space_common(StructRNA *srna) RNA_def_property_ui_text(prop, "Header Text Highlight", ""); RNA_def_property_update(prop, 0, "rna_userdef_theme_update"); + prop = RNA_def_property(srna, "search_match_color", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "Search Match Color", ""); + RNA_def_property_update(prop, 0, "rna_userdef_theme_update"); + /* panel settings */ prop = RNA_def_property(srna, "panelcolors", PROP_POINTER, PROP_NONE); RNA_def_property_flag(prop, PROP_NEVER_NULL); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [95fabb12cbc] property-search-ui-v2: Property Search: Highlight panel headers with a search match
Commit: 95fabb12cbcc4b027c53993f00bad0278efe133f Author: Hans Goudey Date: Thu Jul 30 17:44:22 2020 -0400 Branches: property-search-ui-v2 https://developer.blender.org/rB95fabb12cbcc4b027c53993f00bad0278efe133f Property Search: Highlight panel headers with a search match === M source/blender/editors/interface/interface_layout.c M source/blender/editors/interface/interface_panel.c M source/blender/editors/space_buttons/space_buttons.c === diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index b8ad3c11a58..b885ac76851 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -5224,11 +5224,11 @@ static bool block_search_filter_tag_buttons(uiBlock *block) return has_result; } -static void block_search(uiBlock *block) +static bool block_search(uiBlock *block) { /* Only continue if the block has the search filter set. */ if (!(block->search_filter && block->search_filter[0])) { -return; +return false; } /* Also search based on panel labels. */ @@ -5269,8 +5269,10 @@ static void block_search(uiBlock *block) } if (block->panel != NULL) { -ui_panel_set_search_filter_match(block->panel, !has_result); +ui_panel_set_search_filter_match(block->panel, has_result); } + + return panel_label_matches; } static void block_search_deactive_buttons(uiBlock *block) @@ -5281,7 +5283,7 @@ static void block_search_deactive_buttons(uiBlock *block) } LISTBASE_FOREACH (uiBut *, but, >buttons) { -if ((but->flag & UI_SEARCH_FILTER_MATCHES)) { +if (!(but->flag & UI_SEARCH_FILTER_MATCHES)) { but->flag |= UI_BUT_INACTIVE; } } @@ -5702,7 +5704,7 @@ void UI_block_layout_resolve(uiBlock *block, int *r_x, int *r_y) block->curlayout = NULL; - block_search(block); + const bool search_disabled = block_search(block); for (root = block->layouts.first; root; root = root->next) { ui_layout_add_padding_button(root); @@ -5712,7 +5714,9 @@ void UI_block_layout_resolve(uiBlock *block, int *r_x, int *r_y) ui_layout_free(root->layout); } - block_search_deactive_buttons(block); + if (!search_disabled) { +block_search_deactive_buttons(block); + } BLI_freelistN(>layouts); diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index 96e9713ccc2..1c483ea8d2d 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -867,10 +867,10 @@ void ui_panel_set_search_filter_match(struct Panel *panel, const bool value) static void panel_matches_search_filter_recursive(const Panel *panel, bool *filter_matches) { - *filter_matches = *filter_matches && (panel->runtime_flag & PNL_SEARCH_FILTER_MATCHES); + *filter_matches |= panel->runtime_flag & PNL_SEARCH_FILTER_MATCHES; /* If the panel is filtered (removed) we need to check that its children are too. */ - if (*filter_matches) { + if (!*filter_matches) { LISTBASE_FOREACH (const Panel *, child_panel, >children) { panel_matches_search_filter_recursive(child_panel, filter_matches); } @@ -1053,7 +1053,8 @@ void ui_draw_aligned_panel(uiStyle *style, GPU_blend(true); /* draw with background color */ -immUniformThemeColor(TH_PANEL_HEADER); +immUniformThemeColor(UI_panel_matches_search_filter(panel) ? TH_SEARCH_MATCH : + TH_PANEL_HEADER); immRectf(pos, minx, headrect.ymin, maxx, y); immBegin(GPU_PRIM_LINES, 4); diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c index a789f382f76..02814c0e6a8 100644 --- a/source/blender/editors/space_buttons/space_buttons.c +++ b/source/blender/editors/space_buttons/space_buttons.c @@ -347,12 +347,12 @@ static void property_search_all_tabs(const bContext *C, } /* Store whether this tab has any unfiltered panels left. */ -bool has_unfiltered_panel = false; +bool tab_has_search_match = false; LISTBASE_FOREACH ( Panel *, panel, use_actual_region ? _region->panels : _copy->panels) { - has_unfiltered_panel |= UI_panel_matches_search_filter(panel) && UI_panel_is_active(panel); + tab_has_search_match |= UI_panel_matches_search_filter(panel) && UI_panel_is_active(panel); } -if (has_unfiltered_panel) { +if (tab_has_search_match) { sbuts->context_search_filter_active |= (1 << i); } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [93304b483a5] master: Cleanup: Quiet GCC maybe uninitialized warning
Commit: 93304b483a5cdbbef48ce2777a3260ef6440e3ce Author: Hans Goudey Date: Sat Aug 15 22:20:40 2020 -0400 Branches: master https://developer.blender.org/rB93304b483a5cdbbef48ce2777a3260ef6440e3ce Cleanup: Quiet GCC maybe uninitialized warning There was a false positive here. Thankfully, marking the button's type as constant can quiet the warning. === M source/blender/editors/interface/interface_handlers.c === diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index dcae3b9a104..455c4fd5073 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -2025,6 +2025,8 @@ static void ui_apply_but_TRACKPREVIEW(bContext *C, uiBut *but, uiHandleButtonDat static void ui_apply_but( bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, const bool interactive) { + const int but_type = but->type; /* Store as const to quiet maybe uninitialized warning. */ + char *editstr; double *editval; float *editvec; @@ -2086,36 +2088,36 @@ static void ui_apply_but( editstr = but->editstr; editval = but->editval; editvec = but->editvec; - if (but->type == UI_BTYPE_COLORBAND) { + if (but_type == UI_BTYPE_COLORBAND) { uiButColorBand *but_coba = (uiButColorBand *)but; editcoba = but_coba->edit_coba; } - else if (but->type == UI_BTYPE_CURVE) { + else if (but_type == UI_BTYPE_CURVE) { uiButCurveMapping *but_cumap = (uiButCurveMapping *)but; editcumap = but_cumap->edit_cumap; } - else if (but->type == UI_BTYPE_CURVEPROFILE) { + else if (but_type == UI_BTYPE_CURVEPROFILE) { uiButCurveProfile *but_profile = (uiButCurveProfile *)but; editprofile = but_profile->edit_profile; } but->editstr = NULL; but->editval = NULL; but->editvec = NULL; - if (but->type == UI_BTYPE_COLORBAND) { + if (but_type == UI_BTYPE_COLORBAND) { uiButColorBand *but_coba = (uiButColorBand *)but; but_coba->edit_coba = NULL; } - else if (but->type == UI_BTYPE_CURVE) { + else if (but_type == UI_BTYPE_CURVE) { uiButCurveMapping *but_cumap = (uiButCurveMapping *)but; but_cumap->edit_cumap = NULL; } - else if (but->type == UI_BTYPE_CURVEPROFILE) { + else if (but_type == UI_BTYPE_CURVEPROFILE) { uiButCurveProfile *but_profile = (uiButCurveProfile *)but; but_profile->edit_profile = NULL; } /* handle different types */ - switch (but->type) { + switch (but_type) { case UI_BTYPE_BUT: case UI_BTYPE_DECORATOR: ui_apply_but_BUT(C, but, data); @@ -2221,15 +2223,15 @@ static void ui_apply_but( but->editstr = editstr; but->editval = editval; but->editvec = editvec; - if (but->type == UI_BTYPE_COLORBAND) { + if (but_type == UI_BTYPE_COLORBAND) { uiButColorBand *but_coba = (uiButColorBand *)but; but_coba->edit_coba = editcoba; } - else if (but->type == UI_BTYPE_CURVE) { + else if (but_type == UI_BTYPE_CURVE) { uiButCurveMapping *but_cumap = (uiButCurveMapping *)but; but_cumap->edit_cumap = editcumap; } - else if (but->type == UI_BTYPE_CURVEPROFILE) { + else if (but_type == UI_BTYPE_CURVEPROFILE) { uiButCurveProfile *but_profile = (uiButCurveProfile *)but; but_profile->edit_profile = editprofile; } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [4f57e1aaeab] master: Merge branch 'blender-v2.90-release'
Commit: 4f57e1aaeab90f1a03754157978d959f4c7cc18d Author: Hans Goudey Date: Sun Aug 16 08:54:27 2020 -0400 Branches: master https://developer.blender.org/rB4f57e1aaeab90f1a03754157978d959f4c7cc18d Merge branch 'blender-v2.90-release' === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [5c78c16b149] master: UI: Simplify cloth filter type description
Commit: 5c78c16b1494cf3d4bbe3efaf45323e25a2ba52b Author: Hans Goudey Date: Sun Aug 16 08:57:46 2020 -0400 Branches: master https://developer.blender.org/rB5c78c16b1494cf3d4bbe3efaf45323e25a2ba52b UI: Simplify cloth filter type description Remove extra words in the message and avoid repeating the name in the description. === M source/blender/editors/sculpt_paint/sculpt_cloth.c === diff --git a/source/blender/editors/sculpt_paint/sculpt_cloth.c b/source/blender/editors/sculpt_paint/sculpt_cloth.c index 5126dbe1316..4070822a0a8 100644 --- a/source/blender/editors/sculpt_paint/sculpt_cloth.c +++ b/source/blender/editors/sculpt_paint/sculpt_cloth.c @@ -1043,11 +1043,7 @@ static EnumPropertyItem prop_cloth_filter_type[] = { {CLOTH_FILTER_GRAVITY, "GRAVITY", 0, "Gravity", "Applies gravity to the simulation"}, {CLOTH_FILTER_INFLATE, "INFLATE", 0, "Inflate", "Inflates the cloth"}, {CLOTH_FILTER_EXPAND, "EXPAND", 0, "Expand", "Expands the cloth's dimensions"}, -{CLOTH_FILTER_PINCH, - "PINCH", - 0, - "Pinch", - "Pinches the cloth to the point where the cursor was when the filter started"}, +{CLOTH_FILTER_PINCH, "PINCH", 0, "Pinch", "Pulls the cloth to the cursor's start position"}, {0, NULL, 0, NULL, NULL}, }; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [8010cbe620d] blender-v2.90-release: Fix T79823: Typo in cloth filter type description
Commit: 8010cbe620d2b6bc9aac9fe4793cce672459a7f0 Author: Hans Goudey Date: Sun Aug 16 08:54:07 2020 -0400 Branches: blender-v2.90-release https://developer.blender.org/rB8010cbe620d2b6bc9aac9fe4793cce672459a7f0 Fix T79823: Typo in cloth filter type description === M source/blender/editors/sculpt_paint/sculpt_cloth.c === diff --git a/source/blender/editors/sculpt_paint/sculpt_cloth.c b/source/blender/editors/sculpt_paint/sculpt_cloth.c index 4232be91034..b401ed6d889 100644 --- a/source/blender/editors/sculpt_paint/sculpt_cloth.c +++ b/source/blender/editors/sculpt_paint/sculpt_cloth.c @@ -766,7 +766,7 @@ static EnumPropertyItem prop_cloth_filter_type[] = { "PINCH", 0, "Pinch", - "Pinches the cloth to the point were the cursor was when the filter started"}, + "Pinches the cloth to the point where the cursor was when the filter started"}, {0, NULL, 0, NULL, NULL}, }; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [5bd822dc46f] master: Geometry Nodes Point Distribution: Align points to face normals
Commit: 5bd822dc46f60da4b7de125f2d559fa16d781787 Author: Hans Goudey Date: Mon Jan 11 11:42:16 2021 -0600 Branches: master https://developer.blender.org/rB5bd822dc46f60da4b7de125f2d559fa16d781787 Geometry Nodes Point Distribution: Align points to face normals This patch makes the point distribute node write to the "rotation" attribute with the normal of each face at each distributed point. The "normal" attribute is also created with the triangle normal at each point. The conversion from the triangle normal to an Euler rotation is somewhat arbitrary, since we only have one direction vector. For a more flexible rotation for each point, the "Align Rotation to Vector" node can be used in the future. Differential Revision: https://developer.blender.org/D9965 === M source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc === diff --git a/source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc b/source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc index 3c9ad127e8b..f5f9c9f8830 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc @@ -55,9 +55,22 @@ static void node_point_distribute_update(bNodeTree *UNUSED(ntree), bNode *node) namespace blender::nodes { +/** + * Use an arbitrary choice of axes for a usable rotation attribute directly out of this node. + */ +static float3 normal_to_euler_rotation(const float3 normal) +{ + float quat[4]; + vec_to_quat(quat, normal, OB_NEGZ, OB_POSY); + float3 rotation; + quat_to_eul(rotation, quat); + return rotation; +} + static Vector random_scatter_points_from_mesh(const Mesh *mesh, const float density, const FloatReadAttribute _factors, + Vector _normals, Vector _ids, const int seed) { @@ -99,6 +112,10 @@ static Vector random_scatter_points_from_mesh(const Mesh *mesh, /* Build a hash stable even when the mesh is deformed. */ r_ids.append(((int)(bary_coords.hash()) + looptri_index)); + + float3 tri_normal; + normal_tri_v3(tri_normal, v0_pos, v1_pos, v2_pos); + r_normals.append(tri_normal); } } @@ -117,6 +134,7 @@ struct RayCastAll_Data { float base_weight; FloatReadAttribute *density_factors; Vector *projected_points; + Vector *normals; Vector *stable_ids; float cur_point_weight; }; @@ -159,6 +177,8 @@ static void project_2d_bvh_callback(void *userdata, /* Build a hash stable even when the mesh is deformed. */ data->stable_ids->append((int)data->raystart.hash()); + + data->normals->append(hit->no); } } } @@ -167,6 +187,7 @@ static Vector poisson_scatter_points_from_mesh(const Mesh *mesh, const float density, const float minimum_distance, const FloatReadAttribute _factors, + Vector _normals, Vector _ids, const int seed) { @@ -219,6 +240,7 @@ static Vector poisson_scatter_points_from_mesh(const Mesh *mesh, data.mesh = mesh; data.projected_points = _points; data.stable_ids = _ids; + data.normals = _normals; data.density_factors = const_cast(_factors); data.base_weight = std::min( 1.0f, density / (output_points.size() / (point_scale_multiplier * point_scale_multiplier))); @@ -288,16 +310,17 @@ static void geo_node_point_distribute_exec(GeoNodeExecParams params) const int seed = params.get_input("Seed"); Vector stable_ids; + Vector normals; Vector points; switch (distribute_method) { case GEO_NODE_POINT_DISTRIBUTE_RANDOM: points = random_scatter_points_from_mesh( - mesh_in, density, density_factors, stable_ids, seed); + mesh_in, density, density_factors, normals, stable_ids, seed); break; case GEO_NODE_POINT_DISTRIBUTE_POISSON: const float min_dist = params.extract_input("Distance Min"); points = poisson_scatter_points_from_mesh( - mesh_in, density, min_dist, density_factors, stable_ids, seed); + mesh_in, density, min_dist, density_factors, normals, stable_ids, seed); break; } @@ -312,11 +335,31 @@ static void geo_node_point_distribute_exec(GeoNodeExecParams params) geometry_set_out.get_component_for_write
[Bf-blender-cvs] [ecdbd83a8d3] master: Geometry Nodes: Attribute Vector Math Node
Commit: ecdbd83a8d30b982c4280f0dbd8ed821c657fa25 Author: Hans Goudey Date: Mon Jan 11 12:06:52 2021 -0600 Branches: master https://developer.blender.org/rBecdbd83a8d30b982c4280f0dbd8ed821c657fa25 Geometry Nodes: Attribute Vector Math Node This patch implements the same operations and interface as the regular vector math node, but it runs for every element of the attribute. This should expand what's possible with geometry nodes quite a bit. Differential Revision: https://developer.blender.org/D9914 === M release/scripts/startup/nodeitems_builtins.py M source/blender/blenkernel/BKE_node.h M source/blender/blenkernel/intern/node.c M source/blender/editors/space_node/drawnode.c M source/blender/makesdna/DNA_node_types.h M source/blender/makesrna/intern/rna_nodetree.c M source/blender/nodes/CMakeLists.txt M source/blender/nodes/NOD_geometry.h M source/blender/nodes/NOD_math_functions.hh M source/blender/nodes/NOD_static_types.h A source/blender/nodes/geometry/nodes/node_geo_attribute_vector_math.cc M source/blender/nodes/intern/math_functions.cc === diff --git a/release/scripts/startup/nodeitems_builtins.py b/release/scripts/startup/nodeitems_builtins.py index 22344ffcc41..99187589a3c 100644 --- a/release/scripts/startup/nodeitems_builtins.py +++ b/release/scripts/startup/nodeitems_builtins.py @@ -488,6 +488,7 @@ geometry_node_categories = [ NodeItem("GeometryNodeAttributeFill"), NodeItem("GeometryNodeAttributeMix"), NodeItem("GeometryNodeAttributeColorRamp"), +NodeItem("GeometryNodeAttributeVectorMath"), ]), GeometryNodeCategory("GEO_COLOR", "Color", items=[ NodeItem("ShaderNodeValToRGB"), diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index 89a51afede9..3a4862e2bd1 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -1357,6 +1357,7 @@ int ntreeTexExecTree(struct bNodeTree *ntree, #define GEO_NODE_POINT_SEPARATE 1014 #define GEO_NODE_ATTRIBUTE_COMPARE 1015 #define GEO_NODE_ROTATE_POINTS 1016 +#define GEO_NODE_ATTRIBUTE_VECTOR_MATH 1017 /** \} */ diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index ad90c0fe82e..b675c82419f 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -4730,6 +4730,7 @@ static void registerGeometryNodes(void) register_node_type_geo_attribute_compare(); register_node_type_geo_attribute_fill(); + register_node_type_geo_attribute_vector_math(); register_node_type_geo_triangulate(); register_node_type_geo_edge_split(); register_node_type_geo_transform(); diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 4b5ba2af050..74ce0d713bf 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -3228,6 +3228,35 @@ static void node_geometry_buts_attribute_math(uiLayout *layout, uiItemR(layout, ptr, "input_type_b", DEFAULT_FLAGS, IFACE_("Type B"), ICON_NONE); } +static void node_geometry_buts_attribute_vector_math(uiLayout *layout, + bContext *UNUSED(C), + PointerRNA *ptr) +{ + bNode *node = (bNode *)ptr->data; + NodeAttributeVectorMath *node_storage = (NodeAttributeVectorMath *)node->storage; + + uiItemR(layout, ptr, "operation", DEFAULT_FLAGS, "", ICON_NONE); + uiItemR(layout, ptr, "input_type_a", DEFAULT_FLAGS, IFACE_("Type A"), ICON_NONE); + + /* These "use input b / c" checks are copied from the node's code. They could be deduplicated if + * the drawing code was moved to the node's file. */ + if (!ELEM(node_storage->operation, +NODE_VECTOR_MATH_NORMALIZE, +NODE_VECTOR_MATH_FLOOR, +NODE_VECTOR_MATH_CEIL, +NODE_VECTOR_MATH_FRACTION, +NODE_VECTOR_MATH_ABSOLUTE, +NODE_VECTOR_MATH_SINE, +NODE_VECTOR_MATH_COSINE, +NODE_VECTOR_MATH_TANGENT, +NODE_VECTOR_MATH_LENGTH)) { +uiItemR(layout, ptr, "input_type_b", DEFAULT_FLAGS, IFACE_("Type B"), ICON_NONE); + } + if (ELEM(node_storage->operation, NODE_VECTOR_MATH_WRAP)) { +uiItemR(layout, ptr, "input_type_c", DEFAULT_FLAGS, IFACE_("Type C"), ICON_NONE); + } +} + static void node_geometry_buts_point_instance(uiLayout *layout, bContext *UNUSED(C), PointerRNA *
[Bf-blender-cvs] [b9b59aa6de6] master: UI: Update geometry icon files
Commit: b9b59aa6de62c5f455c64a75d0d11aeb1325d69d Author: Hans Goudey Date: Mon Jan 11 15:29:20 2021 -0600 Branches: master https://developer.blender.org/rBb9b59aa6de62c5f455c64a75d0d11aeb1325d69d UI: Update geometry icon files None of these changes should be visible, but the files were somehow out of sync with the blend file, so they need to be updated to reflect those changes. === M release/datafiles/icons/brush.sculpt.draw_sharp.dat M release/datafiles/icons/ops.generic.select.dat M release/datafiles/icons/ops.generic.select_box.dat M release/datafiles/icons/ops.generic.select_circle.dat M release/datafiles/icons/ops.generic.select_lasso.dat M release/datafiles/icons/ops.mesh.primitive_cone_add_gizmo.dat M release/datafiles/icons/ops.mesh.primitive_cube_add_gizmo.dat M release/datafiles/icons/ops.mesh.primitive_cylinder_add_gizmo.dat === diff --git a/release/datafiles/icons/brush.sculpt.draw_sharp.dat b/release/datafiles/icons/brush.sculpt.draw_sharp.dat index 9bea1b02894..1877c0ae4d4 100644 Binary files a/release/datafiles/icons/brush.sculpt.draw_sharp.dat and b/release/datafiles/icons/brush.sculpt.draw_sharp.dat differ diff --git a/release/datafiles/icons/ops.generic.select.dat b/release/datafiles/icons/ops.generic.select.dat index 37a18a1ed79..1070d72d1e3 100644 Binary files a/release/datafiles/icons/ops.generic.select.dat and b/release/datafiles/icons/ops.generic.select.dat differ diff --git a/release/datafiles/icons/ops.generic.select_box.dat b/release/datafiles/icons/ops.generic.select_box.dat index e30586c2bb8..da435ab3925 100644 Binary files a/release/datafiles/icons/ops.generic.select_box.dat and b/release/datafiles/icons/ops.generic.select_box.dat differ diff --git a/release/datafiles/icons/ops.generic.select_circle.dat b/release/datafiles/icons/ops.generic.select_circle.dat index 9d33f73c75f..83e1deb119d 100644 Binary files a/release/datafiles/icons/ops.generic.select_circle.dat and b/release/datafiles/icons/ops.generic.select_circle.dat differ diff --git a/release/datafiles/icons/ops.generic.select_lasso.dat b/release/datafiles/icons/ops.generic.select_lasso.dat index e26168910df..54994c48a3d 100644 Binary files a/release/datafiles/icons/ops.generic.select_lasso.dat and b/release/datafiles/icons/ops.generic.select_lasso.dat differ diff --git a/release/datafiles/icons/ops.mesh.primitive_cone_add_gizmo.dat b/release/datafiles/icons/ops.mesh.primitive_cone_add_gizmo.dat index 211622ce37f..62166a71f54 100644 Binary files a/release/datafiles/icons/ops.mesh.primitive_cone_add_gizmo.dat and b/release/datafiles/icons/ops.mesh.primitive_cone_add_gizmo.dat differ diff --git a/release/datafiles/icons/ops.mesh.primitive_cube_add_gizmo.dat b/release/datafiles/icons/ops.mesh.primitive_cube_add_gizmo.dat index 2befbb101f2..4d43734ce88 100644 Binary files a/release/datafiles/icons/ops.mesh.primitive_cube_add_gizmo.dat and b/release/datafiles/icons/ops.mesh.primitive_cube_add_gizmo.dat differ diff --git a/release/datafiles/icons/ops.mesh.primitive_cylinder_add_gizmo.dat b/release/datafiles/icons/ops.mesh.primitive_cylinder_add_gizmo.dat index 17ba3e6a1e1..219e5fc4ead 100644 Binary files a/release/datafiles/icons/ops.mesh.primitive_cylinder_add_gizmo.dat and b/release/datafiles/icons/ops.mesh.primitive_cylinder_add_gizmo.dat differ ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [57fe65b17e4] master: Cleanup: Reduce indentation
Commit: 57fe65b17e407003f44f5b82c778a9a4c08bba19 Author: Hans Goudey Date: Sun Dec 27 21:26:53 2020 -0600 Branches: master https://developer.blender.org/rB57fe65b17e407003f44f5b82c778a9a4c08bba19 Cleanup: Reduce indentation Since the if statement is just a NULL check, returning early is simpler and makes reading the rest of the funtion easier. === M source/blender/nodes/geometry/nodes/node_geo_point_instance.cc === diff --git a/source/blender/nodes/geometry/nodes/node_geo_point_instance.cc b/source/blender/nodes/geometry/nodes/node_geo_point_instance.cc index 4274ded2024..0a07af37115 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_point_instance.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_point_instance.cc @@ -82,40 +82,42 @@ static void get_instanced_data__collection( bke::PersistentCollectionHandle collection_handle = params.get_input("Collection"); Collection *collection = params.handle_map().lookup(collection_handle); - if (collection != nullptr) { -const bool use_whole_collection = node.custom2 == 0; -if (use_whole_collection) { + if (collection == nullptr) { +return; + } + + const bool use_whole_collection = node.custom2 == 0; + if (use_whole_collection) { +InstancedData instance; +instance.type = INSTANCE_DATA_TYPE_COLLECTION; +instance.data.collection = collection; +r_instances_data.fill(instance); + } + else { +Vector possible_instances; +/* Direct child objects are instanced as objects. */ +LISTBASE_FOREACH (CollectionObject *, cob, >gobject) { + Object *object = cob->ob; + InstancedData instance; + instance.type = INSTANCE_DATA_TYPE_OBJECT; + instance.data.object = object; + possible_instances.append(instance); +} +/* Direct child collections are instanced as collections. */ +LISTBASE_FOREACH (CollectionChild *, child, >children) { + Collection *child_collection = child->collection; InstancedData instance; instance.type = INSTANCE_DATA_TYPE_COLLECTION; - instance.data.collection = collection; - r_instances_data.fill(instance); + instance.data.collection = child_collection; + possible_instances.append(instance); } -else { - Vector possible_instances; - /* Direct child objects are instanced as objects. */ - LISTBASE_FOREACH (CollectionObject *, cob, >gobject) { -Object *object = cob->ob; -InstancedData instance; -instance.type = INSTANCE_DATA_TYPE_OBJECT; -instance.data.object = object; -possible_instances.append(instance); - } - /* Direct child collections are instanced as collections. */ - LISTBASE_FOREACH (CollectionChild *, child, >children) { -Collection *child_collection = child->collection; -InstancedData instance; -instance.type = INSTANCE_DATA_TYPE_COLLECTION; -instance.data.collection = child_collection; -possible_instances.append(instance); - } - if (!possible_instances.is_empty()) { -const int seed = params.get_input("Seed"); -Array ids = get_geometry_element_ids_as_uints(component, ATTR_DOMAIN_POINT); -for (const int i : r_instances_data.index_range()) { - const int index = BLI_hash_int_2d(ids[i], seed) % possible_instances.size(); - r_instances_data[i] = possible_instances[index]; -} +if (!possible_instances.is_empty()) { + const int seed = params.get_input("Seed"); + Array ids = get_geometry_element_ids_as_uints(component, ATTR_DOMAIN_POINT); + for (const int i : r_instances_data.index_range()) { +const int index = BLI_hash_int_2d(ids[i], seed) % possible_instances.size(); +r_instances_data[i] = possible_instances[index]; } } } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [e590d2d167b] master: Cleanup: Declare variables where initialized
Commit: e590d2d167ba7c37f5b129ddc5a592c28dd6f893 Author: Hans Goudey Date: Sun Dec 27 21:46:57 2020 -0600 Branches: master https://developer.blender.org/rBe590d2d167ba7c37f5b129ddc5a592c28dd6f893 Cleanup: Declare variables where initialized === M source/blender/blenkernel/intern/mesh.c M source/blender/blenkernel/intern/mesh_runtime.c === diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 53f2a85fdad..950885d2114 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -845,9 +845,7 @@ static void mesh_tessface_clear_intern(Mesh *mesh, int free_customdata) Mesh *BKE_mesh_add(Main *bmain, const char *name) { - Mesh *me; - - me = BKE_id_new(bmain, ID_ME, name); + Mesh *me = BKE_id_new(bmain, ID_ME, name); return me; } @@ -1007,10 +1005,9 @@ BMesh *BKE_mesh_to_bmesh_ex(const Mesh *me, const struct BMeshCreateParams *create_params, const struct BMeshFromMeshParams *convert_params) { - BMesh *bm; const BMAllocTemplate allocsize = BMALLOC_TEMPLATE_FROM_ME(me); - bm = BM_mesh_create(, create_params); + BMesh *bm = BM_mesh_create(, create_params); BM_mesh_bm_from_me(bm, me, convert_params); return bm; @@ -1162,17 +1159,14 @@ void BKE_mesh_texspace_copy_from_object(Mesh *me, Object *ob) float (*BKE_mesh_orco_verts_get(Object *ob))[3] { Mesh *me = ob->data; - MVert *mvert = NULL; Mesh *tme = me->texcomesh ? me->texcomesh : me; - int a, totvert; - float(*vcos)[3] = NULL; /* Get appropriate vertex coordinates */ - vcos = MEM_calloc_arrayN(me->totvert, sizeof(*vcos), "orco mesh"); - mvert = tme->mvert; - totvert = min_ii(tme->totvert, me->totvert); + float(*vcos)[3] = MEM_calloc_arrayN(me->totvert, sizeof(*vcos), "orco mesh"); + MVert *mvert = tme->mvert; + int totvert = min_ii(tme->totvert, me->totvert); - for (a = 0; a < totvert; a++, mvert++) { + for (int a = 0; a < totvert; a++, mvert++) { copy_v3_v3(vcos[a], mvert->co); } @@ -1182,18 +1176,17 @@ float (*BKE_mesh_orco_verts_get(Object *ob))[3] void BKE_mesh_orco_verts_transform(Mesh *me, float (*orco)[3], int totvert, int invert) { float loc[3], size[3]; - int a; BKE_mesh_texspace_get(me->texcomesh ? me->texcomesh : me, loc, size); if (invert) { -for (a = 0; a < totvert; a++) { +for (int a = 0; a < totvert; a++) { float *co = orco[a]; madd_v3_v3v3v3(co, loc, co, size); } } else { -for (a = 0; a < totvert; a++) { +for (int a = 0; a < totvert; a++) { float *co = orco[a]; co[0] = (co[0] - loc[0]) / size[0]; co[1] = (co[1] - loc[1]) / size[1]; @@ -1274,7 +1267,6 @@ int test_index_face(MFace *mface, CustomData *fdata, int mfindex, int nr) Mesh *BKE_mesh_from_object(Object *ob) { - if (ob == NULL) { return NULL; } @@ -1414,8 +1406,7 @@ void BKE_mesh_smooth_flag_set(Mesh *me, const bool use_smooth) */ int poly_find_loop_from_vert(const MPoly *poly, const MLoop *loopstart, uint vert) { - int j; - for (j = 0; j < poly->totloop; j++, loopstart++) { + for (int j = 0; j < poly->totloop; j++, loopstart++) { if (loopstart->v == vert) { return j; } @@ -1682,11 +1673,9 @@ void BKE_mesh_mselect_validate(Mesh *me) */ int BKE_mesh_mselect_find(Mesh *me, int index, int type) { - int i; - BLI_assert(ELEM(type, ME_VSEL, ME_ESEL, ME_FSEL)); - for (i = 0; i < me->totselect; i++) { + for (int i = 0; i < me->totselect; i++) { if ((me->mselect[i].index == index) && (me->mselect[i].type == type)) { return i; } diff --git a/source/blender/blenkernel/intern/mesh_runtime.c b/source/blender/blenkernel/intern/mesh_runtime.c index b5257983b8c..22f29bef97e 100644 --- a/source/blender/blenkernel/intern/mesh_runtime.c +++ b/source/blender/blenkernel/intern/mesh_runtime.c @@ -154,12 +154,10 @@ int BKE_mesh_runtime_looptri_len(const Mesh *mesh) /* This is a ported copy of dm_getLoopTriArray(dm). */ const MLoopTri *BKE_mesh_runtime_looptri_ensure(Mesh *mesh) { - MLoopTri *looptri; - ThreadMutex *mesh_eval_mutex = (ThreadMutex *)mesh->runtime.eval_mutex; BLI_mutex_lock(mesh_eval_mutex); - looptri = mesh->runtime.looptris.array; + MLoopTri *looptri = mesh->runtime.looptris.array; if (looptri != NULL) { BLI_assert(BKE_mesh_runtime_looptri_len(mesh) == mesh->runtime.looptris.len); @@ -180,8 +178,7 @@ void BKE_mesh_runtime_verttri_from_looptri(MVertTri *r_verttri, const MLoopTri *looptri, int looptri_num) { - int i; - for (i = 0; i < looptri_num; i
[Bf-blender-cvs] [6ea01dc509f] master: UI: Use the 3D cursor icon for the RNA struct
Commit: 6ea01dc509f82458b2e7f1d040dc4d2f0e7820fe Author: Hans Goudey Date: Wed Jan 6 14:00:44 2021 -0600 Branches: master https://developer.blender.org/rB6ea01dc509f82458b2e7f1d040dc4d2f0e7820fe UI: Use the 3D cursor icon for the RNA struct Since there is a specific icon to represent the 3D cursor it makes sense to add it to the RNA struct. This struct's icon is only displayed in the Data API section of the outliner. === M source/blender/makesrna/intern/rna_scene.c === diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 265d9c5b98e..af31f16f4e0 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -2821,6 +2821,7 @@ static void rna_def_view3d_cursor(BlenderRNA *brna) RNA_def_struct_sdna(srna, "View3DCursor"); RNA_def_struct_path_func(srna, "rna_View3DCursor_path"); RNA_def_struct_ui_text(srna, "3D Cursor", ""); + RNA_def_struct_ui_icon(srna, ICON_CURSOR); prop = RNA_def_property(srna, "location", PROP_FLOAT, PROP_XYZ_LENGTH); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [61f1faac3f2] master: Fix T83868: Disabled or inactive list items are not grayed out
Commit: 61f1faac3f2154de27cedbb100b938e447e5046f Author: Hans Goudey Date: Thu Jan 7 16:28:26 2021 -0600 Branches: master https://developer.blender.org/rB61f1faac3f2154de27cedbb100b938e447e5046f Fix T83868: Disabled or inactive list items are not grayed out The cause for this was quite simple-- a misplaced bitwise operation before passing a value to the function that grayed out buttons based on their state, caused by refactoring in rB933bf62a611f before committing. What makes the situation a little more confusing is that the theme colors are overridden for list buttons in UI lists, necessitating a second call to `ui_widget_color_disabled()`. Ideally that wouldn't be necessary. === M source/blender/editors/interface/interface_widgets.c === diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 7cd8cc7a13b..a99f05730bb 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -2558,7 +2558,7 @@ static void widget_state(uiWidgetType *wt, int state, int drawflag, eUIEmbossTyp wt->wcol_theme = >tui.wcol_list_item; if (state & (UI_BUT_DISABLED | UI_BUT_INACTIVE | UI_SEARCH_FILTER_NO_MATCH)) { - ui_widget_color_disabled(wt, state & UI_SEARCH_FILTER_NO_MATCH); + ui_widget_color_disabled(wt, state); } } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [3db975f30dd] master: Fix T84326: No ID for geometry nodes instances after scattering
Commit: 3db975f30dd327381dc1a0e08305460a1a12eba4 Author: Hans Goudey Date: Thu Jan 7 09:27:42 2021 -0600 Branches: master https://developer.blender.org/rB3db975f30dd327381dc1a0e08305460a1a12eba4 Fix T84326: No ID for geometry nodes instances after scattering Instances are created with an "index" parameter used for persistence over time through animation. Currently the geometry nodes instancer passes the index in the array for this value, but the arrays created by the "Point Distribution" node aren't necessarily stable in this way when the input mesh is deformed. In D9832 we already mostly solved this problem with an `id` attribute. The solution here is to create instances with this attribute as well. It's important to note that deforming the instanced points *after* distribution will usually be a better solution for this problem. This solution is likely still important though. Differential Revision: https://developer.blender.org/D10024 === M source/blender/blenkernel/BKE_geometry_set.h M source/blender/blenkernel/BKE_geometry_set.hh M source/blender/blenkernel/intern/geometry_set.cc M source/blender/blenkernel/intern/object_dupli.c M source/blender/nodes/geometry/nodes/node_geo_point_instance.cc === diff --git a/source/blender/blenkernel/BKE_geometry_set.h b/source/blender/blenkernel/BKE_geometry_set.h index 37a3ed82bb8..5b8273def66 100644 --- a/source/blender/blenkernel/BKE_geometry_set.h +++ b/source/blender/blenkernel/BKE_geometry_set.h @@ -49,6 +49,7 @@ int BKE_geometry_set_instances(const struct GeometrySet *geometry_set, float (**r_positions)[3], float (**r_rotations)[3], float (**r_scales)[3], + int **r_ids, struct InstancedData **r_instanced_data); #ifdef __cplusplus diff --git a/source/blender/blenkernel/BKE_geometry_set.hh b/source/blender/blenkernel/BKE_geometry_set.hh index e4232a84a00..9dc2b80d4d4 100644 --- a/source/blender/blenkernel/BKE_geometry_set.hh +++ b/source/blender/blenkernel/BKE_geometry_set.hh @@ -364,6 +364,7 @@ class InstancesComponent : public GeometryComponent { blender::Vector positions_; blender::Vector rotations_; blender::Vector scales_; + blender::Vector ids_; blender::Vector instanced_data_; public: @@ -375,20 +376,24 @@ class InstancesComponent : public GeometryComponent { void add_instance(Object *object, blender::float3 position, blender::float3 rotation = {0, 0, 0}, -blender::float3 scale = {1, 1, 1}); +blender::float3 scale = {1, 1, 1}, +const int id = -1); void add_instance(Collection *collection, blender::float3 position, blender::float3 rotation = {0, 0, 0}, -blender::float3 scale = {1, 1, 1}); +blender::float3 scale = {1, 1, 1}, +const int id = -1); void add_instance(InstancedData data, blender::float3 position, blender::float3 rotation, -blender::float3 scale); +blender::float3 scale, +const int id = -1); blender::Span instanced_data() const; blender::Span positions() const; blender::Span rotations() const; blender::Span scales() const; + blender::Span ids() const; blender::MutableSpan positions(); int instances_amount() const; diff --git a/source/blender/blenkernel/intern/geometry_set.cc b/source/blender/blenkernel/intern/geometry_set.cc index 2a21a60ccc6..5d2b82dcc5f 100644 --- a/source/blender/blenkernel/intern/geometry_set.cc +++ b/source/blender/blenkernel/intern/geometry_set.cc @@ -476,34 +476,38 @@ void InstancesComponent::clear() void InstancesComponent::add_instance(Object *object, blender::float3 position, blender::float3 rotation, - blender::float3 scale) + blender::float3 scale, + const int id) { InstancedData data; data.type = INSTANCE_DATA_TYPE_OBJECT; data.data.object = object; - this->add_instance(data, position, rotation, scale); + this->add_instance(data, position, rotation, scale, id); } void InstancesComponent::add_instance(Collection *collection, blender::float3 position, blender::float3 rotation, - blender::float3 scale) + blender::float3 scale, +
[Bf-blender-cvs] [69f4088ba1f] geometry-nodes: Geometry Nodes: Change modifier name
Commit: 69f4088ba1f598394d4d599f996772a7b183aad7 Author: Hans Goudey Date: Mon Nov 30 10:23:57 2020 -0500 Branches: geometry-nodes https://developer.blender.org/rB69f4088ba1f598394d4d599f996772a7b183aad7 Geometry Nodes: Change modifier name The modifier was called "Empty", which reflects the fact that the modifier doesn't do anything when you add it. However, that is not true after you change the modifier's node group, and the fact that the modifier uses nodes is the one thing that distinguishes it at this point. This commit changes the name to "Geometry Nodes", which is simple and consistent with the "Geometry Node Editor" and the naming of the project so far. === M source/blender/makesrna/intern/rna_modifier.c M source/blender/modifiers/intern/MOD_nodes.cc === diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index b84859543b7..fb2692910c5 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -143,7 +143,7 @@ const EnumPropertyItem rna_enum_object_modifier_type_items[] = { ICON_MOD_EDGESPLIT, "Edge Split", "Split away joined faces at the edges"}, -{eModifierType_Nodes, "NODES", ICON_NODETREE, "Empty", ""}, +{eModifierType_Nodes, "NODES", ICON_NODETREE, "Geometry Nodes", ""}, {eModifierType_Mask, "MASK", ICON_MOD_MASK, diff --git a/source/blender/modifiers/intern/MOD_nodes.cc b/source/blender/modifiers/intern/MOD_nodes.cc index f9f523ce2d4..fd8084d933c 100644 --- a/source/blender/modifiers/intern/MOD_nodes.cc +++ b/source/blender/modifiers/intern/MOD_nodes.cc @@ -1044,7 +1044,7 @@ static void freeData(ModifierData *md) } ModifierTypeInfo modifierType_Nodes = { -/* name */ "Empty", +/* name */ "GeometryNodes", /* structName */ "NodesModifierData", /* structSize */ sizeof(NodesModifierData), /* srna */ _NodesModifier, ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [748f468fdc7] master: Cleanup: Use "region" for ARegion variable names
Commit: 748f468fdc7b80b7e84a854c63443050fcacad9c Author: Hans Goudey Date: Sun Nov 29 18:10:47 2020 -0500 Branches: master https://developer.blender.org/rB748f468fdc7b80b7e84a854c63443050fcacad9c Cleanup: Use "region" for ARegion variable names As proposed in T74432 and already implemented in several commits, "region" is the preferred name for `ARegion` variables, rather than any variant of "ar". This commit changes a few "ar" variables that have popped up over time and also adjusted names of variants like "arnew". === M source/blender/blenkernel/intern/screen.c M source/blender/blenloader/intern/versioning_270.c M source/blender/draw/intern/draw_manager.c M source/blender/editors/interface/interface_handlers.c M source/blender/editors/object/object_modes.c M source/blender/editors/object/object_remesh.c M source/blender/editors/screen/area.c M source/blender/editors/screen/screen_edit.c M source/blender/editors/sculpt_paint/sculpt.c M source/blender/editors/space_view3d/view3d_utils.c M source/blender/editors/uvedit/uvedit_rip.c M source/blender/windowmanager/intern/wm_event_system.c === diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c index 8662fce3dcc..f43bf3182c5 100644 --- a/source/blender/blenkernel/intern/screen.c +++ b/source/blender/blenkernel/intern/screen.c @@ -516,8 +516,8 @@ static void region_copylist(SpaceType *st, ListBase *lb1, ListBase *lb2) BLI_listbase_clear(lb1); for (region = lb2->first; region; region = region->next) { -ARegion *arnew = BKE_area_region_copy(st, region); -BLI_addtail(lb1, arnew); +ARegion *region_new = BKE_area_region_copy(st, region); +BLI_addtail(lb1, region_new); } } diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c index 41e46f8f0a0..adc2b55b350 100644 --- a/source/blender/blenloader/intern/versioning_270.c +++ b/source/blender/blenloader/intern/versioning_270.c @@ -245,13 +245,13 @@ static void do_version_action_editor_properties_region(ListBase *regionbase) } if (region->regiontype == RGN_TYPE_WINDOW) { /* add new region here */ - ARegion *arnew = MEM_callocN(sizeof(ARegion), "buttons for action"); + ARegion *region_new = MEM_callocN(sizeof(ARegion), "buttons for action"); - BLI_insertlinkbefore(regionbase, region, arnew); + BLI_insertlinkbefore(regionbase, region, region_new); - arnew->regiontype = RGN_TYPE_UI; - arnew->alignment = RGN_ALIGN_RIGHT; - arnew->flag = RGN_FLAG_HIDDEN; + region_new->regiontype = RGN_TYPE_UI; + region_new->alignment = RGN_ALIGN_RIGHT; + region_new->flag = RGN_FLAG_HIDDEN; return; } diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index 99f102680e5..988975bd399 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -1512,10 +1512,10 @@ void DRW_draw_view(const bContext *C) } else { Depsgraph *depsgraph = CTX_data_expect_evaluated_depsgraph(C); -ARegion *ar = CTX_wm_region(C); -GPUViewport *viewport = WM_draw_region_get_bound_viewport(ar); +ARegion *region = CTX_wm_region(C); +GPUViewport *viewport = WM_draw_region_get_bound_viewport(region); drw_state_prepare_clean_for_draw(); -DRW_draw_render_loop_2d_ex(depsgraph, ar, viewport, C); +DRW_draw_render_loop_2d_ex(depsgraph, region, viewport, C); } } diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 4fe4bbaf189..3c028977a36 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -8363,8 +8363,8 @@ uiBut *UI_context_active_but_get(const bContext *C) */ uiBut *UI_context_active_but_get_respect_menu(const bContext *C) { - ARegion *ar_menu = CTX_wm_menu(C); - return ui_context_button_active(ar_menu ? ar_menu : CTX_wm_region(C), NULL); + ARegion *region_menu = CTX_wm_menu(C); + return ui_context_button_active(region_menu ? region_menu : CTX_wm_region(C), NULL); } uiBut *UI_region_active_but_get(ARegion *region) diff --git a/source/blender/editors/object/object_modes.c b/source/blender/editors/object/object_modes.c index 9eaa8f3d31b..5a6fa2b8e3e 100644 --- a/source/blender/editors/object/object_modes.c +++ b/source/blender/editors/object/object_modes.c @@ -423,7 +423,7 @@ static bool object_switch_object_poll(bContext *C) static int object_switch_object_invoke(bContext *C, wmOperator *op, const wmEvent *event) { - ARegion *ar = CTX_wm_region(C); +
[Bf-blender-cvs] [dc40bea003b] master: Cleanup: Use LISTBASE_FOREACH macro in screen.c
Commit: dc40bea003b9814c59027a29ac0651fbedd468ab Author: Hans Goudey Date: Sun Nov 29 20:30:11 2020 -0500 Branches: master https://developer.blender.org/rBdc40bea003b9814c59027a29ac0651fbedd468ab Cleanup: Use LISTBASE_FOREACH macro in screen.c This commit replaces while loops and for loops with the equivalent macro. This results in much more readable code in some places, and it's now more apparent when the situation is more complicated than just iterating through a linked list. === M source/blender/blenkernel/intern/screen.c === diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c index f43bf3182c5..97bef99944a 100644 --- a/source/blender/blenkernel/intern/screen.c +++ b/source/blender/blenkernel/intern/screen.c @@ -67,11 +67,10 @@ static void screen_free_data(ID *id) { bScreen *screen = (bScreen *)id; - ARegion *region; /* No animdata here. */ - for (region = screen->regionbase.first; region; region = region->next) { + LISTBASE_FOREACH (ARegion *, region, >regionbase) { BKE_area_region_free(NULL, region); } @@ -325,14 +324,10 @@ static ListBase spacetypes = {NULL, NULL}; /* not SpaceType itself */ static void spacetype_free(SpaceType *st) { - ARegionType *art; - PanelType *pt; - HeaderType *ht; - - for (art = st->regiontypes.first; art; art = art->next) { + LISTBASE_FOREACH (ARegionType *, art, >regiontypes) { BLI_freelistN(>drawcalls); -for (pt = art->paneltypes.first; pt; pt = pt->next) { +LISTBASE_FOREACH (PanelType *, pt, >paneltypes) { if (pt->rna_ext.free) { pt->rna_ext.free(pt->rna_ext.data); } @@ -340,7 +335,7 @@ static void spacetype_free(SpaceType *st) BLI_freelistN(>children); } -for (ht = art->headertypes.first; ht; ht = ht->next) { +LISTBASE_FOREACH (HeaderType *, ht, >headertypes) { if (ht->rna_ext.free) { ht->rna_ext.free(ht->rna_ext.data); } @@ -355,9 +350,7 @@ static void spacetype_free(SpaceType *st) void BKE_spacetypes_free(void) { - SpaceType *st; - - for (st = spacetypes.first; st; st = st->next) { + LISTBASE_FOREACH (SpaceType *, st, ) { spacetype_free(st); } @@ -366,9 +359,7 @@ void BKE_spacetypes_free(void) SpaceType *BKE_spacetype_from_id(int spaceid) { - SpaceType *st; - - for (st = spacetypes.first; st; st = st->next) { + LISTBASE_FOREACH (SpaceType *, st, ) { if (st->spaceid == spaceid) { return st; } @@ -378,9 +369,7 @@ SpaceType *BKE_spacetype_from_id(int spaceid) ARegionType *BKE_regiontype_from_id_or_first(const SpaceType *st, int regionid) { - ARegionType *art; - - for (art = st->regiontypes.first; art; art = art->next) { + LISTBASE_FOREACH (ARegionType *, art, >regiontypes) { if (art->regionid == regionid) { return art; } @@ -393,9 +382,7 @@ ARegionType *BKE_regiontype_from_id_or_first(const SpaceType *st, int regionid) ARegionType *BKE_regiontype_from_id(const SpaceType *st, int regionid) { - ARegionType *art; - - for (art = st->regiontypes.first; art; art = art->next) { + LISTBASE_FOREACH (ARegionType *, art, >regiontypes) { if (art->regionid == regionid) { return art; } @@ -410,10 +397,8 @@ const ListBase *BKE_spacetypes_list(void) void BKE_spacetype_register(SpaceType *st) { - SpaceType *stype; - /* sanity check */ - stype = BKE_spacetype_from_id(st->spaceid); + SpaceType *stype = BKE_spacetype_from_id(st->spaceid); if (stype) { printf("error: redefinition of spacetype %s\n", stype->name); spacetype_free(stype); @@ -432,14 +417,11 @@ bool BKE_spacetype_exists(int spaceid) void BKE_spacedata_freelist(ListBase *lb) { - SpaceLink *sl; - ARegion *region; - - for (sl = lb->first; sl; sl = sl->next) { + LISTBASE_FOREACH (SpaceLink *, sl, lb) { SpaceType *st = BKE_spacetype_from_id(sl->spacetype); /* free regions for pushed spaces */ -for (region = sl->regionbase.first; region; region = region->next) { +LISTBASE_FOREACH (ARegion *, region, >regionbase) { BKE_area_region_free(st, region); } @@ -510,12 +492,10 @@ ARegion *BKE_area_region_copy(const SpaceType *st, const ARegion *region) /* from lb2 to lb1, lb1 is supposed to be freed */ static void region_copylist(SpaceType *st, ListBase *lb1, ListBase *lb2) { - ARegion *region; - /* to be sure */ BLI_listbase_clear(lb1); - for (region = lb2->first; region; region = region->next) { + LISTBASE_FOREACH (ARegion *, region, lb2) { ARegion *region_new = BKE_area_region_copy(st, region); BLI_addtail(lb1, region_new); } @@ -524,11 +504,9 @@ static void region_copylist(SpaceType *st, ListBase *lb1, ListBase *lb2
[Bf-blender-cvs] [c19b363256a] geometry-nodes: Geometry Nodes: Support exposing string sockets to the modifier
Commit: c19b363256a733c968fe1ad56885ce9ff164dda5 Author: Hans Goudey Date: Fri Nov 27 12:21:08 2020 -0500 Branches: geometry-nodes https://developer.blender.org/rBc19b363256a733c968fe1ad56885ce9ff164dda5 Geometry Nodes: Support exposing string sockets to the modifier Create a string IDProperty in the modifier initialized with the socket's default value. === M source/blender/modifiers/intern/MOD_nodes.cc === diff --git a/source/blender/modifiers/intern/MOD_nodes.cc b/source/blender/modifiers/intern/MOD_nodes.cc index 86efd086f6f..d91a7c5d78d 100644 --- a/source/blender/modifiers/intern/MOD_nodes.cc +++ b/source/blender/modifiers/intern/MOD_nodes.cc @@ -622,6 +622,28 @@ static const SocketPropertyType *get_socket_property_type(const bNodeSocket }; return _type; } +case SOCK_STRING: { + static const SocketPropertyType string_type = { + [](const bNodeSocket , const char *name) { +bNodeSocketValueString *value = (bNodeSocketValueString *)socket.default_value; +return IDP_NewString( +value->value, name, BLI_strnlen(value->value, sizeof(value->value)) + 1); + }, + nullptr, + nullptr, + [](const bNodeSocket , const char *name) { +bNodeSocketValueString *value = (bNodeSocketValueString *)socket.default_value; +return IDP_NewString( +value->value, name, BLI_strnlen(value->value, sizeof(value->value)) + 1); + }, + nullptr, + [](const IDProperty ) { return property.type == IDP_STRING; }, + [](const IDProperty , void *r_value) { +new (r_value) std::string(IDP_String()); + }, + }; + return _type; +} default: { return nullptr; } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [b4f3c3cca00] geometry-nodes: Geometry Nodes: Use context for active modifier operators
Commit: b4f3c3cca00d889abb585e3bc7d9806e003c3a11 Author: Hans Goudey Date: Wed Nov 25 11:46:02 2020 -0500 Branches: geometry-nodes https://developer.blender.org/rBb4f3c3cca00d889abb585e3bc7d9806e003c3a11 Geometry Nodes: Use context for active modifier operators This adds "modifier" as a new context variable in the property editor. It is used instead of getting the active modifier directly. This way it displays in the breadcrumbs panel, and the variable can be set only in the modifier tab, meaning it won't work from the shortcut even when the modifiers aren't visible. === M source/blender/editors/object/object_modifier.c M source/blender/editors/space_buttons/buttons_context.c === diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 864b3357ea2..7d12fa1805b 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -1101,7 +1101,7 @@ static void edit_modifier_report_property(wmOperatorType *ot) * Using modifier names and data context. * \{ */ -static bool edit_modifier_properties_base(bContext *C, wmOperator *op) +bool edit_modifier_invoke_properties(bContext *C, wmOperator *op) { if (RNA_struct_property_is_set(op->ptr, "modifier")) { return true; @@ -1117,73 +1117,6 @@ static bool edit_modifier_properties_base(bContext *C, wmOperator *op) return false; } -static bool edit_modifier_properties_active(bContext *C, wmOperator *op) -{ - Object *ob = ED_object_active_context(C); - if (ob != NULL) { -ModifierData *md = BKE_object_active_modifier(ob); -if (md != NULL) { - RNA_string_set(op->ptr, "modifier", md->name); - return true; -} - } - - return false; -} - -bool edit_modifier_invoke_properties(bContext *C, wmOperator *op) -{ - if (edit_modifier_properties_base(C, op)) { -return true; - } - if (edit_modifier_properties_active(C, op)) { -return true; - } - - return false; -} - -/** - * Run the regular invoke properties, then also check the custom data - * of panels under the mouse for a modifier. - * - * \param event: If this isn't NULL, the operator will also look for panels underneath - * the cursor with customdata set to a modifier. - * \param r_retval: This should be used if #event is used in order to to return - * #OPERATOR_PASS_THROUGH to check other operators with the same key set. - */ -bool edit_modifier_invoke_properties_with_hover_no_active(bContext *C, - wmOperator *op, - const wmEvent *event, - int *r_retval) -{ - - if (edit_modifier_properties_base(C, op)) { -return true; - } - - PointerRNA *panel_ptr = UI_region_panel_custom_data_under_cursor(C, event); - - if (!(panel_ptr == NULL || RNA_pointer_is_null(panel_ptr))) { -if (RNA_struct_is_a(panel_ptr->type, _Modifier)) { - ModifierData *md = panel_ptr->data; - RNA_string_set(op->ptr, "modifier", md->name); - return true; -} -BLI_assert(r_retval != NULL); /* We need the return value in this case. */ -if (r_retval != NULL) { - *r_retval = (OPERATOR_PASS_THROUGH | OPERATOR_CANCELLED); -} -return false; - } - - if (r_retval != NULL) { -*r_retval = OPERATOR_CANCELLED; - } - - return false; -} - ModifierData *edit_modifier_property_get(wmOperator *op, Object *ob, int type) { char modifier_name[MAX_NAME]; @@ -1248,7 +1181,9 @@ static int modifier_remove_invoke(bContext *C, wmOperator *op, const wmEvent *UN if (edit_modifier_invoke_properties(C, op)) { return modifier_remove_exec(C, op); } - return OPERATOR_CANCELLED; + + /* Work around multiple operators using the same shortcut. */ + return (OPERATOR_PASS_THROUGH | OPERATOR_CANCELLED); } void OBJECT_OT_modifier_remove(wmOperatorType *ot) @@ -1293,7 +1228,8 @@ static int modifier_move_up_invoke(bContext *C, wmOperator *op, const wmEvent *U if (edit_modifier_invoke_properties(C, op)) { return modifier_move_up_exec(C, op); } - return OPERATOR_CANCELLED; + /* Work around multiple operators using the same shortcut. */ + return (OPERATOR_PASS_THROUGH | OPERATOR_CANCELLED); } void OBJECT_OT_modifier_move_up(wmOperatorType *ot) @@ -1337,7 +1273,8 @@ static int modifier_move_down_invoke(bContext *C, wmOperator *op, const wmEvent if (edit_modifier_invoke_properties(C, op)) { return modifier_move_down_exec(C, op); } - return OPERATOR_CANCELLED; + /* Work around multiple operators using the same shortcut. */ + return (OPERATOR_PASS_THROUGH | OPERATOR_CANCELLED); } void OBJECT_OT_modifier_move_down(wmOperatorType *ot) @@ -1483,7 +1420,8 @@
[Bf-blender-cvs] [0eb096f4060] master: Cleanup: Declare variables where initialized
Commit: 0eb096f4060538d6b8db506ec6099137704ed8a7 Author: Hans Goudey Date: Fri Nov 20 21:54:52 2020 -0500 Branches: master https://developer.blender.org/rB0eb096f4060538d6b8db506ec6099137704ed8a7 Cleanup: Declare variables where initialized Reduce variable scope, and in a few cases, use bool instead of int. === M source/blender/editors/interface/interface_widgets.c === diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index e2c835ac461..6d7e3ec1d8d 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -519,8 +519,8 @@ void UI_draw_anti_tria( float x1, float y1, float x2, float y2, float x3, float y3, const float color[4]) { const float tri_arr[3][2] = {{x1, y1}, {x2, y2}, {x3, y3}}; - float draw_color[4]; + float draw_color[4]; copy_v4_v4(draw_color, color); /* Note: This won't give back the original color. */ draw_color[3] *= 1.0f / WIDGET_AA_JITTER; @@ -645,8 +645,7 @@ static int round_box_shadow_edges( float (*vert)[2], const rcti *rect, float rad, int roundboxalign, float step) { float vec[WIDGET_CURVE_RESOLU][2]; - float minx, miny, maxx, maxy; - int a, tot = 0; + int tot = 0; rad += step; @@ -654,65 +653,65 @@ static int round_box_shadow_edges( rad = 0.5f * BLI_rcti_size_y(rect); } - minx = rect->xmin - step; - miny = rect->ymin - step; - maxx = rect->xmax + step; - maxy = rect->ymax + step; + const float minx = rect->xmin - step; + const float miny = rect->ymin - step; + const float maxx = rect->xmax + step; + const float maxy = rect->ymax + step; /* mult */ - for (a = 0; a < WIDGET_CURVE_RESOLU; a++) { + for (int a = 0; a < WIDGET_CURVE_RESOLU; a++) { vec[a][0] = rad * cornervec[a][0]; vec[a][1] = rad * cornervec[a][1]; } /* start with left-top, anti clockwise */ if (roundboxalign & UI_CNR_TOP_LEFT) { -for (a = 0; a < WIDGET_CURVE_RESOLU; a++, tot++) { +for (int a = 0; a < WIDGET_CURVE_RESOLU; a++, tot++) { vert[tot][0] = minx + rad - vec[a][0]; vert[tot][1] = maxy - vec[a][1]; } } else { -for (a = 0; a < WIDGET_CURVE_RESOLU; a++, tot++) { +for (int a = 0; a < WIDGET_CURVE_RESOLU; a++, tot++) { vert[tot][0] = minx; vert[tot][1] = maxy; } } if (roundboxalign & UI_CNR_BOTTOM_LEFT) { -for (a = 0; a < WIDGET_CURVE_RESOLU; a++, tot++) { +for (int a = 0; a < WIDGET_CURVE_RESOLU; a++, tot++) { vert[tot][0] = minx + vec[a][1]; vert[tot][1] = miny + rad - vec[a][0]; } } else { -for (a = 0; a < WIDGET_CURVE_RESOLU; a++, tot++) { +for (int a = 0; a < WIDGET_CURVE_RESOLU; a++, tot++) { vert[tot][0] = minx; vert[tot][1] = miny; } } if (roundboxalign & UI_CNR_BOTTOM_RIGHT) { -for (a = 0; a < WIDGET_CURVE_RESOLU; a++, tot++) { +for (int a = 0; a < WIDGET_CURVE_RESOLU; a++, tot++) { vert[tot][0] = maxx - rad + vec[a][0]; vert[tot][1] = miny + vec[a][1]; } } else { -for (a = 0; a < WIDGET_CURVE_RESOLU; a++, tot++) { +for (int a = 0; a < WIDGET_CURVE_RESOLU; a++, tot++) { vert[tot][0] = maxx; vert[tot][1] = miny; } } if (roundboxalign & UI_CNR_TOP_RIGHT) { -for (a = 0; a < WIDGET_CURVE_RESOLU; a++, tot++) { +for (int a = 0; a < WIDGET_CURVE_RESOLU; a++, tot++) { vert[tot][0] = maxx - vec[a][1]; vert[tot][1] = maxy - rad + vec[a][0]; } } else { -for (a = 0; a < WIDGET_CURVE_RESOLU; a++, tot++) { +for (int a = 0; a < WIDGET_CURVE_RESOLU; a++, tot++) { vert[tot][0] = maxx; vert[tot][1] = maxy; } @@ -733,7 +732,7 @@ static void round_box__edges( /* for uv, can divide by zero */ const float facxi = (maxxi != minxi) ? 1.0f / (maxxi - minxi) : 0.0f; const float facyi = (maxyi != minyi) ? 1.0f / (maxyi - minyi) : 0.0f; - int a, tot = 0, minsize; + int tot = 0; const int hnum = ((roundboxalign & (UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT)) == (UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT) || (roundboxalign & (UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT)) == @@ -747,7 +746,7 @@ static void round_box__edges( 1 : 2; - minsize = min_ii(BLI_rcti_size_x(rect) * hnum, BLI_rcti_size_y(rect) * vnum); + int minsize = min_ii(BLI_rcti_size_x(rect) * hnum, BLI_rcti_size_y(rect) * vnum); if (2.0f * rad > minsize) { rad = 0.5f * minsize; @@ -769,7 +768,7 @@ static void round_box__edges( BLI_rctf_init(>uniform_params.recti, minxi, maxxi, minyi, maxyi); /* mult */ - for (a = 0; a < WIDGET_
[Bf-blender-cvs] [c1b655c06af] geometry-nodes: Geometry Nodes: Improve wording of modifier error messages
Commit: c1b655c06af9c259701db338a80f580ac0f4c278 Author: Hans Goudey Date: Wed Nov 25 13:32:36 2020 -0500 Branches: geometry-nodes https://developer.blender.org/rBc1b655c06af9c259701db338a80f580ac0f4c278 Geometry Nodes: Improve wording of modifier error messages - Don't use contractions - Remove unecessary words === M source/blender/modifiers/intern/MOD_nodes.cc === diff --git a/source/blender/modifiers/intern/MOD_nodes.cc b/source/blender/modifiers/intern/MOD_nodes.cc index f96fffb6ce3..c1660cb80f4 100644 --- a/source/blender/modifiers/intern/MOD_nodes.cc +++ b/source/blender/modifiers/intern/MOD_nodes.cc @@ -814,17 +814,16 @@ static void check_property_socket_sync(const Object *ob, ModifierData *md) IDProperty *property = IDP_GetPropertyFromGroup(nmd->settings.properties, socket->identifier); if (property == nullptr) { if (socket->type == SOCK_STRING) { -BKE_modifier_set_error(ob, md, "String sockets cannot be exposed in the modifier"); +BKE_modifier_set_error(ob, md, "String socket can not be exposed in the modifier"); } else if (socket->type == SOCK_OBJECT) { -BKE_modifier_set_error(ob, md, "Object sockets cannot be exposed in the modifier"); +BKE_modifier_set_error(ob, md, "Object socket can not be exposed in the modifier"); } else if (socket->type == SOCK_GEOMETRY) { -BKE_modifier_set_error(ob, md, "The node group can only have one geometry input"); +BKE_modifier_set_error(ob, md, "Node group can only have one geometry input"); } else { -BKE_modifier_set_error( -ob, md, "Missing modifier property for input socket \"%s\"", socket->name); +BKE_modifier_set_error(ob, md, "Missing property for input socket \"%s\"", socket->name); } continue; } @@ -832,7 +831,7 @@ static void check_property_socket_sync(const Object *ob, ModifierData *md) const SocketPropertyType *property_type = get_socket_property_type(*socket); if (!property_type->is_correct_type(*property)) { BKE_modifier_set_error( - ob, md, "Property type does not match for input socket \"(%s)\"", socket->name); + ob, md, "Property type does not match input socket \"(%s)\"", socket->name); continue; } } @@ -845,7 +844,7 @@ static void check_property_socket_sync(const Object *ob, ModifierData *md) } if (!has_geometry_output) { -BKE_modifier_set_error(ob, md, "The node group must have a geometry output"); +BKE_modifier_set_error(ob, md, "Node group must have a geometry output"); } } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [6c241b2dd7f] geometry-nodes: Geometry Nodes: Node editor header interaction with active modifier
Commit: 6c241b2dd7fc48e8981335e7750dd378b5e4f02b Author: Hans Goudey Date: Wed Nov 25 15:34:29 2020 -0500 Branches: geometry-nodes https://developer.blender.org/rB6c241b2dd7fc48e8981335e7750dd378b5e4f02b Geometry Nodes: Node editor header interaction with active modifier This commit makes the way the selector in the middle of the node editor header interacts with the active modifier much more intuitive. - With no active modifier, or when the active modifier is a non-node modifier, the "new" operator adds a new nodes modifier. - With an active node modifier, the drop-down affects the modifier's selected node group. - With no active object, there is no drop-down in the header. - The node editor's node group always updates, even when there is no active modifier. - Pinning disables the drop-down and keeps the same node group selected, regardless of the context. This is designed to work similarly to materials and material slots, which should be familiar to any Blender user. One workflow not allowed by this design is editing any geometry node group, regardless of the context, but if that turns out to be an issue it should be solved in a similar way for all node editors. === M release/scripts/startup/bl_operators/geometry_nodes.py M release/scripts/startup/bl_ui/space_node.py M source/blender/nodes/geometry/node_geometry_tree.cc === diff --git a/release/scripts/startup/bl_operators/geometry_nodes.py b/release/scripts/startup/bl_operators/geometry_nodes.py index 0b8c7814808..0d4eb89494f 100644 --- a/release/scripts/startup/bl_operators/geometry_nodes.py +++ b/release/scripts/startup/bl_operators/geometry_nodes.py @@ -18,35 +18,82 @@ import bpy +def geometry_node_group_empty_new(context): +group = bpy.data.node_groups.new("Geometry Nodes", 'GeometryNodeTree') +group.inputs.new('NodeSocketGeometry', "Geometry") +group.outputs.new('NodeSocketGeometry', "Geometry") +input_node = group.nodes.new('NodeGroupInput') +output_node = group.nodes.new('NodeGroupOutput') +output_node.is_active_output = True -class NewGeometryNodeTree(bpy.types.Operator): -"""Create a new geometry node tree""" +input_node.location.x = -200 - input_node.width +output_node.location.x = 200 -bl_idname = "node.new_geometry_node_tree" -bl_label = "New Geometry Node Tree" +group.links.new(output_node.inputs[0], input_node.outputs[0]) + +return group + +def node_editor_geometry_modifier_poll(context) -> bool: +if not (context.area.type == 'NODE_EDITOR' and context.space_data.tree_type == 'GeometryNodeTree'): +return False + +ob = context.object + +# Test object support for geometry node modifier (No volume or hair object support yet) +if not ob or ob.type not in {'MESH', 'CURVE', 'SURFACE', 'META', 'FONT', 'POINTCLOUD'}: +return False + +return True + +class NewGeometryNodeModifier(bpy.types.Operator): +"""Create a new modifier with a new geometry node group""" + +bl_idname = "node.new_geometry_node_modifier" +bl_label = "New Geometry Node Modifier" bl_options = {'REGISTER', 'UNDO'} @classmethod def poll(cls, context): -return context.area.type == 'NODE_EDITOR' and context.space_data.tree_type == 'GeometryNodeTree' +return node_editor_geometry_modifier_poll(context) def execute(self, context): -group = bpy.data.node_groups.new("Geometry Nodes", 'GeometryNodeTree') -group.inputs.new('NodeSocketGeometry', "Geometry") -group.outputs.new('NodeSocketGeometry', "Geometry") -input_node = group.nodes.new('NodeGroupInput') -output_node = group.nodes.new('NodeGroupOutput') -output_node.is_active_output = True +modifier = context.object.modifiers.new("Empty", "NODES") -input_node.location.x = -200 - input_node.width -output_node.location.x = 200 +if not modifier: +return {'CANCELLED'} -group.links.new(output_node.inputs[0], input_node.outputs[0]) +group = geometry_node_group_empty_new(context) +modifier.node_group = group context.space_data.node_tree = group return {'FINISHED'} +class NewGeometryNodeTreeAssign(bpy.types.Operator): +"""Create a new geometry node group and assign it the the active modifier""" + +bl_idname = "node.new_geometry_node_group_assign" +bl_label = "Assign New Geometry Node Group" +bl_options = {'REGISTER', 'UNDO'} + +@classmethod +def poll(cls, context): +return node_editor_geometry_modifier_poll(context)
[Bf-blender-cvs] [d40126d636b] geometry-nodes: Geometry Nodes: Use ID template node group selector in the modifier
Commit: d40126d636b261850a2c2790caf46a3efb7d3d38 Author: Hans Goudey Date: Thu Nov 26 12:49:09 2020 -0500 Branches: geometry-nodes https://developer.blender.org/rBd40126d636b261850a2c2790caf46a3efb7d3d38 Geometry Nodes: Use ID template node group selector in the modifier This puts the same controls as in the node editor header in the modifier panel. === M release/scripts/startup/bl_operators/geometry_nodes.py M source/blender/modifiers/intern/MOD_nodes.cc === diff --git a/release/scripts/startup/bl_operators/geometry_nodes.py b/release/scripts/startup/bl_operators/geometry_nodes.py index 0d4eb89494f..23926f28ab0 100644 --- a/release/scripts/startup/bl_operators/geometry_nodes.py +++ b/release/scripts/startup/bl_operators/geometry_nodes.py @@ -33,10 +33,7 @@ def geometry_node_group_empty_new(context): return group -def node_editor_geometry_modifier_poll(context) -> bool: -if not (context.area.type == 'NODE_EDITOR' and context.space_data.tree_type == 'GeometryNodeTree'): -return False - +def geometry_modifier_poll(context) -> bool: ob = context.object # Test object support for geometry node modifier (No volume or hair object support yet) @@ -54,7 +51,7 @@ class NewGeometryNodeModifier(bpy.types.Operator): @classmethod def poll(cls, context): -return node_editor_geometry_modifier_poll(context) +return geometry_modifier_poll(context) def execute(self, context): modifier = context.object.modifiers.new("Empty", "NODES") @@ -65,7 +62,6 @@ class NewGeometryNodeModifier(bpy.types.Operator): group = geometry_node_group_empty_new(context) modifier.node_group = group -context.space_data.node_tree = group return {'FINISHED'} @@ -78,7 +74,7 @@ class NewGeometryNodeTreeAssign(bpy.types.Operator): @classmethod def poll(cls, context): -return node_editor_geometry_modifier_poll(context) +return geometry_modifier_poll(context) def execute(self, context): modifier = context.object.modifiers.active @@ -88,7 +84,6 @@ class NewGeometryNodeTreeAssign(bpy.types.Operator): group = geometry_node_group_empty_new(context) modifier.node_group = group -context.space_data.node_tree = group return {'FINISHED'} diff --git a/source/blender/modifiers/intern/MOD_nodes.cc b/source/blender/modifiers/intern/MOD_nodes.cc index c1660cb80f4..86efd086f6f 100644 --- a/source/blender/modifiers/intern/MOD_nodes.cc +++ b/source/blender/modifiers/intern/MOD_nodes.cc @@ -940,7 +940,7 @@ static void draw_property_for_socket(uiLayout *layout, } } -static void panel_draw(const bContext *UNUSED(C), Panel *panel) +static void panel_draw(const bContext *C, Panel *panel) { uiLayout *layout = panel->layout; @@ -948,9 +948,19 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel) NodesModifierData *nmd = static_cast(ptr->data); uiLayoutSetPropSep(layout, true); + /* This should be removed, but animation currently doesn't work with the IDProperties. */ uiLayoutSetPropDecorate(layout, false); - uiItemR(layout, ptr, "node_group", 0, nullptr, ICON_NODETREE); + uiTemplateID(layout, + C, + ptr, + "node_group", + "node.new_geometry_node_group_assign", + nullptr, + nullptr, + 0, + ICON_NONE, + nullptr); if (nmd->node_group != nullptr && nmd->settings.properties != nullptr) { PointerRNA settings_ptr; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [26eb8d6aa0c] master: UI: Use decorators in volume modifiers
Commit: 26eb8d6aa0c8fcf59d427390f57765c61fde2c92 Author: Hans Goudey Date: Thu Nov 26 12:56:12 2020 -0500 Branches: master https://developer.blender.org/rB26eb8d6aa0c8fcf59d427390f57765c61fde2c92 UI: Use decorators in volume modifiers This is consistent with the UI for other modifier types. === M source/blender/modifiers/intern/MOD_mesh_to_volume.cc M source/blender/modifiers/intern/MOD_volume_displace.cc M source/blender/modifiers/intern/MOD_volume_to_mesh.cc === diff --git a/source/blender/modifiers/intern/MOD_mesh_to_volume.cc b/source/blender/modifiers/intern/MOD_mesh_to_volume.cc index 61d556a64af..e137a59e10f 100644 --- a/source/blender/modifiers/intern/MOD_mesh_to_volume.cc +++ b/source/blender/modifiers/intern/MOD_mesh_to_volume.cc @@ -143,7 +143,6 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel) MeshToVolumeModifierData *mvmd = static_cast(ptr->data); uiLayoutSetPropSep(layout, true); - uiLayoutSetPropDecorate(layout, false); uiItemR(layout, ptr, "object", 0, nullptr, ICON_NONE); uiItemR(layout, ptr, "density", 0, nullptr, ICON_NONE); diff --git a/source/blender/modifiers/intern/MOD_volume_displace.cc b/source/blender/modifiers/intern/MOD_volume_displace.cc index f4e1936713c..90e570f55fb 100644 --- a/source/blender/modifiers/intern/MOD_volume_displace.cc +++ b/source/blender/modifiers/intern/MOD_volume_displace.cc @@ -112,7 +112,6 @@ static void panel_draw(const bContext *C, Panel *panel) VolumeDisplaceModifierData *vdmd = static_cast(ptr->data); uiLayoutSetPropSep(layout, true); - uiLayoutSetPropDecorate(layout, false); uiTemplateID(layout, C, ptr, "texture", "texture.new", nullptr, nullptr, 0, ICON_NONE, nullptr); uiItemR(layout, ptr, "texture_map_mode", 0, "Texture Mapping", ICON_NONE); diff --git a/source/blender/modifiers/intern/MOD_volume_to_mesh.cc b/source/blender/modifiers/intern/MOD_volume_to_mesh.cc index e008dc3f140..ec53914f115 100644 --- a/source/blender/modifiers/intern/MOD_volume_to_mesh.cc +++ b/source/blender/modifiers/intern/MOD_volume_to_mesh.cc @@ -95,7 +95,6 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel) VolumeToMeshModifierData *vmmd = static_cast(ptr->data); uiLayoutSetPropSep(layout, true); - uiLayoutSetPropDecorate(layout, false); { uiLayout *col = uiLayoutColumn(layout, false); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [267ba329ece] geometry-nodes-point-separate-node: Point separate node: Refactor, add comments, clean up
Commit: 267ba329ece56b9bd30abb4866ff75e437cb7f83 Author: Hans Goudey Date: Tue Dec 1 22:33:47 2020 -0500 Branches: geometry-nodes-point-separate-node https://developer.blender.org/rB267ba329ece56b9bd30abb4866ff75e437cb7f83 Point separate node: Refactor, add comments, clean up Make more of the logic generic so that it can more easily work on more component types in the future. Basically anything that handles attributes can be generic. === M source/blender/nodes/geometry/nodes/node_geo_point_separate.cc === diff --git a/source/blender/nodes/geometry/nodes/node_geo_point_separate.cc b/source/blender/nodes/geometry/nodes/node_geo_point_separate.cc index 81a193723b2..1fa2c87c95e 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_point_separate.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_point_separate.cc @@ -39,10 +39,10 @@ static bNodeSocketTemplate geo_node_point_instance_out[] = { namespace blender::nodes { -static void fill_attribute_from_input(ReadAttributePtr input_attribute, - WriteAttributePtr out_attribute_a, - WriteAttributePtr out_attribute_b, - Span a_or_b) +static void fill_new_attribute_from_input(ReadAttributePtr input_attribute, + WriteAttributePtr out_attribute_a, + WriteAttributePtr out_attribute_b, + Span a_or_b) { fn::GSpan in_span = input_attribute->get_span(); int i_a = 0; @@ -59,36 +59,44 @@ static void fill_attribute_from_input(ReadAttributePtr input_attribute, } } -static void separate_component_attributes(const PointCloudComponent , - GeometrySet *out_set_a, - GeometrySet *out_set_b, - const int a_total, - const int b_total, +/** + * Move the original attribute values to the two output components. + * + * \note This assumes a consistent ordering of indices before and after the split. + * This is trivial for simple components like point clouds, but for meshes a map between + * input and output indices might be necessary. + */ +static void separate_component_attributes(const GeometryComponent _component, + GeometryComponent _component_a, + GeometryComponent _component_b, Span a_or_b) { - /* Start fresh with new pointclouds. */ - out_set_a->replace_pointcloud(BKE_pointcloud_new_nomain(a_total)); - out_set_b->replace_pointcloud(BKE_pointcloud_new_nomain(b_total)); - PointCloudComponent _component_a = out_set_a->get_component_for_write(); - PointCloudComponent _component_b = out_set_b->get_component_for_write(); + Set attribute_names = in_component.attribute_names(); - Set attribute_names = component.attribute_names(); for (const std::string : attribute_names) { -ReadAttributePtr attribute = component.attribute_try_get_for_read(name); +ReadAttributePtr attribute = in_component.attribute_try_get_for_read(name); BLI_assert(attribute); const CustomDataType data_type = bke::cpp_type_to_custom_data_type(attribute->cpp_type()); const AttributeDomain domain = attribute->domain(); -if (!component.attribute_is_builtin(name)) { - const bool create_success_a = out_component_a.attribute_try_create(name, domain, data_type); - const bool create_success_b = out_component_b.attribute_try_create(name, domain, data_type); - if (!(create_success_a && create_success_b)) { -/* Since the input attribute is from the same component type, - * it should always be possible to create the new attributes. */ + +/* Don't try to create the attribute on the new component if it already exists. Built-in + * attributes will already exist on new components by definition. It should always be possible + * to recreate the attribute on the same component type. Also, if one of the new components + * has the attribute the other one should have it too, but check independently to be safe. */ +if (!out_component_a.has_attribute(name)) { + if (!out_component_a.attribute_try_create(name, domain, data_type)) { +BLI_assert(false); +continue; + } +} +if (!out_component_b.has_attribute(name)) { + if (!out_component_b.attribute_try_create(name, domain, data_type)) { BLI_assert(false); continue; } } + WriteAttributePtr out_attribute_a = out_component_a.attribute_try_get_for_write(name); WriteAttributePtr out_attribute_b = out_component_b.att
[Bf-blender-cvs] [59414e6a6f0] geometry-nodes-point-separate-node: Point Separate Node: Revert earlier change to point cloud creation
Commit: 59414e6a6f032e38008d4a1e935e9d6926fe3831 Author: Hans Goudey Date: Tue Dec 1 22:29:55 2020 -0500 Branches: geometry-nodes-point-separate-node https://developer.blender.org/rB59414e6a6f032e38008d4a1e935e9d6926fe3831 Point Separate Node: Revert earlier change to point cloud creation I'm not quite sure creating the "radius" attribute in here is necessary when any other attribute can be created later, but without this the original radius attribute didn't pass to the new point cloud components properly. This should be investigated though, because the "radius" attribute of pointclouds currently exists in some "semi-built-in" space that doesn't really make sense. === M source/blender/blenkernel/intern/pointcloud.cc === diff --git a/source/blender/blenkernel/intern/pointcloud.cc b/source/blender/blenkernel/intern/pointcloud.cc index 1d38b69462a..5f6685817b9 100644 --- a/source/blender/blenkernel/intern/pointcloud.cc +++ b/source/blender/blenkernel/intern/pointcloud.cc @@ -243,6 +243,13 @@ PointCloud *BKE_pointcloud_new_nomain(const int totpoint) pointcloud->totpoint = totpoint; + CustomData_add_layer_named(>pdata, + CD_PROP_FLOAT, + CD_CALLOC, + nullptr, + pointcloud->totpoint, + POINTCLOUD_ATTR_RADIUS); + pointcloud->totpoint = totpoint; CustomData_realloc(>pdata, pointcloud->totpoint); BKE_pointcloud_update_customdata_pointers(pointcloud); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [bce42fbfe4b] geometry-nodes-point-separate-node: Attribute Access: Add a "has_attribute" method
Commit: bce42fbfe4b61d7351eac3f912729e721512f52a Author: Hans Goudey Date: Tue Dec 1 22:31:00 2020 -0500 Branches: geometry-nodes-point-separate-node https://developer.blender.org/rBbce42fbfe4b61d7351eac3f912729e721512f52a Attribute Access: Add a "has_attribute" method === M source/blender/blenkernel/BKE_geometry_set.hh M source/blender/blenkernel/intern/attribute_access.cc === diff --git a/source/blender/blenkernel/BKE_geometry_set.hh b/source/blender/blenkernel/BKE_geometry_set.hh index ef3ae3c381c..bcf9bef4708 100644 --- a/source/blender/blenkernel/BKE_geometry_set.hh +++ b/source/blender/blenkernel/BKE_geometry_set.hh @@ -122,6 +122,7 @@ class GeometryComponent { const AttributeDomain domain, const CustomDataType data_type); + virtual bool has_attribute(const blender::StringRef attribute_name) const; virtual blender::Set attribute_names() const; virtual bool is_empty() const; @@ -293,6 +294,7 @@ class MeshComponent : public GeometryComponent { const AttributeDomain domain, const CustomDataType data_type) final; + bool has_attribute(const blender::StringRef attribute_name) const; blender::Set attribute_names() const final; bool is_empty() const final; @@ -335,6 +337,7 @@ class PointCloudComponent : public GeometryComponent { const AttributeDomain domain, const CustomDataType data_type) final; + bool has_attribute(const blender::StringRef attribute_name) const; blender::Set attribute_names() const final; bool is_empty() const final; diff --git a/source/blender/blenkernel/intern/attribute_access.cc b/source/blender/blenkernel/intern/attribute_access.cc index 2345c834be4..adedf1a74cd 100644 --- a/source/blender/blenkernel/intern/attribute_access.cc +++ b/source/blender/blenkernel/intern/attribute_access.cc @@ -590,6 +590,11 @@ Set GeometryComponent::attribute_names() const return {}; } +bool GeometryComponent::has_attribute(const blender::StringRef UNUSED(attribute_name)) const +{ + return false; +} + static ReadAttributePtr try_adapt_data_type(ReadAttributePtr attribute, const blender::fn::CPPType _type) { @@ -803,6 +808,11 @@ bool PointCloudComponent::attribute_try_create(const StringRef attribute_name, return true; } +bool PointCloudComponent::has_attribute(const blender::StringRef attribute_name) const +{ + return custom_data_has_layer_with_name(pointcloud_->pdata, attribute_name); +} + Set PointCloudComponent::attribute_names() const { if (pointcloud_ == nullptr) { @@ -1059,6 +1069,11 @@ bool MeshComponent::attribute_try_create(const StringRef attribute_name, } } +bool MeshComponent::has_attribute(const blender::StringRef attribute_name) const +{ + return custom_data_has_layer_with_name(mesh_->pdata, attribute_name); +} + Set MeshComponent::attribute_names() const { if (mesh_ == nullptr) { ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [e7ec68cd46d] geometry-nodes-point-separate-node: Merge branch 'master' into geometry-nodes-point-separate-node
Commit: e7ec68cd46d04efb6fde6c57f10467a232cfbab3 Author: Hans Goudey Date: Mon Dec 7 08:01:00 2020 -0600 Branches: geometry-nodes-point-separate-node https://developer.blender.org/rBe7ec68cd46d04efb6fde6c57f10467a232cfbab3 Merge branch 'master' into geometry-nodes-point-separate-node === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [3e005a32145] master: Cleanup: Use LISTBASE_FOREACH in node transform code
Commit: 3e005a3214533ffa0d8533acc1e5ed3962e32ac3 Author: Hans Goudey Date: Mon Dec 7 11:11:03 2020 -0600 Branches: master https://developer.blender.org/rB3e005a3214533ffa0d8533acc1e5ed3962e32ac3 Cleanup: Use LISTBASE_FOREACH in node transform code Also decrease variable scope. === M source/blender/editors/transform/transform_convert_node.c === diff --git a/source/blender/editors/transform/transform_convert_node.c b/source/blender/editors/transform/transform_convert_node.c index 38db8708d0c..58ff4db324e 100644 --- a/source/blender/editors/transform/transform_convert_node.c +++ b/source/blender/editors/transform/transform_convert_node.c @@ -25,6 +25,7 @@ #include "MEM_guardedalloc.h" +#include "BLI_listbase.h" #include "BLI_math.h" #include "BKE_context.h" @@ -70,8 +71,6 @@ static void NodeToTransData(TransData *td, TransData2D *td2d, bNode *node, const td2d->loc[2] = 0.0f; td2d->loc2d = td2d->loc; /* current location */ - td->flag = 0; - td->loc = td2d->loc; copy_v3_v3(td->iloc, td->loc); /* use node center instead of origin (top-left corner) */ @@ -85,8 +84,8 @@ static void NodeToTransData(TransData *td, TransData2D *td2d, bNode *node, const td->ext = NULL; td->val = NULL; - td->flag |= TD_SELECTED; - td->dist = 0.0; + td->flag = TD_SELECTED; + td->dist = 0.0f; unit_m3(td->mtx); unit_m3(td->smtx); @@ -107,10 +106,7 @@ static bool is_node_parent_select(bNode *node) void createTransNodeData(TransInfo *t) { const float dpi_fac = UI_DPI_FAC; - TransData *td; - TransData2D *td2d; SpaceNode *snode = t->area->spacedata.first; - bNode *node; TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_SINGLE(t); @@ -124,7 +120,7 @@ void createTransNodeData(TransInfo *t) t->flag &= ~T_PROP_EDIT_ALL; /* set transform flags on nodes */ - for (node = snode->edittree->nodes.first; node; node = node->next) { + LISTBASE_FOREACH (bNode *, node, >edittree->nodes) { if (node->flag & NODE_SELECT && is_node_parent_select(node) == false) { node->flag |= NODE_TRANSFORM; tc->data_len++; @@ -134,10 +130,11 @@ void createTransNodeData(TransInfo *t) } } - td = tc->data = MEM_callocN(tc->data_len * sizeof(TransData), "TransNode TransData"); - td2d = tc->data_2d = MEM_callocN(tc->data_len * sizeof(TransData2D), "TransNode TransData2D"); + TransData *td = tc->data = MEM_callocN(tc->data_len * sizeof(TransData), "TransNode TransData"); + TransData2D *td2d = tc->data_2d = MEM_callocN(tc->data_len * sizeof(TransData2D), +"TransNode TransData2D"); - for (node = snode->edittree->nodes.first; node; node = node->next) { + LISTBASE_FOREACH (bNode *, node, >edittree->nodes) { if (node->flag & NODE_TRANSFORM) { NodeToTransData(td++, td2d++, node, dpi_fac); } @@ -156,24 +153,21 @@ void flushTransNodes(TransInfo *t) const float dpi_fac = UI_DPI_FAC; FOREACH_TRANS_DATA_CONTAINER (t, tc) { -int a; -TransData *td; -TransData2D *td2d; - applyGridAbsolute(t); /* flush to 2d vector from internally used 3d vector */ -for (a = 0, td = tc->data, td2d = tc->data_2d; a < tc->data_len; a++, td++, td2d++) { +for (int i = 0; i < tc->data_len; i++) { + TransData *td = >data[i]; + TransData2D *td2d = >data_2d[i]; bNode *node = td->extra; - float locx, locy; /* weirdo - but the node system is a mix of free 2d elements and dpi sensitive UI */ #ifdef USE_NODE_CENTER - locx = (td2d->loc[0] - (BLI_rctf_size_x(>totr)) * +0.5f) / dpi_fac; - locy = (td2d->loc[1] - (BLI_rctf_size_y(>totr)) * -0.5f) / dpi_fac; + float locx = (td2d->loc[0] - (BLI_rctf_size_x(>totr)) * +0.5f) / dpi_fac; + float locy = (td2d->loc[1] - (BLI_rctf_size_y(>totr)) * -0.5f) / dpi_fac; #else - locx = td2d->loc[0] / dpi_fac; - locy = td2d->loc[1] / dpi_fac; + float locx = td2d->loc[0] / dpi_fac; + float locy = td2d->loc[1] / dpi_fac; #endif /* account for parents (nested nodes) */ @@ -209,9 +203,7 @@ void special_aftertrans_update__node(bContext *C, TransInfo *t) /* remove selected nodes on cancel */ bNodeTree *ntree = snode->edittree; if (ntree) { - bNode *node, *node_next; - for (node = ntree->nodes.first; node; node = node_next) { -node_next = node->next; + LISTBASE_FOREACH_MUTABLE (bNode *, node, >nodes) { if (node->flag & NODE_SELECT) { nodeRemoveNode(bmain, ntree, node, true); } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [67faa85fb05] master: Cleanup: Use LISTBASE_FOREACH macro in windowmanager intern
Commit: 67faa85fb05defa5c596ac6549deb52a3654c3a7 Author: Hans Goudey Date: Fri Dec 4 13:50:53 2020 -0600 Branches: master https://developer.blender.org/rB67faa85fb05defa5c596ac6549deb52a3654c3a7 Cleanup: Use LISTBASE_FOREACH macro in windowmanager intern Also decrease the scope of variables related to the loops. === M source/blender/windowmanager/intern/wm_event_system.c M source/blender/windowmanager/intern/wm_files.c M source/blender/windowmanager/intern/wm_init_exit.c M source/blender/windowmanager/intern/wm_jobs.c M source/blender/windowmanager/intern/wm_keymap.c M source/blender/windowmanager/intern/wm_operator_type.c M source/blender/windowmanager/intern/wm_surface.c === diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 1bd8c675807..9d118b70e43 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -376,10 +376,9 @@ void wm_event_do_refresh_wm_and_depsgraph(bContext *C) /* Cached: editor refresh callbacks now, they get context. */ LISTBASE_FOREACH (wmWindow *, win, >windows) { const bScreen *screen = WM_window_get_active_screen(win); -ScrArea *area; CTX_wm_window_set(C, win); -for (area = screen->areabase.first; area; area = area->next) { +LISTBASE_FOREACH (ScrArea *, area, >areabase) { if (area->do_refresh) { CTX_wm_area_set(C, area); ED_area_do_refresh(C, area); @@ -516,7 +515,7 @@ void wm_event_do_notifiers(bContext *C) bScreen *screen = WM_window_get_active_screen(win); WorkSpace *workspace = WM_window_get_active_workspace(win); - /* Dilter out notifiers. */ + /* Filter out notifiers. */ if (note->category == NC_SCREEN && note->reference && note->reference != screen && note->reference != workspace && note->reference != WM_window_get_active_layout(win)) { /* Pass. */ @@ -525,8 +524,6 @@ void wm_event_do_notifiers(bContext *C) /* Pass. */ } else { -ARegion *region; - /* XXX context in notifiers? */ CTX_wm_window_set(C, win); @@ -538,13 +535,13 @@ void wm_event_do_notifiers(bContext *C) # endif ED_screen_do_listen(C, note); -for (region = screen->regionbase.first; region; region = region->next) { +LISTBASE_FOREACH (ARegion *, region, >regionbase) { ED_region_do_listen(win, NULL, region, note, scene); } ED_screen_areas_iter (win, screen, area) { ED_area_do_listen(win, area, note, scene); - for (region = area->regionbase.first; region; region = region->next) { + LISTBASE_FOREACH (ARegion *, region, >regionbase) { ED_region_do_listen(win, area, region, note, scene); } } @@ -1708,7 +1705,8 @@ static void wm_handler_op_context(bContext *C, wmEventHandler_Op *handler, const } if (region == NULL) { -for (region = area->regionbase.first; region; region = region->next) { +LISTBASE_FOREACH (ARegion *, region_iter, >regionbase) { + region = region_iter; if (region == handler->context.region) { break; } @@ -2247,23 +2245,23 @@ static int wm_handler_fileselect_do(bContext *C, } } else { -wmWindow *temp_win; ScrArea *ctx_area = CTX_wm_area(C); -for (temp_win = wm->windows.first; temp_win; temp_win = temp_win->next) { +wmWindow *temp_win = NULL; +LISTBASE_FOREACH (wmWindow *, win, >windows) { bScreen *screen = WM_window_get_active_screen(temp_win); ScrArea *file_area = screen->areabase.first; if (screen->temp && (file_area->spacetype == SPACE_FILE)) { int win_size[2]; bool is_maximized; -ED_fileselect_window_params_get(temp_win, win_size, _maximized); +ED_fileselect_window_params_get(win, win_size, _maximized); ED_fileselect_params_to_userdef(file_area->spacedata.first, win_size, is_maximized); if (BLI_listbase_is_single(_area->spacedata)) { - BLI_assert(ctx_win != temp_win); + BLI_assert(ctx_win != win); - wm_window_close(C, wm, temp_win); + wm_window_close(C, wm, win); CTX_wm_window_set(C, ctx_win); /* #wm_window_close() NULLs. */ /* Some operators expect a drawable context (for EVT_FILESELECT_EXEC). */ @@ -2272,7 +2270,7 @@ static int wm_handler_fileselect_do(bContext *C, * opening (UI_BLOCK_MOVEMOUSE_QUIT). */ wm
[Bf-blender-cvs] [ea37e4ea5a7] master: Fix incorrect variable name after last commit
Commit: ea37e4ea5a712f637e52ef5972a48920fa7e092f Author: Hans Goudey Date: Fri Dec 4 14:46:51 2020 -0600 Branches: master https://developer.blender.org/rBea37e4ea5a712f637e52ef5972a48920fa7e092f Fix incorrect variable name after last commit === M source/blender/windowmanager/intern/wm_event_system.c === diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 9d118b70e43..ac27862d507 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -2249,7 +2249,7 @@ static int wm_handler_fileselect_do(bContext *C, wmWindow *temp_win = NULL; LISTBASE_FOREACH (wmWindow *, win, >windows) { - bScreen *screen = WM_window_get_active_screen(temp_win); + bScreen *screen = WM_window_get_active_screen(win); ScrArea *file_area = screen->areabase.first; if (screen->temp && (file_area->spacetype == SPACE_FILE)) { ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [920edc358cf] geometry-nodes-point-separate-node: Merge branch 'geometry-nodes' into geometry-nodes-point-separate-node
Commit: 920edc358cfd09200f1fdb6bc7fe1dfc1173adfe Author: Hans Goudey Date: Thu Dec 3 11:31:05 2020 -0600 Branches: geometry-nodes-point-separate-node https://developer.blender.org/rB920edc358cfd09200f1fdb6bc7fe1dfc1173adfe Merge branch 'geometry-nodes' into geometry-nodes-point-separate-node === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [f58d9d7500c] geometry-nodes-point-separate-node: Merge branch 'master' into geometry-nodes-point-separate-node
Commit: f58d9d7500cc28cb57cb007922b6157cdbe02244 Author: Hans Goudey Date: Thu Dec 3 11:31:18 2020 -0600 Branches: geometry-nodes-point-separate-node https://developer.blender.org/rBf58d9d7500cc28cb57cb007922b6157cdbe02244 Merge branch 'master' into geometry-nodes-point-separate-node === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [6505f9c09ae] geometry-nodes-point-separate-node: Geometry Nodes: Add boolean type to random attribute node
Commit: 6505f9c09ae8cd88d67dc4e946bd5ade66af7387 Author: Hans Goudey Date: Thu Dec 3 18:27:20 2020 -0600 Branches: geometry-nodes-point-separate-node https://developer.blender.org/rB6505f9c09ae8cd88d67dc4e946bd5ade66af7387 Geometry Nodes: Add boolean type to random attribute node === M source/blender/makesrna/intern/rna_attribute.c M source/blender/makesrna/intern/rna_nodetree.c M source/blender/nodes/geometry/nodes/node_geo_random_attribute.cc === diff --git a/source/blender/makesrna/intern/rna_attribute.c b/source/blender/makesrna/intern/rna_attribute.c index ad615026343..c8be4344be0 100644 --- a/source/blender/makesrna/intern/rna_attribute.c +++ b/source/blender/makesrna/intern/rna_attribute.c @@ -44,6 +44,7 @@ const EnumPropertyItem rna_enum_attribute_type_items[] = { {CD_PROP_COLOR, "FLOAT_COLOR", 0, "Float Color", "RGBA color with floating point precisions"}, {CD_MLOOPCOL, "BYTE_COLOR", 0, "Byte Color", "RGBA color with 8-bit precision"}, {CD_PROP_STRING, "STRING", 0, "String", "Text string"}, +{CD_PROP_BOOL, "BOOLEAN", 0, "Boolean", "True or false"}, {0, NULL, 0, NULL, NULL}, }; diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 99ae1b85e0c..9ac25da1252 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -1859,7 +1859,7 @@ static const EnumPropertyItem *itemf_function_check( static bool attribute_random_type_supported(const EnumPropertyItem *item) { - return ELEM(item->value, CD_PROP_FLOAT, CD_PROP_FLOAT3); + return ELEM(item->value, CD_PROP_FLOAT, CD_PROP_FLOAT3, CD_PROP_BOOL); } static const EnumPropertyItem *rna_GeometryNodeAttributeRandom_type_itemf( bContext *UNUSED(C), PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) diff --git a/source/blender/nodes/geometry/nodes/node_geo_random_attribute.cc b/source/blender/nodes/geometry/nodes/node_geo_random_attribute.cc index 5cacb96412c..5574a570feb 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_random_attribute.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_random_attribute.cc @@ -59,6 +59,16 @@ static void geo_node_random_attribute_update(bNodeTree *UNUSED(ntree), bNode *no namespace blender::nodes { +static void randomize_attribute(BooleanWriteAttribute , RandomNumberGenerator ) +{ + MutableSpan attribute_span = attribute.get_span(); + for (const int i : IndexRange(attribute.size())) { +const bool value = rng.get_float() > 0.5f; +attribute_span[i] = value; + } + attribute.apply_span(); +} + static void randomize_attribute(FloatWriteAttribute , float min, float max, @@ -121,6 +131,11 @@ static void randomize_attribute(GeometryComponent , randomize_attribute(float3_attribute, min_value, max_value, rng); break; } +case CD_PROP_BOOL: { + BooleanWriteAttribute boolean_attribute = std::move(attribute); + randomize_attribute(boolean_attribute, rng); + break; +} default: break; } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [e9023797642] geometry-nodes-point-separate-node: Geometry Nodes: Attribute compare node
Commit: e90237976426905aae040f2047dea2b5edebfe25 Author: Hans Goudey Date: Thu Dec 3 22:50:45 2020 -0600 Branches: geometry-nodes-point-separate-node https://developer.blender.org/rBe90237976426905aae040f2047dea2b5edebfe25 Geometry Nodes: Attribute compare node This node reads two input attributes as floats and allows for basic element-wise comparison operations. Like the attribute math node, it's also possible to switch to using floats as inputs. This node can be combined with the point separate node for more flexibility on which points to separate out. I used the same abstractions that the attribute math node uses in this commit, assuming that makes sense. === M release/scripts/startup/nodeitems_builtins.py M source/blender/blenkernel/BKE_node.h M source/blender/blenkernel/intern/node.c M source/blender/editors/space_node/drawnode.c M source/blender/makesrna/intern/rna_nodetree.c M source/blender/nodes/CMakeLists.txt M source/blender/nodes/NOD_geometry.h M source/blender/nodes/NOD_math_functions.hh M source/blender/nodes/NOD_static_types.h A source/blender/nodes/geometry/nodes/node_geo_attribute_compare.cc M source/blender/nodes/intern/math_functions.cc === diff --git a/release/scripts/startup/nodeitems_builtins.py b/release/scripts/startup/nodeitems_builtins.py index f955389d36b..27355cda764 100644 --- a/release/scripts/startup/nodeitems_builtins.py +++ b/release/scripts/startup/nodeitems_builtins.py @@ -488,6 +488,7 @@ geometry_node_categories = [ GeometryNodeCategory("GEO_ATTRIBUTE", "Attribute", items=[ NodeItem("GeometryNodeRandomAttribute"), NodeItem("GeometryNodeAttributeMath"), +NodeItem("GeometryNodeAttributeCompare"), ]), GeometryNodeCategory("GEO_COLOR", "Color", items=[ NodeItem("ShaderNodeValToRGB"), diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index 68093affab8..9f15b7f5d62 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -1351,6 +1351,7 @@ int ntreeTexExecTree(struct bNodeTree *ntree, #define GEO_NODE_ATTRIBUTE_MATH 1009 #define GEO_NODE_JOIN_GEOMETRY 1010 #define GEO_NODE_POINT_SEPARATE 1011 +#define GEO_NODE_ATTRIBUTE_COMPARE 1012 /** \} */ diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 8edafce3518..54c68019e81 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -4694,6 +4694,7 @@ static void registerGeometryNodes(void) register_node_type_geo_attribute_math(); register_node_type_geo_join_geometry(); register_node_type_geo_point_separate(); + register_node_type_geo_attribute_compare(); } static void registerFunctionNodes(void) diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 84e7a74fab3..2f84bc668e6 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -3149,6 +3149,15 @@ static void node_geometry_buts_boolean_math(uiLayout *layout, bContext *UNUSED(C uiItemR(layout, ptr, "operation", DEFAULT_FLAGS, "", ICON_NONE); } +static void node_geometry_buts_attribute_compare(uiLayout *layout, + bContext *UNUSED(C), + PointerRNA *ptr) +{ + uiItemR(layout, ptr, "operation", DEFAULT_FLAGS, "", ICON_NONE); + uiItemR(layout, ptr, "input_type_a", DEFAULT_FLAGS, IFACE_("Type A"), ICON_NONE); + uiItemR(layout, ptr, "input_type_b", DEFAULT_FLAGS, IFACE_("Type B"), ICON_NONE); +} + static void node_geometry_buts_subdivision_surface(uiLayout *layout, bContext *UNUSED(C), PointerRNA *UNUSED(ptr)) @@ -3200,6 +3209,9 @@ static void node_geometry_set_butfunc(bNodeType *ntype) case GEO_NODE_ATTRIBUTE_MATH: ntype->draw_buttons = node_geometry_buts_attribute_math; break; +case GEO_NODE_ATTRIBUTE_COMPARE: + ntype->draw_buttons = node_geometry_buts_attribute_compare; + break; } } diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 9ac25da1252..ff238e959eb 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -8368,6 +8368,30 @@ static void def_geo_attribute_math(StructRNA *srna) RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_socket_update"); } +static void def_geo_attri
[Bf-blender-cvs] [be3bb4da032] geometry-nodes-point-separate-node: Geometry Nodes: Refactor and change point separate node
Commit: be3bb4da0325e8f72d73830e6186bea2d4060e3d Author: Hans Goudey Date: Thu Dec 3 18:31:10 2020 -0600 Branches: geometry-nodes-point-separate-node https://developer.blender.org/rBbe3bb4da0325e8f72d73830e6186bea2d4060e3d Geometry Nodes: Refactor and change point separate node The threshold input is unecessary with an "attribute compare" node before this one, or with attribute rounding. So to remove some complexity it is removed, and a boolean input attribute is used instead. For the implementation, the existing code becomes a bit more specific to point cloud data, because I'm realizing that mesh separate is quite a different problem, and it doesn't make sense to force the same code to be able to solve that too. === M source/blender/nodes/geometry/nodes/node_geo_point_separate.cc === diff --git a/source/blender/nodes/geometry/nodes/node_geo_point_separate.cc b/source/blender/nodes/geometry/nodes/node_geo_point_separate.cc index 23e1c720161..d3cf1fc3a8d 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_point_separate.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_point_separate.cc @@ -27,7 +27,6 @@ static bNodeSocketTemplate geo_node_point_instance_in[] = { {SOCK_GEOMETRY, N_("Geometry")}, {SOCK_STRING, N_("Mask")}, -{SOCK_FLOAT, N_("Threshold"), 0.5f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX}, {-1, ""}, }; @@ -47,15 +46,16 @@ static void fill_new_attribute_from_input(ReadAttributePtr input_attribute, fn::GSpan in_span = input_attribute->get_span(); int i_a = 0; int i_b = 0; - for (int i_in : IndexRange(input_attribute->size())) { -if (a_or_b[i_in]) { - out_attribute_a->set(i_a, in_span[i_in]); - i_a++; -} -else { + for (int i_in = 0; i_in < in_span.size(); i_in++) { +const bool move_to_b = a_or_b[i_in]; +if (move_to_b) { out_attribute_b->set(i_b, in_span[i_in]); i_b++; } +else { + out_attribute_a->set(i_a, in_span[i_in]); + i_a++; +} } } @@ -66,10 +66,10 @@ static void fill_new_attribute_from_input(ReadAttributePtr input_attribute, * This is trivial for simple components like point clouds, but for meshes a map between * input and output indices might be necessary. */ -static void separate_component_attributes(const GeometryComponent _component, - GeometryComponent _component_a, - GeometryComponent _component_b, - Span a_or_b) +static void move_split_attributes(const PointCloudComponent _component, + GeometryComponent _component_a, + GeometryComponent _component_b, + Span a_or_b) { Set attribute_names = in_component.attribute_names(); @@ -109,64 +109,49 @@ static void separate_component_attributes(const GeometryComponent _component, } } -/* TODO: How to override based on component type without adding it as an argument? */ -static void create_new_components(GeometrySet *out_set_a, - GeometrySet *out_set_b, - const int a_total, - const int b_total) -{ - /* Start fresh with new pointclouds. */ - out_set_a->replace_pointcloud(BKE_pointcloud_new_nomain(a_total)); - out_set_b->replace_pointcloud(BKE_pointcloud_new_nomain(b_total)); -} - /** * Find total in each new set and find which of the output sets each point will belong to. */ -static Array calculate_split(const GeometryComponent , - const std::string mask_name, - const float threshold, - int *r_a_total, - int *r_b_total) +static Array split_point_cloud_component(const GeometryComponent , + const std::string mask_name, + int *r_a_total, + int *r_b_total) { - /* For now this will always sample the attributes on the point level. */ - const FloatReadAttribute mask_attribute = component.attribute_get_for_read( - mask_name, ATTR_DOMAIN_POINT, 1.0f); - Span masks = mask_attribute.get_span(); + const BooleanReadAttribute mask_attribute = component.attribute_get_for_read( + mask_name, ATTR_DOMAIN_POINT, false); + Array masks = mask_attribute.get_span(); const int in_total = masks.size(); - *r_a_total = 0; - Array a_or_b(in_total); - for (int i : masks.index_range()) { -const bool in_a = masks[i] > threshold; -a_or_b[i] = in_a; -if (in_a) { - *r_a_total += 1; + *r_b_to
[Bf-blender-cvs] [d9b8ddd8836] geometry-nodes-point-separate-node: Geometry Nodes: Add a boolean attribute data type
Commit: d9b8ddd88364203483c7282321e057edcb9b8e1e Author: Hans Goudey Date: Thu Dec 3 18:23:21 2020 -0600 Branches: geometry-nodes-point-separate-node https://developer.blender.org/rBd9b8ddd88364203483c7282321e057edcb9b8e1e Geometry Nodes: Add a boolean attribute data type === M source/blender/blenkernel/BKE_attribute_access.hh M source/blender/blenkernel/intern/attribute_access.cc M source/blender/blenkernel/intern/customdata.c M source/blender/makesdna/DNA_customdata_types.h M source/blender/nodes/NOD_geometry_exec.hh M source/blender/nodes/intern/node_tree_multi_function.cc === diff --git a/source/blender/blenkernel/BKE_attribute_access.hh b/source/blender/blenkernel/BKE_attribute_access.hh index c4a704ef385..797187bacd7 100644 --- a/source/blender/blenkernel/BKE_attribute_access.hh +++ b/source/blender/blenkernel/BKE_attribute_access.hh @@ -266,9 +266,11 @@ template class TypedWriteAttribute { } }; +using BooleanReadAttribute = TypedReadAttribute; using FloatReadAttribute = TypedReadAttribute; using Float3ReadAttribute = TypedReadAttribute; using Color4fReadAttribute = TypedReadAttribute; +using BooleanWriteAttribute = TypedWriteAttribute; using FloatWriteAttribute = TypedWriteAttribute; using Float3WriteAttribute = TypedWriteAttribute; using Color4fWriteAttribute = TypedWriteAttribute; diff --git a/source/blender/blenkernel/intern/attribute_access.cc b/source/blender/blenkernel/intern/attribute_access.cc index 2edf3981c38..d899adf3f07 100644 --- a/source/blender/blenkernel/intern/attribute_access.cc +++ b/source/blender/blenkernel/intern/attribute_access.cc @@ -392,6 +392,8 @@ const blender::fn::CPPType *custom_data_type_to_cpp_type(const CustomDataType ty return ::get(); case CD_PROP_COLOR: return ::get(); +case CD_PROP_BOOL: + return ::get(); default: return nullptr; } @@ -415,6 +417,9 @@ CustomDataType cpp_type_to_custom_data_type(const blender::fn::CPPType ) if (type.is()) { return CD_PROP_COLOR; } + if (type.is()) { +return CD_PROP_BOOL; + } return static_cast(-1); } @@ -449,6 +454,9 @@ static ReadAttributePtr read_attribute_from_custom_data(const CustomData case CD_PROP_COLOR: return std::make_unique>( domain, Span(static_cast(layer.data), size)); +case CD_PROP_BOOL: + return std::make_unique>( + domain, Span(static_cast(layer.data), size)); } } } @@ -490,6 +498,9 @@ static WriteAttributePtr write_attribute_from_custom_data( case CD_PROP_COLOR: return std::make_unique>( domain, MutableSpan(static_cast(layer.data), size)); +case CD_PROP_BOOL: + return std::make_unique>( + domain, MutableSpan(static_cast(layer.data), size)); } } } @@ -718,6 +729,7 @@ bool PointCloudComponent::attribute_domain_with_type_supported( const AttributeDomain domain, const CustomDataType data_type) const { return domain == ATTR_DOMAIN_POINT && ELEM(data_type, + CD_PROP_BOOL, CD_PROP_FLOAT, CD_PROP_FLOAT2, CD_PROP_FLOAT3, @@ -841,8 +853,13 @@ bool MeshComponent::attribute_domain_with_type_supported(const AttributeDomain d if (!this->attribute_domain_supported(domain)) { return false; } - return ELEM( - data_type, CD_PROP_FLOAT, CD_PROP_FLOAT2, CD_PROP_FLOAT3, CD_PROP_INT32, CD_PROP_COLOR); + return ELEM(data_type, + CD_PROP_BOOL, + CD_PROP_FLOAT, + CD_PROP_FLOAT2, + CD_PROP_FLOAT3, + CD_PROP_INT32, + CD_PROP_COLOR); } int MeshComponent::attribute_domain_size(const AttributeDomain domain) const diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index fdb3e246382..1e2bc570c65 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -1837,6 +1837,21 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = { layerMultiply_propfloat2, NULL, layerAdd_propfloat2}, +/* 50: CD_PROP_POOL */ +{sizeof(bool), + "bool", + 1, + N_("Boolean"), + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL}, }; static const char *LAYERTYPENAMES[CD_NUMTYPES] = { @@ -1892,6 +1907,7 @@ static const char *LAYERTYPENAMES[CD_NUMTYPES] = { "CDPropCol", "CDPropFloat3", "CDPropFloat2", +"CDPropBoolean", }; const CustomData_MeshMasks
[Bf-blender-cvs] [2bd0263fbf2] master: Fix T83346: Scrolling doesn't work with mouse over panel header
Commit: 2bd0263fbf2175c672d46c9df9eff7fd3ceecbce Author: Hans Goudey Date: Thu Dec 3 23:37:16 2020 -0600 Branches: master https://developer.blender.org/rB2bd0263fbf2175c672d46c9df9eff7fd3ceecbce Fix T83346: Scrolling doesn't work with mouse over panel header Just a misplaced assignment to the return value from the panel handler in rB600fb28b6295. === M source/blender/editors/interface/interface_panel.c === diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index b60fa40f39a..e96c0a25d6d 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -2452,11 +2452,12 @@ int ui_handler_panel_region(bContext *C, if (mouse_state == PANEL_MOUSE_INSIDE_HEADER) { /* All mouse clicks inside panel headers should return in break. */ - retval = WM_UI_HANDLER_BREAK; if (ELEM(event->type, EVT_RETKEY, EVT_PADENTER, LEFTMOUSE)) { +retval = WM_UI_HANDLER_BREAK; ui_handle_panel_header(C, block, mx, event->type, event->ctrl, event->shift); } else if (event->type == RIGHTMOUSE) { +retval = WM_UI_HANDLER_BREAK; ui_popup_context_menu_for_panel(C, region, block->panel); } break; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [d6354a7ee27] geometry-nodes-point-separate-node: Merge branch 'master' into geometry-nodes-point-separate-node
Commit: d6354a7ee270f328f23026c26b04406fcdf5b189 Author: Hans Goudey Date: Mon Dec 7 11:15:41 2020 -0600 Branches: geometry-nodes-point-separate-node https://developer.blender.org/rBd6354a7ee270f328f23026c26b04406fcdf5b189 Merge branch 'master' into geometry-nodes-point-separate-node === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [e0c199a527e] geometry-nodes-point-separate-node: Review feedback: Only move pointcloud, use numbers for naming
Commit: e0c199a527e7052b294f39bbca6d56c27923abbf Author: Hans Goudey Date: Mon Dec 7 11:56:00 2020 -0600 Branches: geometry-nodes-point-separate-node https://developer.blender.org/rBe0c199a527e7052b294f39bbca6d56c27923abbf Review feedback: Only move pointcloud, use numbers for naming === M source/blender/nodes/geometry/nodes/node_geo_point_separate.cc === diff --git a/source/blender/nodes/geometry/nodes/node_geo_point_separate.cc b/source/blender/nodes/geometry/nodes/node_geo_point_separate.cc index d3cf1fc3a8d..0ec25aae5cd 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_point_separate.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_point_separate.cc @@ -31,8 +31,8 @@ static bNodeSocketTemplate geo_node_point_instance_in[] = { }; static bNodeSocketTemplate geo_node_point_instance_out[] = { -{SOCK_GEOMETRY, N_("Geometry A")}, -{SOCK_GEOMETRY, N_("Geometry B")}, +{SOCK_GEOMETRY, N_("Geometry 1")}, +{SOCK_GEOMETRY, N_("Geometry 2")}, {-1, ""}, }; @@ -158,7 +158,7 @@ static void geo_node_point_separate_exec(GeoNodeExecParams params) { GeometrySet geometry_set = params.extract_input("Geometry"); GeometrySet out_set_a(geometry_set); - GeometrySet out_set_b(geometry_set); + GeometrySet out_set_b; const std::string mask_name = params.extract_input("Mask"); @@ -169,8 +169,8 @@ static void geo_node_point_separate_exec(GeoNodeExecParams params) out_set_b.get_component_for_write()); } - params.set_output("Geometry A", std::move(out_set_a)); - params.set_output("Geometry B", std::move(out_set_b)); + params.set_output("Geometry 1", std::move(out_set_a)); + params.set_output("Geometry 2", std::move(out_set_b)); } } // namespace blender::nodes ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [ae4afcfbee2] geometry-nodes-point-separate-node: Merge branch 'master' into geometry-nodes-point-separate-node
Commit: ae4afcfbee2c55f82ceda1461a264d1f7af31fc1 Author: Hans Goudey Date: Tue Dec 8 11:27:16 2020 -0600 Branches: geometry-nodes-point-separate-node https://developer.blender.org/rBae4afcfbee2c55f82ceda1461a264d1f7af31fc1 Merge branch 'master' into geometry-nodes-point-separate-node === === diff --cc source/blender/makesrna/intern/rna_attribute.c index c8be4344be0,95f6340174a..f98ca47d767 --- a/source/blender/makesrna/intern/rna_attribute.c +++ b/source/blender/makesrna/intern/rna_attribute.c @@@ -38,13 -38,12 +38,13 @@@ #include "WM_types.h" const EnumPropertyItem rna_enum_attribute_type_items[] = { - {CD_PROP_FLOAT, "FLOAT", 0, "Float", "Floating point value"}, - {CD_PROP_INT32, "INT", 0, "Integer", "32 bit integer"}, - {CD_PROP_FLOAT3, "FLOAT_VECTOR", 0, "Vector", "3D vector with floating point values"}, - {CD_PROP_COLOR, "FLOAT_COLOR", 0, "Float Color", "RGBA color with floating point precisions"}, + {CD_PROP_FLOAT, "FLOAT", 0, "Float", "Floating-point value"}, + {CD_PROP_INT32, "INT", 0, "Integer", "32-bit integer"}, + {CD_PROP_FLOAT3, "FLOAT_VECTOR", 0, "Vector", "3D vector with floating-point values"}, + {CD_PROP_COLOR, "FLOAT_COLOR", 0, "Float Color", "RGBA color with floating-point precisions"}, {CD_MLOOPCOL, "BYTE_COLOR", 0, "Byte Color", "RGBA color with 8-bit precision"}, {CD_PROP_STRING, "STRING", 0, "String", "Text string"}, +{CD_PROP_BOOL, "BOOLEAN", 0, "Boolean", "True or false"}, {0, NULL, 0, NULL, NULL}, }; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [268508d2b01] geometry-nodes: Geometry Nodes: Make next modifier active when deleting
Commit: 268508d2b01b9d058d787c4a5c013d3413433bc7 Author: Hans Goudey Date: Tue Nov 24 13:52:20 2020 -0500 Branches: geometry-nodes https://developer.blender.org/rB268508d2b01b9d058d787c4a5c013d3413433bc7 Geometry Nodes: Make next modifier active when deleting Previously it was the previous modifier, but this change keeps the index of the object's active modifier consistent when deleting a modifier. === M source/blender/blenkernel/intern/modifier.c === diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index de820786549..c9bdaecfa2a 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -221,12 +221,12 @@ void BKE_modifier_remove_from_list(Object *ob, ModifierData *md) if (md->flag & eModifierFlag_Active) { /* Prefer the previous modifier but use the next if this modifier is the first in the list. */ -if (md->prev != NULL) { - BKE_object_modifier_set_active(ob, md->prev); -} -else if (md->next != NULL) { +if (md->next != NULL) { BKE_object_modifier_set_active(ob, md->next); } +else if (md->prev != NULL) { + BKE_object_modifier_set_active(ob, md->prev); +} } BLI_remlink(>modifiers, md); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [41a74159c33] geometry-nodes: Geometry Nodes: Fix missing node editor redraw for active modifier
Commit: 41a74159c33c672c47070de9e69b605b9704ecd8 Author: Hans Goudey Date: Tue Nov 24 17:38:53 2020 -0500 Branches: geometry-nodes https://developer.blender.org/rB41a74159c33c672c47070de9e69b605b9704ecd8 Geometry Nodes: Fix missing node editor redraw for active modifier When the active modifier changes, or when its node group changes, the node editor should redraw, because these actions change its context. === M source/blender/editors/space_node/space_node.c === diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c index 5d57c7a385d..afc1a963f4f 100644 --- a/source/blender/editors/space_node/space_node.c +++ b/source/blender/editors/space_node/space_node.c @@ -408,6 +408,14 @@ static void node_area_listener(wmWindow *UNUSED(win), ED_area_tag_refresh(area); } } + else if (ED_node_is_geometry(snode)) { +/* Rather strict check: only redraw when the reference matches the current editor's ID. */ +if (wmn->data == ND_MODIFIER) { + if (wmn->reference == snode->id || snode->id == NULL) { +ED_area_tag_refresh(area); + } +} + } break; case NC_SPACE: if (wmn->data == ND_SPACE_NODE) { ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [8a2b329a21d] geometry-nodes: Geometry Nodes: Always use the active modifier for shortcuts
Commit: 8a2b329a21d6f996ba574d73db074d7d825eee3d Author: Hans Goudey Date: Tue Nov 24 16:57:45 2020 -0500 Branches: geometry-nodes https://developer.blender.org/rB8a2b329a21d6f996ba574d73db074d7d825eee3d Geometry Nodes: Always use the active modifier for shortcuts Based on discussion with the team, summarized in T82691, it makes sense to simplify the shortcut behavior and remove the way the shortcuts currently activate on hover if there is no active modifier. This commit also removes the behavior of clearing the active modifier when you click on blank space in the modifier tab. === M source/blender/editors/object/object_intern.h M source/blender/editors/object/object_modifier.c === diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h index c5783135323..e6ef53a3d65 100644 --- a/source/blender/editors/object/object_intern.h +++ b/source/blender/editors/object/object_intern.h @@ -161,10 +161,6 @@ bool edit_modifier_invoke_properties_with_hover_no_active(struct bContext *C, struct wmOperator *op, const struct wmEvent *event, int *r_retval); -bool edit_modifier_invoke_properties_with_hover(struct bContext *C, -struct wmOperator *op, -const struct wmEvent *event, -int *r_retval); struct ModifierData *edit_modifier_property_get(struct wmOperator *op, struct Object *ob, diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 1a499075d5d..864b3357ea2 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -1131,82 +1131,54 @@ static bool edit_modifier_properties_active(bContext *C, wmOperator *op) return false; } -/** - * Check the custom data of panels under the mouse for a modifier. - */ -static bool edit_modifier_properties_hover(bContext *C, - wmOperator *op, - const wmEvent *event, - int *r_retval) +bool edit_modifier_invoke_properties(bContext *C, wmOperator *op) { - PointerRNA *panel_ptr = UI_region_panel_custom_data_under_cursor(C, event); - - if (!(panel_ptr == NULL || RNA_pointer_is_null(panel_ptr))) { -if (RNA_struct_is_a(panel_ptr->type, _Modifier)) { - ModifierData *md = panel_ptr->data; - RNA_string_set(op->ptr, "modifier", md->name); - return true; -} -BLI_assert(r_retval != NULL); /* We need the return value in this case. */ -if (r_retval != NULL) { - *r_retval = (OPERATOR_PASS_THROUGH | OPERATOR_CANCELLED); -} -return false; + if (edit_modifier_properties_base(C, op)) { +return true; } - - if (r_retval != NULL) { -*r_retval = OPERATOR_CANCELLED; + if (edit_modifier_properties_active(C, op)) { +return true; } return false; } /** + * Run the regular invoke properties, then also check the custom data + * of panels under the mouse for a modifier. + * * \param event: If this isn't NULL, the operator will also look for panels underneath * the cursor with customdata set to a modifier. * \param r_retval: This should be used if #event is used in order to to return * #OPERATOR_PASS_THROUGH to check other operators with the same key set. */ -bool edit_modifier_invoke_properties(bContext *C, wmOperator *op) -{ - if (edit_modifier_properties_base(C, op)) { -return true; - } - if (edit_modifier_properties_active(C, op)) { -return true; - } - - return false; -} - bool edit_modifier_invoke_properties_with_hover_no_active(bContext *C, wmOperator *op, const wmEvent *event, int *r_retval) { + if (edit_modifier_properties_base(C, op)) { return true; } - if (edit_modifier_properties_hover(C, op, event, r_retval)) { -return true; - } - return false; -} + PointerRNA *panel_ptr = UI_region_panel_custom_data_under_cursor(C, event); -bool edit_modifier_invoke_properties_with_hover(bContext *C, -wmOperator *op, -const wmEvent *event, -int *r_retval) -{ - if (edit_modifier_properties_base(C, op)) { -return true; - } - if (edit_modifier_p
[Bf-blender-cvs] [52c6d36e4e8] geometry-nodes: Geometry Nodes: Initial implementation for attribute math node
Commit: 52c6d36e4e8c034f194291c7e398084134feb26c Author: Hans Goudey Date: Mon Nov 23 17:01:53 2020 -0500 Branches: geometry-nodes https://developer.blender.org/rB52c6d36e4e8c034f194291c7e398084134feb26c Geometry Nodes: Initial implementation for attribute math node This provide a simple implementation for basic math operations. Add, subtract, multiple, and divide are implemented so far. Domain interpolation is not implemented yet either. This commit also adds two "Type" options to the node for choosing explicitly whether to use an attribute or a float value as one of the inputs. It is not possible to use two floats as inputs, because that would be a regular math node. Some cleanup to avoid some code duplication will come in a future commit. === M source/blender/editors/space_node/drawnode.c M source/blender/makesdna/DNA_node_types.h M source/blender/makesrna/intern/rna_nodetree.c M source/blender/nodes/geometry/nodes/node_geo_attribute_math.cc === diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 56bbe8c8988..cb1dcf96bfb 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -3176,6 +3176,8 @@ static void node_geometry_buts_attribute_math(uiLayout *layout, PointerRNA *ptr) { uiItemR(layout, ptr, "operation", DEFAULT_FLAGS, "", ICON_NONE); + uiItemR(layout, ptr, "input_type_a", DEFAULT_FLAGS, IFACE_("Type A"), ICON_NONE); + uiItemR(layout, ptr, "input_type_b", DEFAULT_FLAGS, IFACE_("Type B"), ICON_NONE); } static void node_geometry_set_butfunc(bNodeType *ntype) diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h index 6de72fd996e..29c83d2d4ed 100644 --- a/source/blender/makesdna/DNA_node_types.h +++ b/source/blender/makesdna/DNA_node_types.h @@ -1459,6 +1459,11 @@ typedef enum GeometryNodeTriangulateQuads { GEO_NODE_TRIANGULATE_QUAD_SHORTEDGE = 3, } GeometryNodeTriangulateQuads; +typedef enum GeometryNodeUseAttributeFlag { + GEO_NODE_USE_ATTRIBUTE_A = (1 << 0), + GEO_NODE_USE_ATTRIBUTE_B = (1 << 1), +} GeometryNodeUseAttributeFlag; + #ifdef __cplusplus } #endif diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index ea0fc4b5567..6795426a6d2 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -423,6 +423,18 @@ static const EnumPropertyItem rna_node_geometry_triangulate_ngon_method_items[] {0, NULL, 0, NULL, NULL}, }; +static const EnumPropertyItem rna_node_geometry_attribute_input_a_items[] = { +{0, "FLOAT", 0, "Float", ""}, +{GEO_NODE_USE_ATTRIBUTE_A, "ATTRIBUTE", 0, "Attribute", ""}, +{0, NULL, 0, NULL, NULL}, +}; + +static const EnumPropertyItem rna_node_geometry_attribute_input_b_items[] = { +{0, "FLOAT", 0, "Float", ""}, +{GEO_NODE_USE_ATTRIBUTE_B, "ATTRIBUTE", 0, "Attribute", ""}, +{0, NULL, 0, NULL, NULL}, +}; + #endif #ifdef RNA_RUNTIME @@ -3837,7 +3849,7 @@ static void rna_ShaderNode_socket_update(Main *bmain, Scene *scene, PointerRNA * rna_Node_update(bmain, scene, ptr); } -static void rna_FunctionNode_socket_update(Main *bmain, Scene *scene, PointerRNA *ptr) +static void rna_Node_socket_update(Main *bmain, Scene *scene, PointerRNA *ptr) { bNodeTree *ntree = (bNodeTree *)ptr->owner_id; bNode *node = (bNode *)ptr->data; @@ -4298,7 +4310,7 @@ static void def_boolean_math(StructRNA *srna) RNA_def_property_enum_sdna(prop, NULL, "custom1"); RNA_def_property_enum_items(prop, rna_enum_node_boolean_math_items); RNA_def_property_ui_text(prop, "Operation", ""); - RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_FunctionNode_socket_update"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_socket_update"); } static void def_float_compare(StructRNA *srna) @@ -4309,7 +4321,7 @@ static void def_float_compare(StructRNA *srna) RNA_def_property_enum_sdna(prop, NULL, "custom1"); RNA_def_property_enum_items(prop, rna_enum_node_float_compare_items); RNA_def_property_ui_text(prop, "Operation", ""); - RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_FunctionNode_socket_update"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_socket_update"); } static void def_fn_switch(StructRNA *srna) @@ -4320,7 +4332,7 @@ static void def_fn_switch(StructRNA *srna) RNA_def_property_enum_sdn
[Bf-blender-cvs] [e68e8970772] geometry-nodes: Cleanup: Correct node name in definition function
Commit: e68e89707729aa92911097a97e16654b3f424d29 Author: Hans Goudey Date: Mon Nov 23 18:32:36 2020 -0500 Branches: geometry-nodes https://developer.blender.org/rBe68e89707729aa92911097a97e16654b3f424d29 Cleanup: Correct node name in definition function === M source/blender/nodes/function/nodes/node_fn_float_compare.cc === diff --git a/source/blender/nodes/function/nodes/node_fn_float_compare.cc b/source/blender/nodes/function/nodes/node_fn_float_compare.cc index f8bd9a30940..3d4006b5953 100644 --- a/source/blender/nodes/function/nodes/node_fn_float_compare.cc +++ b/source/blender/nodes/function/nodes/node_fn_float_compare.cc @@ -100,7 +100,7 @@ void register_node_type_fn_float_compare() { static bNodeType ntype; - fn_node_type_base(, FN_NODE_FLOAT_COMPARE, "Boolean Math", 0, 0); + fn_node_type_base(, FN_NODE_FLOAT_COMPARE, "Float Compare", 0, 0); node_type_socket_templates(, fn_node_float_compare_in, fn_node_float_compare_out); node_type_label(, node_float_compare_label); node_type_update(, node_float_compare_update); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [043926bfd28] geometry-nodes-point-separate-node: Merge branch 'master' into geometry-nodes-point-separate-node
Commit: 043926bfd2867782be99e6ee9c77e4ae1aedec7b Author: Hans Goudey Date: Wed Dec 9 08:35:24 2020 -0600 Branches: geometry-nodes-point-separate-node https://developer.blender.org/rB043926bfd2867782be99e6ee9c77e4ae1aedec7b Merge branch 'master' into geometry-nodes-point-separate-node === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [81fb9720fef] geometry-nodes-point-separate-node: Support meshes in addition to point clouds
Commit: 81fb9720fef7f2c09580e73ea9ca61b280207d98 Author: Hans Goudey Date: Wed Dec 9 09:43:32 2020 -0600 Branches: geometry-nodes-point-separate-node https://developer.blender.org/rB81fb9720fef7f2c09580e73ea9ca61b280207d98 Support meshes in addition to point clouds === M source/blender/nodes/geometry/nodes/node_geo_point_separate.cc === diff --git a/source/blender/nodes/geometry/nodes/node_geo_point_separate.cc b/source/blender/nodes/geometry/nodes/node_geo_point_separate.cc index 0ec25aae5cd..d29dfe3eb40 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_point_separate.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_point_separate.cc @@ -62,11 +62,10 @@ static void fill_new_attribute_from_input(ReadAttributePtr input_attribute, /** * Move the original attribute values to the two output components. * - * \note This assumes a consistent ordering of indices before and after the split. - * This is trivial for simple components like point clouds, but for meshes a map between - * input and output indices might be necessary. + * \note This assumes a consistent ordering of indices before and after the split, + * which is true for points and a simple vertex array. */ -static void move_split_attributes(const PointCloudComponent _component, +static void move_split_attributes(const GeometryComponent _component, GeometryComponent _component_a, GeometryComponent _component_b, Span a_or_b) @@ -77,6 +76,11 @@ static void move_split_attributes(const PointCloudComponent _component, ReadAttributePtr attribute = in_component.attribute_try_get_for_read(name); BLI_assert(attribute); +/* Since this node only creates points and vertices, don't copy other attributes. */ +if (attribute->domain() != ATTR_DOMAIN_POINT) { + continue; +} + const CustomDataType data_type = bke::cpp_type_to_custom_data_type(attribute->cpp_type()); const AttributeDomain domain = attribute->domain(); @@ -112,10 +116,10 @@ static void move_split_attributes(const PointCloudComponent _component, /** * Find total in each new set and find which of the output sets each point will belong to. */ -static Array split_point_cloud_component(const GeometryComponent , - const std::string mask_name, - int *r_a_total, - int *r_b_total) +static Array count_point_splits(const GeometryComponent , + const std::string mask_name, + int *r_a_total, + int *r_b_total) { const BooleanReadAttribute mask_attribute = component.attribute_get_for_read( mask_name, ATTR_DOMAIN_POINT, false); @@ -123,7 +127,7 @@ static Array split_point_cloud_component(const GeometryComponent const int in_total = masks.size(); *r_b_total = 0; - for (bool mask : masks) { + for (const bool mask : masks) { if (mask) { *r_b_total += 1; } @@ -133,6 +137,26 @@ static Array split_point_cloud_component(const GeometryComponent return masks; } +static void separate_mesh(const MeshComponent _component, + const std::string mask_name, + MeshComponent _component_a, + MeshComponent _component_b) +{ + const int size = in_component.attribute_domain_size(ATTR_DOMAIN_POINT); + if (size == 0) { +return; + } + + int a_total; + int b_total; + Array a_or_b = count_point_splits(in_component, mask_name, _total, _total); + + out_component_a.replace(BKE_mesh_new_nomain(a_total, 0, 0, 0, 0)); + out_component_b.replace(BKE_mesh_new_nomain(b_total, 0, 0, 0, 0)); + + move_split_attributes(in_component, out_component_a, out_component_b, a_or_b.as_span()); +} + static void separate_point_cloud(const PointCloudComponent _component, const std::string mask_name, PointCloudComponent _component_a, @@ -145,9 +169,8 @@ static void separate_point_cloud(const PointCloudComponent _component, int a_total; int b_total; - Array a_or_b = split_point_cloud_component(in_component, mask_name, _total, _total); + Array a_or_b = count_point_splits(in_component, mask_name, _total, _total); - /* Start fresh with new components. */ out_component_a.replace(BKE_pointcloud_new_nomain(a_total)); out_component_b.replace(BKE_pointcloud_new_nomain(b_total)); @@ -168,6 +191,12 @@ static void geo_node_point_separate_exec(GeoNodeExecParams params) out_set_a.get_component_for_write(), out_set_b.get_component_
[Bf-blender-cvs] [96feddd85f0] geometry-nodes-point-separate-node: Use text for comparison RNA enum items
Commit: 96feddd85f02c4996f3a4193e456f1d9c4d846ec Author: Hans Goudey Date: Wed Dec 9 09:00:24 2020 -0600 Branches: geometry-nodes-point-separate-node https://developer.blender.org/rB96feddd85f02c4996f3a4193e456f1d9c4d846ec Use text for comparison RNA enum items === M source/blender/makesrna/intern/rna_nodetree.c === diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index ff238e959eb..96562805368 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -272,32 +272,32 @@ const EnumPropertyItem rna_enum_node_float_compare_items[] = { {NODE_FLOAT_COMPARE_LESS_THAN, "LESS_THAN", 0, - "A < B", + "Less Than", "True when the first input is smaller than second input"}, {NODE_FLOAT_COMPARE_LESS_EQUAL, "LESS_EQUAL", 0, - "A <= B", + "Less Than or Equal", "True when the first input is smaller than the second input or equal"}, {NODE_FLOAT_COMPARE_GREATER_THAN, "GREATER_THAN", 0, - "A > B", + "Greater Than", "True when the first input is greater than the second input"}, {NODE_FLOAT_COMPARE_GREATER_EQUAL, "GREATER_EQUAL", 0, - "A >= B", + "Greater Than or Equal", "True when the first input is greater than the second input or equal"}, {NODE_FLOAT_COMPARE_EQUAL, "EQUAL", 0, - "A = B", + "Equal", "True when both inputs are approximately equal"}, {NODE_FLOAT_COMPARE_NOT_EQUAL, "NOT_EQUAL", 0, - "A != B", + "Not Equal", "True when both inputs are not approximately equal"}, {0, NULL, 0, NULL, NULL}, }; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [200cbb6adfc] geometry-nodes-point-separate-node: Geometry Nodes: Add utilities for getting an attribute's data type
Commit: 200cbb6adfca8f5fe55ff73650882cc0026da27b Author: Hans Goudey Date: Wed Dec 9 16:29:49 2020 -0600 Branches: geometry-nodes-point-separate-node https://developer.blender.org/rB200cbb6adfca8f5fe55ff73650882cc0026da27b Geometry Nodes: Add utilities for getting an attribute's data type With the previous helper function in this file you had to know the data type you wanted for the input attribute before requesting it. This adds another utility function for getting the data type without building the attribute. The attribute's can be requested later after doing some logic to figure out the right data type to read. No functional changes in this commit. === M source/blender/nodes/NOD_geometry_exec.hh M source/blender/nodes/intern/node_geometry_exec.cc === diff --git a/source/blender/nodes/NOD_geometry_exec.hh b/source/blender/nodes/NOD_geometry_exec.hh index a9c208bbc93..805f843c162 100644 --- a/source/blender/nodes/NOD_geometry_exec.hh +++ b/source/blender/nodes/NOD_geometry_exec.hh @@ -170,10 +170,21 @@ class GeoNodeExecParams { return this->get_input_attribute(name, component, domain, type, _value); } + /** + * Get the type of an input property or the associated constant socket types. + * Fall back to the default value if no attribute exists with the name. + */ + CustomDataType get_input_attribute_data_type(const StringRef name, + const GeometryComponent , + const CustomDataType default_type) const; + private: /* Utilities for detecting common errors at when using this class. */ void check_extract_input(StringRef identifier, const CPPType *requested_type = nullptr) const; void check_set_output(StringRef identifier, const CPPType _type) const; + + /* Finds a socket with the name (not identifier) that is currently active. */ + const bNodeSocket *find_available_socket(const StringRef name) const; }; } // namespace blender::nodes diff --git a/source/blender/nodes/intern/node_geometry_exec.cc b/source/blender/nodes/intern/node_geometry_exec.cc index a6d9115f01f..eef2c6c9125 100644 --- a/source/blender/nodes/intern/node_geometry_exec.cc +++ b/source/blender/nodes/intern/node_geometry_exec.cc @@ -19,23 +19,31 @@ namespace blender::nodes { -ReadAttributePtr GeoNodeExecParams::get_input_attribute(const StringRef name, -const GeometryComponent , -const AttributeDomain domain, -const CustomDataType type, -const void *default_value) const +const bNodeSocket *GeoNodeExecParams::find_available_socket(const StringRef name) const { - const bNodeSocket *found_socket = nullptr; LISTBASE_FOREACH (const bNodeSocket *, socket, _.inputs) { if ((socket->flag & SOCK_UNAVAIL) != 0) { continue; } if (name == socket->name) { - found_socket = socket; - break; + return socket; } } - BLI_assert(found_socket != nullptr); + + return nullptr; +} + +ReadAttributePtr GeoNodeExecParams::get_input_attribute(const StringRef name, +const GeometryComponent , +const AttributeDomain domain, +const CustomDataType type, +const void *default_value) const +{ + const bNodeSocket *found_socket = this->find_available_socket(name); + BLI_assert(found_socket != nullptr); /* There should always be available socket for the name. */ + if (found_socket == nullptr) { +return component.attribute_get_constant_for_read(domain, type, default_value); + } if (found_socket->type == SOCK_STRING) { const std::string name = this->get_input(found_socket->identifier); @@ -60,6 +68,42 @@ ReadAttributePtr GeoNodeExecParams::get_input_attribute(const StringRef name, return component.attribute_get_constant_for_read(domain, type, default_value); } +CustomDataType GeoNodeExecParams::get_input_attribute_data_type( +const StringRef name, +const GeometryComponent , +const CustomDataType default_type) const +{ + const bNodeSocket *found_socket = this->find_available_socket(name); + BLI_assert(found_socket != nullptr); /* There should always be available socket for the name. */ + if (found_socket == nullptr) { +return default_type; + } + + if (found_socket->type == SOCK_STRING) { +const std::string name = this->get_input(found_socket->identifier); +ReadAttributePtr attribute = component.attribute_try_ge
[Bf-blender-cvs] [62953c2bf39] geometry-nodes-point-separate-node: Geometry Nodes: Support equality operations with all data types
Commit: 62953c2bf39252fc59d0365b9a33453e179b66c0 Author: Hans Goudey Date: Wed Dec 9 16:42:23 2020 -0600 Branches: geometry-nodes-point-separate-node https://developer.blender.org/rB62953c2bf39252fc59d0365b9a33453e179b66c0 Geometry Nodes: Support equality operations with all data types Testing equality of vectors can't be done properly if they are implicitly converted to float before-hand. This adds a lot of boilerplate code to the node, maybe that can made more elegant in the future, but it's not so complicated anyway. === M source/blender/makesdna/DNA_node_types.h M source/blender/makesrna/intern/rna_nodetree.c M source/blender/nodes/NOD_math_functions.hh M source/blender/nodes/geometry/nodes/node_geo_attribute_compare.cc === diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h index 13f8b11352a..a9e94ee9b0f 100644 --- a/source/blender/makesdna/DNA_node_types.h +++ b/source/blender/makesdna/DNA_node_types.h @@ -1059,6 +1059,17 @@ typedef struct NodeDenoise { char _pad[7]; } NodeDenoise; +typedef struct NodeAttributeCompare { + /* e.g. NODE_FLOAT_COMPARE_LESS_THAN. */ + uint8_t operation; + + /* GeometryNodeAttributeInputMode */ + uint8_t input_type_a; + uint8_t input_type_b; + + char _pad[5]; +} NodeAttributeCompare; + /* script node mode */ #define NODE_SCRIPT_INTERNAL 0 #define NODE_SCRIPT_EXTERNAL 1 @@ -1336,14 +1347,14 @@ enum { }; /* Float compare node operations. */ -enum { +typedef enum FloatCompareOperation { NODE_FLOAT_COMPARE_LESS_THAN = 0, NODE_FLOAT_COMPARE_LESS_EQUAL = 1, NODE_FLOAT_COMPARE_GREATER_THAN = 2, NODE_FLOAT_COMPARE_GREATER_EQUAL = 3, NODE_FLOAT_COMPARE_EQUAL = 4, NODE_FLOAT_COMPARE_NOT_EQUAL = 5, -}; +} FloatCompareOperation; /* Clamp node types. */ enum { @@ -1469,6 +1480,7 @@ typedef enum GeometryNodeAttributeInputMode { GEO_NODE_ATTRIBUTE_INPUT_FLOAT = 1, GEO_NODE_ATTRIBUTE_INPUT_VECTOR = 2, GEO_NODE_ATTRIBUTE_INPUT_COLOR = 3, + GEO_NODE_ATTRIBUTE_INPUT_BOOLEAN = 4, } GeometryNodeAttributeInputMode; #ifdef __cplusplus diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 96562805368..9cf11f1197d 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -435,6 +435,14 @@ static const EnumPropertyItem rna_node_geometry_attribute_input_b_items[] = { {0, NULL, 0, NULL, NULL}, }; +static const EnumPropertyItem rna_node_geometry_attribute_input_type_items[] = { +{GEO_NODE_ATTRIBUTE_INPUT_ATTRIBUTE, "ATTRIBUTE", 0, "Attribute", ""}, +{GEO_NODE_ATTRIBUTE_INPUT_FLOAT, "FLOAT", 0, "Float", ""}, +{GEO_NODE_ATTRIBUTE_INPUT_VECTOR, "VECTOR", 0, "Vector", ""}, +{GEO_NODE_ATTRIBUTE_INPUT_COLOR, "COLOR", 0, "Color", ""}, +{GEO_NODE_ATTRIBUTE_INPUT_BOOLEAN, "BOOLEAN", 0, "Boolean", ""}, +{0, NULL, 0, NULL, NULL}, +}; #endif #ifdef RNA_RUNTIME @@ -8372,22 +8380,21 @@ static void def_geo_attribute_attribute_compare(StructRNA *srna) { PropertyRNA *prop; + RNA_def_struct_sdna_from(srna, "NodeAttributeCompare", "storage"); + prop = RNA_def_property(srna, "operation", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "custom1"); RNA_def_property_enum_items(prop, rna_enum_node_float_compare_items); RNA_def_property_enum_default(prop, NODE_MATH_ADD); RNA_def_property_ui_text(prop, "Operation", ""); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_socket_update"); prop = RNA_def_property(srna, "input_type_a", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_bitflag_sdna(prop, NULL, "custom2"); - RNA_def_property_enum_items(prop, rna_node_geometry_attribute_input_a_items); + RNA_def_property_enum_items(prop, rna_node_geometry_attribute_input_type_items); RNA_def_property_ui_text(prop, "Input Type A", ""); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_socket_update"); prop = RNA_def_property(srna, "input_type_b", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_bitflag_sdna(prop, NULL, "custom2"); - RNA_def_property_enum_items(prop, rna_node_geometry_attribute_input_b_items); + RNA_def_property_enum_items(prop, rna_node_geometry_attribute_input_type_items); RNA_def_property_ui_text(prop, "Input Type B", ""); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_socket_update"); } diff --git a/source/blender/nodes/NOD_math_functions.hh b/source/blender/nodes/NOD_math_functions.hh index
[Bf-blender-cvs] [c61c9f61c6d] geometry-nodes-point-separate-node: Use new get_input_attribute abstraction
Commit: c61c9f61c6dd692d3cdd44e059d8e43aaedfaae8 Author: Hans Goudey Date: Wed Dec 9 10:29:29 2020 -0600 Branches: geometry-nodes-point-separate-node https://developer.blender.org/rBc61c9f61c6dd692d3cdd44e059d8e43aaedfaae8 Use new get_input_attribute abstraction === M source/blender/nodes/geometry/nodes/node_geo_point_separate.cc === diff --git a/source/blender/nodes/geometry/nodes/node_geo_point_separate.cc b/source/blender/nodes/geometry/nodes/node_geo_point_separate.cc index d29dfe3eb40..088bb387316 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_point_separate.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_point_separate.cc @@ -117,12 +117,12 @@ static void move_split_attributes(const GeometryComponent _component, * Find total in each new set and find which of the output sets each point will belong to. */ static Array count_point_splits(const GeometryComponent , - const std::string mask_name, + const GeoNodeExecParams , int *r_a_total, int *r_b_total) { - const BooleanReadAttribute mask_attribute = component.attribute_get_for_read( - mask_name, ATTR_DOMAIN_POINT, false); + const BooleanReadAttribute mask_attribute = params.get_input_attribute( + "Mask", component, ATTR_DOMAIN_POINT, false); Array masks = mask_attribute.get_span(); const int in_total = masks.size(); @@ -138,7 +138,7 @@ static Array count_point_splits(const GeometryComponent , } static void separate_mesh(const MeshComponent _component, - const std::string mask_name, + const GeoNodeExecParams , MeshComponent _component_a, MeshComponent _component_b) { @@ -149,7 +149,7 @@ static void separate_mesh(const MeshComponent _component, int a_total; int b_total; - Array a_or_b = count_point_splits(in_component, mask_name, _total, _total); + Array a_or_b = count_point_splits(in_component, params, _total, _total); out_component_a.replace(BKE_mesh_new_nomain(a_total, 0, 0, 0, 0)); out_component_b.replace(BKE_mesh_new_nomain(b_total, 0, 0, 0, 0)); @@ -158,7 +158,7 @@ static void separate_mesh(const MeshComponent _component, } static void separate_point_cloud(const PointCloudComponent _component, - const std::string mask_name, + const GeoNodeExecParams , PointCloudComponent _component_a, PointCloudComponent _component_b) { @@ -169,7 +169,7 @@ static void separate_point_cloud(const PointCloudComponent _component, int a_total; int b_total; - Array a_or_b = count_point_splits(in_component, mask_name, _total, _total); + Array a_or_b = count_point_splits(in_component, params, _total, _total); out_component_a.replace(BKE_pointcloud_new_nomain(a_total)); out_component_b.replace(BKE_pointcloud_new_nomain(b_total)); @@ -183,17 +183,15 @@ static void geo_node_point_separate_exec(GeoNodeExecParams params) GeometrySet out_set_a(geometry_set); GeometrySet out_set_b; - const std::string mask_name = params.extract_input("Mask"); - if (geometry_set.has()) { separate_point_cloud(*geometry_set.get_component_for_read(), - mask_name, + params, out_set_a.get_component_for_write(), out_set_b.get_component_for_write()); } if (geometry_set.has()) { separate_mesh(*geometry_set.get_component_for_read(), - mask_name, + params, out_set_a.get_component_for_write(), out_set_b.get_component_for_write()); } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [9acba6f716f] geometry-nodes-point-separate-node: Merge branch 'master' into geometry-nodes-point-separate-node
Commit: 9acba6f716fabd8d41d158ee18ddae21fab80e16 Author: Hans Goudey Date: Wed Dec 9 09:53:17 2020 -0600 Branches: geometry-nodes-point-separate-node https://developer.blender.org/rB9acba6f716fabd8d41d158ee18ddae21fab80e16 Merge branch 'master' into geometry-nodes-point-separate-node === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [0e757da3b54] geometry-nodes-point-separate-node: Geometry Nodes: Add a method to find the lowest complexity attribute
Commit: 0e757da3b548543ac938620d4defe177348220bd Author: Hans Goudey Date: Wed Dec 9 16:33:09 2020 -0600 Branches: geometry-nodes-point-separate-node https://developer.blender.org/rB0e757da3b548543ac938620d4defe177348220bd Geometry Nodes: Add a method to find the lowest complexity attribute For the attribute comparison node, it makes sense to read both input attributes implicitly converted to the same data type. But the choice of which of the two data types to read with is somewhat arbitrary. This commit adds a utility function to choose the least "complex" data type as a lowest common denominator, to make that choice less arbitrary , and to support other needs in the future. === M source/blender/nodes/geometry/node_geometry_util.cc M source/blender/nodes/geometry/node_geometry_util.hh === diff --git a/source/blender/nodes/geometry/node_geometry_util.cc b/source/blender/nodes/geometry/node_geometry_util.cc index 34c7d224f03..f9ded0e1995 100644 --- a/source/blender/nodes/geometry/node_geometry_util.cc +++ b/source/blender/nodes/geometry/node_geometry_util.cc @@ -36,6 +36,48 @@ void update_attribute_input_socket_availabilities(bNode , } } +static int attribute_data_type_complexity(const CustomDataType data_type) +{ + switch (data_type) { +case CD_PROP_BOOL: + return 0; +case CD_PROP_FLOAT: + return 2; +case CD_PROP_FLOAT3: + return 4; +case CD_PROP_COLOR: + return 5; +#if 0 /* Attribute types are not supported yet. */ +case CD_PROP_INT32: + return 1; +case CD_MLOOPCOL: + return 3; +case CD_PROP_STRING: + return 6; +#endif +default: + /* Only accept "generic" custom data types used by the attribute system. */ + BLI_assert(false); + return 0; + } +} + +CustomDataType attribute_domain_lowest_complexity(Span data_types) +{ + int lowest_complexity = INT_MAX; + CustomDataType least_complex_type = CD_PROP_BOOL; + + for (const CustomDataType data_type : data_types) { +const int complexity = attribute_data_type_complexity(data_type); +if (complexity < lowest_complexity) { + lowest_complexity = complexity; + least_complex_type = data_type; +} + } + + return least_complex_type; +} + } // namespace blender::nodes bool geo_node_poll_default(bNodeType *UNUSED(ntype), bNodeTree *ntree) diff --git a/source/blender/nodes/geometry/node_geometry_util.hh b/source/blender/nodes/geometry/node_geometry_util.hh index ec389961615..b8728016230 100644 --- a/source/blender/nodes/geometry/node_geometry_util.hh +++ b/source/blender/nodes/geometry/node_geometry_util.hh @@ -42,4 +42,7 @@ namespace blender::nodes { void update_attribute_input_socket_availabilities(bNode , const StringRef name, const GeometryNodeAttributeInputMode mode); -} + +CustomDataType attribute_domain_lowest_complexity(Span); + +} // namespace blender::nodes \ 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] [4bdb67d5c0d] geometry-nodes-point-separate-node: Merge branch 'master' into geometry-nodes-point-separate-node
Commit: 4bdb67d5c0d4d88646f617e2f8f3be766edfad9f Author: Hans Goudey Date: Thu Dec 10 08:55:44 2020 -0600 Branches: geometry-nodes-point-separate-node https://developer.blender.org/rB4bdb67d5c0d4d88646f617e2f8f3be766edfad9f Merge branch 'master' into geometry-nodes-point-separate-node === === diff --cc release/scripts/startup/nodeitems_builtins.py index e624b4e5d1b,df98645aee0..85f0f035a9c --- a/release/scripts/startup/nodeitems_builtins.py +++ b/release/scripts/startup/nodeitems_builtins.py @@@ -483,7 -483,7 +483,8 @@@ geometry_node_categories = GeometryNodeCategory("GEO_ATTRIBUTE", "Attribute", items=[ NodeItem("GeometryNodeRandomAttribute"), NodeItem("GeometryNodeAttributeMath"), +NodeItem("GeometryNodeAttributeCompare"), + NodeItem("GeometryNodeAttributeFill"), ]), GeometryNodeCategory("GEO_COLOR", "Color", items=[ NodeItem("ShaderNodeValToRGB"), diff --cc source/blender/blenkernel/BKE_node.h index 9f15b7f5d62,56ed60c1f67..84ceed49674 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@@ -1350,8 -1350,7 +1350,9 @@@ int ntreeTexExecTree(struct bNodeTree * #define GEO_NODE_RANDOM_ATTRIBUTE 1008 #define GEO_NODE_ATTRIBUTE_MATH 1009 #define GEO_NODE_JOIN_GEOMETRY 1010 - #define GEO_NODE_POINT_SEPARATE 1011 - #define GEO_NODE_ATTRIBUTE_COMPARE 1012 + #define GEO_NODE_ATTRIBUTE_FILL 1011 ++#define GEO_NODE_POINT_SEPARATE 1012 ++#define GEO_NODE_ATTRIBUTE_COMPARE 1013 /** \} */ diff --cc source/blender/editors/space_node/drawnode.c index 2f84bc668e6,2ff32a4a82e..606583922f8 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@@ -3209,9 -3208,9 +3217,12 @@@ static void node_geometry_set_butfunc(b case GEO_NODE_ATTRIBUTE_MATH: ntype->draw_buttons = node_geometry_buts_attribute_math; break; +case GEO_NODE_ATTRIBUTE_COMPARE: + ntype->draw_buttons = node_geometry_buts_attribute_compare; + break; + case GEO_NODE_ATTRIBUTE_FILL: + ntype->draw_buttons = node_geometry_buts_attribute_fill; + break; } } diff --cc source/blender/nodes/CMakeLists.txt index af34e1ec786,d09b1a8534d..3b2987d8fa8 --- a/source/blender/nodes/CMakeLists.txt +++ b/source/blender/nodes/CMakeLists.txt @@@ -138,7 -138,7 +138,8 @@@ set(SR function/nodes/node_fn_switch.cc function/node_function_util.cc + geometry/nodes/node_geo_attribute_compare.cc + geometry/nodes/node_geo_attribute_fill.cc geometry/nodes/node_geo_attribute_math.cc geometry/nodes/node_geo_common.cc geometry/nodes/node_geo_boolean.cc diff --cc source/blender/nodes/NOD_static_types.h index 982fe2bf05a,8ca978d1339..90a5ddc54dc --- a/source/blender/nodes/NOD_static_types.h +++ b/source/blender/nodes/NOD_static_types.h @@@ -277,8 -277,7 +277,9 @@@ DefNode(GeometryNode, GEO_NODE_OBJECT_I DefNode(GeometryNode, GEO_NODE_RANDOM_ATTRIBUTE, def_geo_random_attribute, "RANDOM_ATTRIBUTE", RandomAttribute, "Random Attribute", "") DefNode(GeometryNode, GEO_NODE_ATTRIBUTE_MATH, def_geo_attribute_math, "ATTRIBUTE_MATH", AttributeMath, "Attribute Math", "") DefNode(GeometryNode, GEO_NODE_JOIN_GEOMETRY, 0, "JOIN_GEOMETRY", JoinGeometry, "Join Geometry", "") + DefNode(GeometryNode, GEO_NODE_ATTRIBUTE_FILL, def_geo_attribute_fill, "ATTRIBUTE_FILL", AttributeFill, "Attribute Fill", "") +DefNode(GeometryNode, GEO_NODE_POINT_SEPARATE, 0, "POINT_SEPARATE", PointSeparate, "Point Separate", "") +DefNode(GeometryNode, GEO_NODE_ATTRIBUTE_COMPARE, def_geo_attribute_attribute_compare, "ATTRIBUTE_COMPARE", AttributeCompare, "Attribute Compare", "") /* undefine macros */ #undef DefNode ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [98b1e09d064] geometry-nodes-point-separate-node: Optimize comparisons by squaring threshold first
Commit: 98b1e09d06440deb8c83f966e0c10b87591584b2 Author: Hans Goudey Date: Thu Dec 10 09:09:44 2020 -0600 Branches: geometry-nodes-point-separate-node https://developer.blender.org/rB98b1e09d06440deb8c83f966e0c10b87591584b2 Optimize comparisons by squaring threshold first === M source/blender/nodes/geometry/nodes/node_geo_attribute_compare.cc === diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_compare.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_compare.cc index dc1fe858b07..7ec27bc85d6 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_compare.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_compare.cc @@ -121,11 +121,12 @@ static void do_equal_operation(const Float3ReadAttribute _a, const float threshold, MutableSpan span_result) { + const float threshold_squared = pow2f(threshold); const int size = input_a.size(); for (const int i : IndexRange(size)) { const float3 a = input_a[i]; const float3 b = input_b[i]; -span_result[i] = len_v3v3(a, b) < threshold; +span_result[i] = len_squared_v3v3(a, b) < threshold_squared; } } @@ -134,11 +135,12 @@ static void do_equal_operation(const Color4fReadAttribute _a, const float threshold, MutableSpan span_result) { + const float threshold_squared = pow2f(threshold); const int size = input_a.size(); for (const int i : IndexRange(size)) { const Color4f a = input_a[i]; const Color4f b = input_b[i]; -span_result[i] = sqrtf(len_squared_v4v4(a, b)) < threshold; +span_result[i] = len_squared_v4v4(a, b) < threshold_squared; } } @@ -173,12 +175,12 @@ static void do_not_equal_operation(const Float3ReadAttribute _a, const float threshold, MutableSpan span_result) { + const float threshold_squared = pow2f(threshold); const int size = input_a.size(); for (const int i : IndexRange(size)) { const float3 a = input_a[i]; const float3 b = input_b[i]; - -span_result[i] = len_v3v3(a, b) >= threshold; +span_result[i] = len_squared_v3v3(a, b) >= threshold_squared; } } @@ -187,11 +189,12 @@ static void do_not_equal_operation(const Color4fReadAttribute _a, const float threshold, MutableSpan span_result) { + const float threshold_squared = pow2f(threshold); const int size = input_a.size(); for (const int i : IndexRange(size)) { const Color4f a = input_a[i]; const Color4f b = input_b[i]; -span_result[i] = sqrtf(len_squared_v4v4(a, b)) >= threshold; +span_result[i] = len_squared_v4v4(a, b) >= threshold_squared; } } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [abd2ee4a8d8] geometry-nodes-point-separate-node: Attribute Compare: Use the most complex data type instead of the least
Commit: abd2ee4a8d80d74d59604be7e11b507389f0778f Author: Hans Goudey Date: Thu Dec 10 09:31:42 2020 -0600 Branches: geometry-nodes-point-separate-node https://developer.blender.org/rBabd2ee4a8d80d74d59604be7e11b507389f0778f Attribute Compare: Use the most complex data type instead of the least === M source/blender/nodes/geometry/node_geometry_util.cc M source/blender/nodes/geometry/node_geometry_util.hh M source/blender/nodes/geometry/nodes/node_geo_attribute_compare.cc === diff --git a/source/blender/nodes/geometry/node_geometry_util.cc b/source/blender/nodes/geometry/node_geometry_util.cc index f9ded0e1995..6dccfa300d1 100644 --- a/source/blender/nodes/geometry/node_geometry_util.cc +++ b/source/blender/nodes/geometry/node_geometry_util.cc @@ -62,20 +62,20 @@ static int attribute_data_type_complexity(const CustomDataType data_type) } } -CustomDataType attribute_domain_lowest_complexity(Span data_types) +CustomDataType attribute_domain_highest_complexity(Span data_types) { - int lowest_complexity = INT_MAX; - CustomDataType least_complex_type = CD_PROP_BOOL; + int highest_complexity = INT_MIN; + CustomDataType most_complex_type = CD_PROP_COLOR; for (const CustomDataType data_type : data_types) { const int complexity = attribute_data_type_complexity(data_type); -if (complexity < lowest_complexity) { - lowest_complexity = complexity; - least_complex_type = data_type; +if (complexity > highest_complexity) { + highest_complexity = complexity; + most_complex_type = data_type; } } - return least_complex_type; + return most_complex_type; } } // namespace blender::nodes diff --git a/source/blender/nodes/geometry/node_geometry_util.hh b/source/blender/nodes/geometry/node_geometry_util.hh index b8728016230..44c9406c61c 100644 --- a/source/blender/nodes/geometry/node_geometry_util.hh +++ b/source/blender/nodes/geometry/node_geometry_util.hh @@ -43,6 +43,6 @@ void update_attribute_input_socket_availabilities(bNode , const StringRef name, const GeometryNodeAttributeInputMode mode); -CustomDataType attribute_domain_lowest_complexity(Span); +CustomDataType attribute_domain_highest_complexity(Span); } // namespace blender::nodes \ No newline at end of file diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_compare.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_compare.cc index 7ec27bc85d6..972f536e2ee 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_compare.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_compare.cc @@ -221,12 +221,12 @@ static CustomDataType get_data_type(GeometryComponent , CustomDataType data_type_b = params.get_input_attribute_data_type( "B", component, CD_PROP_FLOAT); -/* Convert the input attributes to the same data type for the equality tests. Use the lower - * complexity attribute type because any other information would be arbitrary anyway.*/ -return attribute_domain_lowest_complexity(Span{data_type_a, data_type_b}); +/* Convert the input attributes to the same data type for the equality tests. Use the higher + * complexity attribute type, otherwise information necessary to the comparison may be lost. */ +return attribute_domain_highest_complexity({data_type_a, data_type_b}); } - /* Use float compare for every operation besides equality. (This might have to change). */ + /* Use float compare for every operation besides equality. */ return CD_PROP_FLOAT; } @@ -265,8 +265,8 @@ static void attribute_compare_calc(GeometryComponent , const GeoNodeEx BooleanWriteAttribute attribute_result_bool = std::move(attribute_result); MutableSpan result_span = attribute_result_bool.get_span(); - /* Use specific types for correct equality operations, but for other - * operations we can use* implicit conversions and float comparison. */ + /* Use specific types for correct equality operations, but for other operations we use implicit + * conversions and float comparison. In other words, the comparison is not element-wise. */ if (operation_is_equality(*node_storage)) { const float threshold = params.get_input("Threshold"); if (operation == NODE_FLOAT_COMPARE_EQUAL) { ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [348bd319d5a] master: Geometry Nodes: Attribute Fill Node
Commit: 348bd319d5a88f45410a22f8ce2f527d8da48ef0 Author: Hans Goudey Date: Thu Dec 10 07:58:45 2020 -0600 Branches: master https://developer.blender.org/rB348bd319d5a88f45410a22f8ce2f527d8da48ef0 Geometry Nodes: Attribute Fill Node This commit adds a node that fills every element of an attribute with the same value. Currently it supports float, vector, and color attributes. An immediate use case is for "billboard" scattering. Currently people are using the same input to a Random Attribute node's min and max input to fill every element of a vector with the same value, which is an unintuitive way to accomplish the same thing. Differential Revision: https://developer.blender.org/D9790 === M release/scripts/startup/nodeitems_builtins.py M source/blender/blenkernel/BKE_node.h M source/blender/blenkernel/intern/node.c M source/blender/editors/space_node/drawnode.c M source/blender/makesrna/intern/rna_nodetree.c M source/blender/nodes/CMakeLists.txt M source/blender/nodes/NOD_geometry.h M source/blender/nodes/NOD_static_types.h A source/blender/nodes/geometry/nodes/node_geo_attribute_fill.cc === diff --git a/release/scripts/startup/nodeitems_builtins.py b/release/scripts/startup/nodeitems_builtins.py index abab50b95a2..df98645aee0 100644 --- a/release/scripts/startup/nodeitems_builtins.py +++ b/release/scripts/startup/nodeitems_builtins.py @@ -483,6 +483,7 @@ geometry_node_categories = [ GeometryNodeCategory("GEO_ATTRIBUTE", "Attribute", items=[ NodeItem("GeometryNodeRandomAttribute"), NodeItem("GeometryNodeAttributeMath"), +NodeItem("GeometryNodeAttributeFill"), ]), GeometryNodeCategory("GEO_COLOR", "Color", items=[ NodeItem("ShaderNodeValToRGB"), diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index a8a94958772..56ed60c1f67 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -1350,6 +1350,7 @@ int ntreeTexExecTree(struct bNodeTree *ntree, #define GEO_NODE_RANDOM_ATTRIBUTE 1008 #define GEO_NODE_ATTRIBUTE_MATH 1009 #define GEO_NODE_JOIN_GEOMETRY 1010 +#define GEO_NODE_ATTRIBUTE_FILL 1011 /** \} */ diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 31de95817fd..ecc17ff0e5e 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -4682,6 +4682,7 @@ static void registerGeometryNodes(void) { register_node_type_geo_group(); + register_node_type_geo_attribute_fill(); register_node_type_geo_triangulate(); register_node_type_geo_edge_split(); register_node_type_geo_transform(); diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 84e7a74fab3..2ff32a4a82e 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -3182,6 +3182,14 @@ static void node_geometry_buts_attribute_math(uiLayout *layout, uiItemR(layout, ptr, "input_type_b", DEFAULT_FLAGS, IFACE_("Type B"), ICON_NONE); } +static void node_geometry_buts_attribute_fill(uiLayout *layout, + bContext *UNUSED(C), + PointerRNA *ptr) +{ + uiItemR(layout, ptr, "data_type", DEFAULT_FLAGS, "", ICON_NONE); + // uiItemR(layout, ptr, "domain", DEFAULT_FLAGS, "", ICON_NONE); +} + static void node_geometry_set_butfunc(bNodeType *ntype) { switch (ntype->type) { @@ -3200,6 +3208,9 @@ static void node_geometry_set_butfunc(bNodeType *ntype) case GEO_NODE_ATTRIBUTE_MATH: ntype->draw_buttons = node_geometry_buts_attribute_math; break; +case GEO_NODE_ATTRIBUTE_FILL: + ntype->draw_buttons = node_geometry_buts_attribute_fill; + break; } } diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index dd02cc214e0..07dba3e55a1 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -1879,6 +1879,30 @@ static const EnumPropertyItem *rna_GeometryNodeAttributeRandom_domain_itemf( return itemf_function_check(rna_enum_attribute_domain_items, attribute_random_domain_supported); } +static bool attribute_fill_type_supported(const EnumPropertyItem *item) +{ + return ELEM(item->value, CD_PROP_FLOAT, CD_PROP_FLOAT3, CD_PROP_COLOR); +} +static const EnumPropertyItem *rna_GeometryNodeAttributeFill_type_itemf(bContext *UNUSED(C), +
[Bf-blender-cvs] [6022103264c] master: Cleanup: Clang tidy void argument
Commit: 6022103264cf2e23ad884fce6b5dfadf88b24e05 Author: Hans Goudey Date: Mon Nov 30 13:44:58 2020 -0500 Branches: master https://developer.blender.org/rB6022103264cf2e23ad884fce6b5dfadf88b24e05 Cleanup: Clang tidy void argument === M source/blender/gpu/opengl/gl_shader.cc === diff --git a/source/blender/gpu/opengl/gl_shader.cc b/source/blender/gpu/opengl/gl_shader.cc index 28b89ad48f5..dd08a67517e 100644 --- a/source/blender/gpu/opengl/gl_shader.cc +++ b/source/blender/gpu/opengl/gl_shader.cc @@ -426,7 +426,7 @@ void GLShader::vertformat_from_shader(GPUVertFormat *format) const } } -int GLShader::program_handle_get(void) const +int GLShader::program_handle_get() const { return (int)this->shader_program_; } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [007a0e43a01] master: Cleanup: Reduce variable scope in node drawing code
Commit: 007a0e43a01af97a2e393e2f98d9a86469ec4a78 Author: Hans Goudey Date: Mon Nov 30 13:56:46 2020 -0500 Branches: master https://developer.blender.org/rB007a0e43a01af97a2e393e2f98d9a86469ec4a78 Cleanup: Reduce variable scope in node drawing code Also use LISTBASE_FOREACH in a few places and generally clean up the code for the two sidebar panels "Sockets" and "Interface". === M source/blender/editors/space_node/node_buttons.c M source/blender/editors/space_node/node_draw.c === diff --git a/source/blender/editors/space_node/node_buttons.c b/source/blender/editors/space_node/node_buttons.c index 6475e753409..0aba45ceafc 100644 --- a/source/blender/editors/space_node/node_buttons.c +++ b/source/blender/editors/space_node/node_buttons.c @@ -68,23 +68,20 @@ static bool node_sockets_poll(const bContext *C, PanelType *UNUSED(pt)) static void node_sockets_panel(const bContext *C, Panel *panel) { - SpaceNode *snode = CTX_wm_space_node(C); - bNodeTree *ntree = (snode) ? snode->edittree : NULL; - bNode *node = (ntree) ? nodeGetActive(ntree) : NULL; - bNodeSocket *sock; - uiLayout *layout = panel->layout, *split; - char name[UI_MAX_NAME_STR]; - - if (ELEM(NULL, ntree, node)) { + SpaceNode *snode = CTX_wm_space_node(C); /* NULL checked in poll function. */ + bNodeTree *ntree = snode->edittree; /* NULL checked in poll function. */ + bNode *node = nodeGetActive(ntree); + if (node == NULL) { return; } - for (sock = node->inputs.first; sock; sock = sock->next) { -BLI_snprintf(name, sizeof(name), "%s:", sock->name); + LISTBASE_FOREACH (bNodeSocket *, socket, >inputs) { +char name[UI_MAX_NAME_STR]; +BLI_snprintf(name, sizeof(name), "%s:", socket->name); -split = uiLayoutSplit(layout, 0.35f, false); +uiLayout *split = uiLayoutSplit(panel->layout, 0.35f, false); uiItemL(split, name, ICON_NONE); -uiTemplateNodeLink(split, (bContext *)C, ntree, node, sock); +uiTemplateNodeLink(split, (bContext *)C, ntree, node, socket); } } @@ -96,19 +93,20 @@ static bool node_tree_interface_poll(const bContext *C, PanelType *UNUSED(pt)) (snode->edittree->inputs.first || snode->edittree->outputs.first)); } -static bool node_tree_find_active_socket(bNodeTree *ntree, bNodeSocket **r_sock, int *r_in_out) +static bool node_tree_find_active_socket(bNodeTree *ntree, + bNodeSocket **r_sock, + eNodeSocketInOut *r_in_out) { - bNodeSocket *sock; - for (sock = ntree->inputs.first; sock; sock = sock->next) { -if (sock->flag & SELECT) { - *r_sock = sock; + LISTBASE_FOREACH (bNodeSocket *, socket, >inputs) { +if (socket->flag & SELECT) { + *r_sock = socket; *r_in_out = SOCK_IN; return true; } } - for (sock = ntree->outputs.first; sock; sock = sock->next) { -if (sock->flag & SELECT) { - *r_sock = sock; + LISTBASE_FOREACH (bNodeSocket *, socket, >outputs) { +if (socket->flag & SELECT) { + *r_sock = socket; *r_in_out = SOCK_OUT; return true; } @@ -121,28 +119,24 @@ static bool node_tree_find_active_socket(bNodeTree *ntree, bNodeSocket **r_sock, static void node_tree_interface_panel(const bContext *C, Panel *panel) { - SpaceNode *snode = CTX_wm_space_node(C); - bNodeTree *ntree = (snode) ? snode->edittree : NULL; - bNodeSocket *sock; - int in_out; - uiLayout *layout = panel->layout, *row, *split, *col; - PointerRNA ptr, sockptr, opptr; - wmOperatorType *ot; - - if (!ntree) { -return; - } + SpaceNode *snode = CTX_wm_space_node(C); /* NULL checked in poll function. */ + bNodeTree *ntree = snode->edittree; /* NULL checked in poll function. */ + uiLayout *layout = panel->layout; + PointerRNA ptr; RNA_id_pointer_create((ID *)ntree, ); - node_tree_find_active_socket(ntree, , _out); - RNA_pointer_create((ID *)ntree, _NodeSocketInterface, sock, ); + bNodeSocket *socket; + eNodeSocketInOut in_out; + node_tree_find_active_socket(ntree, , _out); + PointerRNA sockptr; + RNA_pointer_create((ID *)ntree, _NodeSocketInterface, socket, ); - row = uiLayoutRow(layout, false); + uiLayout *row = uiLayoutRow(layout, false); - split = uiLayoutRow(row, true); - col = uiLayoutColumn(split, true); - ot = WM_operatortype_find("NODE_OT_tree_socket_add", false); + uiLayout *split = uiLayoutRow(row, true); + uiLayout *col = uiLayoutColumn(split, true); + wmOperatorType *ot = WM_operatortype_find("NODE_OT_tree_socket_add", false); uiItemL(col, IFACE_("Inputs:"), ICON_NONE); uiTemplateList(col, (bContext *)C, @@ -159,6 +153,7 @@ static void node_tree_in
[Bf-blender-cvs] [4eef1d2edc1] geometry-nodes-point-separate-node: Geometry Nodes: Point separate node
Commit: 4eef1d2edc16b113e2ef83e0279e555cbb2e0884 Author: Hans Goudey Date: Tue Dec 1 16:05:35 2020 -0500 Branches: geometry-nodes-point-separate-node https://developer.blender.org/rB4eef1d2edc16b113e2ef83e0279e555cbb2e0884 Geometry Nodes: Point separate node This node takes an input geometry and ouputs two geometries, moving some points to the first and other points to the second depending on a mask attribute input and a threshold. The implementation tries to be "attribute component agnostic", meaning it should be relatively easy to add "separate" functionality for more component types in the future when they need to support it. (Then the node could be renamed "Separate Geometry"). There is still an error carrying over the values for some attributes to the output geometries. === M release/scripts/startup/nodeitems_builtins.py M source/blender/blenkernel/BKE_node.h M source/blender/blenkernel/intern/node.c M source/blender/blenkernel/intern/pointcloud.cc M source/blender/nodes/CMakeLists.txt M source/blender/nodes/NOD_geometry.h M source/blender/nodes/NOD_static_types.h A source/blender/nodes/geometry/nodes/node_geo_point_separate.cc === diff --git a/release/scripts/startup/nodeitems_builtins.py b/release/scripts/startup/nodeitems_builtins.py index b1789776728..f955389d36b 100644 --- a/release/scripts/startup/nodeitems_builtins.py +++ b/release/scripts/startup/nodeitems_builtins.py @@ -512,6 +512,7 @@ geometry_node_categories = [ GeometryNodeCategory("GEO_POINT", "Point", items=[ NodeItem("GeometryNodePointDistribute"), NodeItem("GeometryNodePointInstance"), +NodeItem("GeometryNodePointSeparate"), ]), GeometryNodeCategory("GEO_UTILITIES", "Utilities", items=[ NodeItem("ShaderNodeMapRange"), diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index a8a94958772..68093affab8 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -1350,6 +1350,7 @@ int ntreeTexExecTree(struct bNodeTree *ntree, #define GEO_NODE_RANDOM_ATTRIBUTE 1008 #define GEO_NODE_ATTRIBUTE_MATH 1009 #define GEO_NODE_JOIN_GEOMETRY 1010 +#define GEO_NODE_POINT_SEPARATE 1011 /** \} */ diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index b564a4c468b..8edafce3518 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -4693,6 +4693,7 @@ static void registerGeometryNodes(void) register_node_type_geo_random_attribute(); register_node_type_geo_attribute_math(); register_node_type_geo_join_geometry(); + register_node_type_geo_point_separate(); } static void registerFunctionNodes(void) diff --git a/source/blender/blenkernel/intern/pointcloud.cc b/source/blender/blenkernel/intern/pointcloud.cc index 5f6685817b9..1d38b69462a 100644 --- a/source/blender/blenkernel/intern/pointcloud.cc +++ b/source/blender/blenkernel/intern/pointcloud.cc @@ -243,13 +243,6 @@ PointCloud *BKE_pointcloud_new_nomain(const int totpoint) pointcloud->totpoint = totpoint; - CustomData_add_layer_named(>pdata, - CD_PROP_FLOAT, - CD_CALLOC, - nullptr, - pointcloud->totpoint, - POINTCLOUD_ATTR_RADIUS); - pointcloud->totpoint = totpoint; CustomData_realloc(>pdata, pointcloud->totpoint); BKE_pointcloud_update_customdata_pointers(pointcloud); diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt index a367f40dca7..3e1f287dd91 100644 --- a/source/blender/nodes/CMakeLists.txt +++ b/source/blender/nodes/CMakeLists.txt @@ -147,6 +147,7 @@ set(SRC geometry/nodes/node_geo_subdivision_surface.cc geometry/nodes/node_geo_point_distribute.cc geometry/nodes/node_geo_point_instance.cc + geometry/nodes/node_geo_point_separate.cc geometry/nodes/node_geo_random_attribute.cc geometry/nodes/node_geo_transform.cc geometry/nodes/node_geo_triangulate.cc diff --git a/source/blender/nodes/NOD_geometry.h b/source/blender/nodes/NOD_geometry.h index 0532547375f..2faa7f50f10 100644 --- a/source/blender/nodes/NOD_geometry.h +++ b/source/blender/nodes/NOD_geometry.h @@ -37,6 +37,7 @@ void register_node_type_geo_object_info(void); void register_node_type_geo_random_attribute(void); void register_node_type_geo_attribute_math(void); void register_node_type_geo_join_geometry(void); +void register_node_type_geo_point_separate(void); #ifdef __cplusplus } diff --git a/source/blender/nodes/NOD_static_types.h b/source/blender/nodes/NOD_static_types.h i
[Bf-blender-cvs] [2f0f2696848] geometry-nodes-point-separate-node: Point Separate Node: Change has_attribute function
Commit: 2f0f2696848a3294731cf723040f3d33b4f1235d Author: Hans Goudey Date: Wed Dec 2 09:08:33 2020 -0500 Branches: geometry-nodes-point-separate-node https://developer.blender.org/rB2f0f2696848a3294731cf723040f3d33b4f1235d Point Separate Node: Change has_attribute function === M source/blender/blenkernel/BKE_geometry_set.hh M source/blender/blenkernel/intern/attribute_access.cc M source/blender/nodes/geometry/nodes/node_geo_point_separate.cc === diff --git a/source/blender/blenkernel/BKE_geometry_set.hh b/source/blender/blenkernel/BKE_geometry_set.hh index bcf9bef4708..00f461bcd84 100644 --- a/source/blender/blenkernel/BKE_geometry_set.hh +++ b/source/blender/blenkernel/BKE_geometry_set.hh @@ -88,6 +88,8 @@ class GeometryComponent { GeometryComponentType type() const; + bool attribute_exists(const blender::StringRef attribute_name) const; + /* Returns true when the geometry component supports this attribute domain. */ virtual bool attribute_domain_supported(const AttributeDomain domain) const; /* Returns true when the given data type is supported in the given domain. */ @@ -122,7 +124,6 @@ class GeometryComponent { const AttributeDomain domain, const CustomDataType data_type); - virtual bool has_attribute(const blender::StringRef attribute_name) const; virtual blender::Set attribute_names() const; virtual bool is_empty() const; @@ -294,7 +295,6 @@ class MeshComponent : public GeometryComponent { const AttributeDomain domain, const CustomDataType data_type) final; - bool has_attribute(const blender::StringRef attribute_name) const; blender::Set attribute_names() const final; bool is_empty() const final; @@ -337,7 +337,6 @@ class PointCloudComponent : public GeometryComponent { const AttributeDomain domain, const CustomDataType data_type) final; - bool has_attribute(const blender::StringRef attribute_name) const; blender::Set attribute_names() const final; bool is_empty() const final; diff --git a/source/blender/blenkernel/intern/attribute_access.cc b/source/blender/blenkernel/intern/attribute_access.cc index adedf1a74cd..2edf3981c38 100644 --- a/source/blender/blenkernel/intern/attribute_access.cc +++ b/source/blender/blenkernel/intern/attribute_access.cc @@ -590,8 +590,12 @@ Set GeometryComponent::attribute_names() const return {}; } -bool GeometryComponent::has_attribute(const blender::StringRef UNUSED(attribute_name)) const +bool GeometryComponent::attribute_exists(const blender::StringRef attribute_name) const { + ReadAttributePtr attribute = this->attribute_try_get_for_read(attribute_name); + if (attribute) { +return true; + } return false; } @@ -808,11 +812,6 @@ bool PointCloudComponent::attribute_try_create(const StringRef attribute_name, return true; } -bool PointCloudComponent::has_attribute(const blender::StringRef attribute_name) const -{ - return custom_data_has_layer_with_name(pointcloud_->pdata, attribute_name); -} - Set PointCloudComponent::attribute_names() const { if (pointcloud_ == nullptr) { @@ -1069,11 +1068,6 @@ bool MeshComponent::attribute_try_create(const StringRef attribute_name, } } -bool MeshComponent::has_attribute(const blender::StringRef attribute_name) const -{ - return custom_data_has_layer_with_name(mesh_->pdata, attribute_name); -} - Set MeshComponent::attribute_names() const { if (mesh_ == nullptr) { diff --git a/source/blender/nodes/geometry/nodes/node_geo_point_separate.cc b/source/blender/nodes/geometry/nodes/node_geo_point_separate.cc index 1fa2c87c95e..23e1c720161 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_point_separate.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_point_separate.cc @@ -84,13 +84,13 @@ static void separate_component_attributes(const GeometryComponent _component, * attributes will already exist on new components by definition. It should always be possible * to recreate the attribute on the same component type. Also, if one of the new components * has the attribute the other one should have it too, but check independently to be safe. */ -if (!out_component_a.has_attribute(name)) { +if (!out_component_a.attribute_exists(name)) { if (!out_component_a.attribute_try_create(name, domain, data_type)) { BLI_assert(false); continue; } } -if (!out_component_b.has_attribute(name)) { +if (!out_component_b.attribute_exists(name)) { if (!out_component_b.attribute_try_create(name, domain, data_type)) { BLI_assert(false); continue; @@ -146,7 +146,7 @@ static Array calculate_split(const Geometry
[Bf-blender-cvs] [04d3b54000b] master: Cleanup: Declare variables where initialized
Commit: 04d3b54000bedd06bc767fa908772c0b20cb792f Author: Hans Goudey Date: Fri Dec 4 08:03:14 2020 -0600 Branches: master https://developer.blender.org/rB04d3b54000bedd06bc767fa908772c0b20cb792f Cleanup: Declare variables where initialized === M source/blender/editors/interface/interface_context_menu.c === diff --git a/source/blender/editors/interface/interface_context_menu.c b/source/blender/editors/interface/interface_context_menu.c index 02a9c3742d7..39b405a02b8 100644 --- a/source/blender/editors/interface/interface_context_menu.c +++ b/source/blender/editors/interface/interface_context_menu.c @@ -90,9 +90,8 @@ static IDProperty *shortcut_property_from_rna(bContext *C, uiBut *but) } /* Create ID property of data path, to pass to the operator. */ - IDProperty *prop; const IDPropertyTemplate val = {0}; - prop = IDP_New(IDP_GROUP, , __func__); + IDProperty *prop = IDP_New(IDP_GROUP, , __func__); IDP_AddToGroup(prop, IDP_NewString(final_data_path, "data_path", strlen(final_data_path) + 1)); MEM_freeN((void *)final_data_path); @@ -167,43 +166,40 @@ static void but_shortcut_name_func(bContext *C, void *arg1, int UNUSED(event)) static uiBlock *menu_change_shortcut(bContext *C, ARegion *region, void *arg) { wmWindowManager *wm = CTX_wm_manager(C); - uiBlock *block; uiBut *but = (uiBut *)arg; - wmKeyMap *km; - wmKeyMapItem *kmi; PointerRNA ptr; - uiLayout *layout; const uiStyle *style = UI_style_get_dpi(); IDProperty *prop; const char *idname = shortcut_get_operator_property(C, but, ); - kmi = WM_key_event_operator(C, - idname, - but->opcontext, - prop, - EVT_TYPE_MASK_HOTKEY_INCLUDE, - EVT_TYPE_MASK_HOTKEY_EXCLUDE, - ); + wmKeyMap *km; + wmKeyMapItem *kmi = WM_key_event_operator(C, +idname, +but->opcontext, +prop, +EVT_TYPE_MASK_HOTKEY_INCLUDE, +EVT_TYPE_MASK_HOTKEY_EXCLUDE, +); U.runtime.is_dirty = true; BLI_assert(kmi != NULL); RNA_pointer_create(>id, _KeyMapItem, kmi, ); - block = UI_block_begin(C, region, "_popup", UI_EMBOSS); + uiBlock *block = UI_block_begin(C, region, "_popup", UI_EMBOSS); UI_block_func_handle_set(block, but_shortcut_name_func, but); UI_block_flag_enable(block, UI_BLOCK_MOVEMOUSE_QUIT); UI_block_direction_set(block, UI_DIR_CENTER_Y); - layout = UI_block_layout(block, - UI_LAYOUT_VERTICAL, - UI_LAYOUT_PANEL, - 0, - 0, - U.widget_unit * 10, - U.widget_unit * 2, - 0, - style); + uiLayout *layout = UI_block_layout(block, + UI_LAYOUT_VERTICAL, + UI_LAYOUT_PANEL, + 0, + 0, + U.widget_unit * 10, + U.widget_unit * 2, + 0, + style); uiItemL(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Change Shortcut"), ICON_HAND); uiItemR(layout, , "type", UI_ITEM_R_FULL_EVENT | UI_ITEM_R_IMMEDIATE, "", ICON_NONE); @@ -223,22 +219,17 @@ static int g_kmi_id_hack; static uiBlock *menu_add_shortcut(bContext *C, ARegion *region, void *arg) { wmWindowManager *wm = CTX_wm_manager(C); - uiBlock *block; uiBut *but = (uiBut *)arg; - wmKeyMap *km; - wmKeyMapItem *kmi; PointerRNA ptr; - uiLayout *layout; const uiStyle *style = UI_style_get_dpi(); - int kmi_id; IDProperty *prop; const char *idname = shortcut_get_operator_property(C, but, ); /* XXX this guess_opname can potentially return a different keymap * than being found on adding later... */ - km = WM_keymap_guess_opname(C, idname); - kmi = WM_keymap_add_item(km, idname, EVT_AKEY, KM_PRESS, 0, 0); - kmi_id = kmi->id; + wmKeyMap *km = WM_keymap_guess_opname(C, idname); + wmKeyMapItem *kmi = WM_keymap_add_item(km, idname, EVT_AKEY, KM_PRESS, 0, 0); + int kmi_id = kmi->id; /* This takes ownership of prop, or prop can be NULL for reset. */ WM_keymap_item_properties_reset(kmi, prop); @@ -252,19 +243,19 @@ static uiBlock *menu_add_shortcut(bContext *C, ARegion *region, void *arg) RNA_poi
[Bf-blender-cvs] [4bb53147549] master: Cleanup: Use typedef for button string info type
Commit: 4bb531475490c36c57065fb3db3d41974fb14897 Author: Hans Goudey Date: Fri Dec 4 08:01:54 2020 -0600 Branches: master https://developer.blender.org/rB4bb531475490c36c57065fb3db3d41974fb14897 Cleanup: Use typedef for button string info type Before, it wasn't clear what the int in `uiStringInfo` was supposed to store. Using a typedef can make this someone more explicit. === M source/blender/editors/include/UI_interface.h M source/blender/editors/interface/interface.c === diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index f9dc23502c7..a190194d89d 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -1351,7 +1351,7 @@ struct PointerRNA *UI_but_operator_ptr_get(uiBut *but); void UI_but_unit_type_set(uiBut *but, const int unit_type); int UI_but_unit_type_get(const uiBut *but); -enum { +typedef enum uiStringInfoType { BUT_GET_RNAPROP_IDENTIFIER = 1, BUT_GET_RNASTRUCT_IDENTIFIER, BUT_GET_RNAENUM_IDENTIFIER, @@ -1364,10 +1364,10 @@ enum { BUT_GET_RNAENUM_TIP, BUT_GET_OP_KEYMAP, BUT_GET_PROP_KEYMAP, -}; +} uiStringInfoType; typedef struct uiStringInfo { - int type; + uiStringInfoType type; char *strinfo; } uiStringInfo; diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 685b34b7185..4a02c6b6e88 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -6795,7 +6795,7 @@ void UI_but_string_info_get(bContext *C, uiBut *but, ...) va_start(args, but); while ((si = (uiStringInfo *)va_arg(args, void *))) { -int type = si->type; +uiStringInfoType type = si->type; char *tmp = NULL; if (type == BUT_GET_LABEL) { ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [4705fafa7e3] master: UI: Fix incorrect offset for panel label when zooming in
Commit: 4705fafa7e3e197581acf6d391b03f0004fd7667 Author: Hans Goudey Date: Thu Nov 26 10:29:03 2020 -0500 Branches: master https://developer.blender.org/rB4705fafa7e3e197581acf6d391b03f0004fd7667 UI: Fix incorrect offset for panel label when zooming in The panel title text intersected any buttons in the header because the label offset retrieved from the layout code was not scaled by the block's zoom level. Error in rB0d93bd8d63980. === M source/blender/editors/interface/interface_panel.c === diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index 514bc872b4a..5cfaafeec2c 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -1108,7 +1108,7 @@ static void panel_draw_aligned_widgets(const uiStyle *style, if (panel->drawname[0] != '\0') { /* + 0.001f to avoid flirting with float inaccuracy .*/ const rcti title_rect = { -.xmin = widget_rect.xmin + panel->labelofs + scaled_unit * 1.1f, +.xmin = widget_rect.xmin + (panel->labelofs / aspect) + scaled_unit * 1.1f, .xmax = widget_rect.xmax, .ymin = widget_rect.ymin - 2.0f / aspect, .ymax = widget_rect.ymax, ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [72386c64efd] geometry-nodes: UI: Improvements to interaction with active modifier
Commit: 72386c64efd8a4234e46dcef067b37f596854437 Author: Hans Goudey Date: Mon Nov 23 22:38:12 2020 -0500 Branches: geometry-nodes https://developer.blender.org/rB72386c64efd8a4234e46dcef067b37f596854437 UI: Improvements to interaction with active modifier This commit includes these improvements to operators and how they relate to the active modifier: - Shortcuts performed while there is an active modifier will affect only that modifier. - Clicking anywhere on the empty space in a modifier's panel will make it active. - Clicking anywhere in the empty properties space will clear the active. These changes require some refactoring of object modifier code. First is splitting up the modifier property invoke callback, which now needs to be able to get the active modifier separately from the hovered modifier for the different operators. Second is a change to removing modifiers, where there is now a separate function to remove a modifier from an object's list, in order to handle changing the active. Finally the panel handler neeeds a small tweak so that this "click in panel" event can be handled afterwards. === M release/scripts/presets/keyconfig/keymap_data/blender_default.py M source/blender/blenkernel/BKE_modifier.h M source/blender/blenkernel/intern/fluid.c M source/blender/blenkernel/intern/modifier.c M source/blender/blenkernel/intern/particle.c M source/blender/editors/interface/interface_panel.c M source/blender/editors/object/object_data_transfer.c M source/blender/editors/object/object_hook.c M source/blender/editors/object/object_intern.h M source/blender/editors/object/object_modifier.c M source/blender/editors/object/object_relations.c M source/blender/makesrna/intern/rna_modifier.c M source/blender/modifiers/intern/MOD_ui_common.c M source/blender/nodes/geometry/node_geometry_tree.cc === diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py index d66d7c45dd4..5c7c96b05b6 100644 --- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py +++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py @@ -742,6 +742,7 @@ def km_property_editor(_params): ("buttons.start_filter", {"type": 'F', "value": 'PRESS', "ctrl": True}, None), ("buttons.clear_filter", {"type": 'F', "value": 'PRESS', "alt": True}, None), # Modifier panels +("object.modifier_set_active", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None), ("object.modifier_remove", {"type": 'X', "value": 'PRESS'}, {"properties": [("report", True)]}), ("object.modifier_remove", {"type": 'DEL', "value": 'PRESS'}, {"properties": [("report", True)]}), ("object.modifier_copy", {"type": 'D', "value": 'PRESS', "shift": True}, None), diff --git a/source/blender/blenkernel/BKE_modifier.h b/source/blender/blenkernel/BKE_modifier.h index 2491f0953c0..b0a7d89e3d8 100644 --- a/source/blender/blenkernel/BKE_modifier.h +++ b/source/blender/blenkernel/BKE_modifier.h @@ -407,6 +407,7 @@ struct ModifierData *BKE_modifier_new(int type); void BKE_modifier_free_ex(struct ModifierData *md, const int flag); void BKE_modifier_free(struct ModifierData *md); +void BKE_modifier_remove_from_list(struct Object *ob, struct ModifierData *md); /* Generate new UUID for the given modifier. */ void BKE_modifier_session_uuid_generate(struct ModifierData *md); diff --git a/source/blender/blenkernel/intern/fluid.c b/source/blender/blenkernel/intern/fluid.c index 434456a922e..7eac4bf32e3 100644 --- a/source/blender/blenkernel/intern/fluid.c +++ b/source/blender/blenkernel/intern/fluid.c @@ -4559,7 +4559,7 @@ void BKE_fluid_particle_system_destroy(struct Object *ob, const int particle_typ if (psys->part->type == particle_type) { /* clear modifier */ pfmd = psys_get_modifier(ob, psys); - BLI_remlink(>modifiers, pfmd); + BKE_modifier_remove_from_list(ob, pfmd); BKE_modifier_free((ModifierData *)pfmd); /* clear particle system */ diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 3c8b685a0e0..de820786549 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -212,6 +212,26 @@ void BKE_modifier_free(ModifierData *md) BKE_modifier_free_ex(md, 0); } +/** + * Use instead of `BLI_remlink` when the object's active modifier should change. + */ +void BKE_modi
[Bf-blender-cvs] [6b12dad1901] master: Cleanup: Use LISTBASE_FOREACH for node tree sockets RNA code
Commit: 6b12dad1901e60b5deb28d4de105241f57f99f79 Author: Hans Goudey Date: Mon Nov 30 16:39:07 2020 -0500 Branches: master https://developer.blender.org/rB6b12dad1901e60b5deb28d4de105241f57f99f79 Cleanup: Use LISTBASE_FOREACH for node tree sockets RNA code === M source/blender/makesrna/intern/rna_nodetree.c === diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index e91b0d860c6..a9924c46fdd 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -1165,11 +1165,9 @@ static void rna_NodeTree_link_clear(bNodeTree *ntree, Main *bmain, ReportList *r static int rna_NodeTree_active_input_get(PointerRNA *ptr) { bNodeTree *ntree = (bNodeTree *)ptr->data; - bNodeSocket *gsock; - int index; - - for (gsock = ntree->inputs.first, index = 0; gsock; gsock = gsock->next, index++) { -if (gsock->flag & SELECT) { + int index = 0; + LISTBASE_FOREACH_INDEX (bNodeSocket *, socket, >inputs, index) { +if (socket->flag & SELECT) { return index; } } @@ -1179,30 +1177,22 @@ static int rna_NodeTree_active_input_get(PointerRNA *ptr) static void rna_NodeTree_active_input_set(PointerRNA *ptr, int value) { bNodeTree *ntree = (bNodeTree *)ptr->data; - bNodeSocket *gsock; - int index; - for (gsock = ntree->inputs.first, index = 0; gsock; gsock = gsock->next, index++) { -if (index == value) { - gsock->flag |= SELECT; -} -else { - gsock->flag &= ~SELECT; -} + int index = 0; + LISTBASE_FOREACH_INDEX (bNodeSocket *, socket, >inputs, index) { +SET_FLAG_FROM_TEST(socket->flag, index == value, SELECT); } - for (gsock = ntree->outputs.first; gsock; gsock = gsock->next) { -gsock->flag &= ~SELECT; + LISTBASE_FOREACH (bNodeSocket *, socket, >outputs) { +socket->flag &= ~SELECT; } } static int rna_NodeTree_active_output_get(PointerRNA *ptr) { bNodeTree *ntree = (bNodeTree *)ptr->data; - bNodeSocket *gsock; - int index; - - for (gsock = ntree->outputs.first, index = 0; gsock; gsock = gsock->next, index++) { -if (gsock->flag & SELECT) { + int index = 0; + LISTBASE_FOREACH_INDEX (bNodeSocket *, socket, >outputs, index) { +if (socket->flag & SELECT) { return index; } } @@ -1212,32 +1202,24 @@ static int rna_NodeTree_active_output_get(PointerRNA *ptr) static void rna_NodeTree_active_output_set(PointerRNA *ptr, int value) { bNodeTree *ntree = (bNodeTree *)ptr->data; - bNodeSocket *gsock; - int index; - for (gsock = ntree->inputs.first; gsock; gsock = gsock->next) { -gsock->flag &= ~SELECT; + LISTBASE_FOREACH (bNodeSocket *, socket, >inputs) { +socket->flag &= ~SELECT; } - for (gsock = ntree->outputs.first, index = 0; gsock; gsock = gsock->next, index++) { -if (index == value) { - gsock->flag |= SELECT; -} -else { - gsock->flag &= ~SELECT; -} + int index = 0; + LISTBASE_FOREACH_INDEX (bNodeSocket *, socket, >outputs, index) { +SET_FLAG_FROM_TEST(socket->flag, index == value, SELECT); } } static bNodeSocket *rna_NodeTree_inputs_new( bNodeTree *ntree, Main *bmain, ReportList *reports, const char *type, const char *name) { - bNodeSocket *sock; - if (!rna_NodeTree_check(ntree, reports)) { return NULL; } - sock = ntreeAddSocketInterface(ntree, SOCK_IN, type, name); + bNodeSocket *sock = ntreeAddSocketInterface(ntree, SOCK_IN, type, name); ntreeUpdateTree(bmain, ntree); WM_main_add_notifier(NC_NODE | NA_EDITED, ntree); @@ -1248,13 +1230,11 @@ static bNodeSocket *rna_NodeTree_inputs_new( static bNodeSocket *rna_NodeTree_outputs_new( bNodeTree *ntree, Main *bmain, ReportList *reports, const char *type, const char *name) { - bNodeSocket *sock; - if (!rna_NodeTree_check(ntree, reports)) { return NULL; } - sock = ntreeAddSocketInterface(ntree, SOCK_OUT, type, name); + bNodeSocket *sock = ntreeAddSocketInterface(ntree, SOCK_OUT, type, name); ntreeUpdateTree(bmain, ntree); WM_main_add_notifier(NC_NODE | NA_EDITED, ntree); @@ -1284,15 +1264,12 @@ static void rna_NodeTree_socket_remove(bNodeTree *ntree, static void rna_NodeTree_inputs_clear(bNodeTree *ntree, Main *bmain, ReportList *reports) { - bNodeSocket *sock, *nextsock; - if (!rna_NodeTree_check(ntree, reports)) { return; } - for (sock = ntree->inputs.first; sock; sock = nextsock) { -nextsock = sock->next; -ntreeRemoveSocketInterface(ntree, sock); + LISTBASE_FOREACH_MUTABLE (bNodeSocket *, socket, >inputs) { +ntreeRemoveSocketInterface(ntree, socket); } ntreeUpdateTree(bmain, ntree); @@ -1301,15 +1278,12 @@ static v
[Bf-blender-cvs] [1bb2c7dda30] geometry-nodes: Cleanup: Store "is_active" instead of pointer property in panel type
Commit: 1bb2c7dda3005279c43b7bf9db4c63320abc7d04 Author: Hans Goudey Date: Mon Nov 30 17:43:14 2020 -0500 Branches: geometry-nodes https://developer.blender.org/rB1bb2c7dda3005279c43b7bf9db4c63320abc7d04 Cleanup: Store "is_active" instead of pointer property in panel type This is consistent with the way other panel type fields are stored. === M source/blender/blenkernel/BKE_screen.h M source/blender/editors/interface/interface_panel.c M source/blender/modifiers/intern/MOD_ui_common.c === diff --git a/source/blender/blenkernel/BKE_screen.h b/source/blender/blenkernel/BKE_screen.h index dea9884f508..473a684eaba 100644 --- a/source/blender/blenkernel/BKE_screen.h +++ b/source/blender/blenkernel/BKE_screen.h @@ -234,6 +234,8 @@ typedef struct PanelType { char category[BKE_ST_MAXNAME]; /* for category tabs */ char owner_id[BKE_ST_MAXNAME]; /* for work-spaces to selectively show. */ char parent_id[BKE_ST_MAXNAME]; /* parent idname for sub-panels */ + /** Boolean property identifier of the panel custom data. Used to draw a highlighted border. */ + char active_property[BKE_ST_MAXNAME]; short space_type; short region_type; /* For popovers, 0 for default. */ @@ -251,11 +253,6 @@ typedef struct PanelType { /* draw entirely, view changes should be handled here */ void (*draw)(const struct bContext *C, struct Panel *panel); - /** - * Identifier of a boolean property of the panel custom data. Used to draw a highlighted border. - */ - const char *active_property; - /* For instanced panels corresponding to a list: */ /** Reorder function, called when drag and drop finishes. */ diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index d1e5bbcb536..b60fa40f39a 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -589,7 +589,7 @@ static bool panel_use_active_highlight(const Panel *panel) BLI_assert(UI_panel_is_active(panel)); BLI_assert(panel->type != NULL); - if (panel->type->active_property) { + if (panel->type->active_property[0] != '\0') { PointerRNA *ptr = UI_panel_custom_data_get(panel); if (ptr != NULL && !RNA_pointer_is_null(ptr)) { return RNA_boolean_get(ptr, panel->type->active_property); diff --git a/source/blender/modifiers/intern/MOD_ui_common.c b/source/blender/modifiers/intern/MOD_ui_common.c index 166d77624e8..fa5243c548f 100644 --- a/source/blender/modifiers/intern/MOD_ui_common.c +++ b/source/blender/modifiers/intern/MOD_ui_common.c @@ -409,6 +409,7 @@ PanelType *modifier_panel_register(ARegionType *region_type, ModifierType type, BLI_strncpy(panel_type->label, "", BKE_ST_MAXNAME); BLI_strncpy(panel_type->context, "modifier", BKE_ST_MAXNAME); BLI_strncpy(panel_type->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA, BKE_ST_MAXNAME); + BLI_strncpy(panel_type->active_property, "is_active", BKE_ST_MAXNAME); panel_type->draw_header = modifier_panel_header; panel_type->draw = draw; @@ -417,7 +418,6 @@ PanelType *modifier_panel_register(ARegionType *region_type, ModifierType type, /* Give the panel the special flag that says it was built here and corresponds to a * modifier rather than a #PanelType. */ panel_type->flag = PANEL_TYPE_HEADER_EXPAND | PANEL_TYPE_DRAW_BOX | PANEL_TYPE_INSTANCED; - panel_type->active_property = "is_active"; panel_type->reorder = modifier_reorder; panel_type->get_list_data_expand_flag = get_modifier_expand_flag; panel_type->set_list_data_expand_flag = set_modifier_expand_flag; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [a0f41a4fd1a] geometry-nodes: Merge branch 'master' into geometry-nodes
Commit: a0f41a4fd1a559bced7f73e4b4c3b051c38c804c Author: Hans Goudey Date: Mon Nov 30 17:36:14 2020 -0500 Branches: geometry-nodes https://developer.blender.org/rBa0f41a4fd1a559bced7f73e4b4c3b051c38c804c Merge branch 'master' into geometry-nodes === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [3d0c5455edf] master: Cleanup: Store "is_active" instead of pointer property in panel type
Commit: 3d0c5455edf4e32e6e8120b280710cb4b531e38a Author: Hans Goudey Date: Mon Nov 30 17:43:14 2020 -0500 Branches: master https://developer.blender.org/rB3d0c5455edf4e32e6e8120b280710cb4b531e38a Cleanup: Store "is_active" instead of pointer property in panel type This is consistent with the way other panel type fields are stored. === M source/blender/blenkernel/BKE_screen.h M source/blender/editors/interface/interface_panel.c M source/blender/modifiers/intern/MOD_ui_common.c === diff --git a/source/blender/blenkernel/BKE_screen.h b/source/blender/blenkernel/BKE_screen.h index dea9884f508..473a684eaba 100644 --- a/source/blender/blenkernel/BKE_screen.h +++ b/source/blender/blenkernel/BKE_screen.h @@ -234,6 +234,8 @@ typedef struct PanelType { char category[BKE_ST_MAXNAME]; /* for category tabs */ char owner_id[BKE_ST_MAXNAME]; /* for work-spaces to selectively show. */ char parent_id[BKE_ST_MAXNAME]; /* parent idname for sub-panels */ + /** Boolean property identifier of the panel custom data. Used to draw a highlighted border. */ + char active_property[BKE_ST_MAXNAME]; short space_type; short region_type; /* For popovers, 0 for default. */ @@ -251,11 +253,6 @@ typedef struct PanelType { /* draw entirely, view changes should be handled here */ void (*draw)(const struct bContext *C, struct Panel *panel); - /** - * Identifier of a boolean property of the panel custom data. Used to draw a highlighted border. - */ - const char *active_property; - /* For instanced panels corresponding to a list: */ /** Reorder function, called when drag and drop finishes. */ diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index d1e5bbcb536..b60fa40f39a 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -589,7 +589,7 @@ static bool panel_use_active_highlight(const Panel *panel) BLI_assert(UI_panel_is_active(panel)); BLI_assert(panel->type != NULL); - if (panel->type->active_property) { + if (panel->type->active_property[0] != '\0') { PointerRNA *ptr = UI_panel_custom_data_get(panel); if (ptr != NULL && !RNA_pointer_is_null(ptr)) { return RNA_boolean_get(ptr, panel->type->active_property); diff --git a/source/blender/modifiers/intern/MOD_ui_common.c b/source/blender/modifiers/intern/MOD_ui_common.c index 166d77624e8..fa5243c548f 100644 --- a/source/blender/modifiers/intern/MOD_ui_common.c +++ b/source/blender/modifiers/intern/MOD_ui_common.c @@ -409,6 +409,7 @@ PanelType *modifier_panel_register(ARegionType *region_type, ModifierType type, BLI_strncpy(panel_type->label, "", BKE_ST_MAXNAME); BLI_strncpy(panel_type->context, "modifier", BKE_ST_MAXNAME); BLI_strncpy(panel_type->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA, BKE_ST_MAXNAME); + BLI_strncpy(panel_type->active_property, "is_active", BKE_ST_MAXNAME); panel_type->draw_header = modifier_panel_header; panel_type->draw = draw; @@ -417,7 +418,6 @@ PanelType *modifier_panel_register(ARegionType *region_type, ModifierType type, /* Give the panel the special flag that says it was built here and corresponds to a * modifier rather than a #PanelType. */ panel_type->flag = PANEL_TYPE_HEADER_EXPAND | PANEL_TYPE_DRAW_BOX | PANEL_TYPE_INSTANCED; - panel_type->active_property = "is_active"; panel_type->reorder = modifier_reorder; panel_type->get_list_data_expand_flag = get_modifier_expand_flag; panel_type->set_list_data_expand_flag = set_modifier_expand_flag; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [600fb28b629] master: Geometry Nodes: active modifier + geometry nodes editor
Commit: 600fb28b629598af2537c542e7f3f76ba0e94389 Author: Hans Goudey Date: Wed Dec 2 13:35:07 2020 +0100 Branches: master https://developer.blender.org/rB600fb28b629598af2537c542e7f3f76ba0e94389 Geometry Nodes: active modifier + geometry nodes editor This commit adds functions to set and get the object's active modifier, which is stored as a flag in the ModifierData struct, similar to constraints. This will be used to set the context in the node editor. There are no visible changes in this commit. Similar to how the node editor context works for materials, this commit makes the node group displayed in the node editor depend on the active object and its active modifier. To keep the node group from changing, just pin the node group in the header. * Shortcuts performed while there is an active modifier will affect only that modifier (the exception is the A to expand the modifiers). * Clicking anywhere on the empty space in a modifier's panel will make it active. These changes require some refactoring of object modifier code. First is splitting up the modifier property invoke callback, which now needs to be able to get the active modifier separately from the hovered modifier for the different operators. Second is a change to removing modifiers, where there is now a separate function to remove a modifier from an object's list, in order to handle changing the active. Finally, the panel handler needs a small tweak so that this "click in panel" event can be handled afterwards. === M release/scripts/presets/keyconfig/keymap_data/blender_default.py M source/blender/blenkernel/BKE_modifier.h M source/blender/blenkernel/BKE_object.h M source/blender/blenkernel/BKE_screen.h M source/blender/blenkernel/intern/fluid.c M source/blender/blenkernel/intern/modifier.c M source/blender/blenkernel/intern/object.c M source/blender/blenkernel/intern/particle.c M source/blender/editors/interface/interface_panel.c M source/blender/editors/interface/interface_widgets.c M source/blender/editors/object/object_data_transfer.c M source/blender/editors/object/object_hook.c M source/blender/editors/object/object_intern.h M source/blender/editors/object/object_modifier.c M source/blender/editors/object/object_ops.c M source/blender/editors/object/object_relations.c M source/blender/editors/space_buttons/buttons_context.c M source/blender/editors/space_node/space_node.c M source/blender/makesdna/DNA_modifier_types.h M source/blender/makesdna/DNA_object_types.h M source/blender/makesrna/intern/rna_modifier.c M source/blender/makesrna/intern/rna_object.c M source/blender/modifiers/intern/MOD_ui_common.c M source/blender/nodes/geometry/node_geometry_tree.cc === diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py index 20755fcf856..8171b9ce1a4 100644 --- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py +++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py @@ -742,6 +742,7 @@ def km_property_editor(_params): ("buttons.start_filter", {"type": 'F', "value": 'PRESS', "ctrl": True}, None), ("buttons.clear_filter", {"type": 'F', "value": 'PRESS', "alt": True}, None), # Modifier panels +("object.modifier_set_active", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None), ("object.modifier_remove", {"type": 'X', "value": 'PRESS'}, {"properties": [("report", True)]}), ("object.modifier_remove", {"type": 'DEL', "value": 'PRESS'}, {"properties": [("report", True)]}), ("object.modifier_copy", {"type": 'D', "value": 'PRESS', "shift": True}, None), diff --git a/source/blender/blenkernel/BKE_modifier.h b/source/blender/blenkernel/BKE_modifier.h index 2491f0953c0..b0a7d89e3d8 100644 --- a/source/blender/blenkernel/BKE_modifier.h +++ b/source/blender/blenkernel/BKE_modifier.h @@ -407,6 +407,7 @@ struct ModifierData *BKE_modifier_new(int type); void BKE_modifier_free_ex(struct ModifierData *md, const int flag); void BKE_modifier_free(struct ModifierData *md); +void BKE_modifier_remove_from_list(struct Object *ob, struct ModifierData *md); /* Generate new UUID for the given modifier. */ void BKE_modifier_session_uuid_generate(struct ModifierData *md); diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h index 28c912a4c9a..a620d9af946 100644 --- a/source/blender/blenkernel/BKE_object.
[Bf-blender-cvs] [b1d1a58c77f] master: Geometry Nodes: improve operators for node editor header
Commit: b1d1a58c77fb165855c3ff8c13fdebe3d4297db8 Author: Hans Goudey Date: Tue Dec 1 21:35:26 2020 +0100 Branches: master https://developer.blender.org/rBb1d1a58c77fb165855c3ff8c13fdebe3d4297db8 Geometry Nodes: improve operators for node editor header This allows users to create new modifiers directly from the Geometry Nodes Editor. === M release/scripts/startup/bl_operators/geometry_nodes.py M release/scripts/startup/bl_ui/space_node.py === diff --git a/release/scripts/startup/bl_operators/geometry_nodes.py b/release/scripts/startup/bl_operators/geometry_nodes.py index 374bd4161a7..23926f28ab0 100644 --- a/release/scripts/startup/bl_operators/geometry_nodes.py +++ b/release/scripts/startup/bl_operators/geometry_nodes.py @@ -18,6 +18,20 @@ import bpy +def geometry_node_group_empty_new(context): +group = bpy.data.node_groups.new("Geometry Nodes", 'GeometryNodeTree') +group.inputs.new('NodeSocketGeometry', "Geometry") +group.outputs.new('NodeSocketGeometry', "Geometry") +input_node = group.nodes.new('NodeGroupInput') +output_node = group.nodes.new('NodeGroupOutput') +output_node.is_active_output = True + +input_node.location.x = -200 - input_node.width +output_node.location.x = 200 + +group.links.new(output_node.inputs[0], input_node.outputs[0]) + +return group def geometry_modifier_poll(context) -> bool: ob = context.object @@ -28,11 +42,34 @@ def geometry_modifier_poll(context) -> bool: return True +class NewGeometryNodeModifier(bpy.types.Operator): +"""Create a new modifier with a new geometry node group""" + +bl_idname = "node.new_geometry_node_modifier" +bl_label = "New Geometry Node Modifier" +bl_options = {'REGISTER', 'UNDO'} + +@classmethod +def poll(cls, context): +return geometry_modifier_poll(context) + +def execute(self, context): +modifier = context.object.modifiers.new("Empty", "NODES") + +if not modifier: +return {'CANCELLED'} + +group = geometry_node_group_empty_new(context) +modifier.node_group = group + +return {'FINISHED'} + + +class NewGeometryNodeTreeAssign(bpy.types.Operator): +"""Create a new geometry node group and assign it the the active modifier""" -class NewGeometryNodeTree(bpy.types.Operator): -"""Create a new geometry node tree""" -bl_idname = "node.new_geometry_node_tree" -bl_label = "New Geometry Node Tree" +bl_idname = "node.new_geometry_node_group_assign" +bl_label = "Assign New Geometry Node Group" bl_options = {'REGISTER', 'UNDO'} @classmethod @@ -40,21 +77,18 @@ class NewGeometryNodeTree(bpy.types.Operator): return geometry_modifier_poll(context) def execute(self, context): -group = bpy.data.node_groups.new("Geometry Nodes", 'GeometryNodeTree') -group.inputs.new('NodeSocketGeometry', "Geometry") -group.outputs.new('NodeSocketGeometry', "Geometry") -input_node = group.nodes.new('NodeGroupInput') -output_node = group.nodes.new('NodeGroupOutput') -output_node.is_active_output = True +modifier = context.object.modifiers.active -input_node.location.x = -200 - input_node.width -output_node.location.x = 200 +if not modifier: +return {'CANCELLED'} -group.links.new(output_node.inputs[0], input_node.outputs[0]) +group = geometry_node_group_empty_new(context) +modifier.node_group = group return {'FINISHED'} classes = ( -NewGeometryNodeTree, +NewGeometryNodeModifier, +NewGeometryNodeTreeAssign, ) diff --git a/release/scripts/startup/bl_ui/space_node.py b/release/scripts/startup/bl_ui/space_node.py index 4cd38831cdf..9ad454d49e1 100644 --- a/release/scripts/startup/bl_ui/space_node.py +++ b/release/scripts/startup/bl_ui/space_node.py @@ -154,7 +154,20 @@ class NODE_HT_header(Header): elif snode.tree_type == 'GeometryNodeTree': NODE_MT_editor_menus.draw_collapsible(context, layout) layout.separator_spacer() -layout.template_ID(snode, "node_tree", new="node.new_geometry_node_tree") + +ob = context.object + +row = layout.row() +if snode.pin: +row.enabled = False +row.template_ID(snode, "node_tree", new="node.new_geometry_node_group_assign") +elif ob: +active_modifier = ob.modifiers.active +if active_modifier and active_modifier.type == "NODES"
[Bf-blender-cvs] [9281a1f4ebc] master: UI: Add new node colors for geometry nodes
Commit: 9281a1f4ebcbbc9ebeb1f11a9f68e45fb2dff5f1 Author: Hans Goudey Date: Tue Dec 1 10:28:29 2020 -0500 Branches: master https://developer.blender.org/rB9281a1f4ebcbbc9ebeb1f11a9f68e45fb2dff5f1 UI: Add new node colors for geometry nodes During the development of the new nodes in the `geometry-nodes` branch the color of the new nodes wasn't considered, so all of the nodes ended up red, the color for "input" nodes. This patch introduces two new colors, one for "Geometry" and one for "Attributes". There are only two attribute nodes currently, but the next sprint will add two more, attribute mix, and sample from texture. The attribute nodes are conceptually different enough from the nodes that modify the geometry that they deserve their own color. Differential Revision: https://developer.blender.org/D9682 === M release/datafiles/userdef/userdef_default_theme.c M release/scripts/presets/interface_theme/blender_light.xml M source/blender/blenkernel/BKE_node.h M source/blender/blenloader/intern/versioning_userdef.c M source/blender/editors/include/UI_resources.h M source/blender/editors/interface/resources.c M source/blender/editors/space_node/node_draw.c M source/blender/makesdna/DNA_userdef_types.h M source/blender/makesrna/intern/rna_userdef.c M source/blender/nodes/function/nodes/node_fn_boolean_math.cc M source/blender/nodes/function/nodes/node_fn_float_compare.cc M source/blender/nodes/geometry/nodes/node_geo_attribute_math.cc M source/blender/nodes/geometry/nodes/node_geo_boolean.cc M source/blender/nodes/geometry/nodes/node_geo_edge_split.cc M source/blender/nodes/geometry/nodes/node_geo_join_geometry.cc M source/blender/nodes/geometry/nodes/node_geo_object_info.cc M source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc M source/blender/nodes/geometry/nodes/node_geo_point_instance.cc M source/blender/nodes/geometry/nodes/node_geo_random_attribute.cc M source/blender/nodes/geometry/nodes/node_geo_subdivision_surface.cc M source/blender/nodes/geometry/nodes/node_geo_transform.cc M source/blender/nodes/geometry/nodes/node_geo_triangulate.cc === diff --git a/release/datafiles/userdef/userdef_default_theme.c b/release/datafiles/userdef/userdef_default_theme.c index 4bfb5151ad8..53e8cd38d02 100644 --- a/release/datafiles/userdef/userdef_default_theme.c +++ b/release/datafiles/userdef/userdef_default_theme.c @@ -840,6 +840,8 @@ const bTheme U_theme_default = { .nodeclass_script = RGBA(0x084d4dff), .nodeclass_pattern = RGBA(0x6c696fff), .nodeclass_layout = RGBA(0x6c696fff), +.nodeclass_geometry = RGBA(0x00d7a4ff), +.nodeclass_attribute = RGBA(0x3f5980ff), .movie = RGBA(0x1a1a1acc), .gp_vertex_size = 3, .gp_vertex = RGBA(0x97979700), diff --git a/release/scripts/presets/interface_theme/blender_light.xml b/release/scripts/presets/interface_theme/blender_light.xml index 25e92386c3e..8ece3b46f5f 100644 --- a/release/scripts/presets/interface_theme/blender_light.xml +++ b/release/scripts/presets/interface_theme/blender_light.xml @@ -818,7 +818,7 @@ metadatabg="#00" metadatatext="#ff" preview_range="#a14d0066" -row_alternate = "#ff0d" +row_alternate="#ff0d" > nodeclass_layout; break; +case TH_NODE_GEOMETRY: + cp = ts->nodeclass_geometry; + break; +case TH_NODE_ATTRIBUTE: + cp = ts->nodeclass_attribute; + break; case TH_NODE_SHADER: cp = ts->nodeclass_shader; break; diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index fb83414e435..fc7fa3a6caa 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -679,6 +679,10 @@ int node_get_colorid(bNode *node) return TH_NODE_PATTERN; case NODE_CLASS_LAYOUT: return TH_NODE_LAYOUT; +case NODE_CLASS_GEOMETRY: + return TH_NODE_GEOMETRY; +case NODE_CLASS_ATTRIBUTE: + return TH_NODE_ATTRIBUTE; default: return TH_NODE; } diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index 885efcb2bea..f5ac6ca4496 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -334,6 +334,7 @@ typedef struct ThemeSpace { unsigned char nodeclass_vector[4], nodeclass_texture[4]; unsigned char nodeclass_shader[4], nodeclass_script[4]; unsigned char nodeclass_pattern[4], nodeclass_layout[4]; + unsigned char nodeclass_ge