[Bf-blender-cvs] [cf0f2f2d3db] master: Fix T67256: Add object redo duplicates, after exiting sculpt mode
Commit: cf0f2f2d3dbf6e90a2c81d59bbdb8af538376f9c Author: Campbell Barton Date: Fri Jul 26 14:24:38 2019 +1000 Branches: master https://developer.blender.org/rBcf0f2f2d3dbf6e90a2c81d59bbdb8af538376f9c Fix T67256: Add object redo duplicates, after exiting sculpt mode === M source/blender/blenkernel/intern/undo_system.c === diff --git a/source/blender/blenkernel/intern/undo_system.c b/source/blender/blenkernel/intern/undo_system.c index 8ea5b47de5f..338ec01ab92 100644 --- a/source/blender/blenkernel/intern/undo_system.c +++ b/source/blender/blenkernel/intern/undo_system.c @@ -560,12 +560,15 @@ bool BKE_undosys_step_push_with_type(UndoStack *ustack, } if (use_memfile_step) { -const char *name_internal = "MemFile Internal (post)"; +/* Make this the user visible undo state, so redo always applies + * on top of the mem-file undo instead of skipping it. see: T67256. */ +UndoStep *us_prev = ustack->step_active; +const char *name_internal = us_prev->name; const bool ok = undosys_stack_push_main(ustack, name_internal, G_MAIN); if (ok) { UndoStep *us = ustack->steps.last; BLI_assert(STREQ(us->name, name_internal)); - us->skip = true; + us_prev->skip = true; #ifdef WITH_GLOBAL_UNDO_CORRECT_ORDER ustack->step_active_memfile = us; #endif ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [dbd558d5740] soc-2019-npr: LANPR: Fixed drawing problems when chaining is enabled.
Commit: dbd558d57400c3bc836c4e09cb91b8d8b7b8114e Author: YimingWu Date: Fri Jul 26 12:20:52 2019 +0800 Branches: soc-2019-npr https://developer.blender.org/rBdbd558d57400c3bc836c4e09cb91b8d8b7b8114e LANPR: Fixed drawing problems when chaining is enabled. === M source/blender/draw/engines/lanpr/lanpr_cpu.c === diff --git a/source/blender/draw/engines/lanpr/lanpr_cpu.c b/source/blender/draw/engines/lanpr/lanpr_cpu.c index 63661491cb0..d00f4d30591 100644 --- a/source/blender/draw/engines/lanpr/lanpr_cpu.c +++ b/source/blender/draw/engines/lanpr/lanpr_cpu.c @@ -382,13 +382,13 @@ void lanpr_software_draw_scene(void *vedata, GPUFrameBuffer *dfb, int is_render) ll->use_same_style ? _thickness : >intersection.thickness, 1); -DRW_shgroup_uniform_int(rb->ChainShgrp, "contour.enabled", >contour.enabled, 1); -DRW_shgroup_uniform_int(rb->ChainShgrp, "crease.enabled", >crease.enabled, 1); +DRW_shgroup_uniform_int(rb->ChainShgrp, "enable_contour", >contour.enabled, 1); +DRW_shgroup_uniform_int(rb->ChainShgrp, "enable_crease", >crease.enabled, 1); DRW_shgroup_uniform_int( rb->ChainShgrp, "enable_material", >material_separate.enabled, 1); -DRW_shgroup_uniform_int(rb->ChainShgrp, "edge_mark.enabled", >edge_mark.enabled, 1); +DRW_shgroup_uniform_int(rb->ChainShgrp, "enable_edge_mark", >edge_mark.enabled, 1); DRW_shgroup_uniform_int( -rb->ChainShgrp, "intersection.enabled", >intersection.enabled, 1); +rb->ChainShgrp, "enable_intersection", >intersection.enabled, 1); DRW_shgroup_uniform_int(rb->ChainShgrp, "normal_mode", >normal_mode, 1); DRW_shgroup_uniform_int( ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [dd3f69a783f] soc-2019-npr: LANPR: Fixed "point" mode in normal control.
Commit: dd3f69a783fe70f0010cf3f038cee62d41793ae9 Author: YimingWu Date: Fri Jul 26 11:33:36 2019 +0800 Branches: soc-2019-npr https://developer.blender.org/rBdd3f69a783fe70f0010cf3f038cee62d41793ae9 LANPR: Fixed "point" mode in normal control. === M release/scripts/startup/bl_ui/properties_render.py M source/blender/draw/engines/lanpr/lanpr_cpu.c M source/blender/makesdna/DNA_lanpr_types.h M source/blender/makesrna/intern/rna_lanpr.c === diff --git a/release/scripts/startup/bl_ui/properties_render.py b/release/scripts/startup/bl_ui/properties_render.py index 15033d8691f..f5a3c204d79 100644 --- a/release/scripts/startup/bl_ui/properties_render.py +++ b/release/scripts/startup/bl_ui/properties_render.py @@ -937,8 +937,8 @@ class RENDER_PT_lanpr_line_normal_effects(RenderButtonsPanel, Panel): layout.use_property_split = True layout.use_property_decorate = False -if active_layer: -layout.prop(active_layer,"normal_mode", text="Mode") +layout.prop(active_layer,"normal_mode", text="Mode") +if active_layer.normal_mode != "DISABLED": layout.prop(active_layer,"normal_control_object") layout.prop(active_layer,"normal_effect_inverse") col = layout.column(align=True) diff --git a/source/blender/draw/engines/lanpr/lanpr_cpu.c b/source/blender/draw/engines/lanpr/lanpr_cpu.c index 569082855af..63661491cb0 100644 --- a/source/blender/draw/engines/lanpr/lanpr_cpu.c +++ b/source/blender/draw/engines/lanpr/lanpr_cpu.c @@ -245,8 +245,6 @@ void lanpr_calculate_normal_object_vector(LANPR_LineLayer *ll, float *normal_obj normal_object_direction[2] = ob->obmat[3][2]; } return; -case LANPR_NORMAL_2D: - return; } } diff --git a/source/blender/makesdna/DNA_lanpr_types.h b/source/blender/makesdna/DNA_lanpr_types.h index 59f4d796cae..1282a63de3f 100644 --- a/source/blender/makesdna/DNA_lanpr_types.h +++ b/source/blender/makesdna/DNA_lanpr_types.h @@ -50,10 +50,10 @@ struct Collection; #define LANPR_USE_DIFFERENT_TAPER 0 #define LANPR_USE_SAME_TAPER 1 +/* Only on/off switch for now, below not used */ #define LANPR_NORMAL_DONT_CARE 0 #define LANPR_NORMAL_DIRECTIONAL 1 #define LANPR_NORMAL_POINT 2 -#define LANPR_NORMAL_2D 3 #define LANPR_COMPONENT_MODE_ALL 0 #define LANPR_COMPONENT_MODE_OBJECT 1 diff --git a/source/blender/makesrna/intern/rna_lanpr.c b/source/blender/makesrna/intern/rna_lanpr.c index 3ba5e8cd5af..f77e4516a4c 100644 --- a/source/blender/makesrna/intern/rna_lanpr.c +++ b/source/blender/makesrna/intern/rna_lanpr.c @@ -72,8 +72,8 @@ void RNA_def_lanpr(BlenderRNA *brna) 0, "Directional", "Use directional vector to control line width"}, - /* Currently inoperative */ - /* {LANPR_NORMAL_POINT, "POINT", 0, "Point", "Use Point Light Style"}, */ + /* Seems working... */ + {LANPR_NORMAL_POINT, "POINT", 0, "Point", "Use Point Light Style"}, {0, NULL, 0, NULL, NULL}}; srna = RNA_def_struct(brna, "LANPR_LineLayerComponent", NULL); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [ee73885bd1a] soc-2019-npr: Merge remote-tracking branch 'origin/master' into soc-2019-npr
Commit: ee73885bd1a8387768c15a318e5a82c079b0aa98 Author: YimingWu Date: Fri Jul 26 11:00:53 2019 +0800 Branches: soc-2019-npr https://developer.blender.org/rBee73885bd1a8387768c15a318e5a82c079b0aa98 Merge remote-tracking branch 'origin/master' 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] [cbaab414500] soc-2019-npr: LANPR: UI refactor: option sub panel fixes.
Commit: cbaab414500af8aa7e5527574001c929ec195379 Author: YimingWu Date: Fri Jul 26 11:04:58 2019 +0800 Branches: soc-2019-npr https://developer.blender.org/rBcbaab414500af8aa7e5527574001c929ec195379 LANPR: UI refactor: option sub panel fixes. === M release/scripts/startup/bl_ui/properties_render.py === diff --git a/release/scripts/startup/bl_ui/properties_render.py b/release/scripts/startup/bl_ui/properties_render.py index 3afddb2b05a..71107184e2f 100644 --- a/release/scripts/startup/bl_ui/properties_render.py +++ b/release/scripts/startup/bl_ui/properties_render.py @@ -1091,11 +1091,11 @@ class RENDER_PT_lanpr_gpencil(RenderButtonsPanel, Panel): layout.prop(lanpr,"auto_update", text='Auto Update') layout.prop(lanpr,"gpencil_overwrite", text='Overwrite') if not lanpr.auto_update: -layout.operator("scene.lanpr_update_gp_strokes", icon='RENDER_STILL', text='Update GPencil Targets') +layout.operator("scene.lanpr_update_gp_strokes", icon='FILE_REFRESH', text='Update GPencil Targets') layout.operator("scene.lanpr_bake_gp_strokes", icon='RENDER_ANIMATION', text='Bake All Frames') class RENDER_PT_lanpr_software_chain_styles(RenderButtonsPanel, Panel): -bl_label = "Chaining Options" +bl_label = "Chaining" bl_parent_id = "RENDER_PT_lanpr" bl_options = {'DEFAULT_CLOSED'} COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_LANPR', 'BLENDER_OPENGL', 'BLENDER_EEVEE'} @@ -1161,8 +1161,6 @@ class RENDER_PT_lanpr_options(RenderButtonsPanel, Panel): if scene.render.engine=='BLENDER_LANPR': layout.prop(lanpr,"enable_chaining", text = "Chain lines") -else: -layout.label(text='Chain is enabled to generate GP strokes.') classes = ( @@ -1197,13 +1195,13 @@ classes = ( RENDER_PT_lanpr, RENDER_PT_lanpr_layer_settings, RENDER_PT_lanpr_gpencil, -RENDER_PT_lanpr_options, RENDER_PT_lanpr_line_components, RENDER_PT_lanpr_line_normal_effects, RENDER_PT_lanpr_line_gpu_effects, RENDER_PT_lanpr_snake_sobel_parameters, RENDER_PT_lanpr_snake_settings, RENDER_PT_lanpr_software_chain_styles, +RENDER_PT_lanpr_options, LANPR_UL_linesets, ) ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [ac7fe46ec39] master: Fix T67709: Texture paint undo gets out of sync
Commit: ac7fe46ec393b1f7273f6896498c280dff7f7ff0 Author: Campbell Barton Date: Fri Jul 26 13:13:47 2019 +1000 Branches: master https://developer.blender.org/rBac7fe46ec393b1f7273f6896498c280dff7f7ff0 Fix T67709: Texture paint undo gets out of sync === M source/blender/editors/sculpt_paint/paint_image_undo.c === diff --git a/source/blender/editors/sculpt_paint/paint_image_undo.c b/source/blender/editors/sculpt_paint/paint_image_undo.c index e7f100ebacb..1527ba31040 100644 --- a/source/blender/editors/sculpt_paint/paint_image_undo.c +++ b/source/blender/editors/sculpt_paint/paint_image_undo.c @@ -507,7 +507,7 @@ static void image_undosys_step_decode_redo_impl(ImageUndoStep *us) us->step.is_applied = true; } -static void image_undosys_step_decode_undo(ImageUndoStep *us) +static void image_undosys_step_decode_undo(ImageUndoStep *us, bool is_final) { ImageUndoStep *us_iter = us; while (us_iter->step.next && (us_iter->step.next->type == us_iter->step.type)) { @@ -516,8 +516,11 @@ static void image_undosys_step_decode_undo(ImageUndoStep *us) } us_iter = (ImageUndoStep *)us_iter->step.next; } - while (us_iter != us) { + while (us_iter != us || (is_final && us_iter == us)) { image_undosys_step_decode_undo_impl(us_iter); +if (is_final) { + break; +} us_iter = (ImageUndoStep *)us_iter->step.prev; } } @@ -541,7 +544,7 @@ static void image_undosys_step_decode_redo(ImageUndoStep *us) } static void image_undosys_step_decode( -struct bContext *C, struct Main *bmain, UndoStep *us_p, int dir, bool UNUSED(is_final)) +struct bContext *C, struct Main *bmain, UndoStep *us_p, int dir, bool is_final) { ImageUndoStep *us = (ImageUndoStep *)us_p; #if 0 @@ -549,7 +552,7 @@ static void image_undosys_step_decode( #endif if (dir < 0) { -image_undosys_step_decode_undo(us); +image_undosys_step_decode_undo(us, is_final); } else { image_undosys_step_decode_redo(us); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [52db223bd6e] soc-2019-npr: LANPR: UI refactor: naming fixes in the main panel.
Commit: 52db223bd6e302ce17128144376243f4c7b823fc Author: YimingWu Date: Fri Jul 26 11:09:11 2019 +0800 Branches: soc-2019-npr https://developer.blender.org/rB52db223bd6e302ce17128144376243f4c7b823fc LANPR: UI refactor: naming fixes in the main panel. === M release/scripts/startup/bl_ui/properties_render.py M source/blender/makesrna/intern/rna_scene.c === diff --git a/release/scripts/startup/bl_ui/properties_render.py b/release/scripts/startup/bl_ui/properties_render.py index 71107184e2f..15033d8691f 100644 --- a/release/scripts/startup/bl_ui/properties_render.py +++ b/release/scripts/startup/bl_ui/properties_render.py @@ -845,7 +845,7 @@ class RENDER_PT_lanpr_layer_settings(RenderButtonsPanel, Panel): active_layer = lanpr.layers[0] if mode == "SOFTWARE": -layout.prop(active_layer, "use_multiple_levels") +layout.prop(active_layer, "use_multiple_levels", text="Multiple Levels") col = layout.column(align=True) col.prop(active_layer, "qi_begin", text='Level Start') if active_layer.use_multiple_levels: @@ -943,10 +943,10 @@ class RENDER_PT_lanpr_line_normal_effects(RenderButtonsPanel, Panel): layout.prop(active_layer,"normal_effect_inverse") col = layout.column(align=True) col.prop(active_layer,"normal_ramp_begin") -col.prop(active_layer,"normal_ramp_end") +col.prop(active_layer,"normal_ramp_end", text="End") col = layout.column(align=True) col.prop(active_layer,"normal_thickness_begin", slider=True) -col.prop(active_layer,"normal_thickness_end", slider=True) +col.prop(active_layer,"normal_thickness_end", slider=True, text="End") class RENDER_PT_lanpr_line_gpu_effects(RenderButtonsPanel, Panel): bl_label = "Effects" @@ -972,13 +972,13 @@ class RENDER_PT_lanpr_line_gpu_effects(RenderButtonsPanel, Panel): col = layout.column(align = True) col.prop(lanpr, "crease_threshold") -col.prop(lanpr, "crease_fade_threshold") +col.prop(lanpr, "crease_fade_threshold", text="Fade") col = layout.column(align = True) col.prop(lanpr, "depth_width_influence") -col.prop(lanpr, "depth_width_curve") +col.prop(lanpr, "depth_width_curve", text="Curve") col = layout.column(align = True) col.prop(lanpr, "depth_alpha_influence") -col.prop(lanpr, "depth_alpha_curve") +col.prop(lanpr, "depth_alpha_curve", text="Curve") class RENDER_PT_lanpr_snake_sobel_parameters(RenderButtonsPanel, Panel): @@ -1044,11 +1044,11 @@ class RENDER_PT_lanpr_snake_settings(RenderButtonsPanel, Panel): col = split.column(align = True) col.label(text="Left:") col.prop(lanpr,"taper_left_distance") -col.prop(lanpr,"taper_left_strength") +col.prop(lanpr,"taper_left_strength", text="Strength") col = split.column(align = True) col.label(text="Right:") col.prop(lanpr,"taper_right_distance") -col.prop(lanpr,"taper_right_strength") +col.prop(lanpr,"taper_right_strength", text="Strength") else: split = layout.split() col = split.column(align = True) diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index a3b6dde138a..10ced022bcd 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -7307,28 +7307,28 @@ static void rna_def_scene_lanpr(BlenderRNA *brna) prop = RNA_def_property(srna, "taper_left_distance", PROP_FLOAT, PROP_NONE); RNA_def_property_float_default(prop, 20.0f); - RNA_def_property_ui_text(prop, "Distance Left", "Left side taper distance"); + RNA_def_property_ui_text(prop, "Left Distance", "Left side taper distance"); RNA_def_property_ui_range(prop, 0.0f, 100.0f, 0.1, 2); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_update(prop, NC_SCENE, NULL); prop = RNA_def_property(srna, "taper_right_distance", PROP_FLOAT, PROP_NONE); RNA_def_property_float_default(prop, 20.0f); - RNA_def_property_ui_text(prop, "Distance right", "Right side taper distance"); + RNA_def_property_ui_text(prop, "Right Distance", "Right side taper distance"); RNA_def_property_ui_range(prop, 0.0f, 100.0f, 0.1, 2); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_update(prop, NC_SCENE, NULL); prop = RNA_def_property(srna, "taper_left_strength", PROP_FLOAT, PROP_FACTOR); RNA_def_property_float_default(prop, 1.0f); - RNA_def_property_ui_text(prop, "Strength left", "Left side taper strength"); + RNA_def_property_ui_text(prop, "Left Strength", "Left side taper strength");
[Bf-blender-cvs] [a2fb1f367bd] soc-2019-npr: Merge remote-tracking branch 'origin/greasepencil-object' into soc-2019-npr
Commit: a2fb1f367bd09228d592db2c29288b5e9090a3d1 Author: YimingWu Date: Fri Jul 26 11:00:41 2019 +0800 Branches: soc-2019-npr https://developer.blender.org/rBa2fb1f367bd09228d592db2c29288b5e9090a3d1 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] [955c9dd98bb] soc-2019-outliner: Outliner: Add open/close all children to walk navigation
Commit: 955c9dd98bb70d066bcbe13458e3e334a522eff3 Author: Nathan Craddock Date: Thu Jul 25 20:38:08 2019 -0600 Branches: soc-2019-outliner https://developer.blender.org/rB955c9dd98bb70d066bcbe13458e3e334a522eff3 Outliner: Add open/close all children to walk navigation When pressing Shift and left or right arrow, expand or collapse all child elements in walk navigation. === M release/scripts/presets/keyconfig/keymap_data/blender_default.py M source/blender/editors/space_outliner/outliner_intern.h 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 07fbe8ebff8..e3608fbb54e 100644 --- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py +++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py @@ -721,7 +721,11 @@ def km_outliner(params): ("outliner.select_walk", {"type": 'DOWN_ARROW', "value": 'PRESS', "shift": True}, {"properties": [("direction", 'DOWN'), ("extend", True)]}), ("outliner.select_walk", {"type": 'LEFT_ARROW', "value": 'PRESS'}, {"properties": [("direction", 'LEFT')]}), +("outliner.select_walk", {"type": 'LEFT_ARROW', "value": 'PRESS', "shift": True}, + {"properties": [("direction", 'LEFT'), ("toggle_all", True)]}), ("outliner.select_walk", {"type": 'RIGHT_ARROW', "value": 'PRESS'}, {"properties": [("direction", 'RIGHT')]}), +("outliner.select_walk", {"type": 'RIGHT_ARROW', "value": 'PRESS', "shift": True}, + {"properties": [("direction", 'RIGHT'), ("toggle_all", True)]}), ("outliner.item_openclose", {"type": 'LEFTMOUSE', "value": 'CLICK'}, {"properties": [("all", False)]}), ("outliner.item_openclose", {"type": 'LEFTMOUSE', "value": 'CLICK', "shift": True}, diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h index e00eb5ea365..387bfd18f68 100644 --- a/source/blender/editors/space_outliner/outliner_intern.h +++ b/source/blender/editors/space_outliner/outliner_intern.h @@ -352,6 +352,8 @@ void item_object_mode_exit_cb(struct bContext *C, void outliner_set_coordinates(struct ARegion *ar, struct SpaceOutliner *soops); +bool outliner_item_openclose(TreeElement *te, bool toggle_all); + /* outliner_dragdrop.c */ void outliner_dropboxes(void); diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c index 6e74eab160f..bf3066766d5 100644 --- a/source/blender/editors/space_outliner/outliner_select.c +++ b/source/blender/editors/space_outliner/outliner_select.c @@ -1657,7 +1657,8 @@ static TreeElement *outliner_find_next_element(SpaceOutliner *soops, TreeElement static void do_outliner_select_walk(SpaceOutliner *soops, TreeElement *walk_element, const int direction, -const bool extend) +const bool extend, +const bool toggle_all) { TreeStoreElem *tselem = TREESTORE(walk_element); @@ -1674,17 +1675,19 @@ static void do_outliner_select_walk(SpaceOutliner *soops, walk_element = outliner_find_next_element(soops, walk_element); break; case OUTLINER_SELECT_WALK_LEFT: - /* Close open element or jummp active to parent */ + /* Close open element or walk to parent */ if (TSELEM_OPEN(tselem, soops)) { -tselem->flag |= TSE_CLOSED; +outliner_item_openclose(walk_element, toggle_all); } else if (walk_element->parent) { walk_element = walk_element->parent; } break; case OUTLINER_SELECT_WALK_RIGHT: - if (!TSELEM_OPEN(tselem, soops) && walk_element->subtree.first) { -tselem->flag &= ~TSE_CLOSED; + if ((!TSELEM_OPEN(tselem, soops) || + outliner_flag_is_any_test(_element->subtree, TSE_CLOSED, 1)) && + walk_element->subtree.first) { +outliner_item_openclose(walk_element, toggle_all); } break; } @@ -1743,13 +1746,14 @@ static int outliner_walk_select_invoke(bContext *C, wmOperator *op, const wmEven const int direction = RNA_enum_get(op->ptr, "direction"); const bool extend = RNA_boolean_get(op->ptr, "extend"); + const bool toggle_all = RNA_boolean_get(op->ptr, "toggle_all"); bool changed; TreeElement *walk_element = find_walk_select_start_element(soops, ); /* If finding the starting walk select element did not move the element, proceed to walk */ if (!changed) { -do_outliner_select_walk(soops, walk_element, direction, extend); +do_outliner_select_walk(soops,
[Bf-blender-cvs] [d50b8c0bfb9] soc-2019-outliner: Outliner: Fix item openclose
Commit: d50b8c0bfb97ae7dbc84b55fc9d0782c34c16638 Author: Nathan Craddock Date: Thu Jul 25 20:38:59 2019 -0600 Branches: soc-2019-outliner https://developer.blender.org/rBd50b8c0bfb97ae7dbc84b55fc9d0782c34c16638 Outliner: Fix item openclose Rather than just switching between open and close when toggling all children, first check if any children are closed when the item is open. If so, extend all the children first. This behavior makes more sense. === M source/blender/editors/space_outliner/outliner_edit.c === diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c index b8f44a86344..7f16539054b 100644 --- a/source/blender/editors/space_outliner/outliner_edit.c +++ b/source/blender/editors/space_outliner/outliner_edit.c @@ -141,15 +141,22 @@ void OUTLINER_OT_highlight_update(wmOperatorType *ot) /* Toggle Open/Closed --- */ /* Open or close a tree element, optionally toggling all children recursively */ -static bool outliner_item_openclose(TreeElement *te, bool toggle_all) +bool outliner_item_openclose(TreeElement *te, bool toggle_all) { TreeStoreElem *tselem = TREESTORE(te); - /* all below close/open? */ if (toggle_all) { -const bool open = tselem->flag & TSE_CLOSED; +/* Open all children if this element is closed, or if any children are closed */ +const bool open = (tselem->flag & TSE_CLOSED) || + (outliner_flag_is_any_test(>subtree, TSE_CLOSED, 1)); + +if (open) { + tselem->flag &= ~TSE_CLOSED; +} +else { + tselem->flag |= TSE_CLOSED; +} -tselem->flag ^= TSE_CLOSED; outliner_flag_set(>subtree, TSE_CLOSED, !open); return true; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [88a2c578274] soc-2019-outliner: Outliner: Support click+drag for toggling disclosure triangles
Commit: 88a2c5782745f2ece9d8f2d046fb6bce83a2f7b0 Author: Nathan Craddock Date: Thu Jul 25 15:28:58 2019 -0600 Branches: soc-2019-outliner https://developer.blender.org/rB88a2c5782745f2ece9d8f2d046fb6bce83a2f7b0 Outliner: Support click+drag for toggling disclosure triangles This reworks the openclose operator for toggling disclosure triangles. Rather than mapping to `Enter` by default, it supports left click and left tweak events. This allows click+drag over elements in the tree to open or close levels. Once the click+drag is started, only elements on that level in the outliner will open or close. This removes the toggling from `outliner_select.c` which adds more clarity to the activate function. === M release/scripts/presets/keyconfig/keymap_data/blender_default.py M source/blender/editors/space_outliner/outliner_dragdrop.c M source/blender/editors/space_outliner/outliner_edit.c M source/blender/editors/space_outliner/outliner_intern.h 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 ec820e56e2a..3aa22c16648 100644 --- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py +++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py @@ -726,10 +726,11 @@ def km_outliner(params): {"properties": [("direction", 'DOWN'), ("extend", True)]}), ("outliner.select_walk", {"type": 'LEFT_ARROW', "value": 'PRESS'}, {"properties": [("direction", 'LEFT')]}), ("outliner.select_walk", {"type": 'RIGHT_ARROW', "value": 'PRESS'}, {"properties": [("direction", 'RIGHT')]}), -("outliner.item_openclose", {"type": 'RET', "value": 'PRESS'}, +("outliner.item_openclose", {"type": 'LEFTMOUSE', "value": 'CLICK'}, {"properties": [("all", False)]}), -("outliner.item_openclose", {"type": 'RET', "value": 'PRESS', "shift": True}, +("outliner.item_openclose", {"type": 'LEFTMOUSE', "value": 'CLICK', "shift": True}, {"properties": [("all", True)]}), +("outliner.item_openclose", {"type": 'EVT_TWEAK_L', "value": 'ANY'}, {"properties": [("all", False)]}), ("outliner.operation", {"type": 'RIGHTMOUSE', "value": 'PRESS'}, None), ("outliner.item_drag_drop", {"type": 'EVT_TWEAK_L', "value": 'ANY'}, None), ("outliner.item_drag_drop", {"type": 'EVT_TWEAK_L', "value": 'ANY', "shift": True}, None), diff --git a/source/blender/editors/space_outliner/outliner_dragdrop.c b/source/blender/editors/space_outliner/outliner_dragdrop.c index ca14f9637b8..b7a38c0b82f 100644 --- a/source/blender/editors/space_outliner/outliner_dragdrop.c +++ b/source/blender/editors/space_outliner/outliner_dragdrop.c @@ -994,6 +994,12 @@ static int outliner_item_drag_drop_invoke(bContext *C, return (OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH); } + float view_mval[2]; + UI_view2d_region_to_view(>v2d, event->mval[0], event->mval[1], _mval[0], _mval[1]); + if (outliner_item_is_co_within_close_toggle(te, view_mval[0])) { +return (OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH); + } + wmDrag *drag = WM_event_start_drag(C, data.icon, WM_DRAG_ID, NULL, 0.0, WM_DRAG_NOP); if (ELEM(GS(data.drag_id->name), ID_OB, ID_GR)) { diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c index f80a2cf8fdd..9cccdbdd186 100644 --- a/source/blender/editors/space_outliner/outliner_edit.c +++ b/source/blender/editors/space_outliner/outliner_edit.c @@ -140,59 +140,94 @@ void OUTLINER_OT_highlight_update(wmOperatorType *ot) /* Toggle Open/Closed --- */ -static int do_outliner_item_openclose( -bContext *C, SpaceOutliner *soops, TreeElement *te, const bool all, const float mval[2]) +/* Open or close a tree element */ +static bool outliner_item_openclose(TreeElement *te, bool open_all) { + TreeStoreElem *tselem = TREESTORE(te); - if (mval[1] > te->ys && mval[1] < te->ys + UI_UNIT_Y) { -TreeStoreElem *tselem = TREESTORE(te); + /* all below close/open? */ + if (open_all) { +tselem->flag &= ~TSE_CLOSED; +outliner_flag_set( +>subtree, TSE_CLOSED, !outliner_flag_is_any_test(>subtree, TSE_CLOSED, 1)); -/* all below close/open? */ -if (all) { +return true; + } + else { +if (tselem->flag & TSE_CLOSED) { tselem->flag &= ~TSE_CLOSED; - outliner_flag_set( - >subtree, TSE_CLOSED, !outliner_flag_is_any_test(>subtree, TSE_CLOSED, 1)); } else { - if (tselem->flag & TSE_CLOSED) { -tselem->flag &= ~TSE_CLOSED; - } - else { -tselem->flag |= TSE_CLOSED; - } + tselem->flag |= TSE_CLOSED; } -
[Bf-blender-cvs] [d3c083f5bee] soc-2019-outliner: Outliner: Cleanup outliner_select.c
Commit: d3c083f5bee7d0977d8b6e945dc92810ec36d9ca Author: Nathan Craddock Date: Thu Jul 25 15:36:08 2019 -0600 Branches: soc-2019-outliner https://developer.blender.org/rBd3c083f5bee7d0977d8b6e945dc92810ec36d9ca Outliner: Cleanup outliner_select.c Remove the unnecessary toggle function which involved duplicated code, and move the check for restrict columns to the utils file as it is used in multiple files. === M source/blender/editors/space_outliner/outliner_select.c M source/blender/editors/space_outliner/outliner_utils.c === diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c index 09b62261c90..6e74eab160f 100644 --- a/source/blender/editors/space_outliner/outliner_select.c +++ b/source/blender/editors/space_outliner/outliner_select.c @@ -1331,25 +1331,6 @@ static void do_outliner_range_select(SpaceOutliner *soops, TreeElement *cursor) do_outliner_range_select_recursive(>tree, active, cursor, ); } -static void outliner_item_toggle_closed(TreeElement *te, const bool toggle_children) -{ - TreeStoreElem *tselem = TREESTORE(te); - if (toggle_children) { -tselem->flag &= ~TSE_CLOSED; - -const bool all_opened = !outliner_flag_is_any_test(>subtree, TSE_CLOSED, 1); -outliner_flag_set(>subtree, TSE_CLOSED, all_opened); - } - else { -tselem->flag ^= TSE_CLOSED; - } -} - -bool outliner_item_is_co_within_close_toggle(TreeElement *te, float view_co_x) -{ - return (view_co_x > te->xs) && (view_co_x < te->xs + UI_UNIT_X); -} - static bool outliner_is_co_within_restrict_columns(const SpaceOutliner *soops, const ARegion *ar, float view_co_x) diff --git a/source/blender/editors/space_outliner/outliner_utils.c b/source/blender/editors/space_outliner/outliner_utils.c index 146a9f02f51..428a0f0f6dd 100644 --- a/source/blender/editors/space_outliner/outliner_utils.c +++ b/source/blender/editors/space_outliner/outliner_utils.c @@ -356,3 +356,9 @@ bool outliner_is_element_visible(const TreeElement *te) return true; } + +/* Find if x coordinate is over element disclosure toggle */ +bool outliner_item_is_co_within_close_toggle(TreeElement *te, float view_co_x) +{ + return (view_co_x > te->xs) && (view_co_x < te->xs + UI_UNIT_X); +} \ No newline at end of file ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [504542da09c] soc-2019-outliner: Merge branch 'master' into soc-2019-outliner
Commit: 504542da09c3cd0a81067be56e6c6eac5e142099 Author: Nathan Craddock Date: Thu Jul 25 15:38:03 2019 -0600 Branches: soc-2019-outliner https://developer.blender.org/rB504542da09c3cd0a81067be56e6c6eac5e142099 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] [ec9dfb21d74] soc-2019-outliner: Outliner fix openclose recursive not working as expected
Commit: ec9dfb21d748ad26c5a46a7c76e09e7fd581c8a5 Author: Nathan Craddock Date: Thu Jul 25 16:06:02 2019 -0600 Branches: soc-2019-outliner https://developer.blender.org/rBec9dfb21d748ad26c5a46a7c76e09e7fd581c8a5 Outliner fix openclose recursive not working as expected The openclose all operator would not close the upper element, nor would it work on the outermost collections of a scene. Now the recursive open all option will work as expected, opening all of an element's children, and the element itself, or closing the element and all of its children. === M source/blender/editors/space_outliner/outliner_edit.c === diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c index 9cccdbdd186..b8f44a86344 100644 --- a/source/blender/editors/space_outliner/outliner_edit.c +++ b/source/blender/editors/space_outliner/outliner_edit.c @@ -140,16 +140,17 @@ void OUTLINER_OT_highlight_update(wmOperatorType *ot) /* Toggle Open/Closed --- */ -/* Open or close a tree element */ -static bool outliner_item_openclose(TreeElement *te, bool open_all) +/* Open or close a tree element, optionally toggling all children recursively */ +static bool outliner_item_openclose(TreeElement *te, bool toggle_all) { TreeStoreElem *tselem = TREESTORE(te); /* all below close/open? */ - if (open_all) { -tselem->flag &= ~TSE_CLOSED; -outliner_flag_set( ->subtree, TSE_CLOSED, !outliner_flag_is_any_test(>subtree, TSE_CLOSED, 1)); + if (toggle_all) { +const bool open = tselem->flag & TSE_CLOSED; + +tselem->flag ^= TSE_CLOSED; +outliner_flag_set(>subtree, TSE_CLOSED, !open); return true; } @@ -204,7 +205,7 @@ static int outliner_item_openclose_invoke(bContext *C, wmOperator *op, const wmE ARegion *ar = CTX_wm_region(C); SpaceOutliner *soops = CTX_wm_space_outliner(C); - const bool open_all = RNA_boolean_get(op->ptr, "all"); + const bool toggle_all = RNA_boolean_get(op->ptr, "all"); float view_mval[2]; UI_view2d_region_to_view(>v2d, event->mval[0], event->mval[1], _mval[0], _mval[1]); @@ -212,7 +213,7 @@ static int outliner_item_openclose_invoke(bContext *C, wmOperator *op, const wmE TreeElement *te = outliner_find_item_at_y(soops, >tree, view_mval[1]); if (te && outliner_item_is_co_within_close_toggle(te, view_mval[0])) { -outliner_item_openclose(te, open_all); +outliner_item_openclose(te, toggle_all); ED_region_tag_redraw(ar); /* Store the first clicked on element */ ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [4b786c0a0cf] soc-2019-outliner: Keymap: Remove recursive select from outliner
Commit: 4b786c0a0cf9e135311cbb4ab68a6ce4a6a6a606 Author: Nathan Craddock Date: Thu Jul 25 15:49:46 2019 -0600 Branches: soc-2019-outliner https://developer.blender.org/rB4b786c0a0cf9e135311cbb4ab68a6ce4a6a6a606 Keymap: Remove recursive select from outliner Removes alt and alt+ctrl from outliner for recursive select as there is a context menu option for this, and alt+click can be taken globally by the emulate 3 button mouse option. === M release/scripts/presets/keyconfig/keymap_data/blender_default.py === diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py index 3aa22c16648..07fbe8ebff8 100644 --- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py +++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py @@ -708,10 +708,6 @@ def km_outliner(params): ("outliner.item_activate", {"type": 'LEFTMOUSE', "value": 'CLICK', "shift": True}, {"properties": [("extend", False), ("range", True), ("recursive", False), ("deselect_all", not params.legacy)]}), -("outliner.item_activate", {"type": 'LEFTMOUSE', "value": 'CLICK', "alt": 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), ("outliner.select_box", {"type": 'EVT_TWEAK_L', "value": 'ANY'}, {"properties": [("tweak", True)]}), ("outliner.select_box", {"type": 'EVT_TWEAK_L', "value": 'ANY', "shift": True}, ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [c1b6319e9af] experimental-build: Merge branch 'master' into experimental-build
Commit: c1b6319e9af6963cb1e0270de09bfd266526591d Author: Julian Eisel Date: Fri Jul 26 01:28:59 2019 +0200 Branches: experimental-build https://developer.blender.org/rBc1b6319e9af6963cb1e0270de09bfd266526591d Merge branch 'master' into experimental-build === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [507dc9eb29a] experimental-build: Squashed commit of filebrowser_redesign branch
Commit: 507dc9eb29a17eacd3273d5ef232d4223af89502 Author: Julian Eisel Date: Fri Jul 26 01:30:19 2019 +0200 Branches: experimental-build https://developer.blender.org/rB507dc9eb29a17eacd3273d5ef232d4223af89502 Squashed commit of filebrowser_redesign branch === M release/datafiles/locale M release/datafiles/userdef/userdef_default_theme.c M release/scripts/presets/keyconfig/keymap_data/blender_default.py M release/scripts/startup/bl_ui/space_filebrowser.py M source/blender/blenkernel/BKE_screen.h M source/blender/blenlib/intern/BLI_filelist.c M source/blender/blenloader/intern/versioning_280.c M source/blender/blenloader/intern/versioning_userdef.c M source/blender/editors/include/ED_fileselect.h M source/blender/editors/interface/interface_panel.c M source/blender/editors/screen/area.c M source/blender/editors/space_file/file_draw.c M source/blender/editors/space_file/file_intern.h M source/blender/editors/space_file/file_ops.c M source/blender/editors/space_file/filelist.c M source/blender/editors/space_file/filelist.h M source/blender/editors/space_file/filesel.c M source/blender/editors/space_file/space_file.c M source/blender/makesdna/DNA_screen_types.h M source/blender/makesdna/DNA_space_types.h M source/blender/makesrna/intern/rna_space.c M source/blender/makesrna/intern/rna_ui.c M source/blender/windowmanager/WM_api.h M source/blender/windowmanager/intern/wm_event_system.c M source/blender/windowmanager/intern/wm_files.c M source/blender/windowmanager/intern/wm_operator_props.c M source/blender/windowmanager/intern/wm_window.c M source/tools === diff --git a/release/datafiles/locale b/release/datafiles/locale index 6625026f62f..2b81e2acc01 16 --- a/release/datafiles/locale +++ b/release/datafiles/locale @@ -1 +1 @@ -Subproject commit 6625026f62f492dd677f5f29c68b9d70c96fb34b +Subproject commit 2b81e2acc011a8b79232a18dad3c00b8e654ceee diff --git a/release/datafiles/userdef/userdef_default_theme.c b/release/datafiles/userdef/userdef_default_theme.c index 8611a9ae881..87ab7d7c47e 100644 --- a/release/datafiles/userdef/userdef_default_theme.c +++ b/release/datafiles/userdef/userdef_default_theme.c @@ -385,6 +385,7 @@ const bTheme U_theme_default = { .button_title = RGBA(0x), .button_text = RGBA(0xe5e5e5ff), .button_text_hi = RGBA(0x), +.execution_buts = RGBA(0x424242ff), .panelcolors = { .header = RGBA(0x424242cc), .back = RGBA(0x33b3), diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py index cc4dc4d00e0..44a52e74a34 100644 --- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py +++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py @@ -1825,6 +1825,7 @@ def km_file_browser_main(params): {"properties": [("mode", 'ADD')]}), ("file.rename", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True}, None), ("file.highlight", {"type": 'MOUSEMOVE', "value": 'ANY', "any": True}, None), +("file.sort_column_ui_context", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None), ("file.filenum", {"type": 'NUMPAD_PLUS', "value": 'PRESS'}, {"properties": [("increment", 1)]}), ("file.filenum", {"type": 'NUMPAD_PLUS', "value": 'PRESS', "shift": True}, diff --git a/release/scripts/startup/bl_ui/space_filebrowser.py b/release/scripts/startup/bl_ui/space_filebrowser.py index b939586ff81..b626d77c169 100644 --- a/release/scripts/startup/bl_ui/space_filebrowser.py +++ b/release/scripts/startup/bl_ui/space_filebrowser.py @@ -34,25 +34,19 @@ class FILEBROWSER_HT_header(Header): layout.menu("FILEBROWSER_MT_view") -row = layout.row(align=True) -row.operator("file.previous", text="", icon='BACK') -row.operator("file.next", text="", icon='FORWARD') -row.operator("file.parent", text="", icon='FILE_PARENT') -row.operator("file.refresh", text="", icon='FILE_REFRESH') - -layout.operator_context = 'EXEC_DEFAULT' -layout.operator("file.directory_new", icon='NEWFOLDER', text="") - -layout.operator_context = 'INVOKE_DEFAULT' - # can be None when save/reload with a file selector open if params: is_lib_browser = params.use_library_browsing layout.prop(params, "display_type", expand=True, text="") layout.prop(params, "sort_method", expand=True, text="") +layout.prop(params, "use_sort_invert") layout.prop(params, "show_hidden", text="", icon='FILE_HIDDEN') +row = layout.row(align=True) +row.prop(params,
[Bf-blender-cvs] [c4df8f301f8] experimental-build: Revert "Squashed commit of filebrowser_redesign branch"
Commit: c4df8f301f8ae6f723585fb128aed3da032a65fd Author: Julian Eisel Date: Fri Jul 26 01:31:20 2019 +0200 Branches: experimental-build https://developer.blender.org/rBc4df8f301f8ae6f723585fb128aed3da032a65fd Revert "Squashed commit of filebrowser_redesign branch" This reverts commit 507dc9eb29a17eacd3273d5ef232d4223af89502. === M release/datafiles/locale M release/datafiles/userdef/userdef_default_theme.c M release/scripts/presets/keyconfig/keymap_data/blender_default.py M release/scripts/startup/bl_ui/space_filebrowser.py M source/blender/blenkernel/BKE_screen.h M source/blender/blenlib/intern/BLI_filelist.c M source/blender/blenloader/intern/versioning_280.c M source/blender/blenloader/intern/versioning_userdef.c M source/blender/editors/include/ED_fileselect.h M source/blender/editors/interface/interface_panel.c M source/blender/editors/screen/area.c M source/blender/editors/space_file/file_draw.c M source/blender/editors/space_file/file_intern.h M source/blender/editors/space_file/file_ops.c M source/blender/editors/space_file/filelist.c M source/blender/editors/space_file/filelist.h M source/blender/editors/space_file/filesel.c M source/blender/editors/space_file/space_file.c M source/blender/makesdna/DNA_screen_types.h M source/blender/makesdna/DNA_space_types.h M source/blender/makesrna/intern/rna_space.c M source/blender/makesrna/intern/rna_ui.c M source/blender/windowmanager/WM_api.h M source/blender/windowmanager/intern/wm_event_system.c M source/blender/windowmanager/intern/wm_files.c M source/blender/windowmanager/intern/wm_operator_props.c M source/blender/windowmanager/intern/wm_window.c M source/tools === diff --git a/release/datafiles/locale b/release/datafiles/locale index 2b81e2acc01..6625026f62f 16 --- a/release/datafiles/locale +++ b/release/datafiles/locale @@ -1 +1 @@ -Subproject commit 2b81e2acc011a8b79232a18dad3c00b8e654ceee +Subproject commit 6625026f62f492dd677f5f29c68b9d70c96fb34b diff --git a/release/datafiles/userdef/userdef_default_theme.c b/release/datafiles/userdef/userdef_default_theme.c index 87ab7d7c47e..8611a9ae881 100644 --- a/release/datafiles/userdef/userdef_default_theme.c +++ b/release/datafiles/userdef/userdef_default_theme.c @@ -385,7 +385,6 @@ const bTheme U_theme_default = { .button_title = RGBA(0x), .button_text = RGBA(0xe5e5e5ff), .button_text_hi = RGBA(0x), -.execution_buts = RGBA(0x424242ff), .panelcolors = { .header = RGBA(0x424242cc), .back = RGBA(0x33b3), diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py index 44a52e74a34..cc4dc4d00e0 100644 --- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py +++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py @@ -1825,7 +1825,6 @@ def km_file_browser_main(params): {"properties": [("mode", 'ADD')]}), ("file.rename", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True}, None), ("file.highlight", {"type": 'MOUSEMOVE', "value": 'ANY', "any": True}, None), -("file.sort_column_ui_context", {"type": 'LEFTMOUSE', "value": 'PRESS', "any": True}, None), ("file.filenum", {"type": 'NUMPAD_PLUS', "value": 'PRESS'}, {"properties": [("increment", 1)]}), ("file.filenum", {"type": 'NUMPAD_PLUS', "value": 'PRESS', "shift": True}, diff --git a/release/scripts/startup/bl_ui/space_filebrowser.py b/release/scripts/startup/bl_ui/space_filebrowser.py index b626d77c169..b939586ff81 100644 --- a/release/scripts/startup/bl_ui/space_filebrowser.py +++ b/release/scripts/startup/bl_ui/space_filebrowser.py @@ -34,19 +34,25 @@ class FILEBROWSER_HT_header(Header): layout.menu("FILEBROWSER_MT_view") +row = layout.row(align=True) +row.operator("file.previous", text="", icon='BACK') +row.operator("file.next", text="", icon='FORWARD') +row.operator("file.parent", text="", icon='FILE_PARENT') +row.operator("file.refresh", text="", icon='FILE_REFRESH') + +layout.operator_context = 'EXEC_DEFAULT' +layout.operator("file.directory_new", icon='NEWFOLDER', text="") + +layout.operator_context = 'INVOKE_DEFAULT' + # can be None when save/reload with a file selector open if params: is_lib_browser = params.use_library_browsing layout.prop(params, "display_type", expand=True, text="") layout.prop(params, "sort_method", expand=True, text="") -layout.prop(params, "use_sort_invert") layout.prop(params, "show_hidden", text="", icon='FILE_HIDDEN') -
[Bf-blender-cvs] [5c531c7f314] filebrowser_redesign: Merge branch 'master' into filebrowser_redesign
Commit: 5c531c7f3149a6058fe77e9338564db4d784a2db Author: Julian Eisel Date: Fri Jul 26 01:28:25 2019 +0200 Branches: filebrowser_redesign https://developer.blender.org/rB5c531c7f3149a6058fe77e9338564db4d784a2db Merge branch 'master' into filebrowser_redesign === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [8aba00a6735] filebrowser_redesign: Remove dead code
Commit: 8aba00a673565eb9239ec6c9fc4af85f74a49c2a Author: Julian Eisel Date: Fri Jul 26 00:05:43 2019 +0200 Branches: filebrowser_redesign https://developer.blender.org/rB8aba00a673565eb9239ec6c9fc4af85f74a49c2a Remove dead code Now handled in Python. === M source/blender/editors/space_file/file_draw.c === diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c index 588c9df5714..1fbdaeaf712 100644 --- a/source/blender/editors/space_file/file_draw.c +++ b/source/blender/editors/space_file/file_draw.c @@ -77,287 +77,6 @@ static char *file_draw_tooltip_func(bContext *UNUSED(C), void *argN, const char return BLI_strdup(dyn_tooltip); } -#if 0 -/* Note: This function uses pixelspace (0, 0, winx, winy), not view2d. - * The controls are laid out as follows: - * - * --- - * | Directory input | execute | - * --- - * | Filename input| + | - | cancel | - * --- - * - * The input widgets will stretch to fill any excess space. - * When there isn't enough space for all controls to be shown, they are - * hidden in this order: x/-, execute/cancel, input widgets. - */ -void file_draw_filepath_buttons(const bContext *C, ARegion *ar) -{ - /* Button layout. */ - const int max_x = ar->winx - 10; - const int line1_y = ar->winy - (IMASEL_BUTTONS_HEIGHT / 2 + IMASEL_BUTTONS_MARGIN); - const int line2_y = line1_y - (IMASEL_BUTTONS_HEIGHT / 2 + IMASEL_BUTTONS_MARGIN); - const int input_minw = 20; - const int btn_h = UI_UNIT_Y; - const int btn_fn_w = UI_UNIT_X; - const int btn_minw = 80; - const int btn_margin = 20; - const int separator = 4; - - /* Additional locals. */ - char uiblockstr[32]; - int loadbutton; - int fnumbuttons; - int min_x = 10; - int chan_offs = 0; - int available_w = max_x - min_x; - int line1_w = available_w; - int line2_w = available_w; - - uiBut *but; - uiBlock *block; - SpaceFile *sfile = CTX_wm_space_file(C); - FileSelectParams *params = ED_fileselect_get_params(sfile); - ARegion *artmp; - const bool is_browse_only = (sfile->op == NULL); - - /* Initialize UI block. */ - BLI_snprintf(uiblockstr, sizeof(uiblockstr), "win %p", (void *)ar); - block = UI_block_begin(C, ar, uiblockstr, UI_EMBOSS); - - /* exception to make space for collapsed region icon */ - for (artmp = CTX_wm_area(C)->regionbase.first; artmp; artmp = artmp->next) { -if (artmp->regiontype == RGN_TYPE_TOOLS && artmp->flag & RGN_FLAG_HIDDEN) { - chan_offs = 16; - min_x += chan_offs; - available_w -= chan_offs; -} - } - - /* Is there enough space for the execute / cancel buttons? */ - - if (is_browse_only) { -loadbutton = 0; - } - else { -const uiFontStyle *fstyle = UI_FSTYLE_WIDGET; -loadbutton = UI_fontstyle_string_width(fstyle, params->title) + btn_margin; -CLAMP_MIN(loadbutton, btn_minw); -if (available_w <= loadbutton + separator + input_minw) { - loadbutton = 0; -} - } - - if (loadbutton) { -line1_w -= (loadbutton + separator); -line2_w = line1_w; - } - - /* Is there enough space for file number increment/decrement buttons? */ - fnumbuttons = 2 * btn_fn_w; - if (!loadbutton || line2_w <= fnumbuttons + separator + input_minw) { -fnumbuttons = 0; - } - else { -line2_w -= (fnumbuttons + separator); - } - - /* Text input fields for directory and file. */ - if (available_w > 0) { -const struct FileDirEntry *file = sfile->files ? - filelist_file(sfile->files, params->active_file) : - NULL; -int overwrite_alert = file_draw_check_exists(sfile); -const bool is_active_dir = file && (file->typeflag & FILE_TYPE_FOLDER); - -/* callbacks for operator check functions */ -UI_block_func_set(block, file_draw_check_cb, NULL, NULL); - -but = uiDefBut(block, - UI_BTYPE_TEXT, - -1, - "", - min_x, - line1_y, - line1_w - chan_offs, - btn_h, - params->dir, - 0.0, - (float)FILE_MAX, - 0, - 0, - TIP_("File path")); -UI_but_func_complete_set(but, autocomplete_directory, NULL); -UI_but_flag_enable(but, UI_BUT_NO_UTF8); -UI_but_flag_disable(but, UI_BUT_UNDO); -UI_but_funcN_set(but, file_directory_enter_handle, NULL, but); - -/* TODO, directory editing is non-functional while a library is loaded - * until this is properly supported just disable it. */ -if (sfile->files && filelist_lib(sfile->files)) { - UI_but_flag_enable(but, UI_BUT_DISABLED); -} - -
[Bf-blender-cvs] [33371915c9b] filebrowser_redesign: Fix vertical list layout when thumnail view was active previously
Commit: 33371915c9b424fc1bf51b3eb467881e3163e865 Author: Julian Eisel Date: Thu Jul 25 21:58:45 2019 +0200 Branches: filebrowser_redesign https://developer.blender.org/rB33371915c9b424fc1bf51b3eb467881e3163e865 Fix vertical list layout when thumnail view was active previously === M source/blender/editors/space_file/filesel.c === diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index ed824745134..0d7d988b211 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -69,6 +69,8 @@ #include "file_intern.h" #include "filelist.h" +#define VERTLIST_MAJORCOLUMN_WIDTH (25 * UI_UNIT_X) + FileSelectParams *ED_fileselect_get_params(struct SpaceFile *sfile) { if (!sfile->params) { @@ -656,7 +658,6 @@ void ED_fileselect_init_layout(struct SpaceFile *sfile, ARegion *ar) FileSelectParams *params = ED_fileselect_get_params(sfile); FileLayout *layout = NULL; View2D *v2d = >v2d; - int maxlen = 0; int numfiles; int textheight; @@ -725,9 +726,6 @@ void ED_fileselect_init_layout(struct SpaceFile *sfile, ARegion *ar) layout->flag = FILE_LAYOUT_VER; } else if (params->display == FILE_HORIZONTALDISPLAY) { -int column_space = 0.6f * UI_UNIT_X; -int column_icon_space = 0.2f * UI_UNIT_X; - layout->prv_w = ((float)params->thumbnail_size / 20.0f) * UI_UNIT_X; layout->prv_h = ((float)params->thumbnail_size / 20.0f) * UI_UNIT_Y; layout->tile_border_x = 0.4f * UI_UNIT_X; @@ -739,13 +737,9 @@ void ED_fileselect_init_layout(struct SpaceFile *sfile, ARegion *ar) /* Padding by full scrollbar H is too much, can overlap tile border Y. */ layout->rows = (layout->height - V2D_SCROLL_HEIGHT + layout->tile_border_y) / (layout->tile_h + 2 * layout->tile_border_y); +layout->tile_w = VERTLIST_MAJORCOLUMN_WIDTH; details_columns_init(params, layout); -maxlen = ICON_DEFAULT_WIDTH_SCALE + column_icon_space + - (int)layout->details_columns[COLUMN_NAME].width + column_space + - (int)layout->details_columns[COLUMN_DATETIME].width + column_space + - (int)layout->details_columns[COLUMN_SIZE].width + column_space; -layout->tile_w = maxlen; if (layout->rows > 0) { layout->columns = numfiles / layout->rows + 1; // XXX dirty, modulo is zero } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [b2bc426c008] filebrowser_redesign: Add new/changed settings to version patching
Commit: b2bc426c008079c868dbcdcce492d4f7db3b946e Author: Julian Eisel Date: Thu Jul 25 03:16:24 2019 +0200 Branches: filebrowser_redesign https://developer.blender.org/rBb2bc426c008079c868dbcdcce492d4f7db3b946e Add new/changed settings to version patching * Set flag to dynamically size file path region. Without this the region can be resized, which is not wanted. * Enable modification date/time and size details columns === M source/blender/blenloader/intern/versioning_280.c === diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index ffe33253135..aa9f0745df9 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -3539,6 +3539,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_FILE) { +SpaceFile *sfile = (SpaceFile *)sl; ListBase *regionbase = (sl == sa->spacedata.first) ? >regionbase : >regionbase; ARegion *ar_ui = do_versions_find_region(regionbase, RGN_TYPE_UI); ARegion *ar_header = do_versions_find_region(regionbase, RGN_TYPE_HEADER); @@ -3547,6 +3548,12 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) /* Reinsert UI region so that it spawns entire area width */ BLI_remlink(regionbase, ar_ui); BLI_insertlinkafter(regionbase, ar_header, ar_ui); + + ar_ui->flag |= RGN_FLAG_DYNAMIC_SIZE; +} + +if (sfile->params) { + sfile->params->details_flags |= FILE_DETAILS_SIZE | FILE_DETAILS_DATETIME; } } } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [2f6831e6914] filebrowser_redesign: Changed Displaytype to Vertical List and Horizontal List
Commit: 2f6831e69149dbbea86e5a91e8930845c46d428d Author: Brian Meisenheimer Date: Thu Jul 25 14:13:05 2019 +0200 Branches: filebrowser_redesign https://developer.blender.org/rB2f6831e69149dbbea86e5a91e8930845c46d428d Changed Displaytype to Vertical List and Horizontal List === M release/datafiles/locale M source/blender/editors/space_file/file_draw.c M source/blender/editors/space_file/filesel.c M source/blender/editors/space_file/space_file.c M source/blender/makesdna/DNA_space_types.h M source/blender/makesrna/intern/rna_space.c M source/blender/windowmanager/intern/wm_files.c M source/blender/windowmanager/intern/wm_operator_props.c M source/tools === diff --git a/release/datafiles/locale b/release/datafiles/locale index 6625026f62f..2b81e2acc01 16 --- a/release/datafiles/locale +++ b/release/datafiles/locale @@ -1 +1 @@ -Subproject commit 6625026f62f492dd677f5f29c68b9d70c96fb34b +Subproject commit 2b81e2acc011a8b79232a18dad3c00b8e654ceee diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c index fdd70a7d6e5..588c9df5714 100644 --- a/source/blender/editors/space_file/file_draw.c +++ b/source/blender/editors/space_file/file_draw.c @@ -862,7 +862,7 @@ void file_draw_list(const bContext *C, ARegion *ar) eFontStyle_Align align; bool do_drag; unsigned char text_col[4]; - const bool draw_columnheader = (params->display == FILE_SHORTDISPLAY); + const bool draw_columnheader = (params->display == FILE_VERTICALDISPLAY); const float thumb_icon_aspect = sqrtf(64.0f / (float)(params->thumbnail_size)); numfiles = filelist_files_ensure(files); @@ -948,7 +948,7 @@ void file_draw_list(const bContext *C, ARegion *ar) int colorid = (file_selflag & FILE_SEL_SELECTED) ? TH_HILITE : TH_BACK; int shade = (params->highlight_file == i) || (file_selflag & FILE_SEL_HIGHLIGHTED) ? 35 : 0; -const short width = ELEM(params->display, FILE_SHORTDISPLAY, FILE_LONGDISPLAY) ? +const short width = ELEM(params->display, FILE_VERTICALDISPLAY, FILE_HORIZONTALDISPLAY) ? layout->tile_w - (2 * padx) : layout->tile_w; diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index cfa662834f3..ed824745134 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -270,11 +270,11 @@ short ED_fileselect_set_params(SpaceFile *sfile) params->display = FILE_IMGDISPLAY; } else { -params->display = FILE_SHORTDISPLAY; +params->display = FILE_VERTICALDISPLAY; } } else { - params->display = FILE_SHORTDISPLAY; + params->display = FILE_VERTICALDISPLAY; } } else { @@ -295,7 +295,7 @@ short ED_fileselect_set_params(SpaceFile *sfile) params->type = FILE_UNIX; params->flag |= FILE_HIDE_DOT; params->flag &= ~FILE_DIRSEL_ONLY; -params->display = FILE_SHORTDISPLAY; +params->display = FILE_VERTICALDISPLAY; params->display_previous = FILE_DEFAULTDISPLAY; params->sort = FILE_SORT_ALPHA; params->filter = 0; @@ -697,7 +697,7 @@ void ED_fileselect_init_layout(struct SpaceFile *sfile, ARegion *ar) layout->tile_border_y * 2 - layout->offset_top; layout->flag = FILE_LAYOUT_VER; } - else if (params->display == FILE_SHORTDISPLAY) { + else if (params->display == FILE_VERTICALDISPLAY) { int rowcount; layout->prv_w = ((float)params->thumbnail_size / 20.0f) * UI_UNIT_X; @@ -724,7 +724,7 @@ void ED_fileselect_init_layout(struct SpaceFile *sfile, ARegion *ar) layout->tile_border_y * 2 + layout->offset_top; layout->flag = FILE_LAYOUT_VER; } - else if (params->display == FILE_LONGDISPLAY) { + else if (params->display == FILE_HORIZONTALDISPLAY) { int column_space = 0.6f * UI_UNIT_X; int column_icon_space = 0.2f * UI_UNIT_X; diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c index 1f90d09b697..992ffd3f461 100644 --- a/source/blender/editors/space_file/space_file.c +++ b/source/blender/editors/space_file/space_file.c @@ -414,7 +414,7 @@ static void file_main_region_draw(const bContext *C, ARegion *ar) v2d->keepofs &= ~V2D_LOCKOFS_Y; v2d->keepofs |= V2D_LOCKOFS_X; } - else if (params->display == FILE_SHORTDISPLAY) { + else if (params->display == FILE_VERTICALDISPLAY) { v2d->scroll = V2D_SCROLL_RIGHT; v2d->keepofs &= ~V2D_LOCKOFS_Y; v2d->keepofs |= V2D_LOCKOFS_X; diff --git
[Bf-blender-cvs] [d9cf9c659ce] filebrowser_redesign: Use full area width for filepath region
Commit: d9cf9c659ce4e0c072b63637d208ce65be998273 Author: Julian Eisel Date: Thu Jul 25 03:11:58 2019 +0200 Branches: filebrowser_redesign https://developer.blender.org/rBd9cf9c659ce4e0c072b63637d208ce65be998273 Use full area width for filepath region Also adjusts size for old files. === M source/blender/blenloader/intern/versioning_280.c M source/blender/editors/space_file/space_file.c === diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index cb2b64957f0..ffe33253135 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -3535,5 +3535,22 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) { /* Versioning code until next subversion bump goes here. */ +for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { + for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { +for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { + if (sl->spacetype == SPACE_FILE) { +ListBase *regionbase = (sl == sa->spacedata.first) ? >regionbase : >regionbase; +ARegion *ar_ui = do_versions_find_region(regionbase, RGN_TYPE_UI); +ARegion *ar_header = do_versions_find_region(regionbase, RGN_TYPE_HEADER); + +if (ar_ui && ar_header) { + /* Reinsert UI region so that it spawns entire area width */ + BLI_remlink(regionbase, ar_ui); + BLI_insertlinkafter(regionbase, ar_header, ar_ui); +} + } +} + } +} } } diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c index f7d83570b90..1f90d09b697 100644 --- a/source/blender/editors/space_file/space_file.c +++ b/source/blender/editors/space_file/space_file.c @@ -72,6 +72,13 @@ static SpaceLink *file_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scen /* Ignore user preference "USER_HEADER_BOTTOM" here (always show top for new types). */ ar->alignment = RGN_ALIGN_TOP; + /* ui list region */ + ar = MEM_callocN(sizeof(ARegion), "ui region for file"); + BLI_addtail(>regionbase, ar); + ar->regiontype = RGN_TYPE_UI; + ar->alignment = RGN_ALIGN_TOP; + ar->flag |= RGN_FLAG_DYNAMIC_SIZE; + /* Tools region */ ar = MEM_callocN(sizeof(ARegion), "tools region for file"); BLI_addtail(>regionbase, ar); @@ -84,13 +91,6 @@ static SpaceLink *file_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scen ar->regiontype = RGN_TYPE_TOOL_PROPS; ar->alignment = RGN_ALIGN_BOTTOM | RGN_SPLIT_PREV; - /* ui list region */ - ar = MEM_callocN(sizeof(ARegion), "ui region for file"); - BLI_addtail(>regionbase, ar); - ar->regiontype = RGN_TYPE_UI; - ar->alignment = RGN_ALIGN_TOP; - ar->flag |= RGN_FLAG_DYNAMIC_SIZE; - /* Execute region */ ar = MEM_callocN(sizeof(ARegion), "execute region for file"); BLI_addtail(>regionbase, ar); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [248ee40712e] functions: Cleanup: Fix build error with msvc.
Commit: 248ee40712ea7f1fcb6dc2ef03fdac21a5acb13f Author: Lazydodo Date: Thu Jul 25 15:18:33 2019 -0600 Branches: functions https://developer.blender.org/rB248ee40712ea7f1fcb6dc2ef03fdac21a5acb13f Cleanup: Fix build error with msvc. === M source/blender/blenkernel/BKE_node_tree.hpp M source/blender/blenlib/BLI_string_ref.hpp === diff --git a/source/blender/blenkernel/BKE_node_tree.hpp b/source/blender/blenkernel/BKE_node_tree.hpp index 84a761f4d0a..d97e35eac5a 100644 --- a/source/blender/blenkernel/BKE_node_tree.hpp +++ b/source/blender/blenkernel/BKE_node_tree.hpp @@ -127,12 +127,11 @@ class VirtualLink; class VirtualNodeTree { private: bool m_frozen = false; - MonotonicAllocator<> m_allocator; Vector m_nodes; Vector m_links; Vector m_inputs_with_links; MultiMap m_nodes_by_idname; - + MonotonicAllocator<> m_allocator; public: void add_all_of_tree(bNodeTree *btree); VirtualNode *add_bnode(bNodeTree *btree, bNode *bnode); diff --git a/source/blender/blenlib/BLI_string_ref.hpp b/source/blender/blenlib/BLI_string_ref.hpp index 6749dddf5a1..65affae159b 100644 --- a/source/blender/blenlib/BLI_string_ref.hpp +++ b/source/blender/blenlib/BLI_string_ref.hpp @@ -229,7 +229,7 @@ inline bool StringRefBase::endswith(StringRef suffix) const BLI::StringRef a_ref(a); \ BLI::StringRef b_ref(b); \ uint characters = a_ref.size() + b_ref.size(); \ -char *result##_ptr = BLI_array_alloca(result##_ptr, characters + 1); \ +char *result##_ptr = (char*) BLI_array_alloca(result##_ptr, characters + 1); \ for (uint i = 0; i < a_ref.size(); i++) \ result##_ptr[i] = a_ref[i]; \ for (uint i = 0; i < b_ref.size(); i++) \ ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [a3107a0bb13] sybren-usd: USD: Cleanup, removed unnecessary `struct` keyword
Commit: a3107a0bb13e8c9b7b8e9d5f5f13319d361d101f Author: Sybren A. Stüvel Date: Thu Jul 25 16:32:12 2019 +0200 Branches: sybren-usd https://developer.blender.org/rBa3107a0bb13e8c9b7b8e9d5f5f13319d361d101f USD: Cleanup, removed unnecessary `struct` keyword No functional changes. === M source/blender/usd/intern/usd_writer_mesh.cc === diff --git a/source/blender/usd/intern/usd_writer_mesh.cc b/source/blender/usd/intern/usd_writer_mesh.cc index 752a5a6b7c5..4c2994ea29d 100644 --- a/source/blender/usd/intern/usd_writer_mesh.cc +++ b/source/blender/usd/intern/usd_writer_mesh.cc @@ -174,7 +174,7 @@ void USDGenericMeshWriter::write_mesh(HierarchyContext , Mesh *mesh) assign_materials(context, usd_mesh, usd_mesh_data.face_groups); } -static void get_vertices(const Mesh *mesh, struct USDMeshData _mesh_data) +static void get_vertices(const Mesh *mesh, USDMeshData _mesh_data) { usd_mesh_data.points.reserve(mesh->totvert); @@ -184,7 +184,7 @@ static void get_vertices(const Mesh *mesh, struct USDMeshData _mesh_data) } } -static void get_loops_polys(const Mesh *mesh, struct USDMeshData _mesh_data) +static void get_loops_polys(const Mesh *mesh, USDMeshData _mesh_data) { /* Only construct face groups (a.k.a. geometry subsets) when we need them for material * assignments. */ @@ -208,7 +208,7 @@ static void get_loops_polys(const Mesh *mesh, struct USDMeshData _mesh_data) } } -static void get_creases(const Mesh *mesh, struct USDMeshData _mesh_data) +static void get_creases(const Mesh *mesh, USDMeshData _mesh_data) { const float factor = 1.0f / 255.0f; @@ -233,7 +233,7 @@ static void get_creases(const Mesh *mesh, struct USDMeshData _mesh_data) } } -void USDGenericMeshWriter::get_geometry_data(const Mesh *mesh, struct USDMeshData _mesh_data) +void USDGenericMeshWriter::get_geometry_data(const Mesh *mesh, USDMeshData _mesh_data) { get_vertices(mesh, usd_mesh_data); get_loops_polys(mesh, usd_mesh_data); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [f64f0506b72] sybren-usd: USD: Export mesh normals
Commit: f64f0506b725412419dc6de55d728fecafdc5b35 Author: Sybren A. Stüvel Date: Thu Jul 25 16:31:56 2019 +0200 Branches: sybren-usd https://developer.blender.org/rBf64f0506b725412419dc6de55d728fecafdc5b35 USD: Export mesh normals We now write face-varying mesh normals to USD. When the mesh has custom loop normals those are written. Otherwise the poly flag `ME_SMOOTH` is inspected to determine the normals. This commits also changes the subdivision scheme from the default value 'Catmull Clark' to 'None', indicating we're exporting a polygonal mesh. This is necessary for USD to understand our normals; otherwise the mesh is always rendered smooth. In the future we may want to expose this choice of subdivision scheme to the user, or auto-detect it when we actually support exporting pre-subdivision meshes. A possible optimisation could be to inspect whether all polygons are smooth or flat, and mark the USD mesh as such. This can be added when needed. === 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 f2ddbbd628f..752a5a6b7c5 100644 --- a/source/blender/usd/intern/usd_writer_mesh.cc +++ b/source/blender/usd/intern/usd_writer_mesh.cc @@ -7,10 +7,13 @@ extern "C" { #include "BLI_assert.h" +#include "BLI_math_vector.h" #include "BKE_anim.h" +#include "BKE_customdata.h" #include "BKE_library.h" #include "BKE_material.h" +#include "BKE_mesh.h" #include "DEG_depsgraph.h" @@ -160,12 +163,14 @@ void USDGenericMeshWriter::write_mesh(HierarchyContext , Mesh *mesh) } write_uv_maps(mesh, usd_mesh); + write_normals(mesh, usd_mesh); // TODO(Sybren): figure out what happens when the face groups change. if (frame_has_been_written_) { return; } + usd_mesh.CreateSubdivisionSchemeAttr().Set(pxr::UsdGeomTokens->none); assign_materials(context, usd_mesh, usd_mesh_data.face_groups); } @@ -297,6 +302,50 @@ void USDGenericMeshWriter::assign_materials( } } +void USDGenericMeshWriter::write_normals(const Mesh *mesh, pxr::UsdGeomMesh usd_mesh) +{ + pxr::UsdTimeCode timecode = get_export_time_code(); + const float(*lnors)[3] = static_cast(CustomData_get_layer(>ldata, CD_NORMAL)); + + pxr::VtVec3fArray loop_normals; + loop_normals.reserve(mesh->totloop); + + if (lnors != nullptr) { +/* Export custom loop normals. */ +for (int loop_idx = 0, totloop = mesh->totloop; loop_idx < totloop; ++loop_idx) { + loop_normals.push_back(pxr::GfVec3f(lnors[loop_idx])); +} + } + else { +/* Compute the loop normals based on the 'smooth' flag. */ +float normal[3]; +MPoly *mpoly = mesh->mpoly; +const MVert *mvert = mesh->mvert; +for (int poly_idx = 0, totpoly = mesh->totpoly; poly_idx < totpoly; ++poly_idx, ++mpoly) { + MLoop *mloop = mesh->mloop + mpoly->loopstart; + + if ((mpoly->flag & ME_SMOOTH) == 0) { +/* Flat shaded, use common normal for all verts. */ +BKE_mesh_calc_poly_normal(mpoly, mloop, mvert, normal); +pxr::GfVec3f pxr_normal(normal); +for (int loop_idx = 0; loop_idx < mpoly->totloop; ++loop_idx) { + loop_normals.push_back(pxr_normal); +} + } + else { +/* Smooth shaded, use individual vert normals. */ +for (int loop_idx = 0; loop_idx < mpoly->totloop; ++loop_idx, ++mloop) { + normal_short_to_float_v3(normal, mvert[mloop->v].no); + loop_normals.push_back(pxr::GfVec3f(normal)); +} + } +} + } + + usd_mesh.CreateNormalsAttr().Set(loop_normals, timecode); + usd_mesh.SetNormalsInterpolation(pxr::UsdGeomTokens->faceVarying); +} + USDMeshWriter::USDMeshWriter(const USDExporterContext ) : USDGenericMeshWriter(ctx) { } diff --git a/source/blender/usd/intern/usd_writer_mesh.h b/source/blender/usd/intern/usd_writer_mesh.h index aea49fe9523..2eddf114bf4 100644 --- a/source/blender/usd/intern/usd_writer_mesh.h +++ b/source/blender/usd/intern/usd_writer_mesh.h @@ -26,6 +26,7 @@ class USDGenericMeshWriter : public USDAbstractWriter { pxr::UsdGeomMesh usd_mesh, const std::map _face_groups); void write_uv_maps(const Mesh *mesh, pxr::UsdGeomMesh usd_mesh); + void write_normals(const Mesh *mesh, pxr::UsdGeomMesh usd_mesh); }; class USDMeshWriter : public USDGenericMeshWriter { ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [cb10bd379b2] master: Fix T67599: Issue with Simple subdivision of loose edges
Commit: cb10bd379b2d4b33c1626c7bff3c571f26e1493c Author: Sergey Sharybin Date: Thu Jul 25 16:33:04 2019 +0200 Branches: master https://developer.blender.org/rBcb10bd379b2d4b33c1626c7bff3c571f26e1493c Fix T67599: Issue with Simple subdivision of loose edges They were always acting as a B-Spline subdivision. === M source/blender/blenkernel/intern/subdiv_mesh.c === diff --git a/source/blender/blenkernel/intern/subdiv_mesh.c b/source/blender/blenkernel/intern/subdiv_mesh.c index 75e05f8ffab..a6feae2430d 100644 --- a/source/blender/blenkernel/intern/subdiv_mesh.c +++ b/source/blender/blenkernel/intern/subdiv_mesh.c @@ -1086,20 +1086,27 @@ static void subdiv_mesh_vertex_of_loose_edge(const struct SubdivForeachContext * const MEdge *coarse_edge = _mesh->medge[coarse_edge_index]; Mesh *subdiv_mesh = ctx->subdiv_mesh; MVert *subdiv_mvert = subdiv_mesh->mvert; + const bool is_simple = ctx->subdiv->settings.is_simple; /* Find neighbors of the current loose edge. */ const MEdge *neighbors[2]; find_edge_neighbors(ctx, coarse_edge, neighbors); - /* Get points for b-spline interpolation. */ - float points[4][3]; - points_for_loose_edges_interpolation_get(ctx, coarse_edge, neighbors, points); - /* Perform interpolation. */ - float weights[4]; - key_curve_position_weights(u, weights, KEY_BSPLINE); /* Interpolate custom data. */ subdiv_mesh_vertex_of_loose_edge_interpolate(ctx, coarse_edge, u, subdiv_vertex_index); - /* Initialize */ + /* Interpolate coordinate. */ MVert *subdiv_vertex = _mvert[subdiv_vertex_index]; - interp_v3_v3v3v3v3(subdiv_vertex->co, points[0], points[1], points[2], points[3], weights); + if (is_simple) { +const MVert *coarse_mvert = coarse_mesh->mvert; +const MVert *vert_1 = _mvert[coarse_edge->v1]; +const MVert *vert_2 = _mvert[coarse_edge->v2]; +interp_v2_v2v2(subdiv_vertex->co, vert_1->co, vert_2->co, u); + } + else { +float points[4][3]; +points_for_loose_edges_interpolation_get(ctx, coarse_edge, neighbors, points); +float weights[4]; +key_curve_position_weights(u, weights, KEY_BSPLINE); +interp_v3_v3v3v3v3(subdiv_vertex->co, points[0], points[1], points[2], points[3], weights); + } /* Reset flags and such. */ subdiv_vertex->flag = 0; /* TODO(sergey): This matches old behavior, but we can as well interpolate ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [adaf37f4d5d] sybren-usd: USD: Remove the "uv_" prefix from exported UV maps
Commit: adaf37f4d5da35b7ada286bdda9a1dfa5207639f Author: Sybren A. Stüvel Date: Thu Jul 25 15:41:47 2019 +0200 Branches: sybren-usd https://developer.blender.org/rBadaf37f4d5da35b7ada286bdda9a1dfa5207639f USD: Remove the "uv_" prefix from exported UV maps The primvar name is now the same as the UV Map name. This is to allow the standard name "st" for texture coordinates by naming the UV Map as such, without having to guess which UV Map is the "standard" one. === M source/blender/usd/intern/usd_writer_mesh.cc === diff --git a/source/blender/usd/intern/usd_writer_mesh.cc b/source/blender/usd/intern/usd_writer_mesh.cc index c50910ce8f9..f2ddbbd628f 100644 --- a/source/blender/usd/intern/usd_writer_mesh.cc +++ b/source/blender/usd/intern/usd_writer_mesh.cc @@ -99,8 +99,11 @@ void USDGenericMeshWriter::write_uv_maps(const Mesh *mesh, pxr::UsdGeomMesh usd_ continue; } -// UV coordinates are stored in a Primvar on the Mesh, and can be referenced from materials. -pxr::TfToken primvar_name(pxr::TfMakeValidIdentifier(std::string("uv_") + layer->name)); +/* UV coordinates are stored in a Primvar on the Mesh, and can be referenced from materials. + * The primvar name is the same as the UV Map name. This is to allow the standard name "st" + * for texture coordinates by naming the UV Map as such, without having to guess which UV Map + * is the "standard" one. */ +pxr::TfToken primvar_name(pxr::TfMakeValidIdentifier(layer->name)); pxr::UsdGeomPrimvar uv_coords_primvar = usd_mesh.CreatePrimvar( primvar_name, pxr::SdfValueTypeNames->TexCoord2fArray, pxr::UsdGeomTokens->faceVarying); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [1416add5190] sybren-usd: Merge remote-tracking branch 'origin/master' into sybren-usd
Commit: 1416add5190d89e10dfbff34f922ea94a7c117ae Author: Sybren A. Stüvel Date: Thu Jul 25 12:49:12 2019 +0200 Branches: sybren-usd https://developer.blender.org/rB1416add5190d89e10dfbff34f922ea94a7c117ae 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] [33954860c88] sybren-usd: USD: replaced throwing temp C++ exception with BLI_assert() call
Commit: 33954860c88f75597f41ad98afd717e6ec36b156 Author: Sybren A. Stüvel Date: Thu Jul 25 14:46:13 2019 +0200 Branches: sybren-usd https://developer.blender.org/rB33954860c88f75597f41ad98afd717e6ec36b156 USD: replaced throwing temp C++ exception with BLI_assert() call The exception was for making things easier to debug for me. Now the issues are gracefully ignored when things go bad, which is better for users. No functional changes. === M source/blender/usd/intern/usd_writer_mesh.cc === diff --git a/source/blender/usd/intern/usd_writer_mesh.cc b/source/blender/usd/intern/usd_writer_mesh.cc index 3bcad763018..c50910ce8f9 100644 --- a/source/blender/usd/intern/usd_writer_mesh.cc +++ b/source/blender/usd/intern/usd_writer_mesh.cc @@ -6,6 +6,8 @@ #include extern "C" { +#include "BLI_assert.h" + #include "BKE_anim.h" #include "BKE_library.h" #include "BKE_material.h" @@ -123,25 +125,27 @@ void USDGenericMeshWriter::write_mesh(HierarchyContext , Mesh *mesh) // This object data is instanced, just reference the original instead of writing a copy. if (context.export_path == context.original_export_path) { printf("USD ref error: export path is reference path: %s\n", context.export_path.c_str()); - throw "JEEKL"; + BLI_assert(!"USD reference error"); + return; } pxr::SdfPath ref_path(context.original_export_path); -if (usd_mesh.GetPrim().GetReferences().AddInternalReference(ref_path)) { - /* The material path will be of the form , which is outside the - subtree pointed to by ref_path. As a result, the referenced data is not allowed to point out - of its own subtree. It does work when we override the material with exactly the same path, - though.*/ - assign_materials(context, usd_mesh, usd_mesh_data.face_groups); +if (!usd_mesh.GetPrim().GetReferences().AddInternalReference(ref_path)) { + /* See this URL for a description fo why referencing may fail" + * https://graphics.pixar.com/usd/docs/api/class_usd_references.html#Usd_Failing_References + */ + printf("USD Export warning: unable to add reference from %s to %s, not instancing object\n", + context.export_path.c_str(), + context.original_export_path.c_str()); return; } -/* See - https://graphics.pixar.com/usd/docs/api/class_usd_references.html#Usd_Failing_References - * for a description fo why referencing may fail. */ -printf("USD Export warning: unable to add reference from %s to %s, not instancing object\n", - context.export_path.c_str(), - context.original_export_path.c_str()); -throw "JE MOEDER"; +/* The material path will be of the form , which is outside the +subtree pointed to by ref_path. As a result, the referenced data is not allowed to point out +of its own subtree. It does work when we override the material with exactly the same path, +though.*/ +assign_materials(context, usd_mesh, usd_mesh_data.face_groups); +return; } + 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); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [71966f856fa] sybren-usd: USD: simplified nested condition in USDAbstractWriter::write()
Commit: 71966f856fabfc44210663eb0ac820e676fbb192 Author: Sybren A. Stüvel Date: Thu Jul 25 14:48:02 2019 +0200 Branches: sybren-usd https://developer.blender.org/rB71966f856fabfc44210663eb0ac820e676fbb192 USD: simplified nested condition in USDAbstractWriter::write() By flipping a condition the code became much simpler. No functional changes. === M source/blender/usd/intern/usd_writer_abstract.cc === diff --git a/source/blender/usd/intern/usd_writer_abstract.cc b/source/blender/usd/intern/usd_writer_abstract.cc index 4b5724e6ba2..c7c2496ea33 100644 --- a/source/blender/usd/intern/usd_writer_abstract.cc +++ b/source/blender/usd/intern/usd_writer_abstract.cc @@ -43,14 +43,13 @@ pxr::UsdTimeCode USDAbstractWriter::get_export_time_code() const void USDAbstractWriter::write(HierarchyContext ) { - if (frame_has_been_written_) { -if (!is_animated_) { - return; -} - } - else { + if (!frame_has_been_written_) { is_animated_ = export_params.export_animation && check_is_animated(context); } + else if (!is_animated_) { +/* A frame has alrady been written, and without animation one frame is enough. */ +return; + } do_write(context); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [5f5540eaf69] sybren-usd: USD: Removed debug prints
Commit: 5f5540eaf69b668f80335918664107096dab4820 Author: Sybren A. Stüvel Date: Thu Jul 25 12:59:11 2019 +0200 Branches: sybren-usd https://developer.blender.org/rB5f5540eaf69b668f80335918664107096dab4820 USD: Removed debug prints No functional changes. === M source/blender/usd/intern/abstract_hierarchy_iterator.cc M source/blender/usd/intern/usd_capi.cc M source/blender/usd/intern/usd_hierarchy_iterator.cc M source/blender/usd/intern/usd_writer_abstract.cc M source/blender/usd/intern/usd_writer_hair.cc M source/blender/usd/intern/usd_writer_mesh.cc === diff --git a/source/blender/usd/intern/abstract_hierarchy_iterator.cc b/source/blender/usd/intern/abstract_hierarchy_iterator.cc index d0492b76d30..9eb3c5d6ff2 100644 --- a/source/blender/usd/intern/abstract_hierarchy_iterator.cc +++ b/source/blender/usd/intern/abstract_hierarchy_iterator.cc @@ -128,7 +128,6 @@ void AbstractHierarchyIterator::export_graph_construct() { Scene *scene = DEG_get_evaluated_scene(depsgraph); - // printf("== Visiting objects:\n"); DEG_OBJECT_ITER_BEGIN (depsgraph, object, DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY | @@ -192,13 +191,6 @@ void AbstractHierarchyIterator::visit_object(Object *object, copy_m4_m4(context->matrix_world, object->obmat); export_graph[std::make_pair(export_parent, nullptr)].insert(context); - - // std::string export_parent_name = export_parent ? get_object_name(export_parent) : "/"; - // printf("OB %30s %p (export-parent=%s; world x = %f)\n", - //context->export_name.c_str(), - //context->object, - //export_parent_name.c_str(), - //context->matrix_world[3][0]); } void AbstractHierarchyIterator::visit_dupli_object(DupliObject *dupli_object, @@ -244,16 +236,6 @@ void AbstractHierarchyIterator::visit_dupli_object(DupliObject *dupli_object, context->export_name = make_valid_name(get_object_name(context->object) + suffix_stream.str()); export_graph[graph_index].insert(context); - - // std::string export_parent_name = context->export_parent ? - // get_object_name(context->export_parent) : - // "/"; - // printf("DU %30s %p (export-parent=%s; duplicator = %s; world x = %f)\n", - //context->export_name.c_str(), - //context->object, - //export_parent_name.c_str(), - //duplicator->id.name + 2, - //context->matrix_world[3][0]); } static bool prune_the_weak(const HierarchyContext *context, @@ -365,10 +347,6 @@ void AbstractHierarchyIterator::determine_duplication_references( if (it == originals_export_paths.end()) { // The original was not found, so mark this instance as "original". std::string data_path = get_object_data_path(context); - // printf( - // "%s\033[93mUSD issue\033[0m: %s is DATA instance of %p, but no original DATA path - // " "is known\n", indent.c_str(), data_path.c_str(), orig_data_id); - context->mark_as_not_instanced(); originals_export_paths[orig_id] = context->export_path; originals_export_paths[orig_data_id] = data_path; diff --git a/source/blender/usd/intern/usd_capi.cc b/source/blender/usd/intern/usd_capi.cc index d1b84c453bc..ecf20b737ce 100644 --- a/source/blender/usd/intern/usd_capi.cc +++ b/source/blender/usd/intern/usd_capi.cc @@ -128,7 +128,6 @@ static void export_startjob(void *customdata, short *stop, short *do_update, flo 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); scene->r.subframe = frame - scene->r.cfra; diff --git a/source/blender/usd/intern/usd_hierarchy_iterator.cc b/source/blender/usd/intern/usd_hierarchy_iterator.cc index 3214f25386e..2202d132293 100644 --- a/source/blender/usd/intern/usd_hierarchy_iterator.cc +++ b/source/blender/usd/intern/usd_hierarchy_iterator.cc @@ -70,9 +70,6 @@ USDExporterContext USDHierarchyIterator::create_usd_export_context(const Hierarc AbstractHierarchyWriter *USDHierarchyIterator::create_xform_writer(const HierarchyContext *context) { - // printf( - // "\033[32;1mCREATE\033[0m %s at %s\n", context->object->id.name, - // context->export_path.c_str()); return new USDTransformWriter(create_usd_export_context(context)); } @@ -102,9 +99,6 @@ AbstractHierarchyWriter *USDHierarchyIterator::create_data_writer(const Hierarch case OB_LATTICE: case OB_ARMATURE: case OB_GPENCIL: - // printf("USD-\033[34mXFORM-ONLY\033[0m object %s type=%d (no data writer)\n", - //context->object->id.name, - //
[Bf-blender-cvs] [7db0b9c265c] functions: add utility to combine strings on the stack
Commit: 7db0b9c265c4024bf256be59f826eb7cc0128f20 Author: Jacques Lucke Date: Thu Jul 25 15:09:57 2019 +0200 Branches: functions https://developer.blender.org/rB7db0b9c265c4024bf256be59f826eb7cc0128f20 add utility to combine strings on the stack === M source/blender/blenlib/BLI_string_ref.hpp M source/blender/simulations/bparticles/inserters.cpp M tests/gtests/blenlib/BLI_string_ref_test.cc === diff --git a/source/blender/blenlib/BLI_string_ref.hpp b/source/blender/blenlib/BLI_string_ref.hpp index ac300f487b2..6749dddf5a1 100644 --- a/source/blender/blenlib/BLI_string_ref.hpp +++ b/source/blender/blenlib/BLI_string_ref.hpp @@ -26,6 +26,7 @@ #include #include "BLI_utildefines.h" +#include "BLI_alloca.h" namespace BLI { @@ -221,3 +222,18 @@ inline bool StringRefBase::endswith(StringRef suffix) const } } // namespace BLI + +#define BLI_STRINGREF_STACK_COMBINE(result, a, b) \ + BLI::StringRefNull result; \ + { \ +BLI::StringRef a_ref(a); \ +BLI::StringRef b_ref(b); \ +uint characters = a_ref.size() + b_ref.size(); \ +char *result##_ptr = BLI_array_alloca(result##_ptr, characters + 1); \ +for (uint i = 0; i < a_ref.size(); i++) \ + result##_ptr[i] = a_ref[i]; \ +for (uint i = 0; i < b_ref.size(); i++) \ + result##_ptr[i + a_ref.size()] = b_ref[i]; \ +result##_ptr[characters] = '\0'; \ +result = BLI::StringRefNull(result##_ptr, a_ref.size() + b_ref.size()); \ + } diff --git a/source/blender/simulations/bparticles/inserters.cpp b/source/blender/simulations/bparticles/inserters.cpp index d33d0f0063d..74c667e3ffe 100644 --- a/source/blender/simulations/bparticles/inserters.cpp +++ b/source/blender/simulations/bparticles/inserters.cpp @@ -69,7 +69,7 @@ ValueOrError create_particle_function(VirtualNode *main_vnode, VirtualNode *vnode = vsocket->vnode(); SharedType = data_graph.graph()->type_of_output(socket); -std::string name_prefix; +StringRef name_prefix; if (STREQ(vnode->idname(), "bp_ParticleInfoNode")) { name_prefix = "Attribute: "; } @@ -79,7 +79,8 @@ ValueOrError create_particle_function(VirtualNode *main_vnode, else { BLI_assert(false); } -fn_builder.add_input(name_prefix + vsocket->name(), type); +BLI_STRINGREF_STACK_COMBINE(name, name_prefix, vsocket->name()); +fn_builder.add_input(name, type); } SharedFunction fn = fn_builder.build(main_vnode->name()); diff --git a/tests/gtests/blenlib/BLI_string_ref_test.cc b/tests/gtests/blenlib/BLI_string_ref_test.cc index 2e53f1f2c01..00cb7023de6 100644 --- a/tests/gtests/blenlib/BLI_string_ref_test.cc +++ b/tests/gtests/blenlib/BLI_string_ref_test.cc @@ -218,3 +218,23 @@ TEST(string_ref, DropPrefix) EXPECT_EQ(ref2.size(), 1); EXPECT_EQ(ref2, "t"); } + +TEST(string_ref, CombineOnStack1) +{ + StringRef ref1("hello "); + StringRef ref2("world"); + BLI_STRINGREF_STACK_COMBINE(ref_combined, ref1, ref2); + EXPECT_EQ(ref_combined.size(), 11); + EXPECT_EQ(ref_combined, "hello world"); +} + +TEST(string_ref, CombineOnStack2) +{ + StringRef ref1(""); + StringRef ref2(""); + void *before = alloca(1); + BLI_STRINGREF_STACK_COMBINE(ref_combined, ref1, ref2); + void *after = alloca(1); + + EXPECT_TRUE(IN_RANGE_INCL((void *)ref_combined.begin(), before, after)); +} ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [7a3e5c1dadf] functions: simplify creating particle function
Commit: 7a3e5c1dadf01165fd36636f38c26d16fada5647 Author: Jacques Lucke Date: Thu Jul 25 14:31:25 2019 +0200 Branches: functions https://developer.blender.org/rB7a3e5c1dadf01165fd36636f38c26d16fada5647 simplify creating particle function === 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 b38237b75e6..d33d0f0063d 100644 --- a/source/blender/simulations/bparticles/inserters.cpp +++ b/source/blender/simulations/bparticles/inserters.cpp @@ -54,10 +54,10 @@ static ValueOrError create_function__emitter_inputs(VirtualNode return fn; } -static ValueOrError create_function__action_inputs(VirtualNode *action_vnode, - VTreeDataGraph _graph) +ValueOrError create_particle_function(VirtualNode *main_vnode, +VTreeDataGraph _graph) { - Vector sockets_to_compute = find_input_data_sockets(action_vnode, data_graph); + Vector sockets_to_compute = find_input_data_sockets(main_vnode, data_graph); auto dependencies = data_graph.find_placeholder_dependencies(sockets_to_compute); FunctionBuilder fn_builder; @@ -82,29 +82,12 @@ static ValueOrError create_function__action_inputs(VirtualNode * fn_builder.add_input(name_prefix + vsocket->name(), type); } - SharedFunction fn = fn_builder.build(action_vnode->name()); - + SharedFunction fn = fn_builder.build(main_vnode->name()); FunctionGraph fgraph(data_graph.graph(), dependencies.sockets, sockets_to_compute); FN::fgraph_add_TupleCallBody(fn, fgraph); - return fn; -} - -ValueOrError create_function__offset_handler_inputs( -VirtualNode *offset_handler_vnode, VTreeDataGraph _graph) -{ - return create_function__action_inputs(offset_handler_vnode, data_graph); -} -ValueOrError create_function__force_inputs(VirtualNode *force_vnode, - VTreeDataGraph _graph) -{ - return create_function__action_inputs(force_vnode, data_graph); -} - -ValueOrError create_function__event_inputs(VirtualNode *event_vnode, - VTreeDataGraph _graph) -{ - return create_function__action_inputs(event_vnode, data_graph); + ParticleFunction particle_function(fn); + return particle_function; } static std::unique_ptr build_action(BuildContext , @@ -201,7 +184,7 @@ static std::unique_ptr build_action(BuildContext , BLI_assert(start->is_input()); VirtualNode *vnode = start->vnode(); - auto fn_or_error = create_function__action_inputs(vnode, ctx.data_graph); + auto fn_or_error = create_particle_function(vnode, ctx.data_graph); if (fn_or_error.is_error()) { return std::unique_ptr(new NoneAction()); } diff --git a/source/blender/simulations/bparticles/inserters.hpp b/source/blender/simulations/bparticles/inserters.hpp index 7148e0578b5..a98f86e8b9b 100644 --- a/source/blender/simulations/bparticles/inserters.hpp +++ b/source/blender/simulations/bparticles/inserters.hpp @@ -36,14 +36,8 @@ struct BuildContext { } }; -ValueOrError create_function__offset_handler_inputs( -VirtualNode *offset_handler_vnode, VTreeDataGraph _graph); - -ValueOrError create_function__force_inputs(VirtualNode *force_vnode, - VTreeDataGraph _graph); - -ValueOrError create_function__event_inputs(VirtualNode *event_vnode, - VTreeDataGraph _graph); +ValueOrError create_particle_function(VirtualNode *main_vnode, +VTreeDataGraph _graph); using ForceFromNodeCallback = std::function( BuildContext , VirtualNode *vnode, ParticleFunction compute_inputs_fn)>; diff --git a/source/blender/simulations/bparticles/node_frontend.cpp b/source/blender/simulations/bparticles/node_frontend.cpp index 871c6d2c1eb..2410e05b428 100644 --- a/source/blender/simulations/bparticles/node_frontend.cpp +++ b/source/blender/simulations/bparticles/node_frontend.cpp @@ -69,13 +69,12 @@ std::unique_ptr step_description_from_node_tree(VirtualNodeTree for (VirtualNode *vnode : vtree.nodes_with_idname(item.key)) { for (VirtualSocket *linked : vnode->output(0)->links()) { if (is_particle_type_node(linked->vnode())) { - auto fn_or_error = create_function__force_inputs(vnode, data_graph); + auto fn_or_error = create_particle_function(vnode, data_graph); if (fn_or_error.is_error()) { continue; } -
[Bf-blender-cvs] [9b3e1859eff] functions: simplify action builders
Commit: 9b3e1859eff9d0aa52719f22ac9223ac8f9a96c2 Author: Jacques Lucke Date: Thu Jul 25 14:20:36 2019 +0200 Branches: functions https://developer.blender.org/rB9b3e1859eff9d0aa52719f22ac9223ac8f9a96c2 simplify action builders === M source/blender/simulations/bparticles/actions.hpp M source/blender/simulations/bparticles/inserters.cpp === diff --git a/source/blender/simulations/bparticles/actions.hpp b/source/blender/simulations/bparticles/actions.hpp index a06fad36193..088ca8e1498 100644 --- a/source/blender/simulations/bparticles/actions.hpp +++ b/source/blender/simulations/bparticles/actions.hpp @@ -19,8 +19,8 @@ class ChangeDirectionAction : public Action { std::unique_ptr m_post_action; public: - ChangeDirectionAction(ParticleFunction _inputs, std::unique_ptr post_action) - : m_compute_inputs(compute_inputs), m_post_action(std::move(post_action)) + ChangeDirectionAction(ParticleFunction compute_inputs, std::unique_ptr post_action) + : m_compute_inputs(std::move(compute_inputs)), m_post_action(std::move(post_action)) { } @@ -35,10 +35,10 @@ class ExplodeAction : public Action { public: ExplodeAction(StringRef new_particle_name, -ParticleFunction _inputs, +ParticleFunction compute_inputs, std::unique_ptr post_action) : m_new_particle_name(new_particle_name.to_std_string()), -m_compute_inputs(compute_inputs), +m_compute_inputs(std::move(compute_inputs)), m_post_action(std::move(post_action)) { } @@ -52,10 +52,10 @@ class ConditionAction : public Action { std::unique_ptr m_true_action, m_false_action; public: - ConditionAction(ParticleFunction _inputs, + ConditionAction(ParticleFunction compute_inputs, std::unique_ptr true_action, std::unique_ptr false_action) - : m_compute_inputs(compute_inputs), + : m_compute_inputs(std::move(compute_inputs)), m_true_action(std::move(true_action)), m_false_action(std::move(false_action)) { diff --git a/source/blender/simulations/bparticles/inserters.cpp b/source/blender/simulations/bparticles/inserters.cpp index bdbe7466728..b38237b75e6 100644 --- a/source/blender/simulations/bparticles/inserters.cpp +++ b/source/blender/simulations/bparticles/inserters.cpp @@ -110,46 +110,38 @@ ValueOrError create_function__event_inputs(VirtualNode *event_vn static std::unique_ptr build_action(BuildContext , VirtualSocket *start, VirtualSocket *trigger); -using ActionFromNodeCallback = std::function( -BuildContext , VirtualSocket *start, VirtualSocket *trigger)>; +using ActionFromNodeCallback = +std::function(BuildContext , + VirtualSocket *start, + VirtualSocket *trigger, + ParticleFunction compute_inputs_fn)>; static std::unique_ptr BUILD_ACTION_kill(BuildContext (ctx), VirtualSocket *UNUSED(start), - VirtualSocket *UNUSED(trigger)) + VirtualSocket *UNUSED(trigger), + ParticleFunction UNUSED(compute_inputs_fn)) { return std::unique_ptr(new KillAction()); } static std::unique_ptr BUILD_ACTION_change_direction(BuildContext , VirtualSocket *start, - VirtualSocket *trigger) + VirtualSocket *trigger, + ParticleFunction compute_inputs_fn) { VirtualNode *vnode = start->vnode(); - auto fn_or_error = create_function__action_inputs(vnode, ctx.data_graph); - if (fn_or_error.is_error()) { -return {}; - } - - SharedFunction fn = fn_or_error.extract_value(); - ParticleFunction particle_fn(fn); auto post_action = build_action(ctx, vnode->output(0), trigger); return std::unique_ptr( - new ChangeDirectionAction(particle_fn, std::move(post_action))); + new ChangeDirectionAction(std::move(compute_inputs_fn), std::move(post_action))); } static std::unique_ptr BUILD_ACTION_explode(BuildContext , VirtualSocket *start, -VirtualSocket *trigger) +VirtualSocket *trigger, +ParticleFunction compute_inputs_fn) { VirtualNode *vnode = start->vnode(); - auto
[Bf-blender-cvs] [c92dd7bed6e] functions: create particle function more centrally for offset handlers
Commit: c92dd7bed6e0df17a70cff38cc832706f22c Author: Jacques Lucke Date: Thu Jul 25 09:54:46 2019 +0200 Branches: functions https://developer.blender.org/rBc92dd7bed6e0df17a70cff38cc832706f22c create particle function more centrally for offset handlers === 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 ad6f22ecac8..4e53f85ccd7 100644 --- a/source/blender/simulations/bparticles/inserters.cpp +++ b/source/blender/simulations/bparticles/inserters.cpp @@ -89,7 +89,7 @@ static ValueOrError create_function__action_inputs(VirtualNode * return fn; } -static ValueOrError create_function__offset_handler_inputs( +ValueOrError create_function__offset_handler_inputs( VirtualNode *offset_handler_vnode, VTreeDataGraph _graph) { return create_function__action_inputs(offset_handler_vnode, data_graph); @@ -460,22 +460,16 @@ static std::unique_ptr BUILD_EMITTER_initial_grid(BuildContext , body.get_output(fn_out, 4, "Size"))); } -static std::unique_ptr BUILD_OFFSET_HANDLER_trails(BuildContext , - VirtualNode *vnode) +static std::unique_ptr BUILD_OFFSET_HANDLER_trails( +BuildContext , VirtualNode *vnode, ParticleFunction compute_inputs_fn) { PointerRNA rna = vnode->rna(); char name[65]; RNA_string_get(, "particle_type_name", name); - auto fn_or_error = create_function__offset_handler_inputs(vnode, ctx.data_graph); - if (fn_or_error.is_error()) { -return {}; - } - - SharedFunction fn = fn_or_error.extract_value(); - if (ctx.type_name_exists(name)) { -return std::unique_ptr(new CreateTrailHandler(name, ParticleFunction(fn))); +return std::unique_ptr( +new CreateTrailHandler(name, std::move(compute_inputs_fn))); } else { return {}; diff --git a/source/blender/simulations/bparticles/inserters.hpp b/source/blender/simulations/bparticles/inserters.hpp index 68284f81c14..a4c9d696337 100644 --- a/source/blender/simulations/bparticles/inserters.hpp +++ b/source/blender/simulations/bparticles/inserters.hpp @@ -5,10 +5,12 @@ #include "BKE_node_tree.hpp" #include "FN_data_flow_nodes.hpp" #include "BLI_string_map.hpp" +#include "BLI_value_or_error.hpp" #include "world_state.hpp" #include "step_description.hpp" #include "forces.hpp" +#include "particle_function.hpp" namespace BParticles { @@ -20,6 +22,7 @@ using BKE::VirtualNode; using BKE::VirtualNodeTree; using BKE::VirtualSocket; using BLI::StringMap; +using BLI::ValueOrError; using FN::DataFlowNodes::VTreeDataGraph; struct BuildContext { @@ -33,6 +36,9 @@ struct BuildContext { } }; +ValueOrError create_function__offset_handler_inputs( +VirtualNode *offset_handler_vnode, VTreeDataGraph _graph); + using ForceFromNodeCallback = std::function(BuildContext , VirtualNode *vnode)>; @@ -42,8 +48,8 @@ using EventFromNodeCallback = using EmitterFromNodeCallback = std::function( BuildContext , VirtualNode *vnode, StringRef particle_type_name)>; -using OffsetHandlerFromNodeCallback = -std::function(BuildContext , VirtualNode *vnode)>; +using OffsetHandlerFromNodeCallback = std::function( +BuildContext , VirtualNode *vnode, ParticleFunction compute_inputs_fn)>; StringMap _force_builders(); StringMap _event_builders(); diff --git a/source/blender/simulations/bparticles/node_frontend.cpp b/source/blender/simulations/bparticles/node_frontend.cpp index 5ff33b561a6..70c16ea8c0f 100644 --- a/source/blender/simulations/bparticles/node_frontend.cpp +++ b/source/blender/simulations/bparticles/node_frontend.cpp @@ -83,7 +83,14 @@ std::unique_ptr step_description_from_node_tree(VirtualNodeTree for (VirtualNode *vnode : vtree.nodes_with_idname(item.key)) { for (VirtualSocket *linked : vnode->output(0)->links()) { if (is_particle_type_node(linked->vnode())) { - auto listener = item.value(ctx, vnode); + auto fn_or_error = create_function__offset_handler_inputs(vnode, data_graph); + if (fn_or_error.is_error()) { +continue; + } + + ParticleFunction fn(fn_or_error.extract_value()); + + auto listener = item.value(ctx, vnode, std::move(fn)); if (listener) { offset_handlers.add(linked->vnode()->name(), listener.release()); } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [7e4c4897784] functions: use particle function for gravity force
Commit: 7e4c48977846b7eb18d1ad81d87236baa6356e63 Author: Jacques Lucke Date: Thu Jul 25 10:01:10 2019 +0200 Branches: functions https://developer.blender.org/rB7e4c48977846b7eb18d1ad81d87236baa6356e63 use particle function for gravity force === M source/blender/simulations/bparticles/forces.cpp M source/blender/simulations/bparticles/forces.hpp M source/blender/simulations/bparticles/inserters.cpp === diff --git a/source/blender/simulations/bparticles/forces.cpp b/source/blender/simulations/bparticles/forces.cpp index 9101e7d9271..f28fb478785 100644 --- a/source/blender/simulations/bparticles/forces.cpp +++ b/source/blender/simulations/bparticles/forces.cpp @@ -13,17 +13,11 @@ void GravityForce::add_force(ForceInterface ) ParticlesBlock = interface.block(); ArrayRef destination = interface.combined_destination(); - FN_TUPLE_CALL_ALLOC_TUPLES(m_compute_acceleration_body, fn_in, fn_out); - - FN::ExecutionStack stack; - FN::ExecutionContext execution_context(stack); - - m_compute_acceleration_body.call(fn_in, fn_out, execution_context); - - float3 acceleration = fn_out.get(0); + auto inputs = m_compute_inputs.compute(interface); - for (uint i = 0; i < block.active_amount(); i++) { -destination[i] += acceleration; + for (uint pindex = 0; pindex < block.active_amount(); pindex++) { +float3 acceleration = inputs->get("Direction", 0, pindex); +destination[pindex] += acceleration; } }; diff --git a/source/blender/simulations/bparticles/forces.hpp b/source/blender/simulations/bparticles/forces.hpp index 7460a1877c2..83807f26cee 100644 --- a/source/blender/simulations/bparticles/forces.hpp +++ b/source/blender/simulations/bparticles/forces.hpp @@ -14,13 +14,10 @@ class Force { class GravityForce : public Force { private: - SharedFunction m_compute_acceleration_fn; - TupleCallBody _compute_acceleration_body; + ParticleFunction m_compute_inputs; public: - GravityForce(SharedFunction _acceleration_fn) - : m_compute_acceleration_fn(compute_acceleration_fn), - m_compute_acceleration_body(m_compute_acceleration_fn->body()) + GravityForce(ParticleFunction compute_inputs) : m_compute_inputs(std::move(compute_inputs)) { } diff --git a/source/blender/simulations/bparticles/inserters.cpp b/source/blender/simulations/bparticles/inserters.cpp index 4e53f85ccd7..be37daadbc1 100644 --- a/source/blender/simulations/bparticles/inserters.cpp +++ b/source/blender/simulations/bparticles/inserters.cpp @@ -232,7 +232,7 @@ static std::unique_ptr BUILD_FORCE_gravity(BuildContext , VirtualNode } SharedFunction fn = fn_or_error.extract_value(); - return std::unique_ptr(new GravityForce(fn)); + return std::unique_ptr(new GravityForce(ParticleFunction(fn))); } static std::unique_ptr BUILD_FORCE_turbulence(BuildContext , VirtualNode *vnode) ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [63a9949c278] functions: compute particle functions more centrally for events
Commit: 63a9949c278a8e681c240ab77988af49730f8ff4 Author: Jacques Lucke Date: Thu Jul 25 10:18:22 2019 +0200 Branches: functions https://developer.blender.org/rB63a9949c278a8e681c240ab77988af49730f8ff4 compute particle functions more centrally for events === M source/blender/simulations/bparticles/inserters.cpp M source/blender/simulations/bparticles/inserters.hpp M source/blender/simulations/bparticles/node_frontend.cpp M source/blender/simulations/bparticles/particle_function.hpp === diff --git a/source/blender/simulations/bparticles/inserters.cpp b/source/blender/simulations/bparticles/inserters.cpp index 8326687b864..bdbe7466728 100644 --- a/source/blender/simulations/bparticles/inserters.cpp +++ b/source/blender/simulations/bparticles/inserters.cpp @@ -101,8 +101,8 @@ ValueOrError create_function__force_inputs(VirtualNode *force_vn return create_function__action_inputs(force_vnode, data_graph); } -static ValueOrError create_function__event_inputs(VirtualNode *event_vnode, - VTreeDataGraph _graph) +ValueOrError create_function__event_inputs(VirtualNode *event_vnode, + VTreeDataGraph _graph) { return create_function__action_inputs(event_vnode, data_graph); } @@ -238,7 +238,8 @@ static std::unique_ptr BUILD_FORCE_turbulence(BuildContext (ctx), return std::unique_ptr(new TurbulenceForce(std::move(compute_inputs_fn))); } -static std::unique_ptr BUILD_EVENT_mesh_collision(BuildContext , VirtualNode *vnode) +static std::unique_ptr BUILD_EVENT_mesh_collision( +BuildContext , VirtualNode *vnode, ParticleFunction UNUSED(compute_inputs_fn)) { PointerRNA rna = vnode->rna(); Object *object = (Object *)RNA_pointer_get(, "object").id.data; @@ -250,29 +251,27 @@ static std::unique_ptr BUILD_EVENT_mesh_collision(BuildContext , Virt return std::unique_ptr(new MeshCollisionEvent(vnode->name(), object, std::move(action))); } -static std::unique_ptr BUILD_EVENT_age_reached(BuildContext , VirtualNode *vnode) +static std::unique_ptr BUILD_EVENT_age_reached(BuildContext , + VirtualNode *vnode, + ParticleFunction compute_inputs_fn) { - auto fn_or_error = create_function__event_inputs(vnode, ctx.data_graph); - if (fn_or_error.is_error()) { -return {}; - } - - SharedFunction fn = fn_or_error.extract_value(); auto action = build_action_for_trigger(ctx, vnode->output(0)); return std::unique_ptr( - new AgeReachedEvent(vnode->name(), ParticleFunction(fn), std::move(action))); + new AgeReachedEvent(vnode->name(), std::move(compute_inputs_fn), std::move(action))); } -static std::unique_ptr BUILD_EVENT_close_by_points(BuildContext , VirtualNode *vnode) +static std::unique_ptr BUILD_EVENT_close_by_points(BuildContext , + VirtualNode *vnode, + ParticleFunction compute_inputs) { - auto fn_or_error = create_function__event_inputs(vnode, ctx.data_graph); - if (fn_or_error.is_error()) { + if (compute_inputs.depends_on_particle()) { return {}; } - SharedFunction fn = fn_or_error.extract_value(); auto action = build_action_for_trigger(ctx, vnode->output(0)); + SharedFunction = compute_inputs.function(); + BLI_assert(fn->input_amount() == 0); TupleCallBody = fn->body(); FN_TUPLE_CALL_ALLOC_TUPLES(body, fn_in, fn_out); body.call__setup_execution_context(fn_in, fn_out); diff --git a/source/blender/simulations/bparticles/inserters.hpp b/source/blender/simulations/bparticles/inserters.hpp index cb56f3fae4a..7148e0578b5 100644 --- a/source/blender/simulations/bparticles/inserters.hpp +++ b/source/blender/simulations/bparticles/inserters.hpp @@ -42,11 +42,14 @@ ValueOrError create_function__offset_handler_inputs( ValueOrError create_function__force_inputs(VirtualNode *force_vnode, VTreeDataGraph _graph); +ValueOrError create_function__event_inputs(VirtualNode *event_vnode, + VTreeDataGraph _graph); + using ForceFromNodeCallback = std::function( BuildContext , VirtualNode *vnode, ParticleFunction compute_inputs_fn)>; -using EventFromNodeCallback = -std::function(BuildContext , VirtualNode *vnode)>; +using EventFromNodeCallback = std::function( +BuildContext , VirtualNode *vnode, ParticleFunction compute_inputs_fn)>; using EmitterFromNodeCallback = std::function( BuildContext , VirtualNode *vnode, StringRef particle_type_name)>; diff --git a/source/blender/simulations/bparticles/node_frontend.cpp
[Bf-blender-cvs] [6c3afa78010] functions: create particle function for force inputs more centrally
Commit: 6c3afa780109f7124ca79bbdd3e16e7802770ca3 Author: Jacques Lucke Date: Thu Jul 25 10:06:03 2019 +0200 Branches: functions https://developer.blender.org/rB6c3afa780109f7124ca79bbdd3e16e7802770ca3 create particle function for force inputs more centrally === 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 be37daadbc1..8326687b864 100644 --- a/source/blender/simulations/bparticles/inserters.cpp +++ b/source/blender/simulations/bparticles/inserters.cpp @@ -95,8 +95,8 @@ ValueOrError create_function__offset_handler_inputs( return create_function__action_inputs(offset_handler_vnode, data_graph); } -static ValueOrError create_function__force_inputs(VirtualNode *force_vnode, - VTreeDataGraph _graph) +ValueOrError create_function__force_inputs(VirtualNode *force_vnode, + VTreeDataGraph _graph) { return create_function__action_inputs(force_vnode, data_graph); } @@ -224,26 +224,18 @@ static std::unique_ptr build_action_for_trigger(BuildContext , Virtu return build_action(ctx, start, start); } -static std::unique_ptr BUILD_FORCE_gravity(BuildContext , VirtualNode *vnode) +static std::unique_ptr BUILD_FORCE_gravity(BuildContext (ctx), + VirtualNode *UNUSED(vnode), + ParticleFunction compute_inputs_fn) { - auto fn_or_error = create_function__force_inputs(vnode, ctx.data_graph); - if (fn_or_error.is_error()) { -return {}; - } - - SharedFunction fn = fn_or_error.extract_value(); - return std::unique_ptr(new GravityForce(ParticleFunction(fn))); + return std::unique_ptr(new GravityForce(std::move(compute_inputs_fn))); } -static std::unique_ptr BUILD_FORCE_turbulence(BuildContext , VirtualNode *vnode) +static std::unique_ptr BUILD_FORCE_turbulence(BuildContext (ctx), + VirtualNode *UNUSED(vnode), + ParticleFunction compute_inputs_fn) { - auto fn_or_error = create_function__force_inputs(vnode, ctx.data_graph); - if (fn_or_error.is_error()) { -return {}; - } - - SharedFunction fn = fn_or_error.extract_value(); - return std::unique_ptr(new TurbulenceForce(ParticleFunction(fn))); + return std::unique_ptr(new TurbulenceForce(std::move(compute_inputs_fn))); } static std::unique_ptr BUILD_EVENT_mesh_collision(BuildContext , VirtualNode *vnode) diff --git a/source/blender/simulations/bparticles/inserters.hpp b/source/blender/simulations/bparticles/inserters.hpp index a4c9d696337..cb56f3fae4a 100644 --- a/source/blender/simulations/bparticles/inserters.hpp +++ b/source/blender/simulations/bparticles/inserters.hpp @@ -39,8 +39,11 @@ struct BuildContext { ValueOrError create_function__offset_handler_inputs( VirtualNode *offset_handler_vnode, VTreeDataGraph _graph); -using ForceFromNodeCallback = -std::function(BuildContext , VirtualNode *vnode)>; +ValueOrError create_function__force_inputs(VirtualNode *force_vnode, + VTreeDataGraph _graph); + +using ForceFromNodeCallback = std::function( +BuildContext , VirtualNode *vnode, ParticleFunction compute_inputs_fn)>; using EventFromNodeCallback = std::function(BuildContext , VirtualNode *vnode)>; diff --git a/source/blender/simulations/bparticles/node_frontend.cpp b/source/blender/simulations/bparticles/node_frontend.cpp index 70c16ea8c0f..1b0564b279d 100644 --- a/source/blender/simulations/bparticles/node_frontend.cpp +++ b/source/blender/simulations/bparticles/node_frontend.cpp @@ -69,7 +69,13 @@ std::unique_ptr step_description_from_node_tree(VirtualNodeTree for (VirtualNode *vnode : vtree.nodes_with_idname(item.key)) { for (VirtualSocket *linked : vnode->output(0)->links()) { if (is_particle_type_node(linked->vnode())) { - auto force = item.value(ctx, vnode); + auto fn_or_error = create_function__force_inputs(vnode, data_graph); + if (fn_or_error.is_error()) { +continue; + } + + ParticleFunction fn(fn_or_error.extract_value()); + auto force = item.value(ctx, vnode, std::move(fn)); if (force) { forces.add(linked->vnode()->name(), force.release()); } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org
[Bf-blender-cvs] [84516c806ba] sculpt-mode-features: Merge branch 'master' into sculpt-mode-features
Commit: 84516c806bae5f3fb82f6ccc1123bd1428298c2e Author: Pablo Dobarro Date: Thu Jul 25 14:25:22 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rB84516c806bae5f3fb82f6ccc1123bd1428298c2e Merge branch 'master' into sculpt-mode-features === === diff --cc source/blender/blenloader/intern/versioning_280.c index d971e4543f7,cb2b64957f0..f21d3692cc5 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@@ -3515,12 -3531,9 +3537,16 @@@ void blo_do_versions_280(FileData *fd, LISTBASE_FOREACH (bArmature *, arm, >armatures) { arm->flag &= ~(ARM_FLAG_UNUSED_6); } + +Brush *br; +for (br = bmain->brushes.first; br; br = br->id.next) { + if (br->ob_mode & OB_MODE_SCULPT) { +br->normal_radius_factor = 0.2f; + } +} } + + { + /* Versioning code until next subversion bump goes here. */ + } } diff --cc source/blender/editors/sculpt_paint/paint_vertex.c index 7fd31ec7841,980b043bf8b..7b50f35070d --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@@ -1,4 -1,4 +1,4 @@@ --/* ++/* * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 @@@ -2322,8 -2350,7 +2351,8 @@@ static void wpaint_stroke_update_step(b /* calculate pivot for rotation around seletion if needed */ /* also needed for "View Selected" on last stroke */ + ED_view3d_autodist_init(depsgraph, vc->ar, vc->v3d, 0); - paint_last_stroke_update(scene, vc->ar, mval); + paint_last_stroke_update(scene, vc->ar, ss->cache->mouse); BKE_mesh_batch_cache_dirty_tag(ob->data, BKE_MESH_BATCH_DIRTY_ALL); @@@ -3303,8 -3329,7 +3332,8 @@@ static void vpaint_stroke_update_step(b /* calculate pivot for rotation around seletion if needed */ /* also needed for "View Selected" on last stroke */ + ED_view3d_autodist_init(depsgraph, vc->ar, vc->v3d, 0); - paint_last_stroke_update(scene, vc->ar, mval); + paint_last_stroke_update(scene, vc->ar, ss->cache->mouse); ED_region_tag_redraw(vc->ar); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [80a6acd8149] soc-2019-npr: Cleanup: Remove . at the end of text
Commit: 80a6acd814961cbe82ab16f9f753b7f77fc240ca Author: Antonioya Date: Thu Jul 25 14:03:02 2019 +0200 Branches: soc-2019-npr https://developer.blender.org/rB80a6acd814961cbe82ab16f9f753b7f77fc240ca Cleanup: Remove . at the end of text === M source/blender/editors/lanpr/lanpr_ops.c === diff --git a/source/blender/editors/lanpr/lanpr_ops.c b/source/blender/editors/lanpr/lanpr_ops.c index 6deb0463e69..5082f8b82a9 100644 --- a/source/blender/editors/lanpr/lanpr_ops.c +++ b/source/blender/editors/lanpr/lanpr_ops.c @@ -399,7 +399,7 @@ void SCENE_OT_lanpr_move_line_layer(struct wmOperatorType *ot) void SCENE_OT_lanpr_enable_all_line_types(struct wmOperatorType *ot) { ot->name = "Enable All Line Types"; - ot->description = "Enable All Line Types In This Line Layer."; + ot->description = "Enable All Line Types In This Line Layer"; ot->idname = "SCENE_OT_lanpr_enable_all_line_types"; ot->exec = lanpr_enable_all_line_types_exec; @@ -2598,8 +2598,8 @@ static LANPR_RenderLine *lanpr_triangle_generate_intersection_line_only( return Result; } static void lanpr_triangle_calculate_intersections_in_bounding_area(LANPR_RenderBuffer *rb, - LANPR_RenderTriangle *rt, - LANPR_BoundingArea *ba) + LANPR_RenderTriangle *rt, + LANPR_BoundingArea *ba) { tnsVector3d n, c = {0}; tnsVector3d tl, tr; @@ -3323,8 +3323,8 @@ static void lanpr_link_triangle_with_bounding_area(LANPR_RenderBuffer *rb, real *LRUB, int Recursive); static void lanpr_triangle_calculate_intersections_in_bounding_area(LANPR_RenderBuffer *rb, - LANPR_RenderTriangle *rt, - LANPR_BoundingArea *ba); + LANPR_RenderTriangle *rt, + LANPR_BoundingArea *ba); static void lanpr_split_bounding_area(LANPR_RenderBuffer *rb, LANPR_BoundingArea *Root) { @@ -4611,7 +4611,7 @@ void SCENE_OT_lanpr_bake_gp_strokes(struct wmOperatorType *ot) void OBJECT_OT_lanpr_update_gp_target(struct wmOperatorType *ot) { ot->name = "Update Strokes"; - ot->description = "Update LANPR strokes for selected GPencil object."; + ot->description = "Update LANPR strokes for selected GPencil object"; ot->idname = "OBJECT_OT_lanpr_update_gp_target"; ot->poll = lanpr_active_is_gpencil_object; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [c6fbc1db41f] greasepencil-object: Merge branch 'master' into greasepencil-object
Commit: c6fbc1db41ff337f1428327844cb30a8f7251722 Author: Antonioya Date: Thu Jul 25 12:41:59 2019 +0200 Branches: greasepencil-object https://developer.blender.org/rBc6fbc1db41ff337f1428327844cb30a8f7251722 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] [77d3d8b7788] soc-2019-adaptive-cloth: Cloth: fix updating active faces after fixing mesh in collapse edges
Commit: 77d3d8b77886246eb47b14c1ee962f51226260a1 Author: ishbosamiya Date: Thu Jul 25 14:03:43 2019 +0530 Branches: soc-2019-adaptive-cloth https://developer.blender.org/rB77d3d8b77886246eb47b14c1ee962f51226260a1 Cloth: fix updating active faces after fixing mesh in collapse edges === M source/blender/blenkernel/intern/cloth_remeshing.cpp === diff --git a/source/blender/blenkernel/intern/cloth_remeshing.cpp b/source/blender/blenkernel/intern/cloth_remeshing.cpp index 122a4c7dbd9..db6d8deb650 100644 --- a/source/blender/blenkernel/intern/cloth_remeshing.cpp +++ b/source/blender/blenkernel/intern/cloth_remeshing.cpp @@ -1713,7 +1713,7 @@ static void cloth_remeshing_update_active_faces(vector _faces, } } if (already_exists) { - break; + continue; } active_faces.push_back(fix_active[i]); } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [2d9989e18b4] soc-2019-adaptive-cloth: Cloth: better handling of split_edges()
Commit: 2d9989e18b4959df1fd718a7662833f8fb69099b Author: ishbosamiya Date: Thu Jul 25 13:48:15 2019 +0530 Branches: soc-2019-adaptive-cloth https://developer.blender.org/rB2d9989e18b4959df1fd718a7662833f8fb69099b Cloth: better handling of split_edges() === M source/blender/blenkernel/intern/cloth_remeshing.cpp === diff --git a/source/blender/blenkernel/intern/cloth_remeshing.cpp b/source/blender/blenkernel/intern/cloth_remeshing.cpp index 20921bcae69..122a4c7dbd9 100644 --- a/source/blender/blenkernel/intern/cloth_remeshing.cpp +++ b/source/blender/blenkernel/intern/cloth_remeshing.cpp @@ -792,21 +792,9 @@ static BMVert *cloth_remeshing_split_edge_keep_triangles(BMesh *bm, { BLI_assert(BM_vert_in_edge(e, v) == true); - /* find faces containing edge, should be only 2 */ - BMFace *f; - BMIter fiter; - int face_i = 0; - BMFace *f1 = NULL, *f2 = NULL; - BM_ITER_ELEM_INDEX (f, , e, BM_FACES_OF_EDGE, face_i) { -if (face_i == 0) { - f1 = f; -} -else { - f2 = f; -} -/* printf("face_i: %d\n", face_i); */ - } - + BMFace *f1, *f2; + cloth_remeshing_edge_face_pair(e, , ); + /* There should be at least one face for that edge */ if (!f1) { return NULL; } @@ -1134,9 +1122,6 @@ static bool cloth_remeshing_split_edges(ClothModifierData *clmd, vector bad_edges; cloth_remeshing_find_bad_edges(bm, sizing, bad_edges); printf("split edges tagged: %d\n", (int)bad_edges.size()); - if (bad_edges.size() == 0 || bad_edges.size() == prev_num_bad_edges) { -return false; - } prev_num_bad_edges = bad_edges.size(); Cloth *cloth = clmd->clothObject; cloth->verts = (ClothVertex *)MEM_reallocN( @@ -1164,8 +1149,7 @@ static bool cloth_remeshing_split_edges(ClothModifierData *clmd, } } } - bad_edges.clear(); - return true; + return !bad_edges.empty(); } static void cloth_remeshing_uv_of_vert_in_face(BMesh *bm, BMFace *f, BMVert *v, float r_uv[2]) ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [814861cec14] soc-2019-adaptive-cloth: Cloth: edge_vert() now returns the vertex uv if needed
Commit: 814861cec14e8573ca3517db03ece9e9f6d8a677 Author: ishbosamiya Date: Thu Jul 25 10:44:08 2019 +0530 Branches: soc-2019-adaptive-cloth https://developer.blender.org/rB814861cec14e8573ca3517db03ece9e9f6d8a677 Cloth: edge_vert() now returns the vertex uv if needed === M source/blender/blenkernel/intern/cloth_remeshing.cpp === diff --git a/source/blender/blenkernel/intern/cloth_remeshing.cpp b/source/blender/blenkernel/intern/cloth_remeshing.cpp index e9f8646392d..9feae34ae2e 100644 --- a/source/blender/blenkernel/intern/cloth_remeshing.cpp +++ b/source/blender/blenkernel/intern/cloth_remeshing.cpp @@ -138,10 +138,11 @@ static void cloth_remeshing_update_active_faces(vector _faces, static ClothSizing cloth_remeshing_find_average_sizing(ClothSizing _01, ClothSizing _02); static void mul_m2_m2m2(float r[2][2], float a[2][2], float b[2][2]); static BMVert *cloth_remeshing_edge_vert(BMEdge *e, int which); -static BMVert *cloth_remeshing_edge_vert(BMEdge *e, int side, int i); +static BMVert *cloth_remeshing_edge_vert(BMesh *bm, BMEdge *e, int side, int i, float r_uv[2]); static BMVert *cloth_remeshing_edge_opposite_vert(BMEdge *e, int side); static void cloth_remeshing_uv_of_vert(BMesh *bm, BMVert *v, float r_uv[2]); static void cloth_remeshing_edge_face_pair(BMEdge *e, BMFace **r_f1, BMFace **r_f2); +static void cloth_remeshing_uv_of_vert_in_edge(BMesh *bm, BMEdge *e, BMVert *v, float r_uv[2]); static CustomData_MeshMasks cloth_remeshing_get_cd_mesh_masks(void) { @@ -402,8 +403,8 @@ static pair cloth_remeshing_edge_side_verts(BMEdge *e) static bool cloth_remeshing_should_flip(BMesh *bm, BMEdge *e, map ) { BMVert *v1, *v2, *v3, *v4; - v1 = cloth_remeshing_edge_vert(e, 0, 0); - v2 = cloth_remeshing_edge_vert(e, 0, 1); + v1 = cloth_remeshing_edge_vert(bm, e, 0, 0, NULL); + v2 = cloth_remeshing_edge_vert(bm, e, 0, 1, NULL); v3 = cloth_remeshing_edge_opposite_vert(e, 0); v4 = cloth_remeshing_edge_opposite_vert(e, 1); @@ -478,7 +479,9 @@ static bool cloth_remeshing_edge_on_seam_or_boundary_test(BMesh *bm, BMEdge *e) BMFace *f1, *f2; cloth_remeshing_edge_face_pair(e, , ); - return !f1 || !f2 || cloth_remeshing_edge_vert(e, 0, 0) != cloth_remeshing_edge_vert(e, 1, 0); + return !f1 || !f2 || + cloth_remeshing_edge_vert(bm, e, 0, 0, NULL) != + cloth_remeshing_edge_vert(bm, e, 1, 0, NULL); #else BMFace *f, *f1, *f2; BMIter fiter; @@ -689,6 +692,15 @@ static void cloth_remeshing_uv_of_vert(BMesh *bm, BMVert *v, float r_uv[2]) copy_v2_v2(r_uv, luv->uv); } +static void cloth_remeshing_uv_of_vert_in_edge(BMesh *bm, BMEdge *e, BMVert *v, float r_uv[2]) +{ + BMLoop *l; + e->l->v == v ? l = e->l : l = e->l->next; + const int cd_loop_uv_offset = CustomData_get_offset(>ldata, CD_MLOOPUV); + MLoopUV *luv = (MLoopUV *)BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); + copy_v2_v2(r_uv, luv->uv); +} + static float cloth_remeshing_edge_size(BMesh *bm, BMVert *v1, BMVert *v2, @@ -1369,7 +1381,8 @@ static void cloth_remeshing_edge_face_pair(BMEdge *e, BMFace **r_f1, BMFace **r_ } } -static BMVert *cloth_remeshing_edge_vert(BMEdge *e, int side, int i) +/* r_uv is the uv of the BMVert that is returned */ +static BMVert *cloth_remeshing_edge_vert(BMesh *bm, BMEdge *e, int side, int i, float r_uv[2]) { /* BMFace *f, *f1 = NULL, *f2 = NULL; */ /* BMIter fiter; */ @@ -1398,6 +1411,9 @@ static BMVert *cloth_remeshing_edge_vert(BMEdge *e, int side, int i) BM_face_as_array_vert_tri(f, vs); for (int j = 0; j < 3; j++) { if (vs[j] == cloth_remeshing_edge_vert(e, i)) { + if (r_uv != NULL) { +cloth_remeshing_uv_of_vert_in_edge(bm, e, vs[j], r_uv); + } return vs[j]; } } @@ -1438,10 +1454,10 @@ static bool cloth_remeshing_can_collapse_edge( ClothModifierData *clmd, BMesh *bm, BMEdge *e, int which, map ) { for (int s = 0; s < 2; s++) { -BMVert *v1 = cloth_remeshing_edge_vert(e, s, which); -BMVert *v2 = cloth_remeshing_edge_vert(e, s, 1 - which); +BMVert *v1 = cloth_remeshing_edge_vert(bm, e, s, which, NULL); +BMVert *v2 = cloth_remeshing_edge_vert(bm, e, s, 1 - which, NULL); -if (!v1 || (s == 1 && v1 == cloth_remeshing_edge_vert(e, 0, which))) { +if (!v1 || (s == 1 && v1 == cloth_remeshing_edge_vert(bm, e, 0, which, NULL))) { continue; } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [7527a0b434b] soc-2019-adaptive-cloth: Cloth: fixed bug in cloth_remeshing_edge_face_pair()
Commit: 7527a0b434b45f5b8ae545811a7659e01c66305c Author: ishbosamiya Date: Thu Jul 25 12:52:47 2019 +0530 Branches: soc-2019-adaptive-cloth https://developer.blender.org/rB7527a0b434b45f5b8ae545811a7659e01c66305c Cloth: fixed bug in cloth_remeshing_edge_face_pair() === M source/blender/blenkernel/intern/cloth_remeshing.cpp === diff --git a/source/blender/blenkernel/intern/cloth_remeshing.cpp b/source/blender/blenkernel/intern/cloth_remeshing.cpp index e104fef5e4a..2075b647486 100644 --- a/source/blender/blenkernel/intern/cloth_remeshing.cpp +++ b/source/blender/blenkernel/intern/cloth_remeshing.cpp @@ -78,7 +78,7 @@ using namespace std; * reference http://graphics.berkeley.edu/papers/Narain-AAR-2012-11/index.html **/ -#define COLLAPSE_EDGES_DEBUG 0 +#define COLLAPSE_EDGES_DEBUG 1 #define NEXT(x) ((x) < 2 ? (x) + 1 : (x)-2) #define PREV(x) ((x) > 0 ? (x)-1 : (x) + 2) @@ -1328,7 +1328,7 @@ static void cloth_remeshing_edge_face_pair(BMEdge *e, BMFace **r_f1, BMFace **r_ int i = 0; *r_f1 = NULL; *r_f2 = NULL; - BM_ITER_ELEM (f, , e, BM_FACES_OF_EDGE) { + BM_ITER_ELEM_INDEX (f, , e, BM_FACES_OF_EDGE, i) { if (i == 0) { *r_f1 = f; } @@ -1423,6 +1423,14 @@ static bool cloth_remeshing_can_collapse_edge( BMVert *v2 = cloth_remeshing_edge_vert(bm, e, s, 1 - which, uv_v2); if (!v1 || (s == 1 && v1 == cloth_remeshing_edge_vert(bm, e, 0, which, NULL))) { +#if COLLAPSE_EDGES_DEBUG + if (!v1) { +printf("continued at !v1\n"); + } + else { +printf("(s == 1 && v1 == ..)\n"); + } +#endif continue; } @@ -1430,6 +1438,9 @@ static bool cloth_remeshing_can_collapse_edge( BMIter fiter; BM_ITER_ELEM (f, , v1, BM_FACES_OF_VERT) { if (BM_vert_in_face(v2, f)) { +#if COLLAPSE_EDGES_DEBUG +printf("continued at BM_vert_in_face(v2, f)\n"); +#endif continue; } BMVert *vs[3]; @@ -1455,27 +1466,27 @@ static bool cloth_remeshing_can_collapse_edge( float asp = cloth_remeshing_aspect_ratio(uvs[0], uvs[1], uvs[2]); if (a < 1e-6 || asp < clmd->sim_parms->aspect_min) { #if COLLAPSE_EDGES_DEBUG -printf("aspect %f < aspect_min\n", asp); +printf("a: %f < 1e-6 || aspect %f < aspect_min\n", a, asp); #endif return false; } float size; - for (int e = 0; e < 3; e++) { -if (vs[e] != v2) { + for (int ei = 0; ei < 3; ei++) { +if (vs[ei] != v2) { size = cloth_remeshing_edge_size( - bm, vs[NEXT(e)], vs[PREV(e)], uvs[NEXT(e)], uvs[PREV(e)], sizing); + bm, vs[NEXT(ei)], vs[PREV(ei)], uvs[NEXT(ei)], uvs[PREV(ei)], sizing); if (size > 1.0f - REMESHING_HYSTERESIS_PARAMETER) { #if COLLAPSE_EDGES_DEBUG printf("size %f > 1.0f - REMESHING_HYSTERESIS_PARAMETER\n", size); #endif return false; } -} - } #if COLLAPSE_EDGES_DEBUG - printf("size: %f ", size); + printf("size: %f ", size); #endif +} + } } } return true; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [cd173b442b1] soc-2019-adaptive-cloth: Cloth: edge_opposite_vert() now returns the vertex uv if needed
Commit: cd173b442b12a0bbeacfd5cdc93025e8c4431c90 Author: ishbosamiya Date: Thu Jul 25 10:58:08 2019 +0530 Branches: soc-2019-adaptive-cloth https://developer.blender.org/rBcd173b442b12a0bbeacfd5cdc93025e8c4431c90 Cloth: edge_opposite_vert() now returns the vertex uv if needed === M source/blender/blenkernel/intern/cloth_remeshing.cpp === diff --git a/source/blender/blenkernel/intern/cloth_remeshing.cpp b/source/blender/blenkernel/intern/cloth_remeshing.cpp index 9feae34ae2e..35de5f8a757 100644 --- a/source/blender/blenkernel/intern/cloth_remeshing.cpp +++ b/source/blender/blenkernel/intern/cloth_remeshing.cpp @@ -139,7 +139,7 @@ static ClothSizing cloth_remeshing_find_average_sizing(ClothSizing _01, Clo static void mul_m2_m2m2(float r[2][2], float a[2][2], float b[2][2]); static BMVert *cloth_remeshing_edge_vert(BMEdge *e, int which); static BMVert *cloth_remeshing_edge_vert(BMesh *bm, BMEdge *e, int side, int i, float r_uv[2]); -static BMVert *cloth_remeshing_edge_opposite_vert(BMEdge *e, int side); +static BMVert *cloth_remeshing_edge_opposite_vert(BMesh *bm, BMEdge *e, int side, float r_uv[2]); static void cloth_remeshing_uv_of_vert(BMesh *bm, BMVert *v, float r_uv[2]); static void cloth_remeshing_edge_face_pair(BMEdge *e, BMFace **r_f1, BMFace **r_f2); static void cloth_remeshing_uv_of_vert_in_edge(BMesh *bm, BMEdge *e, BMVert *v, float r_uv[2]); @@ -405,8 +405,8 @@ static bool cloth_remeshing_should_flip(BMesh *bm, BMEdge *e, maphttps://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [97ef5d63893] soc-2019-adaptive-cloth: Cloth: stop using uv_of_vert() to increase uv finding accuracy
Commit: 97ef5d638931a5a7c1a625d517b7c736f186c28e Author: ishbosamiya Date: Thu Jul 25 12:14:57 2019 +0530 Branches: soc-2019-adaptive-cloth https://developer.blender.org/rB97ef5d638931a5a7c1a625d517b7c736f186c28e Cloth: stop using uv_of_vert() to increase uv finding accuracy === M source/blender/blenkernel/intern/cloth_remeshing.cpp === diff --git a/source/blender/blenkernel/intern/cloth_remeshing.cpp b/source/blender/blenkernel/intern/cloth_remeshing.cpp index 35de5f8a757..e104fef5e4a 100644 --- a/source/blender/blenkernel/intern/cloth_remeshing.cpp +++ b/source/blender/blenkernel/intern/cloth_remeshing.cpp @@ -403,16 +403,11 @@ static pair cloth_remeshing_edge_side_verts(BMEdge *e) static bool cloth_remeshing_should_flip(BMesh *bm, BMEdge *e, map ) { BMVert *v1, *v2, *v3, *v4; - v1 = cloth_remeshing_edge_vert(bm, e, 0, 0, NULL); - v2 = cloth_remeshing_edge_vert(bm, e, 0, 1, NULL); - v3 = cloth_remeshing_edge_opposite_vert(bm, e, 0, NULL); - v4 = cloth_remeshing_edge_opposite_vert(bm, e, 1, NULL); - float x[2], y[2], z[2], w[2]; - cloth_remeshing_uv_of_vert(bm, v1, x); - cloth_remeshing_uv_of_vert(bm, v2, z); - cloth_remeshing_uv_of_vert(bm, v3, w); - cloth_remeshing_uv_of_vert(bm, v4, y); + v1 = cloth_remeshing_edge_vert(bm, e, 0, 0, x); + v2 = cloth_remeshing_edge_vert(bm, e, 0, 1, z); + v3 = cloth_remeshing_edge_opposite_vert(bm, e, 0, w); + v4 = cloth_remeshing_edge_opposite_vert(bm, e, 1, y); float m[2][2]; /* TODO(Ish): need to fix this when sizing is improved */ @@ -692,8 +687,12 @@ static void cloth_remeshing_uv_of_vert(BMesh *bm, BMVert *v, float r_uv[2]) copy_v2_v2(r_uv, luv->uv); } +/* Ensure the edge also has at least one face associated with it so + * that e->l exists */ static void cloth_remeshing_uv_of_vert_in_edge(BMesh *bm, BMEdge *e, BMVert *v, float r_uv[2]) { + BLI_assert(e->l != NULL); + BMLoop *l; e->l->v == v ? l = e->l : l = e->l->next; const int cd_loop_uv_offset = CustomData_get_offset(>ldata, CD_MLOOPUV); @@ -704,14 +703,13 @@ static void cloth_remeshing_uv_of_vert_in_edge(BMesh *bm, BMEdge *e, BMVert *v, static float cloth_remeshing_edge_size(BMesh *bm, BMVert *v1, BMVert *v2, + float uv1[2], + float uv2[2], map ) { - if (!v1 || !v2) { + if (!v1 || !v2 || uv1 == NULL || uv2 == NULL) { return 0.0f; } - float uv1[2], uv2[2]; - cloth_remeshing_uv_of_vert(bm, v1, uv1); - cloth_remeshing_uv_of_vert(bm, v2, uv2); float uv12[2]; sub_v2_v2v2(uv12, uv1, uv2); @@ -722,50 +720,12 @@ static float cloth_remeshing_edge_size(BMesh *bm, static float cloth_remeshing_edge_size(BMesh *bm, BMEdge *edge, map ) { float u1[2], u2[2]; - float u12[2]; - - /** - * Get UV Coordinates of v1 and v2 - */ - BMLoop *l; - BMLoop *l2; - MLoopUV *luv; - const int cd_loop_uv_offset = CustomData_get_offset(>ldata, CD_MLOOPUV); - - /* find edge_size only if edge has a loop (so it has a face attached) */ if (!edge->l) { -/* TODO(Ish): Might want to mark such an edge as sewing edge, so it can be used when an edge - * connected to 2 sewing edges is split, new sewing edges can be added */ return 0.0f; } - - l = edge->l; - if (l->v == edge->v1) { -if (l->next->v == edge->v2) { - l2 = l->next; -} -else { - l2 = l->prev; -} - } - else { -if (l->next->v == edge->v1) { - l2 = l->next; -} -else { - l2 = l->prev; -} - } - - luv = (MLoopUV *)BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); - copy_v2_v2(u1, luv->uv); - luv = (MLoopUV *)BM_ELEM_CD_GET_VOID_P(l2, cd_loop_uv_offset); - copy_v2_v2(u2, luv->uv); - copy_v2_v2(u12, u1); - sub_v2_v2(u12, u2); - - return sqrtf((cloth_remeshing_norm2(u12, sizing[edge->v1]) + -(cloth_remeshing_norm2(u12, sizing[edge->v2])) * 0.5f)); + cloth_remeshing_uv_of_vert_in_edge(bm, edge, edge->v1, u1); + cloth_remeshing_uv_of_vert_in_edge(bm, edge, edge->v2, u2); + return cloth_remeshing_edge_size(bm, edge->v1, edge->v2, u1, u2, sizing); } static int cloth_remeshing_edge_pair_compare(const void *a, const void *b) @@ -1459,7 +1419,8 @@ static bool cloth_remeshing_can_collapse_edge( { for (int s = 0; s < 2; s++) { BMVert *v1 = cloth_remeshing_edge_vert(bm, e, s, which, NULL); -BMVert *v2 = cloth_remeshing_edge_vert(bm, e, s, 1 - which, NULL); +float uv_v2[2]; +BMVert *v2 = cloth_remeshing_edge_vert(bm, e, s, 1 - which, uv_v2); if (!v1 || (s == 1 && v1 == cloth_remeshing_edge_vert(bm, e, 0, which, NULL))) { continue; @@ -1473,24 +1434,25 @@ static bool cloth_remeshing_can_collapse_edge( } BMVert *vs[3];
[Bf-blender-cvs] [8def5a98db7] soc-2019-adaptive-cloth: Cloth: better edge_size() when edge is given
Commit: 8def5a98db71b6494a6492115ce7a4363f783b73 Author: ishbosamiya Date: Thu Jul 25 13:25:20 2019 +0530 Branches: soc-2019-adaptive-cloth https://developer.blender.org/rB8def5a98db71b6494a6492115ce7a4363f783b73 Cloth: better edge_size() when edge is given === M source/blender/blenkernel/intern/cloth_remeshing.cpp === diff --git a/source/blender/blenkernel/intern/cloth_remeshing.cpp b/source/blender/blenkernel/intern/cloth_remeshing.cpp index 2075b647486..20921bcae69 100644 --- a/source/blender/blenkernel/intern/cloth_remeshing.cpp +++ b/source/blender/blenkernel/intern/cloth_remeshing.cpp @@ -719,6 +719,7 @@ static float cloth_remeshing_edge_size(BMesh *bm, static float cloth_remeshing_edge_size(BMesh *bm, BMEdge *edge, map ) { +#if 0 float u1[2], u2[2]; if (!edge->l) { return 0.0f; @@ -726,6 +727,21 @@ static float cloth_remeshing_edge_size(BMesh *bm, BMEdge *edge, mapv1, u1); cloth_remeshing_uv_of_vert_in_edge(bm, edge, edge->v2, u2); return cloth_remeshing_edge_size(bm, edge->v1, edge->v2, u1, u2, sizing); +#else + float uvs[4][2]; + BMVert *v1 = cloth_remeshing_edge_vert(bm, edge, 0, 0, uvs[0]); + BMVert *v2 = cloth_remeshing_edge_vert(bm, edge, 0, 1, uvs[1]); + BMVert *v3 = cloth_remeshing_edge_vert(bm, edge, 1, 0, uvs[2]); + BMVert *v4 = cloth_remeshing_edge_vert(bm, edge, 1, 1, uvs[3]); + float m = cloth_remeshing_edge_size(bm, v1, v2, uvs[0], uvs[1], sizing) + +cloth_remeshing_edge_size(bm, v3, v4, uvs[2], uvs[3], sizing); + if (BM_edge_face_count(edge) == 2) { +return m * 0.5f; + } + else { +return m; + } +#endif } static int cloth_remeshing_edge_pair_compare(const void *a, const void *b) @@ -1859,7 +1875,7 @@ static void cloth_remeshing_static(ClothModifierData *clmd) cloth_remeshing_export_obj(clmd->clothObject->bm, file_name); #endif -#if 1 +#if 0 int v_count = 0; BM_ITER_MESH (v, , clmd->clothObject->bm, BM_VERTS_OF_MESH) { if (cloth_remeshing_vert_on_seam_or_boundary_test(clmd->clothObject->bm, v)) { @@ -2529,7 +2545,7 @@ Mesh *cloth_remeshing_step(Depsgraph *depsgraph, Object *ob, ClothModifierData * { cloth_remeshing_init_bmesh(ob, clmd, mesh); - if (false) { + if (true) { cloth_remeshing_static(clmd); } else { ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [199bc509257] soc-2019-adaptive-cloth: Cloth: collapse correct vertex
Commit: 199bc509257ded40d1336062bb4f650466fa0322 Author: ishbosamiya Date: Wed Jul 24 00:08:16 2019 +0530 Branches: soc-2019-adaptive-cloth https://developer.blender.org/rB199bc509257ded40d1336062bb4f650466fa0322 Cloth: collapse correct vertex === M source/blender/blenkernel/intern/cloth_remeshing.cpp === diff --git a/source/blender/blenkernel/intern/cloth_remeshing.cpp b/source/blender/blenkernel/intern/cloth_remeshing.cpp index 9b5a1542aaf..81f159ebc27 100644 --- a/source/blender/blenkernel/intern/cloth_remeshing.cpp +++ b/source/blender/blenkernel/intern/cloth_remeshing.cpp @@ -479,6 +479,19 @@ static bool cloth_remeshing_edge_on_seam_or_boundary_test(BMEdge *e) return !f1 || !f2 || cloth_remeshing_edge_vert(e, 0, 0) != cloth_remeshing_edge_vert(e, 1, 0); } +static bool cloth_remeshing_vert_on_seam_or_boundary_test(BMVert *v) +{ + BMEdge *e; + BMIter eiter; + + BM_ITER_ELEM (e, , v, BM_EDGES_OF_VERT) { +if (cloth_remeshing_edge_on_seam_or_boundary_test(e)) { + return true; +} + } + return false; +} + #if 1 static vector cloth_remeshing_find_edges_to_flip(BMesh *bm, map , @@ -1396,9 +1409,10 @@ static bool cloth_remeshing_can_collapse_edge( return false; } + float size; for (int e = 0; e < 3; e++) { if (vs[e] != v2) { - float size = cloth_remeshing_edge_size(bm, vs[NEXT(e)], vs[PREV(e)], sizing); + size = cloth_remeshing_edge_size(bm, vs[NEXT(e)], vs[PREV(e)], sizing); if (size > 1.0f - REMESHING_HYSTERESIS_PARAMETER) { #if COLLAPSE_EDGES_DEBUG printf("size %f > 1.0f - REMESHING_HYSTERESIS_PARAMETER\n", size); @@ -1407,6 +1421,9 @@ static bool cloth_remeshing_can_collapse_edge( } } } +#if COLLAPSE_EDGES_DEBUG + printf("size: %f ", size); +#endif } } return true; @@ -1483,15 +1500,23 @@ static bool cloth_remeshing_vert_on_seam_test(BMesh *bm, BMVert *v) return false; } -static BMVert *cloth_remeshing_collapse_edge(Cloth *cloth, - BMesh *bm, - BMEdge *e, - map ) +static BMVert *cloth_remeshing_collapse_edge( +Cloth *cloth, BMesh *bm, BMEdge *e, int which, map ) { - BMVert v1 = *e->v1; - BMVert *v2 = BM_edge_collapse(bm, e, e->v1, true, true); + BMVert *v1 = cloth_remeshing_edge_vert(e, which); + BMVert v = *v1; + BMVert *v2 = BM_edge_collapse(bm, e, v1, true, true); - cloth_remeshing_remove_vertex_from_cloth(cloth, , sizing); + cloth_remeshing_remove_vertex_from_cloth(cloth, , sizing); +#if COLLAPSE_EDGES_DEBUG + printf("killed %f %f %f into %f %f %f\n", + v.co[0], + v.co[1], + v.co[2], + v2->co[0], + v2->co[1], + v2->co[2]); +#endif return v2; } @@ -1504,11 +1529,20 @@ static BMVert *cloth_remeshing_try_edge_collapse(ClothModifierData *clmd, BMesh *bm = cloth->bm; BMVert *v1 = cloth_remeshing_edge_vert(e, which); - if (cloth_remeshing_boundary_test(v1) && !cloth_remeshing_boundary_test(e)) { -return NULL; - } + /* if (cloth_remeshing_boundary_test(v1) && !cloth_remeshing_boundary_test(e)) { */ + /* return NULL; */ + /* } */ + + /* if (cloth_remeshing_vert_on_seam_test(bm, v1) && !cloth_remeshing_edge_on_seam_test(bm, e)) { + */ + /* return NULL; */ + /* } */ - if (cloth_remeshing_vert_on_seam_test(bm, v1) && !cloth_remeshing_edge_on_seam_test(bm, e)) { + if (cloth_remeshing_vert_on_seam_or_boundary_test(v1) && + !cloth_remeshing_edge_on_seam_or_boundary_test(e)) { +#if COLLAPSE_EDGES_DEBUG +printf("vertex on seam or boundary but not edge\n"); +#endif return NULL; } @@ -1516,7 +1550,7 @@ static BMVert *cloth_remeshing_try_edge_collapse(ClothModifierData *clmd, return NULL; } - return cloth_remeshing_collapse_edge(cloth, bm, e, sizing); + return cloth_remeshing_collapse_edge(cloth, bm, e, which, sizing); } static void cloth_remeshing_remove_face(vector , int index) @@ -1660,12 +1694,13 @@ static bool cloth_remeshing_collapse_edges(ClothModifierData *clmd, count++; return true; } -/* printf("Skipped previous part! size: %d i: %d ", (int)active_faces.size(), i); */ +/* printf("Skipped previous part! active_faces.size: %d i: %d ", (int)active_faces.size(), i); + */ cloth_remeshing_remove_face(active_faces, i--); /* TODO(Ish): a double i-- is a hacky way to ensure there is no * crash when removing a face */ -i--; -/* printf("new size: %d new i: %d\n", (int)active_faces.size(), i); */ +/* i--; */ +/* printf("new active_faces.size: %d new i: %d\n", (int)active_faces.size(), i); */ } return false; } @@ -1834,6
[Bf-blender-cvs] [23cbf600b22] soc-2019-adaptive-cloth: Cloth: better edge_size calculation
Commit: 23cbf600b2248899694b69f6d2868f8deafd6701 Author: ishbosamiya Date: Tue Jul 23 12:37:09 2019 +0530 Branches: soc-2019-adaptive-cloth https://developer.blender.org/rB23cbf600b2248899694b69f6d2868f8deafd6701 Cloth: better edge_size calculation === M source/blender/blenkernel/intern/cloth_remeshing.cpp === diff --git a/source/blender/blenkernel/intern/cloth_remeshing.cpp b/source/blender/blenkernel/intern/cloth_remeshing.cpp index 50e27b44c7f..364a12491bf 100644 --- a/source/blender/blenkernel/intern/cloth_remeshing.cpp +++ b/source/blender/blenkernel/intern/cloth_remeshing.cpp @@ -550,9 +550,15 @@ static ClothSizing cloth_remeshing_find_average_sizing(ClothSizing _01, Clo return new_size; } +static float cloth_remeshing_norm2(float u[2], ClothSizing ) +{ + float temp[2]; + mul_v2_m2v2(temp, s.m, u); + return dot_v2v2(u, temp); +} + static float cloth_remeshing_edge_size(BMesh *bm, BMEdge *edge, map ) { - /* BMVert v1 = *edge->v1; */ float u1[2], u2[2]; float u12[2]; @@ -596,19 +602,8 @@ static float cloth_remeshing_edge_size(BMesh *bm, BMEdge *edge, mapv1], - sizing[edge->v2]); - mul_v2_m2v2(temp_v2, sizing_temp.m, u12); - value += dot_v2v2(u12, temp_v2); - - return sqrtf(fmax(value, 0.0f)); + return sqrtf((cloth_remeshing_norm2(u12, sizing[edge->v1]) + +(cloth_remeshing_norm2(u12, sizing[edge->v2])) * 0.5f)); } static int cloth_remeshing_edge_pair_compare(const void *a, const void *b) ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [4ddf80cf040] soc-2019-adaptive-cloth: Cloth: switch from BM_edge_face_pair() to cloth_remeshing_edge_face_pair()
Commit: 4ddf80cf04071e7c24fa4f3799865e6d5d95d33f Author: ishbosamiya Date: Wed Jul 24 13:21:26 2019 +0530 Branches: soc-2019-adaptive-cloth https://developer.blender.org/rB4ddf80cf04071e7c24fa4f3799865e6d5d95d33f Cloth: switch from BM_edge_face_pair() to cloth_remeshing_edge_face_pair() === M source/blender/blenkernel/intern/cloth_remeshing.cpp === diff --git a/source/blender/blenkernel/intern/cloth_remeshing.cpp b/source/blender/blenkernel/intern/cloth_remeshing.cpp index 3b80c8f25ad..e9f8646392d 100644 --- a/source/blender/blenkernel/intern/cloth_remeshing.cpp +++ b/source/blender/blenkernel/intern/cloth_remeshing.cpp @@ -372,7 +372,7 @@ static pair cloth_remeshing_edge_side_verts(BMEdge *e) pair edge_side_verts; edge_side_verts.first = NULL; edge_side_verts.second = NULL; - BM_edge_face_pair(e, , ); + cloth_remeshing_edge_face_pair(e, , ); if (f1) { BMVert *v; BMIter viter; @@ -439,7 +439,7 @@ static bool cloth_remeshing_should_flip( BMesh *bm, BMVert *v1, BMVert *v2, BMVert *v3, BMVert *v4, map ) { BMFace *f1, *f2; - BM_edge_face_pair(BM_edge_exists(v1, v2), , ); + cloth_remeshing_edge_face_pair(BM_edge_exists(v1, v2), , ); float x[2], y[2], z[2], w[2]; cloth_remeshing_uv_of_vert_in_face(bm, f1, v1, x); cloth_remeshing_uv_of_vert_in_face(bm, f2, v4, y); @@ -575,7 +575,7 @@ static vector cloth_remeshing_find_edges_to_flip(BMesh *bm, pair edge_side_verts = cloth_remeshing_edge_side_verts(e); BMFace *f1, *f2; -BM_edge_face_pair(e, , ); +cloth_remeshing_edge_face_pair(e, , ); BMVert *v3, *v4; v3 = edge_side_verts.first; v4 = edge_side_verts.second; @@ -1217,9 +1217,9 @@ static float cloth_remeshing_edge_size_with_vert( BMesh *bm, BMVert *v1, BMVert *v2, BMVert *v, map ) { BMFace *f1, *f2; - BM_edge_face_pair(BM_edge_exists(v1, v), , ); + cloth_remeshing_edge_face_pair(BM_edge_exists(v1, v), , ); pair face_pair_01 = make_pair(f1, f2); - BM_edge_face_pair(BM_edge_exists(v2, v), , ); + cloth_remeshing_edge_face_pair(BM_edge_exists(v2, v), , ); pair face_pair_02 = make_pair(f1, f2); pair face_pair = cloth_remeshing_find_match( @@ -1291,7 +1291,7 @@ static float cloth_remeshing_aspect_ratio(float u1[2], float u2[2], float u3[2]) static bool cloth_remeshing_aspect_ratio(ClothModifierData *clmd, BMesh *bm, BMEdge *e) { BMFace *f1, *f2; - BM_edge_face_pair(e, , ); + cloth_remeshing_edge_face_pair(e, , ); BMFace *f; BMIter fiter; @@ -1517,7 +1517,7 @@ static void cloth_remeshing_remove_vertex_from_cloth(Cloth *cloth, static bool cloth_remeshing_boundary_test(BMEdge *e) { BMFace *f1, *f2; - BM_edge_face_pair(e, , ); + cloth_remeshing_edge_face_pair(e, , ); return !f1 || !f2; } @@ -1544,7 +1544,7 @@ static bool cloth_remeshing_boundary_test(BMVert *v) static bool cloth_remeshing_edge_on_seam_test(BMesh *bm, BMEdge *e) { BMFace *f1, *f2; - BM_edge_face_pair(e, , ); + cloth_remeshing_edge_face_pair(e, , ); if (!f1 || !f2) { return false; } @@ -2066,7 +2066,7 @@ static float cloth_remeshing_dihedral_angle(BMVert *v1, BMVert *v2) } BMFace *f1, *f2; - BM_edge_face_pair(edge, , ); + cloth_remeshing_edge_face_pair(edge, , ); if (f1 == NULL || f2 == NULL) { return 0.0f; } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [7797336f251] soc-2019-adaptive-cloth: Cloth: switch to different method for collapse edges
Commit: 7797336f2519846fff11eb2c3097ae23239f Author: ishbosamiya Date: Tue Jul 23 17:51:35 2019 +0530 Branches: soc-2019-adaptive-cloth https://developer.blender.org/rB7797336f2519846fff11eb2c3097ae23239f Cloth: switch to different method for collapse edges This method is significantly different and does not depend on edge_size_with_vert() which means that there is no error with that size becoming 100.0f. Now need to change flip edges to use the new edge metric method. === M source/blender/blenkernel/intern/cloth_remeshing.cpp === diff --git a/source/blender/blenkernel/intern/cloth_remeshing.cpp b/source/blender/blenkernel/intern/cloth_remeshing.cpp index 364a12491bf..900b8c60cac 100644 --- a/source/blender/blenkernel/intern/cloth_remeshing.cpp +++ b/source/blender/blenkernel/intern/cloth_remeshing.cpp @@ -79,6 +79,8 @@ using namespace std; **/ #define COLLAPSE_EDGES_DEBUG 1 +#define NEXT(x) ((x) < 2 ? (x) + 1 : (x)-2) +#define PREV(x) ((x) > 0 ? (x)-1 : (x) + 2) /** *The definition of sizing used for remeshing @@ -557,6 +559,33 @@ static float cloth_remeshing_norm2(float u[2], ClothSizing ) return dot_v2v2(u, temp); } +static void cloth_remeshing_uv_of_vert(BMesh *bm, BMVert *v, float r_uv[2]) +{ + BMLoop *l; + v->e->l->v == v ? l = v->e->l : l = v->e->l->next; + const int cd_loop_uv_offset = CustomData_get_offset(>ldata, CD_MLOOPUV); + MLoopUV *luv = (MLoopUV *)BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); + copy_v2_v2(r_uv, luv->uv); +} + +static float cloth_remeshing_edge_size(BMesh *bm, + BMVert *v1, + BMVert *v2, + map ) +{ + if (!v1 || !v2) { +return 0.0f; + } + float uv1[2], uv2[2]; + cloth_remeshing_uv_of_vert(bm, v1, uv1); + cloth_remeshing_uv_of_vert(bm, v2, uv2); + + float uv12[2]; + sub_v2_v2v2(uv12, uv1, uv2); + return sqrtf( + (cloth_remeshing_norm2(uv12, sizing[v1]) + cloth_remeshing_norm2(uv12, sizing[v2])) * 0.5f); +} + static float cloth_remeshing_edge_size(BMesh *bm, BMEdge *edge, map ) { float u1[2], u2[2]; @@ -1120,6 +1149,24 @@ static inline float cloth_remeshing_wedge(float v_01[2], float v_02[2]) #define SQRT3 1.732050808f +static float cloth_remeshing_area(float u1[2], float u2[2], float u3[2]) +{ + float u21[2], u31[2]; + sub_v2_v2v2(u21, u2, u1); + sub_v2_v2v2(u31, u3, u1); + return 0.5 * cloth_remeshing_wedge(u21, u31); +} + +static float cloth_remeshing_perimeter(float u1[2], float u2[2], float u3[2]) +{ + return len_v2(u1) + len_v2(u2) + len_v2(u3); +} + +static float cloth_remeshing_aspect_ratio(float u1[2], float u2[2], float u3[2]) +{ + return 12.0f * SQRT3 * cloth_remeshing_area(u1, u2, u3) * cloth_remeshing_perimeter(u1, u2, u3); +} + static bool cloth_remeshing_aspect_ratio(ClothModifierData *clmd, BMesh *bm, BMEdge *e) { BMFace *f1, *f2; @@ -1171,60 +1218,97 @@ static bool cloth_remeshing_aspect_ratio(ClothModifierData *clmd, BMesh *bm, BME return true; } -#define REMESHING_HYSTERESIS_PARAMETER 0.2 -static bool cloth_remeshing_can_collapse_edge(ClothModifierData *clmd, - BMesh *bm, - BMEdge *e, - map ) +static BMVert *cloth_remeshing_edge_vert(BMEdge *e, int which) { - if (BM_edge_face_count(e) < 2) { -#if COLLAPSE_EDGES_DEBUG -printf("edge face count < 2\n"); -#endif -return false; + if (which == 0) { +return e->v1; } - - /* aspect ratio parameter */ - if (!cloth_remeshing_aspect_ratio(clmd, bm, e)) { -#if COLLAPSE_EDGES_DEBUG -printf("aspect ratio not satisfied\n"); -#endif -return false; + else { +return e->v2; } +} - BMFace *f1, *f2; - BM_edge_face_pair(e, , ); -#if 1 - /* TODO(Ish): This was a hack, figure out why it doesn't give the - * fair pair even though face count is 2 or more - * It might be fixed if the UV seams if fixed */ - if (!f1 || !f2) { -# if COLLAPSE_EDGES_DEBUG -printf("Couldn't find face pair\n"); -# endif -return false; +static BMVert *cloth_remeshing_edge_vert(BMEdge *e, int side, int i) +{ + BMFace *f; + BMIter fiter; + int fi = 0; + BM_ITER_ELEM_INDEX (f, , e, BM_FACES_OF_EDGE, fi) { +if (fi == side) { + break; +} } -#endif - BMVert *v_01 = BM_face_other_vert_loop(f1, e->v1, e->v2)->v; - float size_01 = cloth_remeshing_edge_size_with_vert(bm, e, v_01, sizing); - if (size_01 > (1.0f - REMESHING_HYSTERESIS_PARAMETER)) { -#if COLLAPSE_EDGES_DEBUG -printf("size_01: %f > 1.0f - REMESHING_HYSTERESIS_PARAMETER\n", size_01); -#endif -return false; + if (!f) { +return NULL; } - BMVert *v_02 =
[Bf-blender-cvs] [832201400fb] soc-2019-adaptive-cloth: Cloth: fix bug in collapse edges
Commit: 832201400fb5f8a2bef31e89456cfbffb0c2015a Author: ishbosamiya Date: Mon Jul 22 23:53:27 2019 +0530 Branches: soc-2019-adaptive-cloth https://developer.blender.org/rB832201400fb5f8a2bef31e89456cfbffb0c2015a Cloth: fix bug in collapse edges When the face is not collapsed, it needs to be removed from the active faces. To prevent a crash, doing a double i-- helps it only get faces which are within the size() and not capacity(). === M source/blender/blenkernel/intern/cloth_remeshing.cpp === diff --git a/source/blender/blenkernel/intern/cloth_remeshing.cpp b/source/blender/blenkernel/intern/cloth_remeshing.cpp index 2a30088fe1b..ae480227a44 100644 --- a/source/blender/blenkernel/intern/cloth_remeshing.cpp +++ b/source/blender/blenkernel/intern/cloth_remeshing.cpp @@ -1400,8 +1400,8 @@ static void cloth_remeshing_update_active_faces(vector _faces, /* Assumed that active_faces and fix_active have been updated before * using either of the other 2 update_active_faces function so that * there is no face that is not part of bm */ -static void cloth_remeshing_update_active_faces(vector active_faces, -vector fix_active) +static void cloth_remeshing_update_active_faces(vector _faces, +vector _active) { for (int i = 0; i < fix_active.size(); i++) { bool already_exists = false; @@ -1458,7 +1458,12 @@ static bool cloth_remeshing_collapse_edges(ClothModifierData *clmd, count++; return true; } +/* printf("Skipped previous part! size: %d i: %d ", (int)active_faces.size(), i); */ cloth_remeshing_remove_face(active_faces, i--); +/* TODO(Ish): a double i-- is a hacky way to ensure there is no + * crash when removing a face */ +i--; +/* printf("new size: %d new i: %d\n", (int)active_faces.size(), i); */ } return false; } @@ -1516,12 +1521,6 @@ static void cloth_remeshing_static(ClothModifierData *clmd) BM_ITER_MESH (f, , clmd->clothObject->bm, BM_FACES_OF_MESH) { active_faces.push_back(f); } - for (int i = 0; i < active_faces.size(); i++) { -BMFace *temp_f = active_faces[i]; -if (!(temp_f->head.htype == BM_FACE)) { - printf("htype didn't match: %d\n", i); -} - } int prev_mvert_num = clmd->clothObject->mvert_num; int count = 0; while (cloth_remeshing_collapse_edges(clmd, sizing, active_faces, count)) { @@ -1596,12 +1595,6 @@ static void cloth_remeshing_dynamic(Depsgraph *depsgraph, Object *ob, ClothModif BM_ITER_MESH (f, , clmd->clothObject->bm, BM_FACES_OF_MESH) { active_faces.push_back(f); } - for (int i = 0; i < active_faces.size(); i++) { -BMFace *temp_f = active_faces[i]; -if (!(temp_f->head.htype == BM_FACE)) { - printf("htype didn't match: %d\n", i); -} - } int prev_mvert_num = clmd->clothObject->mvert_num; int count = 0; while (cloth_remeshing_collapse_edges(clmd, sizing, active_faces, count)) { ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [02107418771] soc-2019-adaptive-cloth: Cloth: better seam or boundary test
Commit: 0210741877149b56cd5c32541f616f119bb2e2b5 Author: ishbosamiya Date: Wed Jul 24 13:16:10 2019 +0530 Branches: soc-2019-adaptive-cloth https://developer.blender.org/rB0210741877149b56cd5c32541f616f119bb2e2b5 Cloth: better seam or boundary test === M source/blender/blenkernel/intern/cloth_remeshing.cpp === diff --git a/source/blender/blenkernel/intern/cloth_remeshing.cpp b/source/blender/blenkernel/intern/cloth_remeshing.cpp index 81f159ebc27..3b80c8f25ad 100644 --- a/source/blender/blenkernel/intern/cloth_remeshing.cpp +++ b/source/blender/blenkernel/intern/cloth_remeshing.cpp @@ -78,7 +78,7 @@ using namespace std; * reference http://graphics.berkeley.edu/papers/Narain-AAR-2012-11/index.html **/ -#define COLLAPSE_EDGES_DEBUG 1 +#define COLLAPSE_EDGES_DEBUG 0 #define NEXT(x) ((x) < 2 ? (x) + 1 : (x)-2) #define PREV(x) ((x) > 0 ? (x)-1 : (x) + 2) @@ -141,6 +141,7 @@ static BMVert *cloth_remeshing_edge_vert(BMEdge *e, int which); static BMVert *cloth_remeshing_edge_vert(BMEdge *e, int side, int i); static BMVert *cloth_remeshing_edge_opposite_vert(BMEdge *e, int side); static void cloth_remeshing_uv_of_vert(BMesh *bm, BMVert *v, float r_uv[2]); +static void cloth_remeshing_edge_face_pair(BMEdge *e, BMFace **r_f1, BMFace **r_f2); static CustomData_MeshMasks cloth_remeshing_get_cd_mesh_masks(void) { @@ -471,21 +472,51 @@ static bool cloth_remeshing_should_flip( (cloth_remeshing_wedge(zy, xy) + cloth_remeshing_wedge(xw, zw)); } -static bool cloth_remeshing_edge_on_seam_or_boundary_test(BMEdge *e) +static bool cloth_remeshing_edge_on_seam_or_boundary_test(BMesh *bm, BMEdge *e) { +#if 1 BMFace *f1, *f2; - BM_edge_face_pair(e, , ); + cloth_remeshing_edge_face_pair(e, , ); return !f1 || !f2 || cloth_remeshing_edge_vert(e, 0, 0) != cloth_remeshing_edge_vert(e, 1, 0); +#else + BMFace *f, *f1, *f2; + BMIter fiter; + int i = 0; + BM_ITER_ELEM (f, , e, BM_FACES_OF_EDGE) { +if (i == 0) { + f1 = f; +} +else if (i == 1) { + f2 = f; +} +i++; + } + + if (i < 2) { +return true; + } + + if (!f1 || !f2) { +return false; + } + float uv_f1_v1[2], uv_f1_v2[2], uv_f2_v1[2], uv_f2_v2[2]; + cloth_remeshing_uv_of_vert_in_face(bm, f1, e->v1, uv_f1_v1); + cloth_remeshing_uv_of_vert_in_face(bm, f1, e->v2, uv_f1_v2); + cloth_remeshing_uv_of_vert_in_face(bm, f2, e->v1, uv_f2_v1); + cloth_remeshing_uv_of_vert_in_face(bm, f2, e->v2, uv_f2_v2); + + return (!equals_v2v2(uv_f1_v1, uv_f2_v1) || !equals_v2v2(uv_f1_v2, uv_f2_v2)); +#endif } -static bool cloth_remeshing_vert_on_seam_or_boundary_test(BMVert *v) +static bool cloth_remeshing_vert_on_seam_or_boundary_test(BMesh *bm, BMVert *v) { BMEdge *e; BMIter eiter; BM_ITER_ELEM (e, , v, BM_EDGES_OF_VERT) { -if (cloth_remeshing_edge_on_seam_or_boundary_test(e)) { +if (cloth_remeshing_edge_on_seam_or_boundary_test(bm, e)) { return true; } } @@ -508,7 +539,7 @@ static vector cloth_remeshing_find_edges_to_flip(BMesh *bm, vector fedges; for (int i = 0; i < edges.size(); i++) { BMEdge *e = edges[i]; -if (cloth_remeshing_edge_on_seam_or_boundary_test(e)) { +if (cloth_remeshing_edge_on_seam_or_boundary_test(bm, e)) { continue; } if (!cloth_remeshing_should_flip(bm, e, sizing)) { @@ -1318,17 +1349,49 @@ static BMVert *cloth_remeshing_edge_vert(BMEdge *e, int which) } } -static BMVert *cloth_remeshing_edge_vert(BMEdge *e, int side, int i) +static void cloth_remeshing_edge_face_pair(BMEdge *e, BMFace **r_f1, BMFace **r_f2) { BMFace *f; BMIter fiter; - int fi = 0; - BM_ITER_ELEM_INDEX (f, , e, BM_FACES_OF_EDGE, fi) { -if (fi == side) { + int i = 0; + *r_f1 = NULL; + *r_f2 = NULL; + BM_ITER_ELEM (f, , e, BM_FACES_OF_EDGE) { +if (i == 0) { + *r_f1 = f; +} +else if (i == 1) { + *r_f2 = f; +} +else { break; } } +} + +static BMVert *cloth_remeshing_edge_vert(BMEdge *e, int side, int i) +{ + /* BMFace *f, *f1 = NULL, *f2 = NULL; */ + /* BMIter fiter; */ + /* int fi = 0; */ + /* BM_ITER_ELEM_INDEX (f, , e, BM_FACES_OF_EDGE, fi) { */ + /* if (fi == 0) { */ + /* f1 = f; */ + /* } */ + /* else if (fi == 1) { */ + /* f2 = f; */ + /* } */ + /* if (fi == side) { */ + /* break; */ + /* } */ + /* } */ + BMFace *f, *f1, *f2; + cloth_remeshing_edge_face_pair(e, , ); + side == 0 ? f = f1 : f = f2; if (!f) { +#if 0 +printf("didn't find f in %s\n", __func__); +#endif return NULL; } BMVert *vs[3]; @@ -1343,15 +1406,21 @@ static BMVert *cloth_remeshing_edge_vert(BMEdge *e, int side, int i) static BMVert *cloth_remeshing_edge_opposite_vert(BMEdge *e, int side) { - BMFace *f; - BMIter fiter; - int fi = 0;
[Bf-blender-cvs] [65b8e525d8c] soc-2019-adaptive-cloth: Cloth: improved flip checking
Commit: 65b8e525d8c9ede98c262520b45e9eab754000cb Author: ishbosamiya Date: Tue Jul 23 18:56:39 2019 +0530 Branches: soc-2019-adaptive-cloth https://developer.blender.org/rB65b8e525d8c9ede98c262520b45e9eab754000cb Cloth: improved flip checking No longer relies on edge_size_with_vert() which means no longer need to figure out why it returns 100.0f. === M source/blender/blenkernel/intern/cloth_remeshing.cpp === diff --git a/source/blender/blenkernel/intern/cloth_remeshing.cpp b/source/blender/blenkernel/intern/cloth_remeshing.cpp index 900b8c60cac..9b5a1542aaf 100644 --- a/source/blender/blenkernel/intern/cloth_remeshing.cpp +++ b/source/blender/blenkernel/intern/cloth_remeshing.cpp @@ -137,6 +137,10 @@ static void cloth_remeshing_update_active_faces(vector _faces, BMEdge *e); static ClothSizing cloth_remeshing_find_average_sizing(ClothSizing _01, ClothSizing _02); static void mul_m2_m2m2(float r[2][2], float a[2][2], float b[2][2]); +static BMVert *cloth_remeshing_edge_vert(BMEdge *e, int which); +static BMVert *cloth_remeshing_edge_vert(BMEdge *e, int side, int i); +static BMVert *cloth_remeshing_edge_opposite_vert(BMEdge *e, int side); +static void cloth_remeshing_uv_of_vert(BMesh *bm, BMVert *v, float r_uv[2]); static CustomData_MeshMasks cloth_remeshing_get_cd_mesh_masks(void) { @@ -393,6 +397,43 @@ static pair cloth_remeshing_edge_side_verts(BMEdge *e) /* from Bossen and Heckbert 1996 */ #define CLOTH_REMESHING_EDGE_FLIP_THRESHOLD 0.001f + +static bool cloth_remeshing_should_flip(BMesh *bm, BMEdge *e, map ) +{ + BMVert *v1, *v2, *v3, *v4; + v1 = cloth_remeshing_edge_vert(e, 0, 0); + v2 = cloth_remeshing_edge_vert(e, 0, 1); + v3 = cloth_remeshing_edge_opposite_vert(e, 0); + v4 = cloth_remeshing_edge_opposite_vert(e, 1); + + float x[2], y[2], z[2], w[2]; + cloth_remeshing_uv_of_vert(bm, v1, x); + cloth_remeshing_uv_of_vert(bm, v2, z); + cloth_remeshing_uv_of_vert(bm, v3, w); + cloth_remeshing_uv_of_vert(bm, v4, y); + + float m[2][2]; + /* TODO(Ish): need to fix this when sizing is improved */ + ClothSizing size_temp_01 = cloth_remeshing_find_average_sizing(sizing[v1], sizing[v2]); + ClothSizing size_temp_02 = cloth_remeshing_find_average_sizing(sizing[v3], sizing[v4]); + ClothSizing size_temp = cloth_remeshing_find_average_sizing(size_temp_01, size_temp_02); + copy_m2_m2(m, size_temp.m); + + float zy[2], xy[2], xw[2], mzw[2], mxy[2], zw[2]; + sub_v2_v2v2(zy, z, y); + sub_v2_v2v2(xy, x, y); + sub_v2_v2v2(xw, x, w); + sub_v2_v2v2(zw, z, w); + + mul_v2_m2v2(mzw, m, zw); + mul_v2_m2v2(mxy, m, xy); + + return cloth_remeshing_wedge(zy, xy) * dot_v2v2(xw, mzw) + + dot_v2v2(zy, mxy) * cloth_remeshing_wedge(xw, zw) < + -CLOTH_REMESHING_EDGE_FLIP_THRESHOLD * + (cloth_remeshing_wedge(zy, xy) + cloth_remeshing_wedge(xw, zw)); +} + static bool cloth_remeshing_should_flip( BMesh *bm, BMVert *v1, BMVert *v2, BMVert *v3, BMVert *v4, map ) { @@ -430,6 +471,41 @@ static bool cloth_remeshing_should_flip( (cloth_remeshing_wedge(zy, xy) + cloth_remeshing_wedge(xw, zw)); } +static bool cloth_remeshing_edge_on_seam_or_boundary_test(BMEdge *e) +{ + BMFace *f1, *f2; + BM_edge_face_pair(e, , ); + + return !f1 || !f2 || cloth_remeshing_edge_vert(e, 0, 0) != cloth_remeshing_edge_vert(e, 1, 0); +} + +#if 1 +static vector cloth_remeshing_find_edges_to_flip(BMesh *bm, + map , + vector _faces) +{ + vector edges; + for (int i = 0; i < active_faces.size(); i++) { +BMEdge *e; +BMIter eiter; +BM_ITER_ELEM (e, , active_faces[i], BM_EDGES_OF_FACE) { + edges.push_back(e); +} + } + vector fedges; + for (int i = 0; i < edges.size(); i++) { +BMEdge *e = edges[i]; +if (cloth_remeshing_edge_on_seam_or_boundary_test(e)) { + continue; +} +if (!cloth_remeshing_should_flip(bm, e, sizing)) { + continue; +} +fedges.push_back(e); + } + return fedges; +} +#else static vector cloth_remeshing_find_edges_to_flip(BMesh *bm, map , vector _faces) @@ -489,6 +565,7 @@ static vector cloth_remeshing_find_edges_to_flip(BMesh *bm, } return edges; } +#endif static bool cloth_remeshing_independent_edge_test(BMEdge *e, vector edges) { @@ -1251,6 +1328,29 @@ static BMVert *cloth_remeshing_edge_vert(BMEdge *e, int side, int i) return NULL; } +static BMVert *cloth_remeshing_edge_opposite_vert(BMEdge *e, int side) +{ + BMFace *f; + BMIter fiter; + int fi = 0; + BM_ITER_ELEM_INDEX (f, , e, BM_FACES_OF_EDGE, fi) { +if (fi == side) { + break; +} + } + if
[Bf-blender-cvs] [b6911a66c6a] soc-2019-adaptive-cloth: Cloth: improved updating active faces
Commit: b6911a66c6aff4f2fe1d86d35a42496e58c0c210 Author: ishbosamiya Date: Mon Jul 22 19:52:52 2019 +0530 Branches: soc-2019-adaptive-cloth https://developer.blender.org/rBb6911a66c6aff4f2fe1d86d35a42496e58c0c210 Cloth: improved updating active faces === M source/blender/blenkernel/intern/cloth_remeshing.cpp === diff --git a/source/blender/blenkernel/intern/cloth_remeshing.cpp b/source/blender/blenkernel/intern/cloth_remeshing.cpp index 338c61b96a7..2a30088fe1b 100644 --- a/source/blender/blenkernel/intern/cloth_remeshing.cpp +++ b/source/blender/blenkernel/intern/cloth_remeshing.cpp @@ -1328,7 +1328,7 @@ static void cloth_remeshing_update_active_faces(vector _faces, BMFace *f, *f2; BMIter fiter; vector new_active_faces; - /* add the newly created faces, all those that have that vertex v */ + /* add the newly created faces, all those that have that edge e */ BM_ITER_ELEM (f, , e, BM_FACES_OF_EDGE) { new_active_faces.push_back(f); } @@ -1397,6 +1397,27 @@ static void cloth_remeshing_update_active_faces(vector _faces, new_active_faces.clear(); } +/* Assumed that active_faces and fix_active have been updated before + * using either of the other 2 update_active_faces function so that + * there is no face that is not part of bm */ +static void cloth_remeshing_update_active_faces(vector active_faces, +vector fix_active) +{ + for (int i = 0; i < fix_active.size(); i++) { +bool already_exists = false; +for (int j = 0; j < active_faces.size(); j++) { + if (active_faces[j] == fix_active[i]) { +already_exists = true; +break; + } +} +if (already_exists) { + break; +} +active_faces.push_back(fix_active[i]); + } +} + static bool cloth_remeshing_collapse_edges(ClothModifierData *clmd, map , vector _faces, @@ -1423,9 +1444,16 @@ static bool cloth_remeshing_collapse_edges(ClothModifierData *clmd, /* run cloth_remeshing_fix_mesh on newly created faces by * cloth_remeshing_try_edge_collapse */ - cloth_remeshing_fix_mesh(clmd->clothObject->bm, sizing, active_faces); + vector fix_active; + BMFace *new_f; + BMIter new_f_iter; + BM_ITER_ELEM (new_f, _f_iter, temp_vert, BM_FACES_OF_VERT) { +fix_active.push_back(new_f); + } + cloth_remeshing_fix_mesh(clmd->clothObject->bm, sizing, fix_active); /* update active_faces */ + cloth_remeshing_update_active_faces(active_faces, fix_active); count++; return true; @@ -2197,7 +2225,7 @@ Mesh *cloth_remeshing_step(Depsgraph *depsgraph, Object *ob, ClothModifierData * { cloth_remeshing_init_bmesh(ob, clmd, mesh); - if (false) { + if (true) { cloth_remeshing_static(clmd); } else { ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [c4990aa9937] soc-2019-adaptive-cloth: Cloth: fix memory leak while finding nearest plane
Commit: c4990aa993752ebb1e19906ad78e8e2d20371aea Author: ishbosamiya Date: Sun Jul 21 15:58:38 2019 +0530 Branches: soc-2019-adaptive-cloth https://developer.blender.org/rBc4990aa993752ebb1e19906ad78e8e2d20371aea Cloth: fix memory leak while finding nearest plane === M source/blender/blenkernel/intern/cloth_remeshing.cpp === diff --git a/source/blender/blenkernel/intern/cloth_remeshing.cpp b/source/blender/blenkernel/intern/cloth_remeshing.cpp index e0407d0212c..338c61b96a7 100644 --- a/source/blender/blenkernel/intern/cloth_remeshing.cpp +++ b/source/blender/blenkernel/intern/cloth_remeshing.cpp @@ -2057,6 +2057,7 @@ static void cloth_remeshing_obstacle_metric( /*Now, actual obstacle metric calculation */ cloth_remeshing_find_nearest_planes(bm, collmd, 0.01f, planes); } + BKE_collision_objects_free(collobjs); } } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [412bce877ea] soc-2019-adaptive-cloth: Cloth: collapse edges debugging statements
Commit: 412bce877ea92ba5a01e483cfb79cd3e59b4a937 Author: ishbosamiya Date: Tue Jul 23 11:46:10 2019 +0530 Branches: soc-2019-adaptive-cloth https://developer.blender.org/rB412bce877ea92ba5a01e483cfb79cd3e59b4a937 Cloth: collapse edges debugging statements === M source/blender/blenkernel/intern/cloth_remeshing.cpp === diff --git a/source/blender/blenkernel/intern/cloth_remeshing.cpp b/source/blender/blenkernel/intern/cloth_remeshing.cpp index ae480227a44..50e27b44c7f 100644 --- a/source/blender/blenkernel/intern/cloth_remeshing.cpp +++ b/source/blender/blenkernel/intern/cloth_remeshing.cpp @@ -78,6 +78,8 @@ using namespace std; * reference http://graphics.berkeley.edu/papers/Narain-AAR-2012-11/index.html **/ +#define COLLAPSE_EDGES_DEBUG 1 + /** *The definition of sizing used for remeshing */ @@ -1162,9 +1164,12 @@ static bool cloth_remeshing_aspect_ratio(ClothModifierData *clmd, BMesh *bm, BME copy_v2_v2(temp_03, uvs[1]); sub_v2_v2(temp_03, uvs[2]); float a = cloth_remeshing_wedge(temp_01, temp_02) * 0.5f; -float p = len_v2(temp_01) + len_v2(temp_02) + len_v3(temp_03); /* This might be wrong */ +float p = len_v2(temp_01) + len_v2(temp_02) + len_v2(temp_03); /* This might be wrong */ float aspect = 12.0f * SQRT3 * a / (p * p); if (a < 1e-6 || aspect < clmd->sim_parms->aspect_min) { +#if COLLAPSE_EDGES_DEBUG + printf("aspect ratio: %f ", aspect); +#endif return false; } } @@ -1178,11 +1183,17 @@ static bool cloth_remeshing_can_collapse_edge(ClothModifierData *clmd, map ) { if (BM_edge_face_count(e) < 2) { +#if COLLAPSE_EDGES_DEBUG +printf("edge face count < 2\n"); +#endif return false; } /* aspect ratio parameter */ if (!cloth_remeshing_aspect_ratio(clmd, bm, e)) { +#if COLLAPSE_EDGES_DEBUG +printf("aspect ratio not satisfied\n"); +#endif return false; } @@ -1193,20 +1204,32 @@ static bool cloth_remeshing_can_collapse_edge(ClothModifierData *clmd, * fair pair even though face count is 2 or more * It might be fixed if the UV seams if fixed */ if (!f1 || !f2) { +# if COLLAPSE_EDGES_DEBUG +printf("Couldn't find face pair\n"); +# endif return false; } #endif BMVert *v_01 = BM_face_other_vert_loop(f1, e->v1, e->v2)->v; float size_01 = cloth_remeshing_edge_size_with_vert(bm, e, v_01, sizing); if (size_01 > (1.0f - REMESHING_HYSTERESIS_PARAMETER)) { +#if COLLAPSE_EDGES_DEBUG +printf("size_01: %f > 1.0f - REMESHING_HYSTERESIS_PARAMETER\n", size_01); +#endif return false; } BMVert *v_02 = BM_face_other_vert_loop(f2, e->v1, e->v2)->v; float size_02 = cloth_remeshing_edge_size_with_vert(bm, e, v_02, sizing); if (size_02 > (1.0f - REMESHING_HYSTERESIS_PARAMETER)) { +#if COLLAPSE_EDGES_DEBUG +printf("size_02: %f > 1.0f - REMESHING_HYSTERESIS_PARAMETER\n", size_02); +#endif return false; } +#if COLLAPSE_EDGES_DEBUG + printf("Can collapse this edge\n"); +#endif return true; } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [5be534cd40d] soc-2019-adaptive-cloth: Cloth: obstacle metric implemented
Commit: 5be534cd40db8184764f7bee16479d5fdea62023 Author: ishbosamiya Date: Sun Jul 21 13:39:52 2019 +0530 Branches: soc-2019-adaptive-cloth https://developer.blender.org/rB5be534cd40db8184764f7bee16479d5fdea62023 Cloth: obstacle metric implemented === M source/blender/blenkernel/BKE_cloth_remeshing.h M source/blender/blenkernel/intern/cloth.c M source/blender/blenkernel/intern/cloth_remeshing.cpp === diff --git a/source/blender/blenkernel/BKE_cloth_remeshing.h b/source/blender/blenkernel/BKE_cloth_remeshing.h index 2300e520cc4..de65a177973 100644 --- a/source/blender/blenkernel/BKE_cloth_remeshing.h +++ b/source/blender/blenkernel/BKE_cloth_remeshing.h @@ -36,7 +36,7 @@ struct Object; extern "C" { #endif -Mesh *cloth_remeshing_step(Object *ob, ClothModifierData *clmd, Mesh *mesh); +Mesh *cloth_remeshing_step(Depsgraph *depsgraph, Object *ob, ClothModifierData *clmd, Mesh *mesh); #ifdef __cplusplus } diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index bde0b66c735..320857984f3 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -382,7 +382,7 @@ static Mesh *do_step_cloth( // printf ( "%f\n", ( float ) tval() ); - Mesh *mesh_result = cloth_remeshing_step(ob, clmd, result); + Mesh *mesh_result = cloth_remeshing_step(depsgraph, ob, clmd, result); if (!ret) { return NULL; diff --git a/source/blender/blenkernel/intern/cloth_remeshing.cpp b/source/blender/blenkernel/intern/cloth_remeshing.cpp index 485ef7e1321..07b92b0181b 100644 --- a/source/blender/blenkernel/intern/cloth_remeshing.cpp +++ b/source/blender/blenkernel/intern/cloth_remeshing.cpp @@ -1525,9 +1525,11 @@ static void cloth_remeshing_static(ClothModifierData *clmd) #endif } -static map cloth_remeshing_compute_vertex_sizing(ClothModifierData *clmd); +static map cloth_remeshing_compute_vertex_sizing(Depsgraph *depsgraph, +Object *ob, + ClothModifierData *clmd); -static void cloth_remeshing_dynamic(ClothModifierData *clmd) +static void cloth_remeshing_dynamic(Depsgraph *depsgraph, Object *ob, ClothModifierData *clmd) { /** * mapping between the verts and its sizing @@ -1538,7 +1540,7 @@ static void cloth_remeshing_dynamic(ClothModifierData *clmd) /** * Define sizing dynamicly */ - sizing = cloth_remeshing_compute_vertex_sizing(clmd); + sizing = cloth_remeshing_compute_vertex_sizing(depsgraph, ob, clmd); /** * Split edges @@ -1886,17 +1888,90 @@ class ClothPlane { float no[3]; }; -/* map is (nearest_point) and the (v->co - nearest_point) */ -static map cloth_remeshing_find_nearest_planes(BMesh *bm, BVHTree *bvhtree) +/* Adapted from editmesh_bvh.c */ +struct FaceSearchUserData { + MVert *mvert; + MVertTri *mvert_tri; + + float dist_max_sq; +}; + +static void cloth_remeshing_find_closest_cb(void *userdata, +int index, +const float co[3], +BVHTreeNearest *hit) { - map planes; + struct FaceSearchUserData *data = (FaceSearchUserData *)userdata; + const float dist_max_sq = data->dist_max_sq; + + float tri_co_01[3]; + float tri_co_02[3]; + float tri_co_03[3]; + + copy_v3_v3(tri_co_01, data->mvert[data->mvert_tri[index].tri[0]].co); + copy_v3_v3(tri_co_02, data->mvert[data->mvert_tri[index].tri[1]].co); + copy_v3_v3(tri_co_03, data->mvert[data->mvert_tri[index].tri[2]].co); + + float co_close[3]; + closest_on_tri_to_point_v3(co_close, co, tri_co_01, tri_co_02, tri_co_03); + const float dist_sq = len_squared_v3v3(co, co_close); + if (dist_sq < hit->dist_sq && dist_sq < dist_max_sq) { +copy_v3_v3(hit->co, co_close); +float no[3]; +sub_v3_v3v3(no, co, co_close); +normalize_v3(no); +copy_v3_v3(hit->no, no); +hit->dist_sq = dist_sq; +hit->index = index; + } +} + +static void cloth_remeshing_find_nearest_planes(BMesh *bm, +CollisionModifierData *collmd, +float dist_max, +map r_planes) +{ + map = r_planes; BMVert *v; BMIter viter; + BVHTree *bvhtree = collmd->bvhtree; + float dist_max_sq = dist_max * dist_max; BM_ITER_MESH (v, , bm, BM_VERTS_OF_MESH) { +BVHTreeNearest hit; +FaceSearchUserData data; +hit.dist_sq = dist_max_sq; +hit.index = -1; + +data.mvert = collmd->x; +data.mvert_tri = collmd->tri; +data.dist_max_sq = dist_max_sq; +BLI_bvhtree_find_nearest(bvhtree, v->co, , cloth_remeshing_find_closest_cb, ); +if (hit.index !=
[Bf-blender-cvs] [4a4214e4a1f] soc-2019-adaptive-cloth: Cloth: split edges now flips edges for newly created faces
Commit: 4a4214e4a1f7ee733821e1adca986fbab5a768a7 Author: ishbosamiya Date: Sun Jul 21 15:54:21 2019 +0530 Branches: soc-2019-adaptive-cloth https://developer.blender.org/rB4a4214e4a1f7ee733821e1adca986fbab5a768a7 Cloth: split edges now flips edges for newly created faces === M source/blender/blenkernel/intern/cloth_remeshing.cpp === diff --git a/source/blender/blenkernel/intern/cloth_remeshing.cpp b/source/blender/blenkernel/intern/cloth_remeshing.cpp index 07b92b0181b..e0407d0212c 100644 --- a/source/blender/blenkernel/intern/cloth_remeshing.cpp +++ b/source/blender/blenkernel/intern/cloth_remeshing.cpp @@ -1014,6 +1014,14 @@ static bool cloth_remeshing_split_edges(ClothModifierData *clmd, cloth_remeshing_add_vertex_to_cloth(cloth, old_edge.v1, old_edge.v2, new_vert, sizing); +vector active_faces; +BMFace *af; +BMIter afiter; +BM_ITER_ELEM (af, , new_vert, BM_FACES_OF_VERT) { + active_faces.push_back(af); +} +cloth_remeshing_fix_mesh(bm, sizing, active_faces); + if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_SEW) { if (cloth_remeshing_find_next_loose_edge(old_edge.v1) != NULL && cloth_remeshing_find_next_loose_edge(old_edge.v2) != NULL) { @@ -2047,7 +2055,7 @@ static void cloth_remeshing_obstacle_metric( collision_move_object(collmd, step + dt, step); /*Now, actual obstacle metric calculation */ -cloth_remeshing_find_nearest_planes(bm, collmd, 10.0f, planes); +cloth_remeshing_find_nearest_planes(bm, collmd, 0.01f, planes); } } } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [4f363283eb2] master: Fix T67593: Crash when making link for instance collection
Commit: 4f363283eb2cd4f54a8278051c85ded18d1efa4a Author: Sergey Sharybin Date: Thu Jul 25 10:02:00 2019 +0200 Branches: master https://developer.blender.org/rB4f363283eb2cd4f54a8278051c85ded18d1efa4a Fix T67593: Crash when making link for instance collection === M source/blender/editors/object/object_relations.c === diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index e6637265fbc..ff31cbc4590 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -1582,6 +1582,7 @@ static int make_links_data_exec(bContext *C, wmOperator *op) id_us_plus(_dst->instance_collection->id); ob_dst->transflag |= OB_DUPLICOLLECTION; } +DEG_id_tag_update(_dst->id, ID_RECALC_COPY_ON_WRITE); break; case MAKE_LINKS_MODIFIERS: BKE_object_link_modifiers(scene, ob_dst, ob_src); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [829cbd88ff5] master: Fix T67588: Crash after clearing animation in outliner
Commit: 829cbd88ff5cef4ce31051562c1449fe5e565a88 Author: Sergey Sharybin Date: Thu Jul 25 09:46:27 2019 +0200 Branches: master https://developer.blender.org/rB829cbd88ff5cef4ce31051562c1449fe5e565a88 Fix T67588: Crash after clearing animation in outliner === M source/blender/editors/space_outliner/outliner_tools.c === diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c index 89eb3b9d953..f9905cc4fcd 100644 --- a/source/blender/editors/space_outliner/outliner_tools.c +++ b/source/blender/editors/space_outliner/outliner_tools.c @@ -747,6 +747,7 @@ static void clear_animdata_cb(int UNUSED(event), void *UNUSED(arg)) { BKE_animdata_free(tselem->id, true); + DEG_id_tag_update(tselem->id, ID_RECALC_ANIMATION); } static void unlinkact_animdata_cb(int UNUSED(event), @@ -756,6 +757,7 @@ static void unlinkact_animdata_cb(int UNUSED(event), { /* just set action to NULL */ BKE_animdata_set_action(NULL, tselem->id, NULL); + DEG_id_tag_update(tselem->id, ID_RECALC_ANIMATION); } static void cleardrivers_animdata_cb(int UNUSED(event), @@ -767,6 +769,7 @@ static void cleardrivers_animdata_cb(int UNUSED(event), /* just free drivers - stored as a list of F-Curves */ free_fcurves(>adt->drivers); + DEG_id_tag_update(tselem->id, ID_RECALC_ANIMATION); } static void refreshdrivers_animdata_cb(int UNUSED(event), @@ -1899,7 +1902,6 @@ static int outliner_animdata_operation_exec(bContext *C, wmOperator *op) SpaceOutliner *soops = CTX_wm_space_outliner(C); int scenelevel = 0, objectlevel = 0, idlevel = 0, datalevel = 0; eOutliner_AnimDataOps event; - short updateDeps = 0; /* check for invalid states */ if (soops == NULL) { @@ -1943,7 +1945,6 @@ static int outliner_animdata_operation_exec(bContext *C, wmOperator *op) WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN, NULL); // ED_undo_push(C, "Refresh Drivers"); /* no undo needed - shouldn't have any impact? */ - updateDeps = 1; break; case OUTLINER_ANIMOP_CLEAR_DRV: @@ -1952,7 +1953,6 @@ static int outliner_animdata_operation_exec(bContext *C, wmOperator *op) WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN, NULL); ED_undo_push(C, "Clear Drivers"); - updateDeps = 1; break; default: // invalid @@ -1960,10 +1960,7 @@ static int outliner_animdata_operation_exec(bContext *C, wmOperator *op) } /* update dependencies */ - if (updateDeps) { -/* rebuild depsgraph for the new deps */ -DEG_relations_tag_update(CTX_data_main(C)); - } + DEG_relations_tag_update(CTX_data_main(C)); return OPERATOR_FINISHED; } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [6a7fcf725e1] master: Fix app-template keymap preferences being ignored
Commit: 6a7fcf725e13b6c862f85f8f710cc281d9fb4d5e Author: Campbell Barton Date: Thu Jul 25 17:39:32 2019 +1000 Branches: master https://developer.blender.org/rB6a7fcf725e13b6c862f85f8f710cc281d9fb4d5e Fix app-template keymap preferences being ignored === M source/blender/blenkernel/intern/blender.c === diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 9fd3c24092c..805c098d238 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -306,6 +306,7 @@ void BKE_blender_userdef_app_template_data_swap(UserDef *userdef_a, UserDef *use LIST_SWAP(themes); LIST_SWAP(addons); LIST_SWAP(user_keymaps); + LIST_SWAP(user_keyconfig_prefs); DATA_SWAP(font_path_ui); DATA_SWAP(font_path_ui_mono); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [7de561f9303] functions: Merge branch 'master' into functions
Commit: 7de561f9303d5f570429a634a8cae89e61100929 Author: Jacques Lucke Date: Thu Jul 25 09:42:45 2019 +0200 Branches: functions https://developer.blender.org/rB7de561f9303d5f570429a634a8cae89e61100929 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] [d24300da5ff] master: Fix app-template keymap being ignored
Commit: d24300da5ff3f381023e2028c5e4b91cccb5ae95 Author: Campbell Barton Date: Thu Jul 25 16:31:02 2019 +1000 Branches: master https://developer.blender.org/rBd24300da5ff3f381023e2028c5e4b91cccb5ae95 Fix app-template keymap being ignored === 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 fd3e7a2d3fc..9de0f08f20b 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -1053,7 +1053,7 @@ void wm_homefile_read(bContext *C, wm_window_match_do(C, , >wm, >wm); } - if (use_factory_settings) { + if (use_userdef) { /* Clear keymaps because the current default keymap may have been initialized * from user preferences, which have been reset. */ for (wmWindowManager *wm = bmain->wm.first; wm; wm = wm->id.next) { ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [9e4cc7c6301] soc-2019-npr: Merge remote-tracking branch 'origin/master' into soc-2019-npr
Commit: 9e4cc7c6301f97ab74abb58caa6a9db7f2862fe9 Author: YimingWu Date: Thu Jul 25 14:34:45 2019 +0800 Branches: soc-2019-npr https://developer.blender.org/rB9e4cc7c6301f97ab74abb58caa6a9db7f2862fe9 Merge remote-tracking branch 'origin/master' into soc-2019-npr === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs