[Bf-blender-cvs] [14999945573] master: Fix T66675: Auto-Save override button has no tooltip
Commit: 1445573428c0cb9ae65651d9c3587716105a Author: Campbell Barton Date: Fri Jul 12 15:45:52 2019 +1000 Branches: master https://developer.blender.org/rB1445573428c0cb9ae65651d9c3587716105a Fix T66675: Auto-Save override button has no tooltip === M release/scripts/startup/bl_ui/space_userpref.py M source/blender/editors/space_userpref/userpref_ops.c === diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py index 4fc54de7c4d..2f573d83132 100644 --- a/release/scripts/startup/bl_ui/space_userpref.py +++ b/release/scripts/startup/bl_ui/space_userpref.py @@ -40,17 +40,22 @@ class USERPREF_HT_header(Header): row = layout.row() row.menu("USERPREF_MT_save_load", text="", icon='COLLAPSEMENU') +# Use '_is_startup' so once factory settings are loaded +# this display option will show, since it's confusing if disabling +# the option makes it dissapiers. if prefs.use_preferences_save: -if bpy.app.use_userpref_skip_save_on_exit: -# We should have an 'alert' icon, for now use 'error'. +use_userpref_skip_save_on_exit = bpy.app.use_userpref_skip_save_on_exit +if use_userpref_skip_save_on_exit or getattr(USERPREF_HT_header, "_is_startup", False): +USERPREF_HT_header._is_startup = True + sub = row.row(align=True) +sub.alignment = 'LEFT' props = sub.operator( -"wm.context_toggle", +"preferences.autosave_override_toggle", text="Skip Auto-Save", -icon='CHECKBOX_HLT', +emboss=False, +icon='CHECKBOX_HLT' if use_userpref_skip_save_on_exit else 'CHECKBOX_DEHLT', ) -props.module = "bpy.app" -props.data_path = "use_userpref_skip_save_on_exit" else: sub = row.row(align=True) sub.active = prefs.is_dirty diff --git a/source/blender/editors/space_userpref/userpref_ops.c b/source/blender/editors/space_userpref/userpref_ops.c index bd3ddf18144..c932d537b54 100644 --- a/source/blender/editors/space_userpref/userpref_ops.c +++ b/source/blender/editors/space_userpref/userpref_ops.c @@ -26,6 +26,7 @@ #include "DNA_screen_types.h" #include "BKE_context.h" +#include "BKE_global.h" #include "BKE_main.h" #include "BKE_report.h" @@ -71,7 +72,39 @@ static void PREFERENCES_OT_reset_default_theme(wmOperatorType *ot) /** \} */ +/* */ +/** \name Toggle Auto-Save Override + * + * This operator only exists so there is a useful tool-tip for for adjusting the global flag. + * \{ */ + +static int preferences_autosave_override_toggle_exec(bContext *UNUSED(C), wmOperator *UNUSED(op)) +{ + G.f ^= G_FLAG_USERPREF_NO_SAVE_ON_EXIT; + return OPERATOR_FINISHED; +} + +static void PREFERENCES_OT_autosave_override_toggle(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Toggle Override Auto-Save"; + ot->idname = "PREFERENCES_OT_autosave_override_toggle"; + ot->description = + "The current session has \"Factory Preferences\" loaded " + "which disables automatically saving.\n" + "Disable this to auto-save the preferences"; + + /* callbacks */ + ot->exec = preferences_autosave_override_toggle_exec; + + /* flags */ + ot->flag = OPTYPE_REGISTER; +} + +/** \} */ + void ED_operatortypes_userpref(void) { WM_operatortype_append(PREFERENCES_OT_reset_default_theme); + WM_operatortype_append(PREFERENCES_OT_autosave_override_toggle); } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [f2df5206987] master: Preferences: disable reading preferences for regular file loading
Commit: f2df5206987f691f245c929a7d3b9086d2020c66 Author: Campbell Barton Date: Fri Jul 12 14:58:37 2019 +1000 Branches: master https://developer.blender.org/rBf2df5206987f691f245c929a7d3b9086d2020c66 Preferences: disable reading preferences for regular file loading Although the Auto-Run Python Scripts flag isn't used, this is still a security risk since exclude paths list is. Further this isn't what users would expect when loading a file & only some preferences were being loaded so it's not useful. === M source/blender/windowmanager/intern/wm_files.c === diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index ef957fa03c5..d517622645c 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -634,7 +634,17 @@ bool WM_file_read(bContext *C, const char *filepath, ReportList *reports) /* confusing this global... */ G.relbase_valid = 1; -retval = BKE_blendfile_read(C, filepath, &(const struct BlendFileReadParams){0}, reports); +retval = BKE_blendfile_read( +C, +filepath, +/* Loading preferences when the user intended to load a regular file is a security risk, + * because the excluded path list is also loaded. + * Further it's just confusing if a user loads a file and various preferences change. */ +&(const struct BlendFileReadParams){ +.is_startup = false, +.skip_flags = BLO_READ_SKIP_USERDEF, +}, +reports); /* BKE_file_read sets new Main into context. */ Main *bmain = CTX_data_main(C); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [d75d2860fd4] soc-2019-outliner: Outliner: Support multiple objects for parenting
Commit: d75d2860fd486286016aa58746676ccbb0c7 Author: Nathan Craddock Date: Thu Jul 11 22:45:53 2019 -0600 Branches: soc-2019-outliner https://developer.blender.org/rBd75d2860fd486286016aa58746676ccbb0c7 Outliner: Support multiple objects for parenting Now parents multiple objects in the outliner on drag and drop. This only works for setting an object as the parent, not for armatures, lattices, etc. Will be improved on. === M source/blender/editors/space_outliner/outliner_dragdrop.c === diff --git a/source/blender/editors/space_outliner/outliner_dragdrop.c b/source/blender/editors/space_outliner/outliner_dragdrop.c index d8276aa2bbc..132939a306e 100644 --- a/source/blender/editors/space_outliner/outliner_dragdrop.c +++ b/source/blender/editors/space_outliner/outliner_dragdrop.c @@ -398,8 +398,27 @@ static int parent_drop_invoke(bContext *C, wmOperator *op, const wmEvent *event) } if ((par->type != OB_ARMATURE) && (par->type != OB_CURVE) && (par->type != OB_LATTICE)) { +if (event->custom != EVT_DATA_DRAGDROP) { + return OPERATOR_CANCELLED; +} + +ListBase *lb = event->customdata; +wmDrag *drag = lb->first; + +bool parent_set = false; int partype = 0; -if (ED_object_parent_set(op->reports, C, scene, ob, par, partype, false, false, NULL)) { +for (wmDragID *drag_id = drag->ids.first; drag_id; drag_id = drag_id->next) { + if (GS(drag_id->id->name) == ID_OB) { +Object *object = (Object *)drag_id->id; + +if (ED_object_parent_set( +op->reports, C, scene, object, par, partype, false, false, NULL)) { + parent_set = true; +} + } +} + +if (parent_set) { DEG_relations_tag_update(bmain); WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); WM_event_add_notifier(C, NC_OBJECT | ND_PARENT, NULL); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [de5589f0ff3] soc-2019-outliner: Revert "Keymap: Simplify outliner select keymap"
Commit: de5589f0ff333574e4b1964da9f5a0ec94609546 Author: Nathan Craddock Date: Thu Jul 11 22:29:41 2019 -0600 Branches: soc-2019-outliner https://developer.blender.org/rBde5589f0ff333574e4b1964da9f5a0ec94609546 Revert "Keymap: Simplify outliner select keymap" This reverts most of commit 210600e7f6df7575ad00ebbe4e4ef40be17677d0. === M release/scripts/presets/keyconfig/keymap_data/blender_default.py M source/blender/editors/space_outliner/outliner_select.c === diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py index d33ade70fbb..cf27b309f45 100644 --- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py +++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py @@ -698,13 +698,15 @@ def km_outliner(params): ("outliner.highlight_update", {"type": 'MOUSEMOVE', "value": 'ANY', "any": True}, None), ("outliner.item_rename", {"type": 'LEFTMOUSE', "value": 'DOUBLE_CLICK'}, None), ("outliner.item_activate", {"type": 'LEFTMOUSE', "value": 'CLICK'}, - {"properties": [("deselect_all", not params.legacy)]}), + {"properties": [("extend", False), ("recursive", False), + ("deselect_all", not params.legacy)]}), ("outliner.item_activate", {"type": 'LEFTMOUSE', "value": 'CLICK', "ctrl": True}, - {"properties": [("extend", True), ("deselect_all", not params.legacy)]}), + {"properties": [("extend", True), ("recursive", False), ("deselect_all", not params.legacy)]}), ("outliner.item_activate", {"type": 'LEFTMOUSE', "value": 'CLICK', "shift": True}, - {"properties": [("range", True), ("deselect_all", not params.legacy)]}), + {"properties": [("extend", False), ("range", True), ("recursive", False), + ("deselect_all", not params.legacy)]}), ("outliner.item_activate", {"type": 'LEFTMOUSE', "value": 'CLICK', "alt": True}, - {"properties": [("recursive", True)]}), + {"properties": [("extend", False), ("recursive", True)]}), ("outliner.item_activate", {"type": 'LEFTMOUSE', "value": 'CLICK', "ctrl": True, "alt": True}, {"properties": [("extend", True), ("recursive", True)]}), ("outliner.select_box", {"type": 'B', "value": 'PRESS'}, None), diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c index 6be65b92387..09752bdb08e 100644 --- a/source/blender/editors/space_outliner/outliner_select.c +++ b/source/blender/editors/space_outliner/outliner_select.c @@ -1455,7 +1455,7 @@ void OUTLINER_OT_item_activate(wmOperatorType *ot) ot->poll = ED_operator_outliner_active; PropertyRNA *prop; - RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend selection for activation"); + RNA_def_boolean(ot->srna, "extend", true, "Extend", "Extend selection for activation"); prop = RNA_def_boolean(ot->srna, "range", false, "Range", "Select a range from active element"); RNA_def_property_flag(prop, PROP_SKIP_SAVE); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [e1ce914c1e2] soc-2019-npr: Merge remote-tracking branch 'origin/greasepencil-object' into soc-2019-npr
Commit: e1ce914c1e2932d5e6a82b5e43d6503253c6c4bf Author: YimingWu Date: Fri Jul 12 09:13:44 2019 +0800 Branches: soc-2019-npr https://developer.blender.org/rBe1ce914c1e2932d5e6a82b5e43d6503253c6c4bf Merge remote-tracking branch 'origin/greasepencil-object' into soc-2019-npr === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [aa6c8f609ce] soc-2019-outliner: Outliner: Disable synced selection in certain modes
Commit: aa6c8f609ce4d9312818910f079c4cfea280c635 Author: Nathan Craddock Date: Thu Jul 11 17:13:05 2019 -0600 Branches: soc-2019-outliner https://developer.blender.org/rBaa6c8f609ce4d9312818910f079c4cfea280c635 Outliner: Disable synced selection in certain modes Certain display modes don't make sense, or don't work well for selection syncing. This disables syncing in Blender Libraries, Data API, and Orphans view. === M release/scripts/startup/bl_ui/space_outliner.py M source/blender/editors/space_outliner/outliner_draw.c M source/blender/editors/space_outliner/outliner_sync.c === diff --git a/release/scripts/startup/bl_ui/space_outliner.py b/release/scripts/startup/bl_ui/space_outliner.py index b5afe72aef9..dadba32d952 100644 --- a/release/scripts/startup/bl_ui/space_outliner.py +++ b/release/scripts/startup/bl_ui/space_outliner.py @@ -46,8 +46,9 @@ class OUTLINER_HT_header(Header): layout.separator_spacer() -row = layout.row(align=True) -row.prop(space, "use_sync_selection", text="") +if display_mode not in {'LIBRARIES', 'DATA_API', 'ORPHAN_DATA'}: +row = layout.row(align=True) +row.prop(space, "use_sync_selection", text="") row = layout.row(align=True) if display_mode in {'SCENES', 'VIEW_LAYER'}: diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index 142925b5b5c..bab62f68228 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -3595,7 +3595,8 @@ void draw_outliner(const bContext *C) outliner_build_tree(mainvar, scene, view_layer, soops, ar); // always /* Sync selection state from view layer or clean outliner if needed */ - if (soops->flag & SO_SYNC_SELECTION) { + if (!ELEM(soops->outlinevis, SO_LIBRARIES, SO_DATA_API, SO_ID_ORPHANS) && + soops->flag & SO_SYNC_SELECTION) { outliner_sync_selection(C, soops); } else { diff --git a/source/blender/editors/space_outliner/outliner_sync.c b/source/blender/editors/space_outliner/outliner_sync.c index c6789337165..10fa564f94b 100644 --- a/source/blender/editors/space_outliner/outliner_sync.c +++ b/source/blender/editors/space_outliner/outliner_sync.c @@ -223,6 +223,11 @@ static void outliner_sync_selection_to_outliner(const bContext *C, /* Set clean outliner and mark other outliners for syncing */ void outliner_select_sync(bContext *C, SpaceOutliner *soops) { + /* Don't sync in certain outliner display modes */ + if (ELEM(soops->outlinevis, SO_LIBRARIES, SO_DATA_API, SO_ID_ORPHANS)) { +return; + } + Scene *scene = CTX_data_scene(C); puts("Outliner select... Mark other outliners as dirty for syncing"); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [210600e7f6d] soc-2019-outliner: Keymap: Simplify outliner select keymap
Commit: 210600e7f6df7575ad00ebbe4e4ef40be17677d0 Author: Nathan Craddock Date: Thu Jul 11 16:16:16 2019 -0600 Branches: soc-2019-outliner https://developer.blender.org/rB210600e7f6df7575ad00ebbe4e4ef40be17677d0 Keymap: Simplify outliner select keymap Changed extend default and simplified the keymap === M release/scripts/presets/keyconfig/keymap_data/blender_default.py M source/blender/editors/space_outliner/outliner_select.c === diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py index 00b1e5720a2..d33ade70fbb 100644 --- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py +++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py @@ -698,14 +698,13 @@ def km_outliner(params): ("outliner.highlight_update", {"type": 'MOUSEMOVE', "value": 'ANY', "any": True}, None), ("outliner.item_rename", {"type": 'LEFTMOUSE', "value": 'DOUBLE_CLICK'}, None), ("outliner.item_activate", {"type": 'LEFTMOUSE', "value": 'CLICK'}, - {"properties": [("extend", False), ("recursive", False), - ("deselect_all", not params.legacy)]}), + {"properties": [("deselect_all", not params.legacy)]}), ("outliner.item_activate", {"type": 'LEFTMOUSE', "value": 'CLICK', "ctrl": True}, - {"properties": [("extend", True), ("recursive", False)]}), + {"properties": [("extend", True), ("deselect_all", not params.legacy)]}), ("outliner.item_activate", {"type": 'LEFTMOUSE', "value": 'CLICK', "shift": True}, - {"properties": [("extend", False), ("range", True), ("recursive", False)]}), + {"properties": [("range", True), ("deselect_all", not params.legacy)]}), ("outliner.item_activate", {"type": 'LEFTMOUSE', "value": 'CLICK', "alt": True}, - {"properties": [("extend", False), ("recursive", True)]}), + {"properties": [("recursive", True)]}), ("outliner.item_activate", {"type": 'LEFTMOUSE', "value": 'CLICK', "ctrl": True, "alt": True}, {"properties": [("extend", True), ("recursive", True)]}), ("outliner.select_box", {"type": 'B', "value": 'PRESS'}, None), diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c index 269883ded5a..6be65b92387 100644 --- a/source/blender/editors/space_outliner/outliner_select.c +++ b/source/blender/editors/space_outliner/outliner_select.c @@ -277,8 +277,8 @@ static eOLDrawState active_viewlayer(bContext *C, /** * Select object tree: - * CTRL+LMB: Select/Deselect object and all children. - * CTRL+SHIFT+LMB: Add/Remove object and all children. + * ALT+LMB: Select/Deselect object and all children. + * CTRL+ALT+LMB: Add/Remove object and all children. */ static void do_outliner_object_select_recursive(ViewLayer *view_layer, Object *ob_parent, @@ -1455,7 +1455,7 @@ void OUTLINER_OT_item_activate(wmOperatorType *ot) ot->poll = ED_operator_outliner_active; PropertyRNA *prop; - RNA_def_boolean(ot->srna, "extend", true, "Extend", "Extend selection for activation"); + RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend selection for activation"); prop = RNA_def_boolean(ot->srna, "range", false, "Range", "Select a range from active element"); RNA_def_property_flag(prop, PROP_SKIP_SAVE); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [a78b73ac6f2] soc-2019-outliner: Outliner: Remove warnings
Commit: a78b73ac6f2107c762f47de531af5e6564f40b6b Author: Nathan Craddock Date: Thu Jul 11 16:15:24 2019 -0600 Branches: soc-2019-outliner https://developer.blender.org/rBa78b73ac6f2107c762f47de531af5e6564f40b6b Outliner: Remove warnings Left a few unused variables from removing old code === M source/blender/editors/space_outliner/outliner_select.c === diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c index dc32530ea57..269883ded5a 100644 --- a/source/blender/editors/space_outliner/outliner_select.c +++ b/source/blender/editors/space_outliner/outliner_select.c @@ -1129,9 +1129,6 @@ static void do_outliner_item_activate_tree_element(bContext *C, const bool extend, const bool recursive) { - TreeElement *te_active = outliner_find_element_with_flag(>tree, TSE_ACTIVE); - Object *obact = OBACT(view_layer); - /* Always makes active object, except for some specific types. */ if (ELEM(tselem->type, TSE_SEQUENCE, ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [b73fc56dfad] soc-2019-outliner: Outliner: Cleanup sync code
Commit: b73fc56dfadb0339c9f06a48d773422e4be4848c Author: Nathan Craddock Date: Thu Jul 11 15:27:58 2019 -0600 Branches: soc-2019-outliner https://developer.blender.org/rBb73fc56dfadb0339c9f06a48d773422e4be4848c Outliner: Cleanup sync code Removed some commented code === M source/blender/editors/space_outliner/outliner_sync.c === diff --git a/source/blender/editors/space_outliner/outliner_sync.c b/source/blender/editors/space_outliner/outliner_sync.c index b6545c9fbb3..56686d15461 100644 --- a/source/blender/editors/space_outliner/outliner_sync.c +++ b/source/blender/editors/space_outliner/outliner_sync.c @@ -228,7 +228,6 @@ void outliner_select_sync(bContext *C, SpaceOutliner *soops) puts("Outliner select... Mark other outliners as dirty for syncing"); outliner_sync_selection_from_outliner(C, >tree); - // outliner_sync_selection_to_sequencer(C, >tree); sync_select_dirty_flag = SYNC_SELECT_NONE; /* Don't need to mark self as dirty here... */ @@ -260,11 +259,6 @@ void outliner_sync_selection(const bContext *C, SpaceOutliner *soops) outliner_sync_selection_to_outliner(C, view_layer, soops, >tree); -// if (soops->outlinevis == SO_SEQUENCE) { -// printf("\tSyncing sequences...\n"); -// outliner_sync_selection_from_sequencer(C, >tree); -// } - soops->flag &= ~SO_IS_DIRTY; } } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [d2ea9f7beda] soc-2019-outliner: Outliner: Improve walk select
Commit: d2ea9f7bedad6d32b9e0f5d82ec9f66a39897362 Author: Nathan Craddock Date: Thu Jul 11 15:40:45 2019 -0600 Branches: soc-2019-outliner https://developer.blender.org/rBd2ea9f7bedad6d32b9e0f5d82ec9f66a39897362 Outliner: Improve walk select Now that walk select doesn't start from active, some selection operators and syncing needed to set the walk element. So after some select operators, set the walk element alongside the active element === M source/blender/editors/space_outliner/outliner_select.c M source/blender/editors/space_outliner/outliner_sync.c === diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c index 7258d6f122c..dc32530ea57 100644 --- a/source/blender/editors/space_outliner/outliner_select.c +++ b/source/blender/editors/space_outliner/outliner_select.c @@ -1288,16 +1288,17 @@ static void do_outliner_range_select_recursive(ListBase *lb, static void do_outliner_range_select(SpaceOutliner *soops, TreeElement *cursor) { TreeElement *active = outliner_find_element_with_flag(>tree, TSE_ACTIVE); + outliner_flag_set(>tree, TSE_WALK, false); if (!active) { -TREESTORE(cursor)->flag |= TSE_SELECTED | TSE_ACTIVE; +TREESTORE(cursor)->flag |= TSE_SELECTED | TSE_ACTIVE | TSE_WALK; return; } TreeStoreElem *tselem = TREESTORE(active); const bool active_selected = (tselem->flag & TSE_SELECTED); - outliner_flag_set(>tree, TSE_SELECTED, false); + outliner_flag_set(>tree, TSE_SELECTED | TSE_WALK, false); /* Select active if under cursor */ if (active == cursor) { @@ -1308,7 +1309,7 @@ static void do_outliner_range_select(SpaceOutliner *soops, TreeElement *cursor) /* If active is not selected, just select the element under the cursor */ if (!active_selected || !outliner_is_element_visible(active)) { tselem->flag &= ~TSE_ACTIVE; -TREESTORE(cursor)->flag |= TSE_SELECTED | TSE_ACTIVE; +TREESTORE(cursor)->flag |= TSE_SELECTED | TSE_ACTIVE | TSE_WALK; return; } diff --git a/source/blender/editors/space_outliner/outliner_sync.c b/source/blender/editors/space_outliner/outliner_sync.c index 56686d15461..c6789337165 100644 --- a/source/blender/editors/space_outliner/outliner_sync.c +++ b/source/blender/editors/space_outliner/outliner_sync.c @@ -190,7 +190,7 @@ static void outliner_sync_selection_to_outliner(const bContext *C, Bone *bone = pchan->bone; if (pchan == pchan_active) { -tselem->flag |= TSE_ACTIVE; +tselem->flag |= TSE_ACTIVE | TSE_WALK; } if (bone->flag & BONE_SELECTED) { ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [e0bd7e67c12] soc-2019-outliner: Outliner: prevent bone selection when sync select disabled
Commit: e0bd7e67c12d46dd178e939899ab0d8674bc9670 Author: Nathan Craddock Date: Thu Jul 11 13:46:23 2019 -0600 Branches: soc-2019-outliner https://developer.blender.org/rBe0bd7e67c12d46dd178e939899ab0d8674bc9670 Outliner: prevent bone selection when sync select disabled More refinements to the synced selection code === M source/blender/editors/space_outliner/outliner_select.c M source/blender/editors/space_outliner/outliner_sync.c === diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c index 27fae072b1f..7258d6f122c 100644 --- a/source/blender/editors/space_outliner/outliner_select.c +++ b/source/blender/editors/space_outliner/outliner_select.c @@ -1132,27 +1132,24 @@ static void do_outliner_item_activate_tree_element(bContext *C, TreeElement *te_active = outliner_find_element_with_flag(>tree, TSE_ACTIVE); Object *obact = OBACT(view_layer); - if (tselem->id && OB_DATA_SUPPORT_EDITMODE(te->idcode)) { + /* Always makes active object, except for some specific types. */ + if (ELEM(tselem->type, + TSE_SEQUENCE, + TSE_SEQ_STRIP, + TSE_SEQUENCE_DUP, + TSE_EBONE, + TSE_LAYER_COLLECTION)) { +/* Note about TSE_EBONE: In case of a same ID_AR datablock shared among several objects, + * we do not want to switch out of edit mode (see T48328 for details). */ + } + else if (tselem->id && OB_DATA_SUPPORT_EDITMODE(te->idcode)) { /* Support edit-mode toggle, keeping the active object as is. */ } else if (tselem->type == TSE_POSE_BASE) { /* Support pose mode toggle, keeping the active object as is. */ } - else if ((obact->mode != OB_MODE_OBJECT) && (te != te_active)) { -/* Select rather than activate other elements when ouside of object mode */ -return; - } - /* Always makes active object, except for some specific types. */ - else if (ELEM(tselem->type, -TSE_SEQUENCE, -TSE_SEQ_STRIP, -TSE_SEQUENCE_DUP, -TSE_EBONE, -TSE_LAYER_COLLECTION)) { -/* Note about TSE_EBONE: In case of a same ID_AR datablock shared among several objects, - * we do not want to switch out of edit mode (see T48328 for details). */ - } else if (soops->flag & SO_SYNC_SELECTION) { +/* Only activate when synced selection is enabled */ tree_element_set_active_object(C, scene, view_layer, @@ -1230,7 +1227,7 @@ static void do_outliner_item_activate_tree_element(bContext *C, tree_element_active(C, scene, view_layer, soops, te, OL_SETSEL_NORMAL, false); } } - else { + else if (soops->flag & SO_SYNC_SELECTION) { tree_element_type_active(C, scene, view_layer, diff --git a/source/blender/editors/space_outliner/outliner_sync.c b/source/blender/editors/space_outliner/outliner_sync.c index e82d88cd5c9..b6545c9fbb3 100644 --- a/source/blender/editors/space_outliner/outliner_sync.c +++ b/source/blender/editors/space_outliner/outliner_sync.c @@ -149,7 +149,8 @@ static void outliner_sync_selection_to_outliner(const bContext *C, { Scene *scene = CTX_data_scene(C); Object *obact = OBACT(view_layer); - Sequence *seq_act = BKE_sequencer_active_get(scene); + Sequence *sequence_active = BKE_sequencer_active_get(scene); + bPoseChannel *pchan_active = CTX_data_active_pose_bone(C); for (TreeElement *te = tree->first; te; te = te->next) { TreeStoreElem *tselem = TREESTORE(te); @@ -188,6 +189,10 @@ static void outliner_sync_selection_to_outliner(const bContext *C, bPoseChannel *pchan = (bPoseChannel *)te->directdata; Bone *bone = pchan->bone; + if (pchan == pchan_active) { +tselem->flag |= TSE_ACTIVE; + } + if (bone->flag & BONE_SELECTED) { tselem->flag |= TSE_SELECTED; } @@ -199,7 +204,7 @@ static void outliner_sync_selection_to_outliner(const bContext *C, printf("\t\tSyncing a sequence: %s\n", te->name); Sequence *seq = (Sequence *)tselem->id; - if (seq == seq_act) { + if (seq == sequence_active) { outliner_element_activate(soops, tselem); } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [09872df1c71] soc-2019-openxr: Check runtime DirectX requirements for graphics binding too
Commit: 09872df1c7141ee010da4071f7f7faa2ca1fbc2c Author: Julian Eisel Date: Thu Jul 11 21:05:13 2019 +0200 Branches: soc-2019-openxr https://developer.blender.org/rB09872df1c7141ee010da4071f7f7faa2ca1fbc2c Check runtime DirectX requirements for graphics binding too === M intern/ghost/intern/GHOST_IXrGraphicsBinding.h M intern/ghost/intern/GHOST_XrGraphicsBinding.cpp === diff --git a/intern/ghost/intern/GHOST_IXrGraphicsBinding.h b/intern/ghost/intern/GHOST_IXrGraphicsBinding.h index 66073643317..e426312ba30 100644 --- a/intern/ghost/intern/GHOST_IXrGraphicsBinding.h +++ b/intern/ghost/intern/GHOST_IXrGraphicsBinding.h @@ -22,7 +22,9 @@ #define __GHOST_IXRGRAPHICSBINDING_H__ #include +#include #include + #include "GHOST_Xr_openxr_includes.h" class GHOST_IXrGraphicsBinding { diff --git a/intern/ghost/intern/GHOST_XrGraphicsBinding.cpp b/intern/ghost/intern/GHOST_XrGraphicsBinding.cpp index b0b53888a80..8120dccfcd7 100644 --- a/intern/ghost/intern/GHOST_XrGraphicsBinding.cpp +++ b/intern/ghost/intern/GHOST_XrGraphicsBinding.cpp @@ -152,12 +152,26 @@ class GHOST_XrGraphicsBindingOpenGL : public GHOST_IXrGraphicsBinding { #ifdef WIN32 class GHOST_XrGraphicsBindingD3D : public GHOST_IXrGraphicsBinding { public: - bool checkVersionRequirements(GHOST_Context * /*ghost_ctx*/, -XrInstance /*instance*/, -XrSystemId /*system_id*/, -std::string * /*r_requirement_info*/) const override + bool checkVersionRequirements(GHOST_Context *ghost_ctx, +XrInstance instance, +XrSystemId system_id, +std::string *r_requirement_info) const override { -// TODO + +GHOST_ContextD3D *ctx_dx = static_cast(ghost_ctx); +XrGraphicsRequirementsD3D11KHR gpu_requirements{XR_TYPE_GRAPHICS_REQUIREMENTS_D3D11_KHR}; + +xrGetD3D11GraphicsRequirementsKHR(instance, system_id, _requirements); + +if (r_requirement_info) { + std::ostringstream strstream; + strstream << "Min DirectX 11 Feature Level " << gpu_requirements.minFeatureLevel +<< std::endl; + + *r_requirement_info = std::move(strstream.str()); +} + +return ctx_dx->m_device->GetFeatureLevel() >= gpu_requirements.minFeatureLevel; } void initFromGhostContext(GHOST_Context *ghost_ctx) override ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [67d6399da66] soc-2019-openxr: Check runtime OpenGL requirements prior to creating graphics binding
Commit: 67d6399da6602dcf5fba75b5642a750d8b973182 Author: Julian Eisel Date: Thu Jul 11 20:29:18 2019 +0200 Branches: soc-2019-openxr https://developer.blender.org/rB67d6399da6602dcf5fba75b5642a750d8b973182 Check runtime OpenGL requirements prior to creating graphics binding DirectX will need these checks too. Also fix warnings due to wrong printf formatting. === M intern/ghost/intern/GHOST_IXrGraphicsBinding.h M intern/ghost/intern/GHOST_XrContext.cpp M intern/ghost/intern/GHOST_XrGraphicsBinding.cpp M intern/ghost/intern/GHOST_XrSession.cpp === diff --git a/intern/ghost/intern/GHOST_IXrGraphicsBinding.h b/intern/ghost/intern/GHOST_IXrGraphicsBinding.h index 6b1978bcf7d..66073643317 100644 --- a/intern/ghost/intern/GHOST_IXrGraphicsBinding.h +++ b/intern/ghost/intern/GHOST_IXrGraphicsBinding.h @@ -39,6 +39,17 @@ class GHOST_IXrGraphicsBinding { #endif } oxr_binding; + /** + * Does __not__ require this object is initialized (can be called prior to + * #initFromGhostContext). It's actually meant to be called first. + * + * \param r_requirement_info Return argument to retrieve an informal string on the requirements + * to be met. Useful for error/debug messages. + */ + virtual bool checkVersionRequirements(class GHOST_Context *ghost_ctx, +XrInstance instance, +XrSystemId system_id, +std::string *r_requirement_info) const = 0; virtual void initFromGhostContext(class GHOST_Context *ghost_ctx) = 0; virtual bool chooseSwapchainFormat(const std::vector _formats, int64_t *r_result) const = 0; diff --git a/intern/ghost/intern/GHOST_XrContext.cpp b/intern/ghost/intern/GHOST_XrContext.cpp index 2d740ca8705..0db55f6556f 100644 --- a/intern/ghost/intern/GHOST_XrContext.cpp +++ b/intern/ghost/intern/GHOST_XrContext.cpp @@ -116,7 +116,7 @@ void GHOST_XrContext::printInstanceInfo() XrInstanceProperties instance_properties{XR_TYPE_INSTANCE_PROPERTIES}; xrGetInstanceProperties(m_oxr->instance, _properties); - printf("Connected to OpenXR runtime: %s (Version %i.%i.%i)\n", + printf("Connected to OpenXR runtime: %s (Version %u.%u.%u)\n", instance_properties.runtimeName, XR_VERSION_MAJOR(instance_properties.runtimeVersion), XR_VERSION_MINOR(instance_properties.runtimeVersion), diff --git a/intern/ghost/intern/GHOST_XrGraphicsBinding.cpp b/intern/ghost/intern/GHOST_XrGraphicsBinding.cpp index aa047f92fd1..b0b53888a80 100644 --- a/intern/ghost/intern/GHOST_XrGraphicsBinding.cpp +++ b/intern/ghost/intern/GHOST_XrGraphicsBinding.cpp @@ -20,6 +20,7 @@ #include #include +#include #if defined(WITH_X11) # include "GHOST_ContextGLX.h" @@ -54,6 +55,38 @@ static bool choose_swapchain_format_from_candidates(std::vector gpu_bin class GHOST_XrGraphicsBindingOpenGL : public GHOST_IXrGraphicsBinding { public: + bool checkVersionRequirements(GHOST_Context *ghost_ctx, +XrInstance instance, +XrSystemId system_id, +std::string *r_requirement_info) const override + { +#if defined(WITH_X11) +GHOST_ContextGLX *ctx_gl = static_cast(ghost_ctx); +#else +GHOST_ContextWGL *ctx_gl = static_cast(ghost_ctx); +#endif +XrGraphicsRequirementsOpenGLKHR gpu_requirements{XR_TYPE_GRAPHICS_REQUIREMENTS_OPENGL_KHR}; +const uint32_t gl_version = XR_MAKE_VERSION( +ctx_gl->m_contextMajorVersion, ctx_gl->m_contextMinorVersion, 0); + +xrGetOpenGLGraphicsRequirementsKHR(instance, system_id, _requirements); + +if (r_requirement_info) { + std::ostringstream strstream; + strstream << "Min OpenGL version " +<< XR_VERSION_MAJOR(gpu_requirements.minApiVersionSupported) << "." +<< XR_VERSION_MINOR(gpu_requirements.minApiVersionSupported) << std::endl; + strstream << "Max OpenGL version " +<< XR_VERSION_MAJOR(gpu_requirements.maxApiVersionSupported) << "." +<< XR_VERSION_MINOR(gpu_requirements.maxApiVersionSupported) << std::endl; + + *r_requirement_info = std::move(strstream.str()); +} + +return (gl_version >= gpu_requirements.minApiVersionSupported) && + (gl_version <= gpu_requirements.maxApiVersionSupported); + } + void initFromGhostContext(GHOST_Context *ghost_ctx) override { #if defined(WITH_X11) @@ -119,6 +152,14 @@ class GHOST_XrGraphicsBindingOpenGL : public GHOST_IXrGraphicsBinding { #ifdef WIN32 class GHOST_XrGraphicsBindingD3D : public GHOST_IXrGraphicsBinding { public: + bool checkVersionRequirements(GHOST_Context * /*ghost_ctx*/, +XrInstance /*instance*/, +
[Bf-blender-cvs] [c29724912bc] soc-2019-openxr: Merge branch 'master' into soc-2019-openxr
Commit: c29724912bc694f2d2a6e49c31e06968d7f7ba2b Author: Julian Eisel Date: Thu Jul 11 19:26:30 2019 +0200 Branches: soc-2019-openxr https://developer.blender.org/rBc29724912bc694f2d2a6e49c31e06968d7f7ba2b Merge branch 'master' into soc-2019-openxr === === diff --cc source/blender/windowmanager/intern/wm_window.c index 4c0f66f714a,d17b8817691..42c372855ca --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@@ -708,77 -685,63 +708,83 @@@ static void wm_window_ghostwindow_ensur #endif } - for (win = wm->windows.first; win; win = win->next) { -if (win->ghostwin == NULL) { - if ((win->sizex == 0) || (wm_init_state.override_flag & WIN_OVERRIDE_GEOM)) { -win->posx = wm_init_state.start_x; -win->posy = wm_init_state.start_y; -win->sizex = wm_init_state.size_x; -win->sizey = wm_init_state.size_y; - -if (wm_init_state.override_flag & WIN_OVERRIDE_GEOM) { - win->windowstate = GHOST_kWindowStateNormal; - wm_init_state.override_flag &= ~WIN_OVERRIDE_GEOM; -} -else { - win->windowstate = GHOST_WINDOW_STATE_DEFAULT; -} - } + if (win->ghostwin == NULL) { +if ((win->sizex == 0) || (wm_init_state.override_flag & WIN_OVERRIDE_GEOM)) { + win->posx = wm_init_state.start_x; + win->posy = wm_init_state.start_y; + win->sizex = wm_init_state.size_x; + win->sizey = wm_init_state.size_y; - if (wm_init_state.override_flag & WIN_OVERRIDE_WINSTATE) { -win->windowstate = wm_init_state.windowstate; -wm_init_state.override_flag &= ~WIN_OVERRIDE_WINSTATE; + if (wm_init_state.override_flag & WIN_OVERRIDE_GEOM) { +win->windowstate = GHOST_kWindowStateNormal; +wm_init_state.override_flag &= ~WIN_OVERRIDE_GEOM; } - - /* without this, cursor restore may fail, T45456 */ - if (win->cursor == 0) { -win->cursor = CURSOR_STD; + else { +win->windowstate = GHOST_WINDOW_STATE_DEFAULT; } - - wm_window_ghostwindow_add(wm, "Blender", win); } -if (win->ghostwin != NULL) { - /* If we have no ghostwin this is a buggy window that should be removed. - * However we still need to initialize it correctly so the screen doesn't hang. */ +if (wm_init_state.override_flag & WIN_OVERRIDE_WINSTATE) { + win->windowstate = wm_init_state.windowstate; + wm_init_state.override_flag &= ~WIN_OVERRIDE_WINSTATE; +} - /* happens after fileread */ - wm_window_ensure_eventstate(win); +/* without this, cursor restore may fail, T45456 */ +if (win->cursor == 0) { + win->cursor = CURSOR_STD; } -/* add keymap handlers (1 handler for all keys in map!) */ -keymap = WM_keymap_ensure(wm->defaultconf, "Window", 0, 0); -WM_event_add_keymap_handler(>handlers, keymap); +wm_window_ghostwindow_add(wm, "Blender", win, context_type); + } - /* happens after fileread */ - wm_window_ensure_eventstate(win); + -keymap = WM_keymap_ensure(wm->defaultconf, "Screen", 0, 0); -WM_event_add_keymap_handler(>handlers, keymap); ++ if (win->ghostwin != NULL) { ++/* If we have no ghostwin this is a buggy window that should be removed. ++ * However we still need to initialize it correctly so the screen doesn't hang. */ + -keymap = WM_keymap_ensure(wm->defaultconf, "Screen Editing", 0, 0); -WM_event_add_keymap_handler(>modalhandlers, keymap); ++/* happens after fileread */ ++wm_window_ensure_eventstate(win); ++ } -/* add drop boxes */ -{ - ListBase *lb = WM_dropboxmap_find("Window", 0, 0); - WM_event_add_dropbox_handler(>handlers, lb); -} -wm_window_title(wm, win); + /* add keymap handlers (1 handler for all keys in map!) */ + keymap = WM_keymap_ensure(wm->defaultconf, "Window", 0, 0); + WM_event_add_keymap_handler(>handlers, keymap); -/* add topbar */ -ED_screen_global_areas_refresh(win); + keymap = WM_keymap_ensure(wm->defaultconf, "Screen", 0, 0); + WM_event_add_keymap_handler(>handlers, keymap); + + keymap = WM_keymap_ensure(wm->defaultconf, "Screen Editing", 0, 0); + WM_event_add_keymap_handler(>modalhandlers, keymap); + + /* add drop boxes */ + { +ListBase *lb = WM_dropboxmap_find("Window", 0, 0); +WM_event_add_dropbox_handler(>handlers, lb); + } + wm_window_title(wm, win); + + /* add topbar */ + ED_screen_global_areas_refresh(win); +} + +/** + * Initialize #wmWindow without ghostwin, open these and clear. + * + * window size is read from window, if 0 it uses prefsize + * called in #WM_check, also inits stuff after file read. + * + * \warning + * After running, 'win->ghostwin' can be NULL in rare
[Bf-blender-cvs] [137397836a6] soc-2019-outliner: Merge branch 'master' into soc-2019-outliner
Commit: 137397836a6bd1446d3921c9fa8b9224bf44cbc5 Author: Nathan Craddock Date: Thu Jul 11 11:58:52 2019 -0600 Branches: soc-2019-outliner https://developer.blender.org/rB137397836a6bd1446d3921c9fa8b9224bf44cbc5 Merge branch 'master' into soc-2019-outliner === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [c90bc0175cf] soc-2019-outliner: Outliner: Fix setting of active element from the outliner
Commit: c90bc0175cf307d691e7d9ab887948730aa6df02 Author: Nathan Craddock Date: Thu Jul 11 11:56:42 2019 -0600 Branches: soc-2019-outliner https://developer.blender.org/rBc90bc0175cf307d691e7d9ab887948730aa6df02 Outliner: Fix setting of active element from the outliner The active element was being synced, which incorrectly failed when clicking on object data and other non-base elements in the outliner. Now it leaves activation to operators in the outliner rather than syncing to avoid code duplication. === M source/blender/editors/space_outliner/outliner_draw.c M source/blender/editors/space_outliner/outliner_intern.h M source/blender/editors/space_outliner/outliner_select.c M source/blender/editors/space_outliner/outliner_sync.c === diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index 0b83271b741..142925b5b5c 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -3346,8 +3346,7 @@ static void outliner_draw_highlights_recursive(unsigned pos, const int start_y = *io_start_y; /* selection status */ -if ((soops->flag & SO_SYNC_SELECTION) && (tselem->flag & TSE_ACTIVE) && -(tselem->flag & TSE_SELECTED)) { +if ((tselem->flag & TSE_ACTIVE) && (tselem->flag & TSE_SELECTED)) { immUniformColor4fv(col_active); immRecti(pos, 0, start_y, (int)ar->v2d.cur.xmax, start_y + UI_UNIT_Y); } diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h index a9e9185e7f6..fd0489c13cc 100644 --- a/source/blender/editors/space_outliner/outliner_intern.h +++ b/source/blender/editors/space_outliner/outliner_intern.h @@ -261,6 +261,8 @@ void outliner_object_mode_toggle(struct bContext *C, ViewLayer *view_layer, Base *base); +void outliner_element_activate(struct SpaceOutliner *soops, struct TreeStoreElem *tselem); + /* outliner_edit.c -- */ typedef void (*outliner_operation_cb)(struct bContext *C, struct ReportList *, diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c index 9202b8f87a7..27fae072b1f 100644 --- a/source/blender/editors/space_outliner/outliner_select.c +++ b/source/blender/editors/space_outliner/outliner_select.c @@ -1108,6 +1108,12 @@ eOLDrawState tree_element_type_active(bContext *C, /* */ +void outliner_element_activate(SpaceOutliner *soops, TreeStoreElem *tselem) +{ + outliner_flag_set(>tree, TSE_ACTIVE | TSE_WALK, false); + tselem->flag |= TSE_ACTIVE | TSE_WALK; +} + /** * Action when clicking to activate an item (typically under the mouse cursor), * but don't do any cursor intersection checks. @@ -1158,8 +1164,7 @@ static void do_outliner_item_activate_tree_element(bContext *C, } /* Mark as active in the outliner */ - outliner_flag_set(>tree, TSE_ACTIVE, false); - tselem->flag |= TSE_ACTIVE; + outliner_element_activate(soops, tselem); if (tselem->type == 0) { // the lib blocks /* editmode? */ @@ -1247,7 +1252,8 @@ void outliner_item_select(SpaceOutliner *soops, const bool toggle) { TreeStoreElem *tselem = TREESTORE(te); - const short new_flag = toggle ? (tselem->flag ^ TSE_SELECTED) : (tselem->flag | TSE_SELECTED); + const short new_flag = (toggle && (tselem->flag & TSE_ACTIVE)) ? (tselem->flag ^ TSE_SELECTED) : + (tselem->flag | TSE_SELECTED); if (extend == false) { outliner_flag_set(>tree, TSE_SELECTED, false); @@ -1274,7 +1280,7 @@ static void do_outliner_range_select_recursive(ListBase *lb, TREESTORE(te)->flag |= TSE_SELECTED; } -/* Don't look at closed elements */ +/* Don't look inside closed elements */ if (!(TREESTORE(te)->flag & TSE_CLOSED)) { do_outliner_range_select_recursive(>subtree, active, cursor, selecting); } @@ -1296,9 +1302,9 @@ static void do_outliner_range_select(SpaceOutliner *soops, TreeElement *cursor) outliner_flag_set(>tree, TSE_SELECTED, false); - /* Only select active if under cursor */ + /* Select active if under cursor */ if (active == cursor) { -TREESTORE(cursor)->flag |= TSE_SELECTED | TSE_ACTIVE; +TREESTORE(cursor)->flag |= TSE_SELECTED; return; } @@ -1721,6 +1727,8 @@ static TreeElement *find_walk_select_start_element(SpaceOutliner *soops, bool *c /* If walk element is not visible, set that element's first visible parent as walk element */ if
[Bf-blender-cvs] [9ca6ac79326] sybren-usd: USD: Add missing curly braces
Commit: 9ca6ac793267dd581f5efd02832baf382ee2d117 Author: Sybren A. Stüvel Date: Thu Jul 11 17:25:36 2019 +0200 Branches: sybren-usd https://developer.blender.org/rB9ca6ac793267dd581f5efd02832baf382ee2d117 USD: Add missing curly braces No functional changes. === M source/blender/usd/intern/usd_capi.cc === diff --git a/source/blender/usd/intern/usd_capi.cc b/source/blender/usd/intern/usd_capi.cc index a39f7a2f98d..36bc20aae0f 100644 --- a/source/blender/usd/intern/usd_capi.cc +++ b/source/blender/usd/intern/usd_capi.cc @@ -122,8 +122,9 @@ static void export_startjob(void *customdata, short *stop, short *do_update, flo float progress_per_frame = 0.8f / std::max(1, (scene->r.efra - scene->r.sfra + 1)); for (float frame = scene->r.sfra; frame <= scene->r.efra; frame++) { -if (G.is_break) +if (G.is_break) { break; +} printf("\033[35;1mFRAME\033[0m %f\n", frame); // Update the scene for the next frame to render. ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [ae571881918] greasepencil-object: Merge branch 'master' into greasepencil-object
Commit: ae5718819186a5c8f91ecabcad3e35a4e5121ecd Author: Antonioya Date: Thu Jul 11 17:21:22 2019 +0200 Branches: greasepencil-object https://developer.blender.org/rBae5718819186a5c8f91ecabcad3e35a4e5121ecd Merge branch 'master' into greasepencil-object === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [5b7f49edc4a] functions: comment in stringmap
Commit: 5b7f49edc4a927f05e2498d24f0b8402c317d67e Author: Jacques Lucke Date: Thu Jul 11 16:34:53 2019 +0200 Branches: functions https://developer.blender.org/rB5b7f49edc4a927f05e2498d24f0b8402c317d67e comment in stringmap === M source/blender/blenlib/BLI_string_map.hpp === diff --git a/source/blender/blenlib/BLI_string_map.hpp b/source/blender/blenlib/BLI_string_map.hpp index bac3698feb1..5b5ba0e9697 100644 --- a/source/blender/blenlib/BLI_string_map.hpp +++ b/source/blender/blenlib/BLI_string_map.hpp @@ -1,3 +1,29 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/** \file + * \ingroup bli + * + * This tries to solve the issue that a normal map with std::string as key might do many + * allocations when the keys are longer than 16 bytes (the usual small string optimization size). + * + * For now this still uses std::string, but having this abstraction in place will make it easier to + * make it more efficient later on. Also, even if we will never implement this optimization, having + * a special map with string keys can be quite handy. */ + #pragma once #include "BLI_small_map.hpp" ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [12149d8e1bc] functions: initial string map
Commit: 12149d8e1bccae61dcf00bb741dc817a46a7770f Author: Jacques Lucke Date: Thu Jul 11 15:50:46 2019 +0200 Branches: functions https://developer.blender.org/rB12149d8e1bccae61dcf00bb741dc817a46a7770f initial string map === A source/blender/blenlib/BLI_string_map.hpp M source/blender/blenlib/CMakeLists.txt M source/blender/simulations/bparticles/inserters.cpp M source/blender/simulations/bparticles/inserters.hpp === diff --git a/source/blender/blenlib/BLI_string_map.hpp b/source/blender/blenlib/BLI_string_map.hpp new file mode 100644 index 000..d93c240d53e --- /dev/null +++ b/source/blender/blenlib/BLI_string_map.hpp @@ -0,0 +1,31 @@ +#pragma once + +#include "BLI_small_map.hpp" +#include "BLI_string_ref.hpp" + +namespace BLI { + +template class StringMap { + private: + SmallMap m_map; + + public: + StringMap() = default; + + void add_new(StringRef key, const V ) + { +m_map.add_new(key.to_std_string(), value); + } + + V (StringRef key) const + { +return m_map.lookup(key); + } + + decltype(m_map.items()) items() const + { +return m_map.items(); + } +}; + +} // namespace BLI diff --git a/source/blender/blenlib/CMakeLists.txt b/source/blender/blenlib/CMakeLists.txt index 2968faa42c9..e809cadf952 100644 --- a/source/blender/blenlib/CMakeLists.txt +++ b/source/blender/blenlib/CMakeLists.txt @@ -257,6 +257,7 @@ set(SRC BLI_small_set.hpp BLI_small_set_vector.hpp BLI_small_stack.hpp + BLI_string_map.hpp BLI_string_ref.hpp BLI_timeit.hpp BLI_vector_adaptor.hpp diff --git a/source/blender/simulations/bparticles/inserters.cpp b/source/blender/simulations/bparticles/inserters.cpp index 09f462227f9..740444ef9a2 100644 --- a/source/blender/simulations/bparticles/inserters.cpp +++ b/source/blender/simulations/bparticles/inserters.cpp @@ -241,25 +241,25 @@ static std::unique_ptr BUILD_EMITTER_mesh_surface(BuildContext , return EMITTER_mesh_surface(particle_type_name, fn, ctx.world_state, std::move(action)); } -BLI_LAZY_INIT(ForceFromNodeCallbackMap, get_force_builders) +BLI_LAZY_INIT(StringMap, get_force_builders) { - ForceFromNodeCallbackMap map; + StringMap map; map.add_new("bp_GravityForceNode", BUILD_FORCE_gravity); map.add_new("bp_TurbulenceForceNode", BUILD_FORCE_turbulence); return map; } -BLI_LAZY_INIT(EventFromNodeCallbackMap, get_event_builders) +BLI_LAZY_INIT(StringMap, get_event_builders) { - EventFromNodeCallbackMap map; + StringMap map; map.add_new("bp_MeshCollisionEventNode", Build_EVENT_mesh_collision); map.add_new("bp_AgeReachedEventNode", BUILD_EVENT_age_reached); return map; } -BLI_LAZY_INIT(EmitterFromNodeCallbackMap, get_emitter_builders) +BLI_LAZY_INIT(StringMap, get_emitter_builders) { - EmitterFromNodeCallbackMap map; + StringMap map; map.add_new("bp_PointEmitterNode", BUILD_EMITTER_point); map.add_new("bp_MeshEmitterNode", BUILD_EMITTER_mesh_surface); return map; diff --git a/source/blender/simulations/bparticles/inserters.hpp b/source/blender/simulations/bparticles/inserters.hpp index bc2ee622854..4e300513f3e 100644 --- a/source/blender/simulations/bparticles/inserters.hpp +++ b/source/blender/simulations/bparticles/inserters.hpp @@ -4,6 +4,7 @@ #include "BKE_node_tree.hpp" #include "FN_data_flow_nodes.hpp" +#include "BLI_string_map.hpp" #include "world_state.hpp" #include "step_description.hpp" @@ -14,6 +15,7 @@ namespace BParticles { using BKE::bSocketList; using BKE::IndexedNodeTree; using BKE::SocketWithNode; +using BLI::StringMap; using FN::DataFlowNodes::BTreeDataGraph; struct BuildContext { @@ -25,20 +27,17 @@ struct BuildContext { using ForceFromNodeCallback = std::function(BuildContext , bNode *bnode)>; -using ForceFromNodeCallbackMap = SmallMap; -ForceFromNodeCallbackMap _force_builders(); +StringMap _force_builders(); using EventFromNodeCallback = std::function(BuildContext , bNode *bnode)>; -using EventFromNodeCallbackMap = SmallMap; -EventFromNodeCallbackMap _event_builders(); +StringMap _event_builders(); using EmitterFromNodeCallback = std::function( BuildContext , bNode *bnode, StringRef particle_type_name)>; -using EmitterFromNodeCallbackMap = SmallMap; -EmitterFromNodeCallbackMap _emitter_builders(); +StringMap _emitter_builders(); } // namespace BParticles ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [e0a7c11dd08] functions: cleanup simple emitter builders
Commit: e0a7c11dd088eb15cead4d2abad9a2ab02ddbf7a Author: Jacques Lucke Date: Thu Jul 11 15:14:12 2019 +0200 Branches: functions https://developer.blender.org/rBe0a7c11dd088eb15cead4d2abad9a2ab02ddbf7a cleanup simple emitter builders === M source/blender/simulations/bparticles/emitters.cpp M source/blender/simulations/bparticles/emitters.hpp M source/blender/simulations/bparticles/inserters.cpp M source/blender/simulations/bparticles/inserters.hpp M source/blender/simulations/bparticles/node_frontend.cpp === diff --git a/source/blender/simulations/bparticles/emitters.cpp b/source/blender/simulations/bparticles/emitters.cpp index 51be0b5abd5..b6eea03fba6 100644 --- a/source/blender/simulations/bparticles/emitters.cpp +++ b/source/blender/simulations/bparticles/emitters.cpp @@ -156,17 +156,20 @@ class SurfaceEmitter : public Emitter { } }; -Emitter *EMITTER_point(StringRef particle_type_name, float3 point) +std::unique_ptr EMITTER_point(StringRef particle_type_name, float3 point) { - return new PointEmitter(particle_type_name, point); + Emitter *emitter = new PointEmitter(particle_type_name, point); + return std::unique_ptr(emitter); } -Emitter *EMITTER_mesh_surface(StringRef particle_type_name, - SharedFunction _inputs_fn, - WorldState _state, - std::unique_ptr action) +std::unique_ptr EMITTER_mesh_surface(StringRef particle_type_name, + SharedFunction _inputs_fn, + WorldState _state, + std::unique_ptr action) { - return new SurfaceEmitter(particle_type_name, compute_inputs_fn, world_state, std::move(action)); + Emitter *emitter = new SurfaceEmitter( + particle_type_name, compute_inputs_fn, world_state, std::move(action)); + return std::unique_ptr(emitter); } } // namespace BParticles diff --git a/source/blender/simulations/bparticles/emitters.hpp b/source/blender/simulations/bparticles/emitters.hpp index f7f1ffee558..d3380d0343f 100644 --- a/source/blender/simulations/bparticles/emitters.hpp +++ b/source/blender/simulations/bparticles/emitters.hpp @@ -11,11 +11,11 @@ namespace BParticles { using FN::SharedFunction; using FN::TupleCallBody; -Emitter *EMITTER_point(StringRef particle_type_name, float3 point); +std::unique_ptr EMITTER_point(StringRef particle_type_name, float3 point); -Emitter *EMITTER_mesh_surface(StringRef particle_type_name, - SharedFunction _inputs_fn, - WorldState _state, - std::unique_ptr action); +std::unique_ptr EMITTER_mesh_surface(StringRef particle_type_name, + SharedFunction _inputs_fn, + WorldState _state, + std::unique_ptr action); } // namespace BParticles diff --git a/source/blender/simulations/bparticles/inserters.cpp b/source/blender/simulations/bparticles/inserters.cpp index 4fb6f834dba..5e1594383f4 100644 --- a/source/blender/simulations/bparticles/inserters.cpp +++ b/source/blender/simulations/bparticles/inserters.cpp @@ -17,11 +17,6 @@ namespace BParticles { using FN::SharedFunction; -static bool is_particle_type_node(bNode *bnode) -{ - return STREQ(bnode->idname, "bp_ParticleTypeNode"); -} - static bool is_particle_data_input(bNode *bnode) { return STREQ(bnode->idname, "bp_ParticleInfoNode") || @@ -216,54 +211,6 @@ static std::unique_ptr build_action(SocketWithNode start, } } -static void INSERT_EMITTER_mesh_surface(ProcessNodeInterface ) -{ - for (SocketWithNode linked : interface.linked_with_output(1)) { -if (!is_particle_type_node(linked.node)) { - continue; -} - -SharedFunction fn = create_function_for_data_inputs( -interface.bnode(), interface.indexed_tree(), interface.data_graph()); - -auto action = build_action({interface.outputs().get(0), interface.bnode()}, - interface.indexed_tree(), - interface.data_graph(), - interface.step_description()); - -bNode *type_node = linked.node; -Emitter *emitter = EMITTER_mesh_surface( -type_node->name, fn, interface.world_state(), std::move(action)); -interface.step_description().m_emitters.append(emitter); - } -} - -static void INSERT_EMITTER_point(ProcessNodeInterface ) -{ - for (SocketWithNode linked : interface.linked_with_output(0)) { -if (!is_particle_type_node(linked.node)) { - continue; -} - -float3 position; -PointerRNA rna = interface.node_rna(); -RNA_float_get_array(, "position", position); - -
[Bf-blender-cvs] [d8719603f82] functions: pass build context instead of separate parameters
Commit: d8719603f82d8b45a4473dd81e94473c636a4ffa Author: Jacques Lucke Date: Thu Jul 11 15:30:13 2019 +0200 Branches: functions https://developer.blender.org/rBd8719603f82d8b45a4473dd81e94473c636a4ffa pass build context instead of separate parameters === M source/blender/simulations/bparticles/inserters.cpp === diff --git a/source/blender/simulations/bparticles/inserters.cpp b/source/blender/simulations/bparticles/inserters.cpp index ac64af32e17..5f13a83c906 100644 --- a/source/blender/simulations/bparticles/inserters.cpp +++ b/source/blender/simulations/bparticles/inserters.cpp @@ -102,51 +102,38 @@ static SharedFunction create_function_for_data_inputs(bNode *bnode, return create_function(indexed_tree, data_graph, bsockets_to_compute, bnode->name); } -static std::unique_ptr build_action(SocketWithNode start, -IndexedNodeTree _tree, -BTreeDataGraph _graph, -ModifierStepDescription _description); +static std::unique_ptr build_action(BuildContext , SocketWithNode start); static std::unique_ptr BUILD_ACTION_kill() { return ACTION_kill(); } -static std::unique_ptr BUILD_ACTION_change_direction( -IndexedNodeTree _tree, -BTreeDataGraph _graph, -bNode *bnode, -ModifierStepDescription _description) +static std::unique_ptr BUILD_ACTION_change_direction(BuildContext , bNode *bnode) { bSocketList node_inputs(bnode->inputs); bSocketList node_outputs(bnode->outputs); - SharedFunction fn = create_function_for_data_inputs(bnode, indexed_tree, data_graph); + SharedFunction fn = create_function_for_data_inputs(bnode, ctx.indexed_tree, ctx.data_graph); ParticleFunction particle_fn(fn); - return ACTION_change_direction( - particle_fn, - build_action({node_outputs.get(0), bnode}, indexed_tree, data_graph, step_description)); + return ACTION_change_direction(particle_fn, build_action(ctx, {node_outputs.get(0), bnode})); } -static std::unique_ptr BUILD_ACTION_explode(IndexedNodeTree _tree, -BTreeDataGraph _graph, -bNode *bnode, -ModifierStepDescription _description) +static std::unique_ptr BUILD_ACTION_explode(BuildContext , bNode *bnode) { bSocketList node_inputs(bnode->inputs); bSocketList node_outputs(bnode->outputs); - SharedFunction fn = create_function_for_data_inputs(bnode, indexed_tree, data_graph); + SharedFunction fn = create_function_for_data_inputs(bnode, ctx.indexed_tree, ctx.data_graph); ParticleFunction particle_fn(fn); - PointerRNA rna = indexed_tree.get_rna(bnode); + PointerRNA rna = ctx.indexed_tree.get_rna(bnode); char name[65]; RNA_string_get(, "particle_type_name", name); - auto post_action = build_action( - {node_outputs.get(0), bnode}, indexed_tree, data_graph, step_description); + auto post_action = build_action(ctx, {node_outputs.get(0), bnode}); - if (step_description.m_types.contains(name)) { + if (ctx.step_description.m_types.contains(name)) { return ACTION_explode(name, particle_fn, std::move(post_action)); } else { @@ -154,37 +141,29 @@ static std::unique_ptr BUILD_ACTION_explode(IndexedNodeTree _tre } } -static std::unique_ptr BUILD_ACTION_condition(IndexedNodeTree _tree, - BTreeDataGraph _graph, - bNode *bnode, - ModifierStepDescription _description) +static std::unique_ptr BUILD_ACTION_condition(BuildContext , bNode *bnode) { bSocketList node_inputs(bnode->inputs); bSocketList node_outputs(bnode->outputs); - SharedFunction fn = create_function_for_data_inputs(bnode, indexed_tree, data_graph); + SharedFunction fn = create_function_for_data_inputs(bnode, ctx.indexed_tree, ctx.data_graph); ParticleFunction particle_fn(fn); - auto true_action = build_action( - {node_outputs.get(0), bnode}, indexed_tree, data_graph, step_description); - auto false_action = build_action( - {node_outputs.get(1), bnode}, indexed_tree, data_graph, step_description); + auto true_action = build_action(ctx, {node_outputs.get(0), bnode}); + auto false_action = build_action(ctx, {node_outputs.get(1), bnode}); return ACTION_condition(particle_fn, std::move(true_action), std::move(false_action)); } -static std::unique_ptr build_action(SocketWithNode start, -IndexedNodeTree _tree, -BTreeDataGraph _graph, -ModifierStepDescription _description)
[Bf-blender-cvs] [05d742427f0] functions: cleanup action builders
Commit: 05d742427f05f816c1baa123da6a3dbabeacc53a Author: Jacques Lucke Date: Thu Jul 11 15:39:06 2019 +0200 Branches: functions https://developer.blender.org/rB05d742427f05f816c1baa123da6a3dbabeacc53a cleanup action builders === M source/blender/simulations/bparticles/inserters.cpp === diff --git a/source/blender/simulations/bparticles/inserters.cpp b/source/blender/simulations/bparticles/inserters.cpp index 5f13a83c906..09f462227f9 100644 --- a/source/blender/simulations/bparticles/inserters.cpp +++ b/source/blender/simulations/bparticles/inserters.cpp @@ -103,8 +103,11 @@ static SharedFunction create_function_for_data_inputs(bNode *bnode, } static std::unique_ptr build_action(BuildContext , SocketWithNode start); +using ActionFromNodeCallback = +std::function(BuildContext , bNode *bnode)>; +using ActionFromNodeCallbackMap = SmallMap; -static std::unique_ptr BUILD_ACTION_kill() +static std::unique_ptr BUILD_ACTION_kill(BuildContext (ctx), bNode *UNUSED(bnode)) { return ACTION_kill(); } @@ -155,6 +158,16 @@ static std::unique_ptr BUILD_ACTION_condition(BuildContext , bNode * return ACTION_condition(particle_fn, std::move(true_action), std::move(false_action)); } +BLI_LAZY_INIT_STATIC(ActionFromNodeCallbackMap, get_action_builders) +{ + ActionFromNodeCallbackMap map; + map.add_new("bp_KillParticleNode", BUILD_ACTION_kill); + map.add_new("bp_ChangeParticleDirectionNode", BUILD_ACTION_change_direction); + map.add_new("bp_ExplodeParticleNode", BUILD_ACTION_explode); + map.add_new("bp_ParticleConditionNode", BUILD_ACTION_condition); + return map; +} + static std::unique_ptr build_action(BuildContext , SocketWithNode start) { if (start.socket->in_out == SOCK_OUT) { @@ -173,21 +186,8 @@ static std::unique_ptr build_action(BuildContext , SocketWithNode st BLI_assert(start.socket->in_out == SOCK_IN); bNode *bnode = start.node; - if (STREQ(bnode->idname, "bp_KillParticleNode")) { -return BUILD_ACTION_kill(); - } - else if (STREQ(bnode->idname, "bp_ChangeParticleDirectionNode")) { -return BUILD_ACTION_change_direction(ctx, bnode); - } - else if (STREQ(bnode->idname, "bp_ExplodeParticleNode")) { -return BUILD_ACTION_explode(ctx, bnode); - } - else if (STREQ(bnode->idname, "bp_ParticleConditionNode")) { -return BUILD_ACTION_condition(ctx, bnode); - } - else { -return nullptr; - } + auto builders = get_action_builders(); + return builders.lookup(bnode->idname)(ctx, bnode); } static std::unique_ptr BUILD_FORCE_gravity(BuildContext , bNode *bnode) ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [800a578ed79] functions: use StringMap everywhere
Commit: 800a578ed79a9255c428a043c2ca1f0a03bbcda0 Author: Jacques Lucke Date: Thu Jul 11 16:30:46 2019 +0200 Branches: functions https://developer.blender.org/rB800a578ed79a9255c428a043c2ca1f0a03bbcda0 use StringMap everywhere === M source/blender/blenlib/BLI_string_map.hpp M source/blender/functions/frontends/data_flow_nodes/inserters.cpp M source/blender/functions/frontends/data_flow_nodes/inserters.hpp M source/blender/simulations/bparticles/core.hpp M source/blender/simulations/bparticles/inserters.cpp M source/blender/simulations/bparticles/step_description.hpp M source/blender/simulations/bparticles/world_state.hpp === diff --git a/source/blender/blenlib/BLI_string_map.hpp b/source/blender/blenlib/BLI_string_map.hpp index d93c240d53e..bac3698feb1 100644 --- a/source/blender/blenlib/BLI_string_map.hpp +++ b/source/blender/blenlib/BLI_string_map.hpp @@ -17,15 +17,50 @@ template class StringMap { m_map.add_new(key.to_std_string(), value); } - V (StringRef key) const + void add_override(StringRef key, const V ) { -return m_map.lookup(key); +m_map.add_override(key.to_std_string(), value); + } + + V lookup(StringRef key) const + { +return m_map.lookup(key.to_std_string()); + } + + V *lookup_ptr(StringRef key) const + { +return m_map.lookup_ptr(key.to_std_string()); + } + + V lookup_default(StringRef key, const V _value) const + { +return m_map.lookup_default(key.to_std_string(), default_value); + } + + V _ref(StringRef key) const + { +return m_map.lookup_ref(key.to_std_string()); + } + + bool contains(StringRef key) const + { +return m_map.contains(key.to_std_string()); } decltype(m_map.items()) items() const { return m_map.items(); } + + decltype(m_map.keys()) keys() const + { +return m_map.keys(); + } + + decltype(m_map.values()) values() const + { +return m_map.values(); + } }; } // namespace BLI diff --git a/source/blender/functions/frontends/data_flow_nodes/inserters.cpp b/source/blender/functions/frontends/data_flow_nodes/inserters.cpp index 499d837c72c..662fe49147c 100644 --- a/source/blender/functions/frontends/data_flow_nodes/inserters.cpp +++ b/source/blender/functions/frontends/data_flow_nodes/inserters.cpp @@ -27,8 +27,7 @@ BLI_LAZY_INIT(GraphInserters, get_standard_inserters) void GraphInserters::reg_node_inserter(std::string idname, NodeInserter inserter) { - BLI_assert(!m_node_inserters.contains(idname)); - m_node_inserters.add(idname, inserter); + m_node_inserters.add_new(idname, inserter); } void GraphInserters::reg_node_function(std::string idname, FunctionGetter getter) @@ -43,8 +42,7 @@ void GraphInserters::reg_node_function(std::string idname, FunctionGetter getter void GraphInserters::reg_socket_loader(std::string idname, SocketLoader loader) { - BLI_assert(!m_socket_loaders.contains(idname)); - m_socket_loaders.add(idname, loader); + m_socket_loaders.add_new(idname, loader); } void GraphInserters::reg_conversion_inserter(std::string from_type, diff --git a/source/blender/functions/frontends/data_flow_nodes/inserters.hpp b/source/blender/functions/frontends/data_flow_nodes/inserters.hpp index 265ad436d21..4b1712a2033 100644 --- a/source/blender/functions/frontends/data_flow_nodes/inserters.hpp +++ b/source/blender/functions/frontends/data_flow_nodes/inserters.hpp @@ -3,6 +3,7 @@ #include "builder.hpp" #include #include "BLI_optional.hpp" +#include "BLI_string_map.hpp" #include "FN_tuple_call.hpp" struct PointerRNA; @@ -22,8 +23,8 @@ typedef std::function FunctionGetter; class GraphInserters { private: - SmallMap m_node_inserters; - SmallMap m_socket_loaders; + StringMap m_node_inserters; + StringMap m_socket_loaders; SmallMap, ConversionInserter> m_conversion_inserters; public: diff --git a/source/blender/simulations/bparticles/core.hpp b/source/blender/simulations/bparticles/core.hpp index 4f98f62495a..7d319387d80 100644 --- a/source/blender/simulations/bparticles/core.hpp +++ b/source/blender/simulations/bparticles/core.hpp @@ -10,6 +10,7 @@ #include "BLI_string_ref.hpp" #include "BLI_small_map.hpp" #include "BLI_vector_adaptor.hpp" +#include "BLI_string_map.hpp" #include "BLI_lazy_init.hpp" #include "attributes.hpp" @@ -18,6 +19,8 @@ namespace BParticles { +using BLI::StringMap; + class EventFilterInterface; class EventExecuteInterface; class EmitterInterface; @@ -178,7 +181,7 @@ class StepDescription { */ class ParticlesState { private: - SmallMap m_container_by_id; + StringMap m_container_by_id; float m_current_time = 0.0f; public: @@ -194,7 +197,7 @@ class ParticlesState { /** * Access the mapping from particle type names to their corresponding containers. */ - SmallMap _containers(); + StringMap _containers();
[Bf-blender-cvs] [db6a45ce1f9] functions: reorder functions
Commit: db6a45ce1f94a88c48cbe66a06addd076d174f46 Author: Jacques Lucke Date: Thu Jul 11 15:21:11 2019 +0200 Branches: functions https://developer.blender.org/rBdb6a45ce1f94a88c48cbe66a06addd076d174f46 reorder functions === M source/blender/simulations/bparticles/inserters.cpp === diff --git a/source/blender/simulations/bparticles/inserters.cpp b/source/blender/simulations/bparticles/inserters.cpp index 5e1594383f4..ac64af32e17 100644 --- a/source/blender/simulations/bparticles/inserters.cpp +++ b/source/blender/simulations/bparticles/inserters.cpp @@ -223,14 +223,6 @@ static std::unique_ptr BUILD_FORCE_turbulence(BuildContext , bNode *b return FORCE_turbulence(fn); } -BLI_LAZY_INIT(ForceFromNodeCallbackMap, get_force_builders) -{ - ForceFromNodeCallbackMap map; - map.add_new("bp_GravityForceNode", BUILD_FORCE_gravity); - map.add_new("bp_TurbulenceForceNode", BUILD_FORCE_turbulence); - return map; -} - static std::unique_ptr Build_EVENT_mesh_collision(BuildContext , bNode *bnode) { PointerRNA rna = ctx.indexed_tree.get_rna(bnode); @@ -257,14 +249,6 @@ static std::unique_ptr BUILD_EVENT_age_reached(BuildContext , bNode * return EVENT_age_reached(bnode->name, fn, std::move(action)); } -BLI_LAZY_INIT(EventFromNodeCallbackMap, get_event_builders) -{ - EventFromNodeCallbackMap map; - map.add_new("bp_MeshCollisionEventNode", Build_EVENT_mesh_collision); - map.add_new("bp_AgeReachedEventNode", BUILD_EVENT_age_reached); - return map; -} - static std::unique_ptr BUILD_EMITTER_point(BuildContext , bNode *bnode, StringRef particle_type_name) @@ -290,6 +274,22 @@ static std::unique_ptr BUILD_EMITTER_mesh_surface(BuildContext , return EMITTER_mesh_surface(particle_type_name, fn, ctx.world_state, std::move(action)); } +BLI_LAZY_INIT(ForceFromNodeCallbackMap, get_force_builders) +{ + ForceFromNodeCallbackMap map; + map.add_new("bp_GravityForceNode", BUILD_FORCE_gravity); + map.add_new("bp_TurbulenceForceNode", BUILD_FORCE_turbulence); + return map; +} + +BLI_LAZY_INIT(EventFromNodeCallbackMap, get_event_builders) +{ + EventFromNodeCallbackMap map; + map.add_new("bp_MeshCollisionEventNode", Build_EVENT_mesh_collision); + map.add_new("bp_AgeReachedEventNode", BUILD_EVENT_age_reached); + return map; +} + BLI_LAZY_INIT(EmitterFromNodeCallbackMap, get_emitter_builders) { EmitterFromNodeCallbackMap map; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [32e435bbc33] functions: simplify event inserters
Commit: 32e435bbc3320438a459aeda74294eb00212c668 Author: Jacques Lucke Date: Thu Jul 11 14:44:01 2019 +0200 Branches: functions https://developer.blender.org/rB32e435bbc3320438a459aeda74294eb00212c668 simplify event inserters === M source/blender/simulations/bparticles/inserters.cpp M source/blender/simulations/bparticles/inserters.hpp M source/blender/simulations/bparticles/node_frontend.cpp === diff --git a/source/blender/simulations/bparticles/inserters.cpp b/source/blender/simulations/bparticles/inserters.cpp index cd07783a9cf..4fb6f834dba 100644 --- a/source/blender/simulations/bparticles/inserters.cpp +++ b/source/blender/simulations/bparticles/inserters.cpp @@ -256,62 +256,11 @@ static void INSERT_EMITTER_point(ProcessNodeInterface ) } } -static void INSERT_EVENT_age_reached(ProcessNodeInterface ) -{ - FN::SharedFunction fn = create_function_for_data_inputs( - interface.bnode(), interface.indexed_tree(), interface.data_graph()); - - for (SocketWithNode linked : interface.linked_with_input(0)) { -if (!is_particle_type_node(linked.node)) { - continue; -} - -auto action = build_action({interface.outputs().get(0), interface.bnode()}, - interface.indexed_tree(), - interface.data_graph(), - interface.step_description()); -auto event = EVENT_age_reached(interface.bnode()->name, fn, std::move(action)); - -bNode *type_node = linked.node; -interface.step_description() -.m_types.lookup_ref(type_node->name) -->m_events.append(event.release()); - } -} - -static void INSERT_EVENT_mesh_collision(ProcessNodeInterface ) -{ - for (SocketWithNode linked : interface.linked_with_input(0)) { -if (!is_particle_type_node(linked.node)) { - continue; -} - -PointerRNA rna = interface.node_rna(); -Object *object = (Object *)RNA_pointer_get(, "object").id.data; -if (object == nullptr || object->type != OB_MESH) { - continue; -} - -auto action = build_action({interface.outputs().get(0), interface.bnode()}, - interface.indexed_tree(), - interface.data_graph(), - interface.step_description()); -auto event = EVENT_mesh_collision(interface.bnode()->name, object, std::move(action)); - -bNode *type_node = linked.node; -interface.step_description() -.m_types.lookup_ref(type_node->name) -->m_events.append(event.release()); - } -} - BLI_LAZY_INIT(ProcessFunctionsMap, get_node_processors) { ProcessFunctionsMap processors; processors.add_new("bp_MeshEmitterNode", INSERT_EMITTER_mesh_surface); processors.add_new("bp_PointEmitterNode", INSERT_EMITTER_point); - processors.add_new("bp_AgeReachedEventNode", INSERT_EVENT_age_reached); - processors.add_new("bp_MeshCollisionEventNode", INSERT_EVENT_mesh_collision); return processors; } @@ -335,4 +284,38 @@ BLI_LAZY_INIT(ForceFromNodeCallbackMap, get_force_builders) return map; } +static std::unique_ptr Build_EVENT_mesh_collision(BuildContext , bNode *bnode) +{ + PointerRNA rna = ctx.indexed_tree.get_rna(bnode); + Object *object = (Object *)RNA_pointer_get(, "object").id.data; + if (object == nullptr || object->type != OB_MESH) { +return {}; + } + + auto action = build_action({bSocketList(bnode->outputs).get(0), bnode}, + ctx.indexed_tree, + ctx.data_graph, + ctx.step_description); + return EVENT_mesh_collision(bnode->name, object, std::move(action)); +} + +static std::unique_ptr BUILD_EVENT_age_reached(BuildContext , bNode *bnode) +{ + FN::SharedFunction fn = create_function_for_data_inputs(bnode, ctx.indexed_tree, ctx.data_graph); + + auto action = build_action({bSocketList(bnode->outputs).get(0), bnode}, + ctx.indexed_tree, + ctx.data_graph, + ctx.step_description); + return EVENT_age_reached(bnode->name, fn, std::move(action)); +} + +BLI_LAZY_INIT(EventFromNodeCallbackMap, get_event_builders) +{ + EventFromNodeCallbackMap map; + map.add_new("bp_MeshCollisionEventNode", Build_EVENT_mesh_collision); + map.add_new("bp_AgeReachedEventNode", BUILD_EVENT_age_reached); + return map; +} + } // namespace BParticles diff --git a/source/blender/simulations/bparticles/inserters.hpp b/source/blender/simulations/bparticles/inserters.hpp index ab0cf98c85f..c1eefa79a9c 100644 --- a/source/blender/simulations/bparticles/inserters.hpp +++ b/source/blender/simulations/bparticles/inserters.hpp @@ -108,4 +108,10 @@ using ForceFromNodeCallbackMap = SmallMap; ForceFromNodeCallbackMap _force_builders(); +using EventFromNodeCallback = +
[Bf-blender-cvs] [79ec9180e6e] functions: rename GeneratedGraph to BTreeDataGraph
Commit: 79ec9180e6e36cc2d24c47cb65d4ca407951240e Author: Jacques Lucke Date: Thu Jul 11 13:37:43 2019 +0200 Branches: functions https://developer.blender.org/rB79ec9180e6e36cc2d24c47cb65d4ca407951240e rename GeneratedGraph to BTreeDataGraph === M source/blender/functions/frontends/data_flow_nodes/graph_generation.cpp M source/blender/functions/frontends/data_flow_nodes/graph_generation.hpp M source/blender/simulations/bparticles/inserters.cpp M source/blender/simulations/bparticles/inserters.hpp === diff --git a/source/blender/functions/frontends/data_flow_nodes/graph_generation.cpp b/source/blender/functions/frontends/data_flow_nodes/graph_generation.cpp index 2e7db3c2d58..132fed03859 100644 --- a/source/blender/functions/frontends/data_flow_nodes/graph_generation.cpp +++ b/source/blender/functions/frontends/data_flow_nodes/graph_generation.cpp @@ -89,7 +89,7 @@ static void insert_unlinked_inputs(BTreeGraphBuilder , } static void find_interface_sockets(IndexedNodeTree _btree, - GeneratedGraph , + BTreeDataGraph , DFGraphSocketSetVector _inputs, DFGraphSocketSetVector _outputs) { @@ -143,7 +143,7 @@ class BasicUnlinkedInputsHandler : public UnlinkedInputsHandler { } }; -Optional generate_graph(IndexedNodeTree _btree) +Optional generate_graph(IndexedNodeTree _btree) { DataFlowGraphBuilder graph_builder; SmallMap socket_map; @@ -164,24 +164,24 @@ Optional generate_graph(IndexedNodeTree _btree) insert_unlinked_inputs(builder, unlinked_inputs_handler); auto build_result = DataFlowGraph::FromBuilder(graph_builder); - return GeneratedGraph(std::move(build_result.graph), + return BTreeDataGraph(std::move(build_result.graph), build_mapping_for_original_sockets(socket_map, build_result.mapping)); } Optional generate_function_graph(IndexedNodeTree _btree) { - Optional generated_graph_ = generate_graph(indexed_btree); - if (!generated_graph_.has_value()) { + Optional data_graph_ = generate_graph(indexed_btree); + if (!data_graph_.has_value()) { return {}; } - GeneratedGraph _graph = generated_graph_.value(); + BTreeDataGraph _graph = data_graph_.value(); DFGraphSocketSetVector input_sockets; DFGraphSocketSetVector output_sockets; - find_interface_sockets(indexed_btree, generated_graph, input_sockets, output_sockets); + find_interface_sockets(indexed_btree, data_graph, input_sockets, output_sockets); - return FunctionGraph(generated_graph.graph(), input_sockets, output_sockets); + return FunctionGraph(data_graph.graph(), input_sockets, output_sockets); } } // namespace DataFlowNodes diff --git a/source/blender/functions/frontends/data_flow_nodes/graph_generation.hpp b/source/blender/functions/frontends/data_flow_nodes/graph_generation.hpp index 9d619aaa0d8..d761ddd1a90 100644 --- a/source/blender/functions/frontends/data_flow_nodes/graph_generation.hpp +++ b/source/blender/functions/frontends/data_flow_nodes/graph_generation.hpp @@ -19,13 +19,13 @@ class UnlinkedInputsHandler { DFGB_SocketVector _inserted_data_origins) = 0; }; -class GeneratedGraph { +class BTreeDataGraph { private: SharedDataFlowGraph m_graph; SmallMap m_mapping; public: - GeneratedGraph(SharedDataFlowGraph graph, SmallMap mapping) + BTreeDataGraph(SharedDataFlowGraph graph, SmallMap mapping) : m_graph(std::move(graph)), m_mapping(std::move(mapping)) { } @@ -41,7 +41,7 @@ class GeneratedGraph { } }; -Optional generate_graph(IndexedNodeTree _btree); +Optional generate_graph(IndexedNodeTree _btree); Optional generate_function_graph(IndexedNodeTree _btree); diff --git a/source/blender/simulations/bparticles/inserters.cpp b/source/blender/simulations/bparticles/inserters.cpp index 22de1a4c854..c9bf8114d9f 100644 --- a/source/blender/simulations/bparticles/inserters.cpp +++ b/source/blender/simulations/bparticles/inserters.cpp @@ -30,7 +30,7 @@ static bool is_particle_data_input(bNode *bnode) static SmallVector insert_inputs(FN::FunctionBuilder _builder, IndexedNodeTree _tree, - FN::DataFlowNodes::GeneratedGraph _graph, +BTreeDataGraph _graph, ArrayRef output_sockets) { SmallSet to_be_checked = output_sockets; @@ -74,7 +74,7 @@ static SmallVector insert_inputs(FN::FunctionBuilder _buil } static SharedFunction create_function(IndexedNodeTree _tree, - FN::DataFlowNodes::GeneratedGraph _graph, +
[Bf-blender-cvs] [9f1c6250563] functions: cleanup force node handling
Commit: 9f1c6250563355d7eb73ce6cc27f3be267173032 Author: Jacques Lucke Date: Thu Jul 11 14:29:17 2019 +0200 Branches: functions https://developer.blender.org/rB9f1c6250563355d7eb73ce6cc27f3be267173032 cleanup force node handling === M source/blender/blenkernel/intern/node_tree.cpp M source/blender/simulations/bparticles/forces.cpp M source/blender/simulations/bparticles/forces.hpp M source/blender/simulations/bparticles/inserters.cpp M source/blender/simulations/bparticles/inserters.hpp M source/blender/simulations/bparticles/node_frontend.cpp === diff --git a/source/blender/blenkernel/intern/node_tree.cpp b/source/blender/blenkernel/intern/node_tree.cpp index 0c2d8462865..d9c369a9e05 100644 --- a/source/blender/blenkernel/intern/node_tree.cpp +++ b/source/blender/blenkernel/intern/node_tree.cpp @@ -48,7 +48,8 @@ void IndexedNodeTree::find_connected_sockets_left(bNodeSocket *bsocket, SmallVector _sockets) const { BLI_assert(bsocket->in_out == SOCK_IN); - for (SocketWithNode linked : m_direct_links.lookup_default(bsocket)) { + auto from_sockets = m_direct_links.lookup_default(bsocket); + for (SocketWithNode linked : from_sockets) { if (this->is_reroute(linked.node)) { this->find_connected_sockets_left((bNodeSocket *)linked.node->inputs.first, r_sockets); } @@ -61,7 +62,8 @@ void IndexedNodeTree::find_connected_sockets_right(bNodeSocket *bsocket, SmallVector _sockets) const { BLI_assert(bsocket->in_out == SOCK_OUT); - for (SocketWithNode other : m_direct_links.lookup_default(bsocket)) { + auto to_sockets = m_direct_links.lookup_default(bsocket); + for (SocketWithNode other : to_sockets) { if (this->is_reroute(other.node)) { this->find_connected_sockets_right((bNodeSocket *)other.node->outputs.first, r_sockets); } diff --git a/source/blender/simulations/bparticles/forces.cpp b/source/blender/simulations/bparticles/forces.cpp index 013fb3c8134..d1ffcdd4785 100644 --- a/source/blender/simulations/bparticles/forces.cpp +++ b/source/blender/simulations/bparticles/forces.cpp @@ -69,14 +69,16 @@ class TurbulenceForce : public Force { } }; -Force *FORCE_gravity(SharedFunction _acceleration_fn) +std::unique_ptr FORCE_gravity(SharedFunction _acceleration_fn) { - return new GravityForce(compute_acceleration_fn); + Force *force = new GravityForce(compute_acceleration_fn); + return std::unique_ptr(force); } -Force *FORCE_turbulence(SharedFunction _strength_fn) +std::unique_ptr FORCE_turbulence(SharedFunction _strength_fn) { - return new TurbulenceForce(compute_strength_fn); + Force *force = new TurbulenceForce(compute_strength_fn); + return std::unique_ptr(force); } } // namespace BParticles diff --git a/source/blender/simulations/bparticles/forces.hpp b/source/blender/simulations/bparticles/forces.hpp index 4ee25b7dad9..862eee7f025 100644 --- a/source/blender/simulations/bparticles/forces.hpp +++ b/source/blender/simulations/bparticles/forces.hpp @@ -11,7 +11,7 @@ class Force { virtual void add_force(ParticlesBlock , ArrayRef r_force) = 0; }; -Force *FORCE_gravity(SharedFunction _acceleration_fn); -Force *FORCE_turbulence(SharedFunction _strength_fn); +std::unique_ptr FORCE_gravity(SharedFunction _acceleration_fn); +std::unique_ptr FORCE_turbulence(SharedFunction _strength_fn); } // namespace BParticles diff --git a/source/blender/simulations/bparticles/inserters.cpp b/source/blender/simulations/bparticles/inserters.cpp index bbd1a1bf315..cd07783a9cf 100644 --- a/source/blender/simulations/bparticles/inserters.cpp +++ b/source/blender/simulations/bparticles/inserters.cpp @@ -305,44 +305,6 @@ static void INSERT_EVENT_mesh_collision(ProcessNodeInterface ) } } -static void INSERT_FORCE_gravity(ProcessNodeInterface ) -{ - for (SocketWithNode linked : interface.linked_with_output(0)) { -if (!is_particle_type_node(linked.node)) { - continue; -} - -SharedFunction fn = create_function_for_data_inputs( -interface.bnode(), interface.indexed_tree(), interface.data_graph()); - -Force *force = FORCE_gravity(fn); - -bNode *type_node = linked.node; -EulerIntegrator *integrator = reinterpret_cast( - interface.step_description().m_types.lookup_ref(type_node->name)->m_integrator); -integrator->add_force(std::unique_ptr(force)); - } -} - -static void INSERT_FORCE_turbulence(ProcessNodeInterface ) -{ - for (SocketWithNode linked : interface.linked_with_output(0)) { -if (!is_particle_type_node(linked.node)) { - continue; -} - -SharedFunction fn = create_function_for_data_inputs( -interface.bnode(), interface.indexed_tree(), interface.data_graph()); - -Force *force = FORCE_turbulence(fn); - -
[Bf-blender-cvs] [abb76708d13] functions: simplify create function for node inputs
Commit: abb76708d132e01a7a08eaf89d2c737933892b70 Author: Jacques Lucke Date: Thu Jul 11 13:47:53 2019 +0200 Branches: functions https://developer.blender.org/rBabb76708d132e01a7a08eaf89d2c737933892b70 simplify create function for node inputs === M source/blender/functions/frontends/data_flow_nodes/graph_generation.hpp M source/blender/simulations/bparticles/inserters.cpp === diff --git a/source/blender/functions/frontends/data_flow_nodes/graph_generation.hpp b/source/blender/functions/frontends/data_flow_nodes/graph_generation.hpp index d761ddd1a90..e384836b7d7 100644 --- a/source/blender/functions/frontends/data_flow_nodes/graph_generation.hpp +++ b/source/blender/functions/frontends/data_flow_nodes/graph_generation.hpp @@ -39,6 +39,11 @@ class BTreeDataGraph { { return m_mapping.lookup(bsocket); } + + bool uses_socket(bNodeSocket *bsocket) + { +return m_mapping.contains(bsocket); + } }; Optional generate_graph(IndexedNodeTree _btree); diff --git a/source/blender/simulations/bparticles/inserters.cpp b/source/blender/simulations/bparticles/inserters.cpp index c9bf8114d9f..bbd1a1bf315 100644 --- a/source/blender/simulations/bparticles/inserters.cpp +++ b/source/blender/simulations/bparticles/inserters.cpp @@ -94,6 +94,19 @@ static SharedFunction create_function(IndexedNodeTree _tree, return fn; } +static SharedFunction create_function_for_data_inputs(bNode *bnode, + IndexedNodeTree _tree, + BTreeDataGraph _graph) +{ + SmallVector bsockets_to_compute; + for (bNodeSocket *bsocket : bSocketList(bnode->inputs)) { +if (data_graph.uses_socket(bsocket)) { + bsockets_to_compute.append(bsocket); +} + } + return create_function(indexed_tree, data_graph, bsockets_to_compute, bnode->name); +} + static std::unique_ptr build_action(SocketWithNode start, IndexedNodeTree _tree, BTreeDataGraph _graph, @@ -113,8 +126,7 @@ static std::unique_ptr BUILD_ACTION_change_direction( bSocketList node_inputs(bnode->inputs); bSocketList node_outputs(bnode->outputs); - SharedFunction fn = create_function( - indexed_tree, data_graph, {node_inputs.get(1)}, "Compute Direction"); + SharedFunction fn = create_function_for_data_inputs(bnode, indexed_tree, data_graph); ParticleFunction particle_fn(fn); return ACTION_change_direction( particle_fn, @@ -129,8 +141,7 @@ static std::unique_ptr BUILD_ACTION_explode(IndexedNodeTree _tre bSocketList node_inputs(bnode->inputs); bSocketList node_outputs(bnode->outputs); - SharedFunction fn = create_function( - indexed_tree, data_graph, {node_inputs.get(1), node_inputs.get(2)}, bnode->name); + SharedFunction fn = create_function_for_data_inputs(bnode, indexed_tree, data_graph); ParticleFunction particle_fn(fn); PointerRNA rna = indexed_tree.get_rna(bnode); @@ -156,7 +167,7 @@ static std::unique_ptr BUILD_ACTION_condition(IndexedNodeTree _t bSocketList node_inputs(bnode->inputs); bSocketList node_outputs(bnode->outputs); - SharedFunction fn = create_function(indexed_tree, data_graph, {node_inputs.get(1)}, bnode->name); + SharedFunction fn = create_function_for_data_inputs(bnode, indexed_tree, data_graph); ParticleFunction particle_fn(fn); auto true_action = build_action( @@ -212,12 +223,8 @@ static void INSERT_EMITTER_mesh_surface(ProcessNodeInterface ) continue; } -bSocketList inputs = interface.inputs(); -SharedFunction fn = create_function( -interface.indexed_tree(), -interface.data_graph(), -{inputs.get(0), inputs.get(1), inputs.get(2), inputs.get(3), inputs.get(4)}, -interface.bnode()->name); +SharedFunction fn = create_function_for_data_inputs( +interface.bnode(), interface.indexed_tree(), interface.data_graph()); auto action = build_action({interface.outputs().get(0), interface.bnode()}, interface.indexed_tree(), @@ -251,10 +258,8 @@ static void INSERT_EMITTER_point(ProcessNodeInterface ) static void INSERT_EVENT_age_reached(ProcessNodeInterface ) { - FN::SharedFunction fn = create_function(interface.indexed_tree(), - interface.data_graph(), - {interface.inputs().get(1)}, - interface.bnode()->name); + FN::SharedFunction fn = create_function_for_data_inputs( + interface.bnode(), interface.indexed_tree(), interface.data_graph()); for (SocketWithNode linked : interface.linked_with_input(0)) { if (!is_particle_type_node(linked.node)) { @@ -307,10 +312,8 @@ static void
[Bf-blender-cvs] [57f7d83defb] functions: cleanup executing actions for a subset
Commit: 57f7d83defb304a47d07498b88753038d6739849 Author: Jacques Lucke Date: Thu Jul 11 12:47:05 2019 +0200 Branches: functions https://developer.blender.org/rB57f7d83defb304a47d07498b88753038d6739849 cleanup executing actions for a subset === M source/blender/simulations/bparticles/action_interface.cpp M source/blender/simulations/bparticles/action_interface.hpp M source/blender/simulations/bparticles/actions.cpp === diff --git a/source/blender/simulations/bparticles/action_interface.cpp b/source/blender/simulations/bparticles/action_interface.cpp index 66071153399..8a01e3d85d0 100644 --- a/source/blender/simulations/bparticles/action_interface.cpp +++ b/source/blender/simulations/bparticles/action_interface.cpp @@ -6,20 +6,6 @@ Action::~Action() { } -void ActionInterface::execute_action_for_subset(ArrayRef pindices, -std::unique_ptr ) -{ - ParticleSet sub_particles(m_particles.block(), pindices); - ActionInterface sub_interface(m_particle_allocator, -m_array_allocator, -sub_particles, -m_attribute_offsets, -m_current_times, -m_remaining_times, -m_event_info); - action->execute(sub_interface); -} - ParticleFunctionCaller ParticleFunction::get_caller(AttributeArrays attributes, EventInfo _info) { diff --git a/source/blender/simulations/bparticles/action_interface.hpp b/source/blender/simulations/bparticles/action_interface.hpp index 881ceae018f..fd1ae94e69c 100644 --- a/source/blender/simulations/bparticles/action_interface.hpp +++ b/source/blender/simulations/bparticles/action_interface.hpp @@ -87,6 +87,9 @@ class ActionInterface { static void RunFromEvent(std::unique_ptr , EventExecuteInterface _interface, EventInfo *event_info = nullptr); + static void RunForSubset(std::unique_ptr , + ArrayRef pindices, + ActionInterface _interface); EventInfo _info(); @@ -95,7 +98,6 @@ class ActionInterface { float remaining_time_in_step(uint pindex); ArrayRef current_times(); void kill(ArrayRef pindices); - void execute_action_for_subset(ArrayRef pindices, std::unique_ptr ); ParticleAllocator _allocator(); ArrayAllocator _allocator(); }; @@ -177,6 +179,20 @@ inline void ActionInterface::RunFromEvent(std::unique_ptr , action->execute(action_interface); } +inline void ActionInterface::RunForSubset(std::unique_ptr , + ArrayRef pindices, + ActionInterface _interface) +{ + ActionInterface sub_interface(action_interface.m_particle_allocator, +action_interface.m_array_allocator, + ParticleSet(action_interface.m_particles.block(), pindices), +action_interface.m_attribute_offsets, +action_interface.m_current_times, +action_interface.m_remaining_times, +action_interface.m_event_info); + action->execute(sub_interface); +} + inline EventInfo ::event_info() { return m_event_info; diff --git a/source/blender/simulations/bparticles/actions.cpp b/source/blender/simulations/bparticles/actions.cpp index 8cc736687da..77fa1c1a4d7 100644 --- a/source/blender/simulations/bparticles/actions.cpp +++ b/source/blender/simulations/bparticles/actions.cpp @@ -159,8 +159,8 @@ class ConditionAction : public Action { } } -interface.execute_action_for_subset(true_pindices, m_true_action); -interface.execute_action_for_subset(false_pindices, m_false_action); +ActionInterface::RunForSubset(m_true_action, true_pindices, interface); +ActionInterface::RunForSubset(m_false_action, false_pindices, interface); } void compute_conditions(ActionInterface , ArrayRef r_conditions) ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [8eb57698c47] functions: cleanup running action from event
Commit: 8eb57698c47cafa5096ebc1ed1cc56ec2e7bdc0a Author: Jacques Lucke Date: Thu Jul 11 12:36:09 2019 +0200 Branches: functions https://developer.blender.org/rB8eb57698c47cafa5096ebc1ed1cc56ec2e7bdc0a cleanup running action from event === M source/blender/simulations/bparticles/action_interface.hpp M source/blender/simulations/bparticles/events.cpp === diff --git a/source/blender/simulations/bparticles/action_interface.hpp b/source/blender/simulations/bparticles/action_interface.hpp index a520ce6f1cf..881ceae018f 100644 --- a/source/blender/simulations/bparticles/action_interface.hpp +++ b/source/blender/simulations/bparticles/action_interface.hpp @@ -84,6 +84,9 @@ class ActionInterface { ParticleSets _sets, EmitterInterface _interface, EventInfo *event_info = nullptr); + static void RunFromEvent(std::unique_ptr , + EventExecuteInterface _interface, + EventInfo *event_info = nullptr); EventInfo _info(); @@ -124,7 +127,7 @@ inline ActionInterface::ActionInterface(ParticleAllocator _allocator, { } -class EmptyEventinfo : public EventInfo { +class EmptyEventInfo : public EventInfo { void *get_info_array(StringRef UNUSED(name)) { return nullptr; @@ -140,7 +143,7 @@ inline void ActionInterface::RunFromEmitter(std::unique_ptr , AttributeArraysCore offsets_core(info, {}, 0); AttributeArrays offsets = offsets_core.slice_all(); - EmptyEventinfo empty_event_info; + EmptyEventInfo empty_event_info; EventInfo _event_info = (event_info == nullptr) ? empty_event_info : *event_info; for (ParticleSet particles : particle_sets.sets()) { @@ -157,6 +160,23 @@ inline void ActionInterface::RunFromEmitter(std::unique_ptr , } } +inline void ActionInterface::RunFromEvent(std::unique_ptr , + EventExecuteInterface _interface, + EventInfo *event_info) +{ + EmptyEventInfo empty_event_info; + EventInfo _event_info = (event_info == nullptr) ? empty_event_info : *event_info; + + ActionInterface action_interface(event_interface.particle_allocator(), + event_interface.array_allocator(), + event_interface.particles(), + event_interface.attribute_offsets(), + event_interface.current_times(), + event_interface.remaining_times(), + used_event_info); + action->execute(action_interface); +} + inline EventInfo ::event_info() { return m_event_info; diff --git a/source/blender/simulations/bparticles/events.cpp b/source/blender/simulations/bparticles/events.cpp index 903ed38f4ea..9e45b2c56e7 100644 --- a/source/blender/simulations/bparticles/events.cpp +++ b/source/blender/simulations/bparticles/events.cpp @@ -8,13 +8,6 @@ namespace BParticles { -class EmptyEventInfo : public EventInfo { - void *get_info_array(StringRef UNUSED(name)) override - { -return nullptr; - } -}; - class AgeReachedEvent : public Event { private: std::string m_identifier; @@ -85,15 +78,7 @@ class AgeReachedEvent : public Event { was_activated_before[pindex] = true; } -EmptyEventInfo event_info; -ActionInterface action_interface(interface.particle_allocator(), - interface.array_allocator(), - particles, - interface.attribute_offsets(), - interface.current_times(), - interface.remaining_times(), - event_info); -m_action->execute(action_interface); +ActionInterface::RunFromEvent(m_action, interface); } }; @@ -215,14 +200,7 @@ class MeshCollisionEventFilter : public Event { } CollisionEventInfo event_info(normals); -ActionInterface action_interface(interface.particle_allocator(), - interface.array_allocator(), - particles, - interface.attribute_offsets(), - interface.current_times(), - interface.remaining_times(), - event_info); -m_action->execute(action_interface); +ActionInterface::RunFromEvent(m_action, interface, _info); } }; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [401ff628bdf] functions: settings size in point emitter is not necessary anymore
Commit: 401ff628bdfb3a4f0c38597110b193eef3f87758 Author: Jacques Lucke Date: Thu Jul 11 12:28:31 2019 +0200 Branches: functions https://developer.blender.org/rB401ff628bdfb3a4f0c38597110b193eef3f87758 settings size in point emitter is not necessary anymore === M source/blender/simulations/bparticles/emitters.cpp === diff --git a/source/blender/simulations/bparticles/emitters.cpp b/source/blender/simulations/bparticles/emitters.cpp index 53596bc3629..51be0b5abd5 100644 --- a/source/blender/simulations/bparticles/emitters.cpp +++ b/source/blender/simulations/bparticles/emitters.cpp @@ -33,7 +33,6 @@ class PointEmitter : public Emitter { auto target = interface.particle_allocator().request(m_particle_type_name, 1); target.set_float3("Position", {m_point}); target.set_float3("Velocity", {float3{-1, -1, 0}}); -target.fill_float("Size", 0.01f); target.fill_float("Birth Time", interface.time_span().end()); } }; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [75cc874922e] functions: introduce attributes info builder
Commit: 75cc874922ef28f83711856975223deb0db0190e Author: Jacques Lucke Date: Thu Jul 11 12:24:06 2019 +0200 Branches: functions https://developer.blender.org/rB75cc874922ef28f83711856975223deb0db0190e introduce attributes info builder === M source/blender/simulations/bparticles/attributes.cpp M source/blender/simulations/bparticles/attributes.hpp M source/blender/simulations/bparticles/core.hpp M source/blender/simulations/bparticles/events.cpp M source/blender/simulations/bparticles/integrator.cpp M source/blender/simulations/bparticles/simulate.cpp M source/blender/simulations/bparticles/step_description.hpp === diff --git a/source/blender/simulations/bparticles/attributes.cpp b/source/blender/simulations/bparticles/attributes.cpp index 9d25be9eeaa..4bcba019d99 100644 --- a/source/blender/simulations/bparticles/attributes.cpp +++ b/source/blender/simulations/bparticles/attributes.cpp @@ -2,10 +2,27 @@ namespace BParticles { +AttributesInfo::AttributesInfo(AttributesInfoBuilder ) +: AttributesInfo(builder.m_byte_names, + builder.m_float_names, + builder.m_float3_names, + builder.m_byte_defaults, + builder.m_float_defaults, + builder.m_float3_defaults) +{ +} + AttributesInfo::AttributesInfo(ArrayRef byte_names, ArrayRef float_names, - ArrayRef float3_names) + ArrayRef float3_names, + ArrayRef byte_defaults, + ArrayRef float_defaults, + ArrayRef float3_defaults) { + BLI_assert(byte_names.size() == byte_defaults.size()); + BLI_assert(float_names.size() == float_defaults.size()); + BLI_assert(float3_names.size() == float3_defaults.size()); + m_indices = {}; m_indices.add_multiple_new(byte_names); m_indices.add_multiple_new(float_names); @@ -21,9 +38,9 @@ AttributesInfo::AttributesInfo(ArrayRef byte_names, m_types.append_n_times(AttributeType::Float, m_float_attributes.size()); m_types.append_n_times(AttributeType::Float3, m_float3_attributes.size()); - m_byte_defaults.append_n_times(0, m_byte_attributes.size()); - m_float_defaults.append_n_times(0, m_float_attributes.size()); - m_float3_defaults.append_n_times({0, 0, 0}, m_float3_attributes.size()); + m_byte_defaults = byte_defaults; + m_float_defaults = float_defaults; + m_float3_defaults = float3_defaults; } AttributeArraysCore::AttributeArraysCore(AttributesInfo , ArrayRef arrays, uint size) diff --git a/source/blender/simulations/bparticles/attributes.hpp b/source/blender/simulations/bparticles/attributes.hpp index afa24b95544..125cdd64fac 100644 --- a/source/blender/simulations/bparticles/attributes.hpp +++ b/source/blender/simulations/bparticles/attributes.hpp @@ -53,6 +53,27 @@ inline uint size_of_attribute_type(AttributeType type) }; } +class AttributesInfo; + +class AttributesInfoBuilder { + private: + SmallSetVector m_byte_names; + SmallSetVector m_float_names; + SmallSetVector m_float3_names; + SmallVector m_byte_defaults; + SmallVector m_float_defaults; + SmallVector m_float3_defaults; + + friend AttributesInfo; + + public: + AttributesInfoBuilder() = default; + + void use_byte(StringRef name, uint8_t default_value); + void use_float(StringRef name, float default_value); + void use_float3(StringRef name, float3 default_value); +}; + /** * Contains information about a set of attributes. Every attribute is identified by a unique name * and a unique index. So two attributes of different types have to have different names. @@ -75,9 +96,13 @@ class AttributesInfo { public: AttributesInfo() = default; + AttributesInfo(AttributesInfoBuilder ); AttributesInfo(ArrayRef byte_names, ArrayRef float_names, - ArrayRef float3_names); + ArrayRef float3_names, + ArrayRef byte_defaults, + ArrayRef float_defaults, + ArrayRef float3_defaults); /** * Get the number of different attributes. @@ -372,6 +397,30 @@ class AttributeArrays { AttributeArrays take_front(uint n) const; }; +/* Attribute Info Builder + */ + +inline void AttributesInfoBuilder::use_byte(StringRef name, uint8_t default_value) +{ + if (m_byte_names.add(name.to_std_string())) { +m_byte_defaults.append(default_value); + } +} + +inline void AttributesInfoBuilder::use_float(StringRef name, float default_value) +{ + if (m_float_names.add(name.to_std_string())) { +m_float_defaults.append(default_value); + } +} + +inline void AttributesInfoBuilder::use_float3(StringRef name, float3 default_value) +{ + if
[Bf-blender-cvs] [202708eeaed] functions: run action on particle birth
Commit: 202708eeaed5f3ddaf8eb3b727aaff79f494172e Author: Jacques Lucke Date: Thu Jul 11 11:17:53 2019 +0200 Branches: functions https://developer.blender.org/rB202708eeaed5f3ddaf8eb3b727aaff79f494172e run action on particle birth === M release/scripts/startup/nodes/bparticle_nodes/mesh_emitter.py M source/blender/simulations/bparticles/attributes.hpp M source/blender/simulations/bparticles/core.hpp M source/blender/simulations/bparticles/emitters.cpp M source/blender/simulations/bparticles/emitters.hpp M source/blender/simulations/bparticles/inserters.cpp === diff --git a/release/scripts/startup/nodes/bparticle_nodes/mesh_emitter.py b/release/scripts/startup/nodes/bparticle_nodes/mesh_emitter.py index d9dcfe3646a..93d659fa1de 100644 --- a/release/scripts/startup/nodes/bparticle_nodes/mesh_emitter.py +++ b/release/scripts/startup/nodes/bparticle_nodes/mesh_emitter.py @@ -13,4 +13,5 @@ class MeshEmitterNode(bpy.types.Node, BParticlesNode): builder.fixed_input("normal_velocity", "Normal Velocity", "Float", default=1) builder.fixed_input("emitter_velocity", "Emitter Velocity", "Float", default=0) builder.fixed_input("size", "Size", "Float", default=0.05) +builder.control_flow_output("on_birth", "On Birth") builder.emitter_output("emitter", "Emitter") diff --git a/source/blender/simulations/bparticles/attributes.hpp b/source/blender/simulations/bparticles/attributes.hpp index 830e2435308..afa24b95544 100644 --- a/source/blender/simulations/bparticles/attributes.hpp +++ b/source/blender/simulations/bparticles/attributes.hpp @@ -136,7 +136,7 @@ class AttributesInfo { * Get the index corresponding to an attribute with the given name and type. * Returns -1 when the attribute does not exist. */ - bool attribute_index_try(StringRef name, AttributeType type) const + int attribute_index_try(StringRef name, AttributeType type) const { int index = this->attribute_index_try(name); if (index == -1) { diff --git a/source/blender/simulations/bparticles/core.hpp b/source/blender/simulations/bparticles/core.hpp index a23bb99c94a..6d84e786f2b 100644 --- a/source/blender/simulations/bparticles/core.hpp +++ b/source/blender/simulations/bparticles/core.hpp @@ -264,7 +264,7 @@ class ParticleSets { AttributesInfo _info, ArrayRef sets); - operator ArrayRef(); + ArrayRef sets(); void set_byte(uint index, ArrayRef data); void set_byte(StringRef name, ArrayRef data); @@ -631,7 +631,7 @@ inline ArrayRef ParticleAllocator::allocated_blocks() /* ParticleSets inline functions / -inline ParticleSets::operator ArrayRef() +inline ArrayRef ParticleSets::sets() { return m_sets; } diff --git a/source/blender/simulations/bparticles/emitters.cpp b/source/blender/simulations/bparticles/emitters.cpp index c416782c4ba..442b1ae7cec 100644 --- a/source/blender/simulations/bparticles/emitters.cpp +++ b/source/blender/simulations/bparticles/emitters.cpp @@ -44,18 +44,28 @@ class SurfaceEmitter : public Emitter { SharedFunction m_compute_inputs_fn; TupleCallBody *m_compute_inputs_body; WorldState _world_state; + std::unique_ptr m_action; public: SurfaceEmitter(StringRef particle_type_name, SharedFunction _inputs, - WorldState _state) + WorldState _state, + std::unique_ptr action) : m_particle_type_name(particle_type_name.to_std_string()), m_compute_inputs_fn(compute_inputs), -m_world_state(world_state) +m_world_state(world_state), +m_action(std::move(action)) { m_compute_inputs_body = m_compute_inputs_fn->body(); } + class EmitSurfaceEventInfo : public EventInfo { +void *get_info_array(StringRef name) +{ + return nullptr; +} + }; + void emit(EmitterInterface ) override { FN_TUPLE_CALL_ALLOC_TUPLES(m_compute_inputs_body, fn_in, fn_out); @@ -135,6 +145,25 @@ class SurfaceEmitter : public Emitter { target.set_float3("Velocity", velocities); target.set_float("Size", sizes); target.set_float("Birth Time", birth_times); + +AttributesInfo info; +AttributeArraysCore offsets_core(info, {}, 0); +AttributeArrays offsets = offsets_core.slice_all(); + +EmitSurfaceEventInfo event_info; + +for (ParticleSet particles : target.sets()) { + ArrayAllocator::Array durations(interface.array_allocator()); + ArrayRef(durations).fill_indices(particles.pindices(), 0); + ActionInterface action_interface(interface.particle_allocator(), + interface.array_allocator(), + particles, + offsets, +
[Bf-blender-cvs] [5114a48fd7c] functions: correct usage of attribute offsets that are not available
Commit: 5114a48fd7c048cbd9521e340b1e9bef03090aa8 Author: Jacques Lucke Date: Thu Jul 11 10:15:56 2019 +0200 Branches: functions https://developer.blender.org/rB5114a48fd7c048cbd9521e340b1e9bef03090aa8 correct usage of attribute offsets that are not available === M source/blender/simulations/bparticles/actions.cpp M source/blender/simulations/bparticles/attributes.hpp M source/blender/simulations/bparticles/emitters.cpp === diff --git a/source/blender/simulations/bparticles/actions.cpp b/source/blender/simulations/bparticles/actions.cpp index 073df6faf83..8cc736687da 100644 --- a/source/blender/simulations/bparticles/actions.cpp +++ b/source/blender/simulations/bparticles/actions.cpp @@ -25,8 +25,8 @@ class ChangeDirectionAction : public Action { { ParticleSet particles = interface.particles(); auto velocities = particles.attributes().get_float3("Velocity"); -auto position_offsets = interface.attribute_offsets().get_float3("Position"); -auto velocity_offsets = interface.attribute_offsets().get_float3("Velocity"); +auto position_offsets = interface.attribute_offsets().try_get_float3("Position"); +auto velocity_offsets = interface.attribute_offsets().try_get_float3("Velocity"); auto caller = m_compute_inputs.get_caller(particles.attributes(), interface.event_info()); @@ -40,8 +40,13 @@ class ChangeDirectionAction : public Action { float3 direction = fn_out.get(0); velocities[pindex] = direction; - position_offsets[pindex] = direction * interface.remaining_time_in_step(pindex); - velocity_offsets[pindex] = float3(0); + + if (position_offsets.has_value()) { +position_offsets.value()[pindex] = direction * interface.remaining_time_in_step(pindex); + } + if (velocity_offsets.has_value()) { +velocity_offsets.value()[pindex] = float3(0); + } } m_post_action->execute(interface); diff --git a/source/blender/simulations/bparticles/attributes.hpp b/source/blender/simulations/bparticles/attributes.hpp index 295a3676372..830e2435308 100644 --- a/source/blender/simulations/bparticles/attributes.hpp +++ b/source/blender/simulations/bparticles/attributes.hpp @@ -9,12 +9,14 @@ #include "BLI_range.hpp" #include "BLI_small_set_vector.hpp" #include "BLI_array_allocator.hpp" +#include "BLI_optional.hpp" namespace BParticles { using BLI::ArrayAllocator; using BLI::ArrayRef; using BLI::float3; +using BLI::Optional; using BLI::Range; using BLI::SmallSetVector; using BLI::SmallVector; @@ -130,6 +132,24 @@ class AttributesInfo { return m_indices.index(name.to_std_string()); } + /** + * Get the index corresponding to an attribute with the given name and type. + * Returns -1 when the attribute does not exist. + */ + bool attribute_index_try(StringRef name, AttributeType type) const + { +int index = this->attribute_index_try(name); +if (index == -1) { + return -1; +} +else if (this->type_of((uint)index) == type) { + return index; +} +else { + return -1; +} + } + /** * Get the index corresponding to an attribute name. * Asserts when the attribute does not exist. @@ -323,7 +343,8 @@ class AttributeArrays { void init_default(StringRef name); /** - * Get access do the underlying attribute arrays. + * Get access to the underlying attribute arrays. + * Asserts when the attribute does not exists. */ ArrayRef get_byte(uint index) const; ArrayRef get_byte(StringRef name); @@ -332,6 +353,14 @@ class AttributeArrays { ArrayRef get_float3(uint index) const; ArrayRef get_float3(StringRef name); + /** + * Get access to the arrays. + * Does not assert when the attribute does not exist. + */ + Optional> try_get_byte(StringRef name); + Optional> try_get_float(StringRef name); + Optional> try_get_float3(StringRef name); + /** * Get a continuous slice of the attribute arrays. */ @@ -463,6 +492,39 @@ inline ArrayRef AttributeArrays::get_float3(StringRef name) return this->get_float3(this->attribute_index(name)); } +inline Optional> AttributeArrays::try_get_byte(StringRef name) +{ + int index = this->info().attribute_index_try(name, AttributeType::Byte); + if (index == -1) { +return {}; + } + else { +return this->get_byte((uint)index); + } +} + +inline Optional> AttributeArrays::try_get_float(StringRef name) +{ + int index = this->info().attribute_index_try(name, AttributeType::Float); + if (index == -1) { +return {}; + } + else { +return this->get_float((uint)index); + } +} + +inline Optional> AttributeArrays::try_get_float3(StringRef name) +{ + int index = this->info().attribute_index_try(name, AttributeType::Float3); + if (index == -1) { +return {}; + } + else { +return this->get_float3((uint)index);
[Bf-blender-cvs] [7a62e775bb2] functions: simplify calling action from emitter
Commit: 7a62e775bb2d398ae4c88bb90bfe72aa89fd4086 Author: Jacques Lucke Date: Thu Jul 11 11:46:10 2019 +0200 Branches: functions https://developer.blender.org/rB7a62e775bb2d398ae4c88bb90bfe72aa89fd4086 simplify calling action from emitter === M source/blender/simulations/bparticles/action_interface.hpp M source/blender/simulations/bparticles/emitters.cpp === diff --git a/source/blender/simulations/bparticles/action_interface.hpp b/source/blender/simulations/bparticles/action_interface.hpp index 6e56f8cf346..a520ce6f1cf 100644 --- a/source/blender/simulations/bparticles/action_interface.hpp +++ b/source/blender/simulations/bparticles/action_interface.hpp @@ -80,6 +80,11 @@ class ActionInterface { ArrayRef remaining_times, EventInfo _info); + static void RunFromEmitter(std::unique_ptr , + ParticleSets _sets, + EmitterInterface _interface, + EventInfo *event_info = nullptr); + EventInfo _info(); ParticleSet (); @@ -119,6 +124,39 @@ inline ActionInterface::ActionInterface(ParticleAllocator _allocator, { } +class EmptyEventinfo : public EventInfo { + void *get_info_array(StringRef UNUSED(name)) + { +return nullptr; + } +}; + +inline void ActionInterface::RunFromEmitter(std::unique_ptr , +ParticleSets _sets, +EmitterInterface _interface, +EventInfo *event_info) +{ + AttributesInfo info; + AttributeArraysCore offsets_core(info, {}, 0); + AttributeArrays offsets = offsets_core.slice_all(); + + EmptyEventinfo empty_event_info; + EventInfo _event_info = (event_info == nullptr) ? empty_event_info : *event_info; + + for (ParticleSet particles : particle_sets.sets()) { +ArrayAllocator::Array durations(emitter_interface.array_allocator()); +ArrayRef(durations).fill_indices(particles.pindices(), 0); +ActionInterface action_interface(emitter_interface.particle_allocator(), + emitter_interface.array_allocator(), + particles, + offsets, + particles.attributes().get_float("Birth Time"), + durations, + used_event_info); +action->execute(action_interface); + } +} + inline EventInfo ::event_info() { return m_event_info; diff --git a/source/blender/simulations/bparticles/emitters.cpp b/source/blender/simulations/bparticles/emitters.cpp index 442b1ae7cec..53596bc3629 100644 --- a/source/blender/simulations/bparticles/emitters.cpp +++ b/source/blender/simulations/bparticles/emitters.cpp @@ -59,13 +59,6 @@ class SurfaceEmitter : public Emitter { m_compute_inputs_body = m_compute_inputs_fn->body(); } - class EmitSurfaceEventInfo : public EventInfo { -void *get_info_array(StringRef name) -{ - return nullptr; -} - }; - void emit(EmitterInterface ) override { FN_TUPLE_CALL_ALLOC_TUPLES(m_compute_inputs_body, fn_in, fn_out); @@ -146,24 +139,7 @@ class SurfaceEmitter : public Emitter { target.set_float("Size", sizes); target.set_float("Birth Time", birth_times); -AttributesInfo info; -AttributeArraysCore offsets_core(info, {}, 0); -AttributeArrays offsets = offsets_core.slice_all(); - -EmitSurfaceEventInfo event_info; - -for (ParticleSet particles : target.sets()) { - ArrayAllocator::Array durations(interface.array_allocator()); - ArrayRef(durations).fill_indices(particles.pindices(), 0); - ActionInterface action_interface(interface.particle_allocator(), - interface.array_allocator(), - particles, - offsets, - particles.attributes().get_float("Birth Time"), - durations, - event_info); - m_action->execute(action_interface); -} +ActionInterface::RunFromEmitter(m_action, target, interface); } float3 random_point_in_triangle(float3 a, float3 b, float3 c) ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [615269b7492] functions: rename modifiers to effectors
Commit: 615269b749254b451bc94e926acb4f3825f795ff Author: Jacques Lucke Date: Thu Jul 11 11:20:15 2019 +0200 Branches: functions https://developer.blender.org/rB615269b749254b451bc94e926acb4f3825f795ff rename modifiers to effectors === M release/scripts/startup/nodes/bparticle_nodes/particle_type.py === diff --git a/release/scripts/startup/nodes/bparticle_nodes/particle_type.py b/release/scripts/startup/nodes/bparticle_nodes/particle_type.py index 99e331bdc9a..1b14e37162d 100644 --- a/release/scripts/startup/nodes/bparticle_nodes/particle_type.py +++ b/release/scripts/startup/nodes/bparticle_nodes/particle_type.py @@ -8,5 +8,5 @@ class ParticleTypeNode(bpy.types.Node, BParticlesNode): def declaration(self, builder : SocketBuilder): builder.emitter_input("emitters", "Emitters") -builder.particle_modifier_input("modifiers", "Modifiers") +builder.particle_modifier_input("effectors", "Effectors") builder.event_output("events", "Events") ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [35dcbf506de] functions: fill an array partially
Commit: 35dcbf506de5c83af72942abe9cbe22a773c9f0f Author: Jacques Lucke Date: Thu Jul 11 09:53:39 2019 +0200 Branches: functions https://developer.blender.org/rB35dcbf506de5c83af72942abe9cbe22a773c9f0f fill an array partially === M source/blender/blenlib/BLI_array_ref.hpp M source/blender/simulations/bparticles/simulate.cpp M tests/gtests/blenlib/BLI_array_ref_test.cc === diff --git a/source/blender/blenlib/BLI_array_ref.hpp b/source/blender/blenlib/BLI_array_ref.hpp index d17f1e8662d..1c97ea7b537 100644 --- a/source/blender/blenlib/BLI_array_ref.hpp +++ b/source/blender/blenlib/BLI_array_ref.hpp @@ -128,6 +128,16 @@ template class ArrayRef { std::fill_n(m_start, m_size, element); } + /** + * Replace a subset of all elements with the given value. + */ + void fill_indices(ArrayRef indices, const T ) + { +for (uint i : indices) { + m_start[i] = element; +} + } + /** * Copy the values from another array into the references array. */ diff --git a/source/blender/simulations/bparticles/simulate.cpp b/source/blender/simulations/bparticles/simulate.cpp index 891f1e8458a..03c4d8b0a25 100644 --- a/source/blender/simulations/bparticles/simulate.cpp +++ b/source/blender/simulations/bparticles/simulate.cpp @@ -33,10 +33,8 @@ BLI_NOINLINE static void find_next_event_per_particle(ParticleSet particles, ArrayRef r_time_factors_to_next_event, VectorAdaptor _pindices_with_event) { - for (uint pindex : particles.pindices()) { -r_next_event_indices[pindex] = -1; -r_time_factors_to_next_event[pindex] = 1.0f; - } + r_next_event_indices.fill_indices(particles.pindices(), -1); + r_time_factors_to_next_event.fill_indices(particles.pindices(), 1.0f); for (uint event_index = 0; event_index < events.size(); event_index++) { SmallVector triggered_pindices; diff --git a/tests/gtests/blenlib/BLI_array_ref_test.cc b/tests/gtests/blenlib/BLI_array_ref_test.cc index ace7c3f91f2..6559ec67409 100644 --- a/tests/gtests/blenlib/BLI_array_ref_test.cc +++ b/tests/gtests/blenlib/BLI_array_ref_test.cc @@ -179,6 +179,18 @@ TEST(array_ref, Fill) EXPECT_EQ(a[4], 1); } +TEST(array_ref, FillIndices) +{ + std::array a = {0, 0, 0, 0, 0}; + IntArrayRef a_ref(a); + a_ref.fill_indices({0, 2, 3}, 1); + EXPECT_EQ(a[0], 1); + EXPECT_EQ(a[1], 0); + EXPECT_EQ(a[2], 1); + EXPECT_EQ(a[3], 1); + EXPECT_EQ(a[4], 0); +} + TEST(array_ref, CopyFrom) { std::array a = {3, 4, 5}; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [1ef924700c8] sybren-usd: USD: use a struct USDMeshData to group mesh data for USD export
Commit: 1ef924700c802896a556f687af6c5f4d01289a4b Author: Sybren A. Stüvel Date: Thu Jul 11 17:09:07 2019 +0200 Branches: sybren-usd https://developer.blender.org/rB1ef924700c802896a556f687af6c5f4d01289a4b USD: use a struct USDMeshData to group mesh data for USD export === M source/blender/usd/intern/usd_writer_mesh.cc M source/blender/usd/intern/usd_writer_mesh.h === diff --git a/source/blender/usd/intern/usd_writer_mesh.cc b/source/blender/usd/intern/usd_writer_mesh.cc index 2ca8dd064d8..c6c7f51c7c9 100644 --- a/source/blender/usd/intern/usd_writer_mesh.cc +++ b/source/blender/usd/intern/usd_writer_mesh.cc @@ -51,6 +51,13 @@ void USDGenericMeshWriter::free_export_mesh(Mesh *mesh) BKE_id_free(NULL, mesh); } +struct USDMeshData { + pxr::VtArray points; + pxr::VtIntArray face_vertex_counts; + pxr::VtIntArray face_indices; + std::map face_groups; +}; + void USDGenericMeshWriter::write_mesh(HierarchyContext , Mesh *mesh) { pxr::UsdTimeCode timecode = get_export_time_code(); @@ -61,58 +68,50 @@ void USDGenericMeshWriter::write_mesh(HierarchyContext , Mesh *mesh) pxr::UsdGeomMesh usd_mesh = pxr::UsdGeomMesh::Define(stage, usd_path_); - // USD structures for mesh data. - pxr::VtArray usd_points; - pxr::VtIntArray usd_face_vertex_counts, usd_face_indices; - std::map usd_face_groups; - - get_geometry_data(mesh, usd_points, usd_face_vertex_counts, usd_face_indices, usd_face_groups); + USDMeshData usd_mesh_data; + get_geometry_data(mesh, usd_mesh_data); - usd_mesh.CreatePointsAttr().Set(usd_points, timecode); - usd_mesh.CreateFaceVertexCountsAttr().Set(usd_face_vertex_counts, timecode); - usd_mesh.CreateFaceVertexIndicesAttr().Set(usd_face_indices, timecode); + usd_mesh.CreatePointsAttr().Set(usd_mesh_data.points, timecode); + usd_mesh.CreateFaceVertexCountsAttr().Set(usd_mesh_data.face_vertex_counts, timecode); + usd_mesh.CreateFaceVertexIndicesAttr().Set(usd_mesh_data.face_indices, timecode); // TODO(Sybren): figure out what happens when the face groups change. if (frame_has_been_written_) { return; } - assign_materials(context, usd_mesh, usd_face_groups); + assign_materials(context, usd_mesh, usd_mesh_data.face_groups); } -void USDGenericMeshWriter::get_geometry_data(const Mesh *mesh, - pxr::VtArray _points, - pxr::VtIntArray _face_vertex_counts, - pxr::VtIntArray _face_indices, - std::map _face_groups) +void USDGenericMeshWriter::get_geometry_data(const Mesh *mesh, struct USDMeshData _mesh_data) { /* Only construct face groups (a.k.a. geometry subsets) when we need them for material * assignments. */ bool construct_face_groups = mesh->totcol > 1; - usd_points.reserve(mesh->totvert); - usd_face_vertex_counts.reserve(mesh->totpoly); - usd_face_indices.reserve(mesh->totloop); + usd_mesh_data.points.reserve(mesh->totvert); + usd_mesh_data.face_vertex_counts.reserve(mesh->totpoly); + usd_mesh_data.face_indices.reserve(mesh->totloop); // TODO(Sybren): there is probably a more C++-y way to do this, which avoids copying the entire // mesh to a different structure. I haven't seen the approach below in the USD exporters for // Maya/Houdini, but it's simple and it works for now. const MVert *verts = mesh->mvert; for (int i = 0; i < mesh->totvert; ++i) { -usd_points.push_back(pxr::GfVec3f(verts[i].co)); +usd_mesh_data.points.push_back(pxr::GfVec3f(verts[i].co)); } MLoop *mloop = mesh->mloop; MPoly *mpoly = mesh->mpoly; for (int i = 0; i < mesh->totpoly; ++i, ++mpoly) { MLoop *loop = mloop + mpoly->loopstart; -usd_face_vertex_counts.push_back(mpoly->totloop); +usd_mesh_data.face_vertex_counts.push_back(mpoly->totloop); for (int j = 0; j < mpoly->totloop; ++j, ++loop) { - usd_face_indices.push_back(loop->v); + usd_mesh_data.face_indices.push_back(loop->v); } if (construct_face_groups) { - usd_face_groups[mpoly->mat_nr].push_back(i); + usd_mesh_data.face_groups[mpoly->mat_nr].push_back(i); } } } diff --git a/source/blender/usd/intern/usd_writer_mesh.h b/source/blender/usd/intern/usd_writer_mesh.h index ee3a392ff51..b137b16a843 100644 --- a/source/blender/usd/intern/usd_writer_mesh.h +++ b/source/blender/usd/intern/usd_writer_mesh.h @@ -5,6 +5,8 @@ #include +struct USDMeshData; + /* Writer for USD geometry. Does not assume the object is a mesh object. */ class USDGenericMeshWriter : public USDAbstractWriter { public: @@ -18,11 +20,7 @@ class USDGenericMeshWriter : public USDAbstractWriter { private: void write_mesh(HierarchyContext , Mesh *mesh); - void get_geometry_data(const Mesh *mesh, -
[Bf-blender-cvs] [449a1366c80] sybren-usd: USD Export: stop when user presses escape
Commit: 449a1366c808c76c3bb04f587976c0a8088c4ad1 Author: Sybren A. Stüvel Date: Thu Jul 11 16:25:53 2019 +0200 Branches: sybren-usd https://developer.blender.org/rB449a1366c808c76c3bb04f587976c0a8088c4ad1 USD Export: stop when user presses escape === M source/blender/usd/intern/usd_capi.cc === diff --git a/source/blender/usd/intern/usd_capi.cc b/source/blender/usd/intern/usd_capi.cc index 757e2283948..a39f7a2f98d 100644 --- a/source/blender/usd/intern/usd_capi.cc +++ b/source/blender/usd/intern/usd_capi.cc @@ -122,6 +122,9 @@ static void export_startjob(void *customdata, short *stop, short *do_update, flo float progress_per_frame = 0.8f / std::max(1, (scene->r.efra - scene->r.sfra + 1)); for (float frame = scene->r.sfra; frame <= scene->r.efra; frame++) { +if (G.is_break) + break; + printf("\033[35;1mFRAME\033[0m %f\n", frame); // Update the scene for the next frame to render. scene->r.cfra = static_cast(frame); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [ac529e10c71] sybren-usd: Merge remote-tracking branch 'origin/master' into sybren-usd
Commit: ac529e10c71b5798d47a2d08606fa1d69c080de7 Author: Sybren A. Stüvel Date: Thu Jul 11 11:52:15 2019 +0200 Branches: sybren-usd https://developer.blender.org/rBac529e10c71b5798d47a2d08606fa1d69c080de7 Merge remote-tracking branch 'origin/master' into sybren-usd === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [d305148fae6] sybren-usd: HAIR TEST
Commit: d305148fae683fb01951a217281abe16bb39dbd4 Author: Sybren A. Stüvel Date: Thu Jul 11 15:08:40 2019 +0200 Branches: sybren-usd https://developer.blender.org/rBd305148fae683fb01951a217281abe16bb39dbd4 HAIR TEST === M source/blender/usd/intern/usd_writer_hair.cc === diff --git a/source/blender/usd/intern/usd_writer_hair.cc b/source/blender/usd/intern/usd_writer_hair.cc index d8df9294c16..af0d23addcd 100644 --- a/source/blender/usd/intern/usd_writer_hair.cc +++ b/source/blender/usd/intern/usd_writer_hair.cc @@ -31,7 +31,9 @@ void USDHairWriter::do_write(HierarchyContext ) pxr::VtArray points; pxr::VtIntArray curve_point_counts; + pxr::VtArray colors; curve_point_counts.reserve(psys->totpart); + colors.reserve(psys->totpart); ParticleCacheKey **cache = psys->pathcache; ParticleCacheKey *strand; @@ -40,7 +42,7 @@ void USDHairWriter::do_write(HierarchyContext ) int point_count = strand->segments + 1; curve_point_counts.push_back(point_count); -// colors.push_back(pxr::GfVec3f(strand->col)); +colors.push_back(pxr::GfVec3f(strand->col)); for (int point_index = 0; point_index < point_count; ++point_index, ++strand) { points.push_back(pxr::GfVec3f(strand->co)); @@ -49,11 +51,11 @@ void USDHairWriter::do_write(HierarchyContext ) curves.CreatePointsAttr().Set(points, timecode); curves.CreateCurveVertexCountsAttr().Set(curve_point_counts, timecode); + curves.CreateDisplayColorAttr(pxr::VtValue(colors)); if (psys->totpart > 0) { -pxr::VtArray colors; -colors.push_back(pxr::GfVec3f(cache[0]->col)); -curves.CreateDisplayColorAttr(pxr::VtValue(colors)); +// pxr::VtArray colors; +// colors.push_back(pxr::GfVec3f(cache[0]->col)); } } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [99560d9657b] soc-2019-openxr: Disable debug extension on Windows
Commit: 99560d9657b103e1cb61faf9e546d6c5c382b161 Author: Julian Eisel Date: Thu Jul 11 16:44:51 2019 +0200 Branches: soc-2019-openxr https://developer.blender.org/rB99560d9657b103e1cb61faf9e546d6c5c382b161 Disable debug extension on Windows Unfortunately, enabling XR_EXT_debug_utils crashes instance creation with the Windows Mixed Reality runtime. Maybe I'm doing something wrong, for now, just disable it. === M intern/ghost/intern/GHOST_XrContext.cpp === diff --git a/intern/ghost/intern/GHOST_XrContext.cpp b/intern/ghost/intern/GHOST_XrContext.cpp index e4502ae1e99..2d740ca8705 100644 --- a/intern/ghost/intern/GHOST_XrContext.cpp +++ b/intern/ghost/intern/GHOST_XrContext.cpp @@ -326,7 +326,9 @@ void GHOST_XrContext::getExtensionsToEnable(std::vector _ext_nam static std::vector try_ext; /* Try enabling debug extension */ +#ifndef WIN32 XR_DEBUG_ONLY_CALL(this, try_ext.push_back(XR_EXT_DEBUG_UTILS_EXTENSION_NAME)); +#endif r_ext_names.reserve(try_ext.size() + 1); /* + 1 for graphics binding extension. */ ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [b8a7b87873a] soc-2019-openxr: General minor fixes and cleanup
Commit: b8a7b87873a2941d46d29aa3867ac3e398f74862 Author: Julian Eisel Date: Thu Jul 11 16:30:21 2019 +0200 Branches: soc-2019-openxr https://developer.blender.org/rBb8a7b87873a2941d46d29aa3867ac3e398f74862 General minor fixes and cleanup * Initialize all class member variables * Add version to runtime name printing * Separate functionality code from debug prints * Improve code structure using Doxygen groups * Make accessors const functions * Add (Doxygen) comments * Naming * Reorder functions === M intern/ghost/intern/GHOST_XrContext.cpp M intern/ghost/intern/GHOST_XrContext.h M intern/ghost/intern/GHOST_XrSession.cpp M intern/ghost/intern/GHOST_XrSession.h M intern/ghost/intern/GHOST_Xr_intern.h === diff --git a/intern/ghost/intern/GHOST_XrContext.cpp b/intern/ghost/intern/GHOST_XrContext.cpp index bf08adcd25d..e4502ae1e99 100644 --- a/intern/ghost/intern/GHOST_XrContext.cpp +++ b/intern/ghost/intern/GHOST_XrContext.cpp @@ -38,7 +38,7 @@ struct OpenXRInstanceData { static PFN_xrCreateDebugUtilsMessengerEXT s_xrCreateDebugUtilsMessengerEXT_fn; static PFN_xrDestroyDebugUtilsMessengerEXT s_xrDestroyDebugUtilsMessengerEXT_fn; - XrDebugUtilsMessengerEXT debug_messenger; + XrDebugUtilsMessengerEXT debug_messenger{XR_NULL_HANDLE}; }; PFN_xrCreateDebugUtilsMessengerEXT OpenXRInstanceData::s_xrCreateDebugUtilsMessengerEXT_fn = @@ -46,6 +46,11 @@ PFN_xrCreateDebugUtilsMessengerEXT OpenXRInstanceData::s_xrCreateDebugUtilsMesse PFN_xrDestroyDebugUtilsMessengerEXT OpenXRInstanceData::s_xrDestroyDebugUtilsMessengerEXT_fn = nullptr; +/* */ +/** \name Create, Initialize and Destruct + * + * \{ */ + GHOST_XrContext::GHOST_XrContext(const GHOST_XrContextCreateInfo *create_info) : m_oxr(new OpenXRInstanceData()), m_debug(create_info->context_flag & GHOST_kXrContextDebug) { @@ -63,29 +68,25 @@ GHOST_XrContext::~GHOST_XrContext() GHOST_TSuccess GHOST_XrContext::initialize(const GHOST_XrContextCreateInfo *create_info) { - XR_DEBUG_PRINTF(this, "Available OpenXR API-layers/extensions:\n"); if (!enumerateApiLayers() || !enumerateExtensions()) { return GHOST_kFailure; } - XR_DEBUG_PRINTF(this, "Done printing OpenXR API-layers/extensions.\n"); + XR_DEBUG_ONLY_CALL(this, printAvailableAPILayersAndExtensionsInfo()); m_gpu_binding_type = determineGraphicsBindingTypeToEnable(create_info); assert(m_oxr->instance == XR_NULL_HANDLE); createOpenXRInstance(); printInstanceInfo(); - XR_DEBUG_ONLY_BEGIN(this); - initDebugMessenger(); - XR_DEBUG_ONLY_END; + XR_DEBUG_ONLY_CALL(this, initDebugMessenger()); return GHOST_kSuccess; } void GHOST_XrContext::createOpenXRInstance() { - XrInstanceCreateInfo create_info{}; + XrInstanceCreateInfo create_info{XR_TYPE_INSTANCE_CREATE_INFO}; - create_info.type = XR_TYPE_INSTANCE_CREATE_INFO; std::string("Blender").copy(create_info.applicationInfo.applicationName, XR_MAX_APPLICATION_NAME_SIZE); create_info.applicationInfo.apiVersion = XR_CURRENT_API_VERSION; @@ -96,28 +97,108 @@ void GHOST_XrContext::createOpenXRInstance() create_info.enabledApiLayerNames = m_enabled_layers.data(); create_info.enabledExtensionCount = m_enabled_extensions.size(); create_info.enabledExtensionNames = m_enabled_extensions.data(); + XR_DEBUG_ONLY_CALL(this, printExtensionsAndAPILayersToEnable()); xrCreateInstance(_info, _oxr->instance); } +/** \} */ /* Create, Initialize and Destruct */ + +/* */ +/** \name Debug Printing + * + * \{ */ + void GHOST_XrContext::printInstanceInfo() { assert(m_oxr->instance != XR_NULL_HANDLE); - XrInstanceProperties instanceProperties{}; - instanceProperties.type = XR_TYPE_INSTANCE_PROPERTIES; - xrGetInstanceProperties(m_oxr->instance, ); + XrInstanceProperties instance_properties{XR_TYPE_INSTANCE_PROPERTIES}; + xrGetInstanceProperties(m_oxr->instance, _properties); + + printf("Connected to OpenXR runtime: %s (Version %i.%i.%i)\n", + instance_properties.runtimeName, + XR_VERSION_MAJOR(instance_properties.runtimeVersion), + XR_VERSION_MINOR(instance_properties.runtimeVersion), + XR_VERSION_PATCH(instance_properties.runtimeVersion)); +} + +void GHOST_XrContext::printAvailableAPILayersAndExtensionsInfo() +{ + puts("Available OpenXR API-layers/extensions:"); + for (XrApiLayerProperties _info : m_oxr->layers) { +printf("Layer: %s\n", layer_info.layerName); + } + for (XrExtensionProperties _info : m_oxr->extensions) { +printf("Extension: %s\n", ext_info.extensionName); + } +} + +void GHOST_XrContext::printExtensionsAndAPILayersToEnable() +{ + for (const char *layer_name : m_enabled_layers) { +
[Bf-blender-cvs] [06312c6d2db] blender-v2.80-release: Merge branch 'master' into blender-v2.80-release
Commit: 06312c6d2db8a6d959bed153f76a28f9faf866f8 Author: Sergey Sharybin Date: Thu Jul 11 15:50:43 2019 +0200 Branches: blender-v2.80-release https://developer.blender.org/rB06312c6d2db8a6d959bed153f76a28f9faf866f8 Merge branch 'master' into blender-v2.80-release === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [7ad21c3876c] master: Fix T66604: Cycles bake crash on specific scene with volume
Commit: 7ad21c3876c2453f11fd509a0157639d615567fc Author: Sergey Sharybin Date: Thu Jul 11 15:22:03 2019 +0200 Branches: master https://developer.blender.org/rB7ad21c3876c2453f11fd509a0157639d615567fc Fix T66604: Cycles bake crash on specific scene with volume The issue was caused by un-initialized local storage for volume intersection hits which are supposed to be stored in per-thread KernelGlobals. Fix is to make thread_shader() be the same as thread_render() in respect of KernelGlobals. Reviewers: brecht Reviewed By: brecht Differential Revision: https://developer.blender.org/D5230 === M intern/cycles/device/device_cpu.cpp === diff --git a/intern/cycles/device/device_cpu.cpp b/intern/cycles/device/device_cpu.cpp index dc9adcb1537..b2d923dfdf0 100644 --- a/intern/cycles/device/device_cpu.cpp +++ b/intern/cycles/device/device_cpu.cpp @@ -980,14 +980,11 @@ class CPUDevice : public Device { void thread_shader(DeviceTask ) { -KernelGlobals kg = kernel_globals; +KernelGlobals *kg = new KernelGlobals(thread_kernel_globals_init()); -#ifdef WITH_OSL -OSLShader::thread_init(, _globals, _globals); -#endif for (int sample = 0; sample < task.num_samples; sample++) { for (int x = task.shader_x; x < task.shader_x + task.shader_w; x++) -shader_kernel()(, +shader_kernel()(kg, (uint4 *)task.shader_input, (float4 *)task.shader_output, task.shader_eval_type, @@ -1002,9 +999,8 @@ class CPUDevice : public Device { task.update_progress(NULL); } -#ifdef WITH_OSL -OSLShader::thread_free(); -#endif +thread_kernel_globals_free(kg); +delete kg; } int get_split_task_count(DeviceTask ) ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [8a1552545a6] master: Fix T66672: auto and manual texture space affected by modifiers
Commit: 8a1552545a6274d2ff201e0f98067199cbd47cc2 Author: Brecht Van Lommel Date: Thu Jul 11 13:39:19 2019 +0200 Branches: master https://developer.blender.org/rB8a1552545a6274d2ff201e0f98067199cbd47cc2 Fix T66672: auto and manual texture space affected by modifiers It should be based on the mesh bounds before modifier stack evaluation, but some modifiers were causing it to be recomputed. The flag to disable texture space recomputation was not preserved through modifier evaluation. Differential Revision: https://developer.blender.org/D5225 === M source/blender/blenkernel/intern/mesh.c === diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 04164de91ca..f5e93dcf9b7 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -665,6 +665,7 @@ static Mesh *mesh_new_nomain_from_template_ex(const Mesh *me_src, me_dst->cd_flag = me_src->cd_flag; me_dst->editflag = me_src->editflag; + me_dst->texflag = me_src->texflag; CustomData_copy(_src->vdata, _dst->vdata, mask.vmask, CD_CALLOC, verts_len); CustomData_copy(_src->edata, _dst->edata, mask.emask, CD_CALLOC, edges_len); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [f0b72a776ed] master: Fix T66706: crash in viewport shading popover for workbench engine
Commit: f0b72a776ed888da798b41ce43995f7b5ac11ec0 Author: Brecht Van Lommel Date: Thu Jul 11 14:13:22 2019 +0200 Branches: master https://developer.blender.org/rBf0b72a776ed888da798b41ce43995f7b5ac11ec0 Fix T66706: crash in viewport shading popover for workbench engine Differential Revision: https://developer.blender.org/D5226 === M source/blender/makesrna/intern/rna_space.c === diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 1c76753fb1b..2ba5e2ae68c 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -1067,11 +1067,7 @@ static const EnumPropertyItem *rna_View3DShading_color_type_itemf(bContext *UNUS int totitem = 0; - if (shading->type == OB_SOLID) { -r_free = false; -return rna_enum_shading_color_type_items; - } - else if (shading->type == OB_WIRE) { + if (shading->type == OB_WIRE) { EnumPropertyItem *item = NULL; RNA_enum_items_add_value( , , rna_enum_shading_color_type_items, V3D_SHADING_SINGLE_COLOR); @@ -1084,8 +1080,9 @@ static const EnumPropertyItem *rna_View3DShading_color_type_itemf(bContext *UNUS return item; } else { -*r_free = false; -return NULL; +/* Solid mode, or lookdev mode for workbench engine. */ +r_free = false; +return rna_enum_shading_color_type_items; } } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [6f25eda4d7f] soc-2019-embree-gpu: Update timing information
Commit: 6f25eda4d7f60f04e5cd54c9f199ee499763d7c1 Author: MATILLAT Quentin Date: Thu Jul 11 15:05:32 2019 +0200 Branches: soc-2019-embree-gpu https://developer.blender.org/rB6f25eda4d7f60f04e5cd54c9f199ee499763d7c1 Update timing information Timing information are now stored using the same system as visibility : Each node store information from his children === M intern/cycles/bvh/bvh2.cpp M intern/cycles/bvh/bvh2.h M intern/cycles/bvh/bvh_embree_converter.cpp M intern/cycles/bvh/bvh_node.cpp M intern/cycles/kernel/bvh/bvh_local.h M intern/cycles/kernel/bvh/bvh_nodes.h M intern/cycles/kernel/bvh/bvh_shadow_all.h M intern/cycles/kernel/bvh/bvh_traversal.h M intern/cycles/kernel/bvh/bvh_volume.h M intern/cycles/kernel/bvh/bvh_volume_all.h === diff --git a/intern/cycles/bvh/bvh2.cpp b/intern/cycles/bvh/bvh2.cpp index edec6a9aebe..0475ac33887 100644 --- a/intern/cycles/bvh/bvh2.cpp +++ b/intern/cycles/bvh/bvh2.cpp @@ -76,8 +76,8 @@ void BVH2::pack_aligned_inner(const BVHStackEntry , e1.node->bounds, e0.encodeIdx(), e1.encodeIdx(), -e.node->time_from, -e.node->time_to, +make_float2(e0.node->time_from, e0.node->time_to), +make_float2(e1.node->time_from, e1.node->time_to), e0.node->visibility, e1.node->visibility); } @@ -87,8 +87,8 @@ void BVH2::pack_aligned_node(int idx, const BoundBox , int c0, int c1, - float timeFrom, - float timeTo, + float2 time0, + float2 time1, uint visibility0, uint visibility1) { @@ -111,9 +111,10 @@ void BVH2::pack_aligned_node(int idx, __float_as_int(b1.min.z), __float_as_int(b0.max.z), __float_as_int(b1.max.z)), - make_int4(__float_as_int(timeFrom), -__float_as_int(timeTo), -0, 0), + make_int4(__float_as_int(time0.x), +__float_as_int(time1.x), +__float_as_int(time0.y), +__float_as_int(time1.y)), }; memcpy([idx], data, sizeof(int4) * BVH_NODE_SIZE); @@ -289,7 +290,12 @@ void BVH2::refit_node(int idx, bool leaf, BoundBox , uint ) idx, aligned_space, aligned_space, bbox0, bbox1, c0, c1, visibility0, visibility1); } else { - pack_aligned_node(idx, bbox0, bbox1, c0, c1, __int_as_float(data[4].x), __int_as_float(data[4].y), visibility0, visibility1); + pack_aligned_node(idx, +bbox0, bbox1, +c0, c1, +make_float2(__int_as_float(data[4].x), __int_as_float(data[4].z)), +make_float2(__int_as_float(data[4].y), __int_as_float(data[4].w)), +visibility0, visibility1); } bbox.grow(bbox0); diff --git a/intern/cycles/bvh/bvh2.h b/intern/cycles/bvh/bvh2.h index 08938a04bc1..3a371a1d79c 100644 --- a/intern/cycles/bvh/bvh2.h +++ b/intern/cycles/bvh/bvh2.h @@ -65,8 +65,8 @@ class BVH2 : public BVH { const BoundBox , int c0, int c1, - float timeFrom, - float timeTo, + float2 time0, + float2 time1, uint visibility0, uint visibility1); diff --git a/intern/cycles/bvh/bvh_embree_converter.cpp b/intern/cycles/bvh/bvh_embree_converter.cpp index b9e2ca6954d..b93b6039c54 100644 --- a/intern/cycles/bvh/bvh_embree_converter.cpp +++ b/intern/cycles/bvh/bvh_embree_converter.cpp @@ -330,6 +330,7 @@ BVHNode* BVHEmbreeConverter::getBVH2() { std::cout << root->getSubtreeSize(BVH_STAT_TIMELIMIT_NODE) << " times nodes" << std::endl; std::cout << "BVH4 SAH is " << root->computeSubtreeSAHCost(this->params) << std::endl; root = bvh_shrink(root); +std::cout << root->getSubtreeSize(BVH_STAT_TIMELIMIT_NODE) << " times nodes" << std::endl; std::cout << "BVH2 SAH is " << root->computeSubtreeSAHCost(this->params) << std::endl; return root; } diff --git a/intern/cycles/bvh/bvh_node.cpp b/intern/cycles/bvh/bvh_node.cpp index 0e3db43ecb1..413f5befcca 100644 --- a/intern/cycles/bvh/bvh_node.cpp +++ b/intern/cycles/bvh/bvh_node.cpp @@ -92,7 +92,7 @@ int BVHNode::getSubtreeSize(BVH_STAT stat) const } return cnt; case BVH_STAT_TIMELIMIT_NODE: - if(this->time_from != 0 || this->time_to != 1) + if(this->time_from
[Bf-blender-cvs] [4510849e3d8] soc-2019-embree-gpu: Add time limits for each nodes
Commit: 4510849e3d8ddfd2eb167deaf9c0d0aff6754197 Author: MATILLAT Quentin Date: Wed Jul 10 17:37:16 2019 +0200 Branches: soc-2019-embree-gpu https://developer.blender.org/rB4510849e3d8ddfd2eb167deaf9c0d0aff6754197 Add time limits for each nodes === M intern/cycles/bvh/bvh2.cpp M intern/cycles/bvh/bvh2.h M intern/cycles/bvh/bvh_embree.cpp M intern/cycles/bvh/bvh_embree_converter.cpp M intern/cycles/bvh/bvh_embree_converter.h M intern/cycles/bvh/bvh_node.cpp M intern/cycles/bvh/bvh_node.h M intern/cycles/kernel/bvh/bvh_traversal.h === diff --git a/intern/cycles/bvh/bvh2.cpp b/intern/cycles/bvh/bvh2.cpp index fbbcb9589f0..edec6a9aebe 100644 --- a/intern/cycles/bvh/bvh2.cpp +++ b/intern/cycles/bvh/bvh2.cpp @@ -76,6 +76,8 @@ void BVH2::pack_aligned_inner(const BVHStackEntry , e1.node->bounds, e0.encodeIdx(), e1.encodeIdx(), +e.node->time_from, +e.node->time_to, e0.node->visibility, e1.node->visibility); } @@ -85,6 +87,8 @@ void BVH2::pack_aligned_node(int idx, const BoundBox , int c0, int c1, + float timeFrom, + float timeTo, uint visibility0, uint visibility1) { @@ -107,6 +111,9 @@ void BVH2::pack_aligned_node(int idx, __float_as_int(b1.min.z), __float_as_int(b0.max.z), __float_as_int(b1.max.z)), + make_int4(__float_as_int(timeFrom), +__float_as_int(timeTo), +0, 0), }; memcpy([idx], data, sizeof(int4) * BVH_NODE_SIZE); @@ -209,6 +216,7 @@ void BVH2::pack_nodes(const BVHNode *root) pack_leaf(e, leaf); } else { + assert(e.node->num_children() == 2); /* inner node */ int idx[2]; for (int i = 0; i < 2; ++i) { @@ -281,7 +289,7 @@ void BVH2::refit_node(int idx, bool leaf, BoundBox , uint ) idx, aligned_space, aligned_space, bbox0, bbox1, c0, c1, visibility0, visibility1); } else { - pack_aligned_node(idx, bbox0, bbox1, c0, c1, visibility0, visibility1); + pack_aligned_node(idx, bbox0, bbox1, c0, c1, __int_as_float(data[4].x), __int_as_float(data[4].y), visibility0, visibility1); } bbox.grow(bbox0); diff --git a/intern/cycles/bvh/bvh2.h b/intern/cycles/bvh/bvh2.h index c6a4e6fa73a..08938a04bc1 100644 --- a/intern/cycles/bvh/bvh2.h +++ b/intern/cycles/bvh/bvh2.h @@ -34,7 +34,7 @@ class LeafNode; class Object; class Progress; -#define BVH_NODE_SIZE 4 +#define BVH_NODE_SIZE (4+1) #define BVH_NODE_LEAF_SIZE 1 #define BVH_UNALIGNED_NODE_SIZE 7 @@ -65,6 +65,8 @@ class BVH2 : public BVH { const BoundBox , int c0, int c1, + float timeFrom, + float timeTo, uint visibility0, uint visibility1); diff --git a/intern/cycles/bvh/bvh_embree.cpp b/intern/cycles/bvh/bvh_embree.cpp index 2fb216ad88c..2be512d38c8 100644 --- a/intern/cycles/bvh/bvh_embree.cpp +++ b/intern/cycles/bvh/bvh_embree.cpp @@ -816,6 +816,7 @@ void BVHEmbree::add_curves(Object *ob, int i) rtcAttachGeometryByID(scene, geom_id, i * 2 + 1); rtcReleaseGeometry(geom_id); } + void BVHEmbree::pack_nodes(const BVHNode *r) { if(this->bvh_layout == BVH_LAYOUT_EMBREE_CONVERTED) { @@ -970,6 +971,7 @@ void BVHEmbree::refit_nodes() } rtcCommitScene(scene); } + CCL_NAMESPACE_END #endif /* WITH_EMBREE */ diff --git a/intern/cycles/bvh/bvh_embree_converter.cpp b/intern/cycles/bvh/bvh_embree_converter.cpp index 77dbcdc6747..b9e2ca6954d 100644 --- a/intern/cycles/bvh/bvh_embree_converter.cpp +++ b/intern/cycles/bvh/bvh_embree_converter.cpp @@ -40,7 +40,7 @@ struct RangeInput { std::stack groupByRange(std::vector ) { std::sort(ids.begin(), ids.end(), [](const RangeInput , const RangeInput ) -> bool { -return lhs.id > rhs.id; +return lhs.id < rhs.id; }); std::stack groups; @@ -94,11 +94,10 @@ BVHEmbreeConverter::BVHEmbreeConverter(RTCScene scene, std::vector obj objects(objects), params(params) {} - -template -std::deque BVHEmbreeConverter::handleLeaf(const embree::BVH4::NodeRef , const BoundBox &) { +template<> +std::deque BVHEmbreeConverter::handleLeaf(const embree::BVH4::NodeRef , const BoundBox ) { size_t nb; -Primitive *prims = reinterpret_cast(node.leaf(nb)); +embree::Triangle4i *prims = reinterpret_cast(node.leaf(nb)); std::vector ids; ids.reserve(nb * 4); for(size_t i = 0; i < nb;
[Bf-blender-cvs] [d663048696b] master: Fix T66691: Ceash trying to render the 2.80 splash image
Commit: d663048696b2d63a65d607e5e8dec3b2b320982c Author: Sergey Sharybin Date: Thu Jul 11 12:59:19 2019 +0200 Branches: master https://developer.blender.org/rBd663048696b2d63a65d607e5e8dec3b2b320982c Fix T66691: Ceash trying to render the 2.80 splash image Was caused by ray direction becoming NaN after some of the bounces. === M intern/cycles/kernel/bvh/bvh.h === diff --git a/intern/cycles/kernel/bvh/bvh.h b/intern/cycles/kernel/bvh/bvh.h index 7503bad37b0..be0f05285e8 100644 --- a/intern/cycles/kernel/bvh/bvh.h +++ b/intern/cycles/kernel/bvh/bvh.h @@ -174,7 +174,7 @@ ccl_device_inline bool scene_intersect_valid(const Ray *ray) * From production scenes so far it seems it's enough to test first element * only. */ - return isfinite(ray->P.x); + return isfinite_safe(ray->P.x) && isfinite_safe(ray->D.x); } /* Note: ray is passed by value to work around a possible CUDA compiler bug. */ ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [7c48b6c84cb] master: Fix for RC release step to also point at 'current' API doc link.
Commit: 7c48b6c84cbbeb76b9fea5f9bee70e833afc7b8e Author: Bastien Montagne Date: Thu Jul 11 11:50:58 2019 +0200 Branches: master https://developer.blender.org/rB7c48b6c84cbbeb76b9fea5f9bee70e833afc7b8e Fix for RC release step to also point at 'current' API doc link. RC's are supposed to be like "real" releases... === M release/scripts/startup/bl_operators/wm.py === diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py index f2b885d0064..b68ef3da6da 100644 --- a/release/scripts/startup/bl_operators/wm.py +++ b/release/scripts/startup/bl_operators/wm.py @@ -1022,7 +1022,7 @@ class WM_OT_doc_view(Operator): bl_label = "View Documentation" doc_id: doc_id -if bpy.app.version_cycle == "release": +if bpy.app.version_cycle in {"release", "rc"}: _prefix = ("https://docs.blender.org/api/current;) else: _prefix = ("https://docs.blender.org/api/master;) ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [03d8bfb1447] master: API Doc link: make releases/RC's point to their own version of the doc.
Commit: 03d8bfb1447593f8460ce9d67ba17eabcb1aec3d Author: Bastien Montagne Date: Thu Jul 11 12:04:27 2019 +0200 Branches: master https://developer.blender.org/rB03d8bfb1447593f8460ce9d67ba17eabcb1aec3d API Doc link: make releases/RC's point to their own version of the doc. Sounds kind of stupid to have 2.79 pointing to "current" which is now 2.80 API doc... Let's try to avoid that in future. === M release/scripts/startup/bl_operators/wm.py === diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py index b68ef3da6da..5cc4b773b54 100644 --- a/release/scripts/startup/bl_operators/wm.py +++ b/release/scripts/startup/bl_operators/wm.py @@ -1023,7 +1023,8 @@ class WM_OT_doc_view(Operator): doc_id: doc_id if bpy.app.version_cycle in {"release", "rc"}: -_prefix = ("https://docs.blender.org/api/current;) +_prefix = ("https://docs.blender.org/api/%d.%d%s; % + (bpy.app.version[0], bpy.app.version[1], bpy.app.version_char)) else: _prefix = ("https://docs.blender.org/api/master;) ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [3c4f6399d98] master: Fix T66628: "Auto Saved Modified Image" not working
Commit: 3c4f6399d987fb3f832ba3c1ca0fea9426d6d7f5 Author: Jacques Lucke Date: Thu Jul 11 12:06:21 2019 +0200 Branches: master https://developer.blender.org/rB3c4f6399d987fb3f832ba3c1ca0fea9426d6d7f5 Fix T66628: "Auto Saved Modified Image" not working Reviewer: brecht === M source/blender/windowmanager/intern/wm_files.c === diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index 49b13da6b21..ef957fa03c5 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -2949,7 +2949,12 @@ static void wm_block_file_close_save(bContext *C, void *arg_block, void *arg_dat UI_popup_block_close(C, win, arg_block); if (save_images_when_file_is_closed) { -if (!ED_image_should_save_modified(C)) { +if (ED_image_should_save_modified(C)) { + ReportList *reports = CTX_wm_reports(C); + ED_image_save_all_modified(C, reports); + WM_report_banner_show(); +} +else { execute_callback = false; } } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [b6a1af07b4d] soc-2019-fast-io: [Fast import/export] Small refactoring to consistently use size_t isntead of ulong
Commit: b6a1af07b4dbd8836c0c0cfb3c7ec5e1be93001c Author: Hugo Sales Date: Thu Jul 11 10:31:35 2019 +0100 Branches: soc-2019-fast-io https://developer.blender.org/rBb6a1af07b4dbd8836c0c0cfb3c7ec5e1be93001c [Fast import/export] Small refactoring to consistently use size_t isntead of ulong === M source/blender/editors/io/intern/common.hpp M source/blender/editors/io/intern/iterators.hpp M source/blender/editors/io/intern/obj.cpp === diff --git a/source/blender/editors/io/intern/common.hpp b/source/blender/editors/io/intern/common.hpp index 641f401452c..ed2ad4a9a27 100644 --- a/source/blender/editors/io/intern/common.hpp +++ b/source/blender/editors/io/intern/common.hpp @@ -55,7 +55,6 @@ extern "C" { # include namespace common { -using ulong = unsigned long; // --- PROTOTYPES --- @@ -127,9 +126,9 @@ template using set_t = std::set; template using set_mapping_t = std::vector::iterator>; // A pair of the two above, to tie them together template using dedup_pair_t = std::pair, set_mapping_t>; -// The set key for UV and normal. ulong is the original index -using uv_key_t = std::pair, ulong>; -using no_key_t = std::pair, ulong>; +// The set key for UV and normal. size_t is the original index +using uv_key_t = std::pair, size_t>; +using no_key_t = std::pair, size_t>; // Construct a new deduplicated set for either normals or UVs, with the given similarity threshold // C++14/17 would be useful here... diff --git a/source/blender/editors/io/intern/iterators.hpp b/source/blender/editors/io/intern/iterators.hpp index b716238076c..dc84a28d5c5 100644 --- a/source/blender/editors/io/intern/iterators.hpp +++ b/source/blender/editors/io/intern/iterators.hpp @@ -577,13 +577,13 @@ struct deduplicated_iterator { using iterator_category = Tag; deduplicated_iterator(const Mesh *const mesh, dedup_pair_t , -ulong , +size_t , SourceIter it) : it(it), mesh(mesh), dedup_pair(dp), total(total) { } deduplicated_iterator( - const Mesh *const mesh, dedup_pair_t , ulong , ulong reserve, SourceIter it) + const Mesh *const mesh, dedup_pair_t , size_t , size_t reserve, SourceIter it) : deduplicated_iterator(mesh, dp, total, it) { // Reserve space so we don't constantly allocate @@ -643,13 +643,13 @@ struct deduplicated_iterator { SourceIter it; const Mesh *const mesh; dedup_pair_t _pair; - ulong + size_t }; // Iterator to deduplicated normals (returns `const std::array`) struct deduplicated_normal_iter : deduplicated_iterator { deduplicated_normal_iter(const Mesh *const mesh, - ulong , + size_t , dedup_pair_t , const float (*mat)[4]) : deduplicated_iterator( diff --git a/source/blender/editors/io/intern/obj.cpp b/source/blender/editors/io/intern/obj.cpp index b01ec8ff1ca..98679c63b75 100644 --- a/source/blender/editors/io/intern/obj.cpp +++ b/source/blender/editors/io/intern/obj.cpp @@ -4,13 +4,14 @@ extern "C" { #include "BLI_math.h" #include "BLT_translation.h" +#include "BKE_context.h" +#include "BKE_customdata.h" +#include "BKE_global.h" +#include "BKE_library.h" #include "BKE_mesh.h" +#include "BKE_mesh_mapping.h" #include "BKE_mesh_runtime.h" -#include "BKE_global.h" -#include "BKE_context.h" #include "BKE_scene.h" -#include "BKE_library.h" -#include "BKE_customdata.h" #include "DNA_curve_types.h" #include "DNA_ID.h" @@ -214,7 +215,7 @@ bool OBJ_export_curve(bContext *UNUSED(C), totvert += num_points; fprintf(file, "g %s\n", common::get_object_name(eob, cu).c_str()); -fprintf(file, "cstype bspline\ndeg %lu\n", deg_order_u); +fprintf(file, "cstype bspline\ndeg %zu\n", deg_order_u); size_t real_num_points = num_points; if (closed) { @@ -343,13 +344,14 @@ bool OBJ_export_meshes(bContext *UNUSED(C), no = me.no_offset + l.v + 1; } if (settings->export_uvs && settings->export_normals && me.mesh->mloopuv != nullptr) - fprintf(file, " %lu/%lu/%lu", vx, uv, no); + fprintf(file, " %zu/%zu/%zu", vx, uv, no); else if (settings->export_uvs && me.mesh->mloopuv != nullptr) - fprintf(file, " %lu/%lu", vx, uv); + fprintf(file, " %zu/%zu", vx, uv); else if (settings->export_normals) - fprintf(file, " %lu//%lu", vx, no); + fprintf(file, " %zu//%zu", vx, no); else - fprintf(file, " %lu", vx); + fprintf(file, " %zu", vx); +++li; } fputc('\n', file); } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org
[Bf-blender-cvs] [7b26bc3779c] soc-2019-fast-io: Merge remote-tracking branch 'origin/master' into soc-2019-fast-io
Commit: 7b26bc3779c7130f0b41740340a529142072b0cc Author: Hugo Sales Date: Wed Jul 10 10:31:26 2019 +0100 Branches: soc-2019-fast-io https://developer.blender.org/rB7b26bc3779c7130f0b41740340a529142072b0cc Merge remote-tracking branch 'origin/master' into soc-2019-fast-io === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [d1409d2420d] soc-2019-fast-io: [Fast import/export] Added support for smooth groups
Commit: d1409d2420d929f47a79df70bca4301394d10b12 Author: Hugo Sales Date: Thu Jul 11 10:43:05 2019 +0100 Branches: soc-2019-fast-io https://developer.blender.org/rBd1409d2420d929f47a79df70bca4301394d10b12 [Fast import/export] Added support for smooth groups === M source/blender/editors/io/intern/obj.cpp M source/blender/editors/io/io_obj.c M source/blender/editors/io/io_obj.h === diff --git a/source/blender/editors/io/intern/obj.cpp b/source/blender/editors/io/intern/obj.cpp index e9cae2f8f34..6f6a43a44de 100644 --- a/source/blender/editors/io/intern/obj.cpp +++ b/source/blender/editors/io/intern/obj.cpp @@ -332,7 +332,41 @@ bool OBJ_export_meshes(bContext *UNUSED(C), fprintf(file, "g %s\n", name.c_str()); } -for (const MPoly : common::poly_iter(me.mesh)) { +int group_total = 0, *smooth_groups = nullptr; +if (format_specific->export_smooth_groups) { + smooth_groups = BKE_mesh_calc_smoothgroups(me.mesh->medge, + me.mesh->totedge, + me.mesh->mpoly, + me.mesh->totpoly, + me.mesh->mloop, + me.mesh->totloop, + _total, + format_specific->smooth_groups_bitflags); +} + +size_t poly_index = 0; +int state_smooth = -1; +for (auto pi = common::poly_iter(me.mesh); pi != pi.end(); ++pi, ++poly_index) { + const MPoly = *pi; + // Smooth indices start at 1, so 0 is not a valid index + int smooth = (p.flag & ME_SMOOTH) ? 1 : 0; + if (smooth && smooth_groups) { +smooth = smooth_groups[poly_index % group_total]; + } + + if (smooth != state_smooth) { +state_smooth = smooth; +if (smooth && smooth_groups) { + fprintf(file, "s %d\n", smooth_groups[poly_index]); +} +else if (smooth) { + fputs("s 1\n", file); +} +else { + fputs("s off\n", file); +} + } + fputc('f', file); // Loop index int li = p.loopstart; diff --git a/source/blender/editors/io/io_obj.c b/source/blender/editors/io/io_obj.c index 220a8595714..2633ef7a1f2 100644 --- a/source/blender/editors/io/io_obj.c +++ b/source/blender/editors/io/io_obj.c @@ -54,6 +54,8 @@ static int wm_obj_export_exec(bContext *C, wmOperator *op) format_specific->export_objects_as_objects = RNA_boolean_get(op->ptr, "export_objects_as_objects"); format_specific->export_objects_as_groups = RNA_boolean_get(op->ptr, "export_objects_as_groups"); + format_specific->export_smooth_groups = RNA_boolean_get(op->ptr, "export_smooth_groups"); + format_specific->smooth_groups_bitflags = RNA_boolean_get(op->ptr, "smooth_groups_bitflags"); if (!format_specific->export_animations) { format_specific->start_frame = BKE_scene_frame_get(CTX_data_scene(C)); @@ -167,6 +169,15 @@ static void wm_obj_export_draw(bContext *C, wmOperator *op) uiLayoutSetEnabled(row, materials); uiItemR(row, , "path_mode", 0, NULL, ICON_NONE); + sub_box = uiLayoutBox(box); + row = uiLayoutRow(sub_box, false); + uiItemR(row, , "export_smooth_groups", 0, NULL, ICON_NONE); + + const bool smooth_groups = RNA_boolean_get(, "export_smooth_groups"); + row = uiLayoutRow(sub_box, false); + uiLayoutSetEnabled(row, smooth_groups); + uiItemR(row, , "smooth_groups_bitflags", 0, NULL, ICON_NONE); + row = uiLayoutRow(box, false); uiItemR(row, , "export_vcolors", 0, NULL, ICON_NONE); @@ -318,7 +329,7 @@ void WM_OT_obj_export(struct wmOperatorType *ot) RNA_def_boolean( ot->srna, "export_curves", false, "Export curves", "Export curves and NURBS surfaces"); - RNA_def_boolean(ot->srna, "pack_uv", 1, "Pack UV Islands", "Export UVs with packed island"); + RNA_def_boolean(ot->srna, "pack_uv", false, "Pack UV Islands", "Export UVs with packed island"); RNA_def_enum(ot->srna, "path_mode", @@ -327,6 +338,18 @@ void WM_OT_obj_export(struct wmOperatorType *ot) "Path mode", "How external files (such as images) are treated"); + RNA_def_boolean(ot->srna, + "export_smooth_groups", + false, + "Smooth Groups", + "Write sharp edges as smooth groups"); + + RNA_def_boolean(ot->srna, + "smooth_groups_bitflags", + false, + "Bitflags", + "Use bitflags for smooth groups (produces at most 32 groups)"); + /* This dummy prop is used to check whether we need to init the start and *
[Bf-blender-cvs] [7d99e457cda] soc-2019-fast-io: [Fast import/export] Fixed indexes of normals, using poly vertex instead of insertion order
Commit: 7d99e457cdaf01a9bf61376ea5e00e074cf7da2a Author: Hugo Sales Date: Thu Jul 11 10:41:06 2019 +0100 Branches: soc-2019-fast-io https://developer.blender.org/rB7d99e457cdaf01a9bf61376ea5e00e074cf7da2a [Fast import/export] Fixed indexes of normals, using poly vertex instead of insertion order === M source/blender/editors/io/intern/common.cpp M source/blender/editors/io/intern/iterators.hpp M source/blender/editors/io/intern/obj.cpp === diff --git a/source/blender/editors/io/intern/common.cpp b/source/blender/editors/io/intern/common.cpp index f599115b4d3..bed96c4b5d3 100644 --- a/source/blender/editors/io/intern/common.cpp +++ b/source/blender/editors/io/intern/common.cpp @@ -141,8 +141,8 @@ bool get_axis_remap_and_scale_matrix(float ()[4][4], int forward, int up, fl ++axis_from; } // A bit hacky, but it's a pointer anyway, it just modifies the first three elements - cross_v3_v3v3(mat[other_axis], mat[up], mat[forward]); mat[other_axis][3] = 0; + cross_v3_v3v3(mat[other_axis], mat[up], mat[forward]); return true; } diff --git a/source/blender/editors/io/intern/iterators.hpp b/source/blender/editors/io/intern/iterators.hpp index dc84a28d5c5..fbe8b878208 100644 --- a/source/blender/editors/io/intern/iterators.hpp +++ b/source/blender/editors/io/intern/iterators.hpp @@ -408,24 +408,31 @@ struct points_of_nurbs_iter : pointer_iterator_base { // Iterator over the UVs of a mesh (as `const std::array`) struct uv_iter : pointer_iterator_base { - uv_iter(const Mesh *const m) : pointer_iterator_base(m->mloopuv, m->mloopuv ? m->totloop : 0) + uv_iter(const Mesh *const m, const size_t ) + : pointer_iterator_base(m->mloopuv, m->mloopuv ? m->totloop : 0), total(total) { } - uv_iter(const pointer_iterator_base ) : pointer_iterator_base(pi) + uv_iter(const pointer_iterator_base , const size_t ) + : pointer_iterator_base(pi), total(total) { } uv_iter begin() const { -return {{this->first, this->size, this->first}}; +return {{this->first, this->size, this->first}, total}; } uv_iter end() const { -return {{this->first + this->size, this->size, this->first}}; +return {{this->first + this->size, this->size, this->first}, total}; } inline const std::array operator*() { return {this->curr->uv[0], this->curr->uv[1]}; } + size_t index() const + { +return total; + } + const size_t }; // Iterator over the normals of mesh @@ -511,6 +518,10 @@ struct normal_iter { } } } + size_t index() const + { +return ml->v; + } const Mesh *const mesh; const MPoly *mp; const MLoop *ml; @@ -558,6 +569,10 @@ struct transformed_normal_iter { mul_v3_m4v3(no.data(), mat, no.data()); return no; } + size_t index() const + { +return ni.ml->v; + } normal_iter ni; Mat mat; }; @@ -586,14 +601,14 @@ struct deduplicated_iterator { const Mesh *const mesh, dedup_pair_t , size_t , size_t reserve, SourceIter it) : deduplicated_iterator(mesh, dp, total, it) { -// Reserve space so we don't constantly allocate -// if (dedup_pair.second.size() + reserve > dedup_pair.second.capacity()) { -dedup_pair.second.reserve(reserve); -// } -// Need to insert the first element, because we need to dereference before incrementing if (this->it != this->it.end()) { - auto p = dedup_pair.first.insert(std::make_pair(*this->it, total++)); + // Reserve space so we don't constantly allocate + dedup_pair.second.reserve(reserve); + auto p = dedup_pair.first.insert(std::make_pair(*this->it, this->it.index())); + // Need to insert the first element, because we need to dereference before incrementing + // dedup_pair.second.insert(dedup_pair.second.end(), reserve - dedup_pair.second.size(), {}); dedup_pair.second.push_back(p.first); + ++total; ++this->it; } } @@ -615,13 +630,13 @@ struct deduplicated_iterator { if (this->it == this->it.end()) return *this; // try to insert it into the set - auto p = dedup_pair.first.insert(std::make_pair(*this->it, total)); + auto p = dedup_pair.first.insert(std::make_pair(*this->it, this->it.index())); // push the set::iterator onto the back of the mapping vector dedup_pair.second.push_back(p.first); // If we actually inserted in the set if (p.second) { // There's a new element, so increment the total and stop -++total; +++this->total; return *this; } } @@ -653,7 +668,7 @@ struct deduplicated_normal_iter : deduplicated_iterator , const float (*mat)[4]) : deduplicated_iterator( -mesh, dp, total, total + mesh->totvert, transformed_normal_iter(mesh, mat)) +mesh, dp,
[Bf-blender-cvs] [ed9bc5f5c01] functions: Merge branch 'master' into functions
Commit: ed9bc5f5c014fec657dbef9e71f6d43733e53408 Author: Jacques Lucke Date: Thu Jul 11 09:37:08 2019 +0200 Branches: functions https://developer.blender.org/rBed9bc5f5c014fec657dbef9e71f6d43733e53408 Merge branch 'master' into functions === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [0ee9e3c6ef6] temp-text-undo-memcmp: Quiet warning
Commit: 0ee9e3c6ef6fbe4e86e4b9749e6d34a3850be8d9 Author: Campbell Barton Date: Thu Jul 11 16:10:25 2019 +1000 Branches: temp-text-undo-memcmp https://developer.blender.org/rB0ee9e3c6ef6fbe4e86e4b9749e6d34a3850be8d9 Quiet warning === M source/blender/editors/space_text/text_undo.c === diff --git a/source/blender/editors/space_text/text_undo.c b/source/blender/editors/space_text/text_undo.c index 7b72161fdba..eca2baf1e65 100644 --- a/source/blender/editors/space_text/text_undo.c +++ b/source/blender/editors/space_text/text_undo.c @@ -114,7 +114,7 @@ static void text_undosys_step_encode_init(struct bContext *C, UndoStep *us_p) TextUndoStep *us = (TextUndoStep *)us_p; BLI_assert(BLI_array_is_zeroed(>data, 1)); - UNUSED_VARS(C); + UNUSED_VARS(C, us); /* XXX, use to set the undo type only. */ } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [5dd14a4fad1] temp-text-undo-memcmp: Remove text undo code (in favor of binary diffing the entire buffer)
Commit: 5dd14a4fad1492aefa7cb0fbe16a782a7d465df2 Author: Campbell Barton Date: Thu Jul 11 15:55:53 2019 +1000 Branches: temp-text-undo-memcmp https://developer.blender.org/rB5dd14a4fad1492aefa7cb0fbe16a782a7d465df2 Remove text undo code (in favor of binary diffing the entire buffer) === M source/blender/blenkernel/BKE_text.h M source/blender/blenkernel/intern/text.c M source/blender/editors/include/ED_text.h M source/blender/editors/interface/interface_ops.c M source/blender/editors/space_text/text_autocomplete.c M source/blender/editors/space_text/text_ops.c M source/blender/editors/space_text/text_undo.c M source/blender/makesrna/intern/rna_text_api.c === diff --git a/source/blender/blenkernel/BKE_text.h b/source/blender/blenkernel/BKE_text.h index 20322ea0052..03d7e0ca344 100644 --- a/source/blender/blenkernel/BKE_text.h +++ b/source/blender/blenkernel/BKE_text.h @@ -30,7 +30,6 @@ extern "C" { struct Main; struct Text; struct TextLine; -struct TextUndoBuf; void BKE_text_free_lines(struct Text *text); void BKE_text_free(struct Text *text); @@ -49,8 +48,8 @@ void BKE_text_copy_data(struct Main *bmain, const int flag); struct Text *BKE_text_copy(struct Main *bmain, const struct Text *ta); void BKE_text_make_local(struct Main *bmain, struct Text *text, const bool lib_local); -void BKE_text_clear(struct Text *text, struct TextUndoBuf *utxt); -void BKE_text_write(struct Text *text, struct TextUndoBuf *utxt, const char *str); +void BKE_text_clear(struct Text *text); +void BKE_text_write(struct Text *text, const char *str); void BKE_text_reload_from_buf(struct Text *text, const uchar *buf, int buf_len); int BKE_text_file_modified_check(struct Text *text); void BKE_text_file_modified_ignore(struct Text *text); @@ -78,29 +77,26 @@ void txt_move_eol(struct Text *text, const bool sel); void txt_move_toline(struct Text *text, unsigned int line, const bool sel); void txt_move_to(struct Text *text, unsigned int line, unsigned int ch, const bool sel); void txt_pop_sel(struct Text *text); -void txt_delete_char(struct Text *text, struct TextUndoBuf *utxt); -void txt_delete_word(struct Text *text, struct TextUndoBuf *utxt); -void txt_delete_selected(struct Text *text, struct TextUndoBuf *utxt); +void txt_delete_char(struct Text *text); +void txt_delete_word(struct Text *text); +void txt_delete_selected(struct Text *text); void txt_sel_all(struct Text *text); void txt_sel_clear(struct Text *text); void txt_sel_line(struct Text *text); char *txt_sel_to_buf(struct Text *text, int *r_buf_strlen); -void txt_insert_buf(struct Text *text, struct TextUndoBuf *utxt, const char *in_buffer); -void txt_undo_add_op(struct Text *text, struct TextUndoBuf *utxt, int op); -void txt_do_undo(struct Text *text, struct TextUndoBuf *utxt); -void txt_do_redo(struct Text *text, struct TextUndoBuf *utxt); -void txt_split_curline(struct Text *text, struct TextUndoBuf *utxt); -void txt_backspace_char(struct Text *text, struct TextUndoBuf *utxt); -void txt_backspace_word(struct Text *text, struct TextUndoBuf *utxt); -bool txt_add_char(struct Text *text, struct TextUndoBuf *utxt, unsigned int add); -bool txt_add_raw_char(struct Text *text, struct TextUndoBuf *utxt, unsigned int add); -bool txt_replace_char(struct Text *text, struct TextUndoBuf *utxt, unsigned int add); -void txt_unindent(struct Text *text, struct TextUndoBuf *utxt); -void txt_comment(struct Text *text, struct TextUndoBuf *utxt); -void txt_indent(struct Text *text, struct TextUndoBuf *utxt); -void txt_uncomment(struct Text *text, struct TextUndoBuf *utxt); -void txt_move_lines(struct Text *text, struct TextUndoBuf *utxt, const int direction); -void txt_duplicate_line(struct Text *text, struct TextUndoBuf *utxt); +void txt_insert_buf(struct Text *text, const char *in_buffer); +void txt_split_curline(struct Text *text); +void txt_backspace_char(struct Text *text); +void txt_backspace_word(struct Text *text); +bool txt_add_char(struct Text *text, unsigned int add); +bool txt_add_raw_char(struct Text *text, unsigned int add); +bool txt_replace_char(struct Text *text, unsigned int add); +void txt_unindent(struct Text *text); +void txt_comment(struct Text *text); +void txt_indent(struct Text *text); +void txt_uncomment(struct Text *text); +void txt_move_lines(struct Text *text, const int direction); +void txt_duplicate_line(struct Text *text); int txt_setcurr_tab_spaces(struct Text *text, int space); bool txt_cursor_is_line_start(struct Text *text); bool txt_cursor_is_line_end(struct Text *text); @@ -126,11 +122,6 @@ enum { TXT_MOVE_LINE_DOWN = 1, }; -typedef struct TextUndoBuf { - char *buf; - int pos, len; -} TextUndoBuf; - #ifdef __cplusplus } #endif diff --git a/source/blender/blenkernel/intern/text.c