[Bf-blender-cvs] [fa566157a5c] master: PyAPI: unregister add-ons when exiting

2020-10-15 Thread Campbell Barton
Commit: fa566157a5c351775d082b05b180c630665b4afc
Author: Campbell Barton
Date:   Fri Oct 16 16:34:29 2020 +1100
Branches: master
https://developer.blender.org/rBfa566157a5c351775d082b05b180c630665b4afc

PyAPI: unregister add-ons when exiting

This lets add-on authors avoid false positive leaks when exiting.
In particular GPUShaders's although it applies to any PyObject that
stores memory allocated by guarded-alloc.

While this does add overhead on exit, on my system it's
under 1/100th of a second with all addons enabled.

See: T71362

===

M   source/blender/windowmanager/intern/wm_init_exit.c

===

diff --git a/source/blender/windowmanager/intern/wm_init_exit.c 
b/source/blender/windowmanager/intern/wm_init_exit.c
index 4ec3e1297d2..de47234695e 100644
--- a/source/blender/windowmanager/intern/wm_init_exit.c
+++ b/source/blender/windowmanager/intern/wm_init_exit.c
@@ -86,6 +86,7 @@
 #ifdef WITH_PYTHON
 #  include "BPY_extern.h"
 #  include "BPY_extern_python.h"
+#  include "BPY_extern_run.h"
 #endif
 
 #include "GHOST_C-api.h"
@@ -523,6 +524,14 @@ void WM_exit_ex(bContext *C, const bool do_python)
 }
   }
 
+#ifdef WITH_PYTHON
+  /* Without this, we there isn't a good way to manage false-positive resource 
leaks
+   * where a #PyObject references memory allocated with guarded-alloc, T71362.
+   *
+   * This allows add-ons to free resources when unregistered (which is good 
practice anyway). */
+  BPY_run_string_eval(C, (const char *[]){"addon_utils", NULL}, 
"addon_utils.disable_all()");
+#endif
+
   BLI_timer_free();
 
   WM_paneltype_clear();

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [f40294b2d68] master: Fix syntax error in IC-Keymap

2020-10-15 Thread Campbell Barton
Commit: f40294b2d68ba126bbdd3d39ce54148dd6f5bf9a
Author: Campbell Barton
Date:   Fri Oct 16 16:20:44 2020 +1100
Branches: master
https://developer.blender.org/rBf40294b2d68ba126bbdd3d39ce54148dd6f5bf9a

Fix syntax error in IC-Keymap

Regression in e936f042589eeb4c64a9b0df7cfd3b70ef49af22

===

M   
release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py

===

diff --git 
a/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py 
b/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
index f5f770deb84..99df1a422e3 100644
--- a/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
+++ b/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
@@ -462,7 +462,7 @@ def km_outliner(params):
 
 items.extend([
 ("outliner.item_rename", {"type": 'LEFTMOUSE', "value": 
'DOUBLE_CLICK'}, None),
-("outliner.item_rename", {"type": 'RET', "value": 'PRESS'}, None),
+("outliner.item_rename", {"type": 'RET', "value": 'PRESS'},
  {"properties": [("use_active", True)]}),
 ("wm.search_menu", {"type": 'TAB', "value": 'PRESS'}, None),
 ("outliner.highlight_update", {"type": 'MOUSEMOVE', "value": 'ANY', 
"any": True}, None),

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [0a2ae7f220a] master: RNA: support building WITH_PYTHON=OFF

2020-10-15 Thread Campbell Barton
Commit: 0a2ae7f220afd7b06f485947758acb4c27075955
Author: Campbell Barton
Date:   Fri Oct 16 15:56:03 2020 +1100
Branches: master
https://developer.blender.org/rB0a2ae7f220afd7b06f485947758acb4c27075955

RNA: support building WITH_PYTHON=OFF

===

M   source/blender/makesrna/intern/rna_render.c

===

diff --git a/source/blender/makesrna/intern/rna_render.c 
b/source/blender/makesrna/intern/rna_render.c
index 35563ad143e..05b3b0b0c70 100644
--- a/source/blender/makesrna/intern/rna_render.c
+++ b/source/blender/makesrna/intern/rna_render.c
@@ -27,7 +27,9 @@
 #include "BLI_path_util.h"
 #include "BLI_utildefines.h"
 
-#include "BPY_extern.h"
+#ifdef WITH_PYTHON
+#  include "BPY_extern.h"
+#endif
 
 #include "DEG_depsgraph.h"

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [507e7bcbdb9] master: Cleanup: assign variables for re-used context members

2020-10-15 Thread Campbell Barton
Commit: 507e7bcbdb944f424bbc017b1c4f56dd0b35a4f0
Author: Campbell Barton
Date:   Fri Oct 16 14:00:15 2020 +1100
Branches: master
https://developer.blender.org/rB507e7bcbdb944f424bbc017b1c4f56dd0b35a4f0

Cleanup: assign variables for re-used context members

===

M   release/scripts/startup/bl_ui/space_userpref.py

===

diff --git a/release/scripts/startup/bl_ui/space_userpref.py 
b/release/scripts/startup/bl_ui/space_userpref.py
index 604ec302b60..f2934c8c5e8 100644
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@ -1759,6 +1759,7 @@ class USERPREF_PT_addons(AddOnPanel, Panel):
 
 layout = self.layout
 
+wm = context.window_manager
 prefs = context.preferences
 used_ext = {ext.module for ext in prefs.addons}
 
@@ -1784,16 +1785,16 @@ class USERPREF_PT_addons(AddOnPanel, Panel):
 split = layout.split(factor=0.6)
 
 row = split.row()
-row.prop(context.window_manager, "addon_support", expand=True)
+row.prop(wm, "addon_support", expand=True)
 
 row = split.row(align=True)
 row.operator("preferences.addon_install", icon='IMPORT', 
text="Install...")
 row.operator("preferences.addon_refresh", icon='FILE_REFRESH', 
text="Refresh")
 
 row = layout.row()
-row.prop(context.preferences.view, "show_addons_enabled_only")
-row.prop(context.window_manager, "addon_filter", text="")
-row.prop(context.window_manager, "addon_search", text="", 
icon='VIEWZOOM')
+row.prop(prefs.view, "show_addons_enabled_only")
+row.prop(wm, "addon_filter", text="")
+row.prop(wm, "addon_search", text="", icon='VIEWZOOM')
 
 col = layout.column()
 
@@ -1818,10 +1819,10 @@ class USERPREF_PT_addons(AddOnPanel, Panel):
 "(see console for details)",
 )
 
-show_enabled_only = context.preferences.view.show_addons_enabled_only
-filter = context.window_manager.addon_filter
-search = context.window_manager.addon_search.lower()
-support = context.window_manager.addon_support
+show_enabled_only = prefs.view.show_addons_enabled_only
+filter = wm.addon_filter
+search = wm.addon_search.lower()
+support = wm.addon_support
 
 # initialized on demand
 user_addon_paths = []

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [9fb2ce70d69] master: Cleanup: remove f-string use

2020-10-15 Thread Campbell Barton
Commit: 9fb2ce70d69eb8d36a814ea5a430c3da4cc73551
Author: Campbell Barton
Date:   Fri Oct 16 14:06:47 2020 +1100
Branches: master
https://developer.blender.org/rB9fb2ce70d69eb8d36a814ea5a430c3da4cc73551

Cleanup: remove f-string use

===

M   release/scripts/startup/bl_ui/space_userpref.py

===

diff --git a/release/scripts/startup/bl_ui/space_userpref.py 
b/release/scripts/startup/bl_ui/space_userpref.py
index f2934c8c5e8..77b0f17a937 100644
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@ -1036,7 +1036,7 @@ class USERPREF_PT_theme_collection_colors(ThemePanel, 
CenterAlignMixIn, Panel):
 
 flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, 
even_rows=False, align=False)
 for i, ui in enumerate(theme.collection_color, 1):
-flow.prop(ui, "color", text=iface_(f"Color {i:d}"), 
translate=False)
+flow.prop(ui, "color", text=iface_("Color %d") % i, 
translate=False)
 
 
 # Base class for dynamically defined theme-space panels.

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [fa0ceb4959c] master: Cleanup: spelling

2020-10-15 Thread Campbell Barton
Commit: fa0ceb4959cb5f943e73e06fcbb47ce18cea80e7
Author: Campbell Barton
Date:   Fri Oct 16 11:46:48 2020 +1100
Branches: master
https://developer.blender.org/rBfa0ceb4959cb5f943e73e06fcbb47ce18cea80e7

Cleanup: spelling

===

M   source/blender/blenlib/BLI_task.hh
M   source/blender/editors/sculpt_paint/sculpt_intern.h

===

diff --git a/source/blender/blenlib/BLI_task.hh 
b/source/blender/blenlib/BLI_task.hh
index a3679bfbc0d..8a0d77745c8 100644
--- a/source/blender/blenlib/BLI_task.hh
+++ b/source/blender/blenlib/BLI_task.hh
@@ -32,7 +32,7 @@
 #  include 
 #  ifdef WIN32
 /* We cannot keep this defined, since other parts of the code deal with this 
on their own leading
- * to multiple define warnings unless we undefine this. */
+ * to multiple define warnings unless we un-define this. */
 #undef NOMINMAX
 #  endif
 #endif
diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h 
b/source/blender/editors/sculpt_paint/sculpt_intern.h
index 916e7336c37..6055f4e4c8b 100644
--- a/source/blender/editors/sculpt_paint/sculpt_intern.h
+++ b/source/blender/editors/sculpt_paint/sculpt_intern.h
@@ -329,7 +329,7 @@ enum eDynTopoWarnFlag SCULPT_dynamic_topology_check(Scene 
*scene, Object *ob);
 
 void SCULPT_pbvh_clear(Object *ob);
 
-/* Automasking. */
+/* Auto-masking. */
 float SCULPT_automasking_factor_get(struct AutomaskingCache *automasking,
 SculptSession *ss,
 int vert);
@@ -835,8 +835,8 @@ typedef struct AutomaskingSettings {
 
 typedef struct AutomaskingCache {
   AutomaskingSettings settings;
-  /* Precomputed automask factor indexed by vertex, owned by the automasking 
system and initialized
-   * in SCULPT_automasking_cache_init when needed. */
+  /* Precomputed auto-mask factor indexed by vertex, owned by the auto-masking 
system and
+   * initialized in #SCULPT_automasking_cache_init when needed. */
   float *factor;
 } AutomaskingCache;
 
@@ -874,7 +874,7 @@ typedef struct StrokeCache {
   float y_tilt;
 
   /* Position of the mouse corresponding to the stroke location, modified by 
the paint_stroke
-   * operator acording to the stroke type. */
+   * operator according to the stroke type. */
   float mouse[2];
   /* Position of the mouse event in screen space, not modified by the stroke 
type. */
   float mouse_event[2];
@@ -984,7 +984,7 @@ typedef struct StrokeCache {
   float true_gravity_direction[3];
   float gravity_direction[3];
 
-  /* Automasking. */
+  /* Auto-masking. */
   AutomaskingCache *automasking;
 
   float stroke_local_mat[4][4];
@@ -1062,7 +1062,7 @@ typedef struct FilterCache {
 
   int active_face_set;
 
-  /* Automasking. */
+  /* Auto-masking. */
   AutomaskingCache *automasking;
 } FilterCache;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [d1fbcbe1674] usd-importer-T81257: Format fixes.

2020-10-15 Thread Michael A. Kowalski
Commit: d1fbcbe16744fa68a1531c5476646e1dec260de1
Author: Michael A. Kowalski
Date:   Thu Oct 15 19:44:21 2020 -0400
Branches: usd-importer-T81257
https://developer.blender.org/rBd1fbcbe16744fa68a1531c5476646e1dec260de1

Format fixes.

===

M   source/blender/blenkernel/BKE_editmesh_bvh.h
M   source/blender/io/usd/intern/usd_capi.cc

===

diff --git a/source/blender/blenkernel/BKE_editmesh_bvh.h 
b/source/blender/blenkernel/BKE_editmesh_bvh.h
index 8c800ea9529..69d1b4819f8 100644
--- a/source/blender/blenkernel/BKE_editmesh_bvh.h
+++ b/source/blender/blenkernel/BKE_editmesh_bvh.h
@@ -91,7 +91,7 @@ struct BVHTreeOverlap *BKE_bmbvh_overlap(const BMBVHTree 
*bmtree_a,
  unsigned int *r_overlap_tot);
 
 struct BVHTreeOverlap *BKE_bmbvh_overlap_self(const BMBVHTree *bmtree,
- unsigned int *r_overlap_tot);
+  unsigned int *r_overlap_tot);
 
 /** #BKE_bmbvh_new flag parameter. */
 enum {
diff --git a/source/blender/io/usd/intern/usd_capi.cc 
b/source/blender/io/usd/intern/usd_capi.cc
index 40a9bbce162..212e0014c3f 100644
--- a/source/blender/io/usd/intern/usd_capi.cc
+++ b/source/blender/io/usd/intern/usd_capi.cc
@@ -17,9 +17,9 @@
  * All rights reserved.
  */
 
+#include "import/usd_import_util.h"
 #include "import/usd_importer_context.h"
 #include "import/usd_reader_object.h"
-#include "import/usd_import_util.h"
 #include "usd.h"
 #include "usd_hierarchy_iterator.h"

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [20029f91b0e] usd-importer-T81257: USD importer: fixed scene scaling.

2020-10-15 Thread Michael A. Kowalski
Commit: 20029f91b0ea587ecbfc2bb260fd489347b99c49
Author: Michael A. Kowalski
Date:   Thu Oct 15 19:19:05 2020 -0400
Branches: usd-importer-T81257
https://developer.blender.org/rB20029f91b0ea587ecbfc2bb260fd489347b99c49

USD importer: fixed scene scaling.

===

M   source/blender/io/usd/import/usd_reader_object.cc

===

diff --git a/source/blender/io/usd/import/usd_reader_object.cc 
b/source/blender/io/usd/import/usd_reader_object.cc
index 55eb0328acb..1ffa698f567 100644
--- a/source/blender/io/usd/import/usd_reader_object.cc
+++ b/source/blender/io/usd/import/usd_reader_object.cc
@@ -159,9 +159,12 @@ void UsdObjectReader::read_matrix(float r_mat[4][4] /* 
local matrix */,
 copy_m44_axis_swap(r_mat, r_mat, USD_ZUP_FROM_YUP);
   }
 
-  float scale_mat[4][4];
-  scale_m4_fl(scale_mat, scale);
-  mul_m4_m4m4(r_mat, scale_mat, r_mat);
+  /* Apply scaling only to root objects, parenting will propagate it. */
+  if (!this->parent_) {
+float scale_mat[4][4];
+scale_m4_fl(scale_mat, scale);
+mul_m4_m4m4(r_mat, scale_mat, r_mat);
+  }
 }
 
 double UsdObjectReader::minTime() const

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [00f7b572d9e] master: Windows: Fix build issue on windows

2020-10-15 Thread Ray Molenkamp
Commit: 00f7b572d9ebce1af0e9b5afc5d53467374ca738
Author: Ray Molenkamp
Date:   Thu Oct 15 17:14:57 2020 -0600
Branches: master
https://developer.blender.org/rB00f7b572d9ebce1af0e9b5afc5d53467374ca738

Windows: Fix build issue on windows

TBB includes Windows.h which defines a min/max macro
leading to issues when you want to use std::min and
std::max.

This change prevents Windows.h from defining them
sidestepping the issue.

===

M   source/blender/blenlib/BLI_task.hh

===

diff --git a/source/blender/blenlib/BLI_task.hh 
b/source/blender/blenlib/BLI_task.hh
index 7e60f271e9d..a3679bfbc0d 100644
--- a/source/blender/blenlib/BLI_task.hh
+++ b/source/blender/blenlib/BLI_task.hh
@@ -23,7 +23,18 @@
 #ifdef WITH_TBB
 /* Quiet top level deprecation message, unrelated to API usage here. */
 #  define TBB_SUPPRESS_DEPRECATED_MESSAGES 1
+
+#  ifdef WIN32
+/* TBB includes Windows.h which will define min/max macros causing issues
+ * when we try to use std::min and std::max later on. */
+#define NOMINMAX
+#  endif
 #  include 
+#  ifdef WIN32
+/* We cannot keep this defined, since other parts of the code deal with this 
on their own leading
+ * to multiple define warnings unless we undefine this. */
+#undef NOMINMAX
+#  endif
 #endif
 
 #include "BLI_index_range.hh"

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [6ca64058b37] usd-importer-T81257: USD importer xform bug fix.

2020-10-15 Thread Michael A. Kowalski
Commit: 6ca64058b3719a357c15386bc8b55436f8467f86
Author: Michael A. Kowalski
Date:   Thu Oct 15 18:08:29 2020 -0400
Branches: usd-importer-T81257
https://developer.blender.org/rB6ca64058b3719a357c15386bc8b55436f8467f86

USD importer xform bug fix.

Fixed matrix multiplication order when computing
local transform for merged objects.

===

M   source/blender/io/usd/import/usd_reader_object.cc

===

diff --git a/source/blender/io/usd/import/usd_reader_object.cc 
b/source/blender/io/usd/import/usd_reader_object.cc
index 19e77a08484..55eb0328acb 100644
--- a/source/blender/io/usd/import/usd_reader_object.cc
+++ b/source/blender/io/usd/import/usd_reader_object.cc
@@ -141,7 +141,7 @@ void UsdObjectReader::read_matrix(float r_mat[4][4] /* 
local matrix */,
   pxr::GfMatrix4d usd_parent_local_xf;
   parent_xformable.GetLocalTransformation(&usd_parent_local_xf, 
&reset_xform_stack, time);
 
-  usd_local_xf = usd_parent_local_xf * usd_local_xf;
+  usd_local_xf = usd_local_xf * usd_parent_local_xf;
 }
   }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [ba8233174cd] master: Fix build error with clean builds

2020-10-15 Thread Julian Eisel
Commit: ba8233174cd72ded420ff0668cf8c4a99a813534
Author: Julian Eisel
Date:   Thu Oct 15 22:58:33 2020 +0200
Branches: master
https://developer.blender.org/rBba8233174cd72ded420ff0668cf8c4a99a813534

Fix build error with clean builds

Needed after d1b3439b80fd6e. Think the error only happened with fresh builds,
where dna_type_offsets.h didn't already exist.

We have to do the same in other places too, see 8594cdb45684.

===

M   source/blender/gpencil_modifiers/CMakeLists.txt

===

diff --git a/source/blender/gpencil_modifiers/CMakeLists.txt 
b/source/blender/gpencil_modifiers/CMakeLists.txt
index 2cedc5675f7..cb4d74559a4 100644
--- a/source/blender/gpencil_modifiers/CMakeLists.txt
+++ b/source/blender/gpencil_modifiers/CMakeLists.txt
@@ -81,3 +81,5 @@ endif()
 
 
 blender_add_lib(bf_gpencil_modifiers "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
+
+add_dependencies(bf_gpencil_modifiers bf_dna)

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [e936f042589] master: Outliner: Use operator option to decide which item to rename

2020-10-15 Thread Julian Eisel
Commit: e936f042589eeb4c64a9b0df7cfd3b70ef49af22
Author: Julian Eisel
Date:   Thu Oct 15 21:11:31 2020 +0200
Branches: master
https://developer.blender.org/rBe936f042589eeb4c64a9b0df7cfd3b70ef49af22

Outliner: Use operator option to decide which item to rename

The `outliner.item_rename` operator needs to decide if it should rename the
active or the hovered item. Previously it checked if the event is a press
event, which is a hacky way of doing this and limit how the operator can be
used in the keymap.
Now use a operator option to let this be controlled on the keymap level.

Doesn't change any default behavior.

===

M   release/scripts/presets/keyconfig/keymap_data/blender_default.py
M   
release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
M   source/blender/editors/space_outliner/outliner_edit.c

===

diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py 
b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index 6674751f9b8..b27cdbec308 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -773,7 +773,8 @@ def km_outliner(params):
 items.extend([
 ("outliner.highlight_update", {"type": 'MOUSEMOVE', "value": 'ANY', 
"any": True}, None),
 ("outliner.item_rename", {"type": 'LEFTMOUSE', "value": 
'DOUBLE_CLICK'}, None),
-("outliner.item_rename", {"type": 'F2', "value": 'PRESS'}, None),
+("outliner.item_rename", {"type": 'F2', "value": 'PRESS'},
+ {"properties": [("use_active", True)]}),
 ("outliner.item_activate", {"type": 'LEFTMOUSE', "value": 'CLICK'},
  {"properties": [("extend", False), ("deselect_all", not 
params.legacy)]}),
 ("outliner.item_activate", {"type": 'LEFTMOUSE', "value": 'CLICK', 
"ctrl": True},
diff --git 
a/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py 
b/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
index c462ac55c53..f5f770deb84 100644
--- a/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
+++ b/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
@@ -463,6 +463,7 @@ def km_outliner(params):
 items.extend([
 ("outliner.item_rename", {"type": 'LEFTMOUSE', "value": 
'DOUBLE_CLICK'}, None),
 ("outliner.item_rename", {"type": 'RET', "value": 'PRESS'}, None),
+ {"properties": [("use_active", True)]}),
 ("wm.search_menu", {"type": 'TAB', "value": 'PRESS'}, None),
 ("outliner.highlight_update", {"type": 'MOUSEMOVE', "value": 'ANY', 
"any": True}, None),
 ("outliner.item_activate", {"type": 'LEFTMOUSE', "value": 'CLICK'},
diff --git a/source/blender/editors/space_outliner/outliner_edit.c 
b/source/blender/editors/space_outliner/outliner_edit.c
index 4a9aa984398..779efc3cacb 100644
--- a/source/blender/editors/space_outliner/outliner_edit.c
+++ b/source/blender/editors/space_outliner/outliner_edit.c
@@ -363,35 +363,48 @@ void item_rename_fn(bContext *C,
   do_item_rename(region, te, tselem, reports);
 }
 
-static int outliner_item_rename(bContext *C, wmOperator *op, const wmEvent 
*event)
+static TreeElement *outliner_item_rename_find_active(const SpaceOutliner 
*space_outliner,
+ ReportList *reports)
 {
-  ARegion *region = CTX_wm_region(C);
-  SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
-  float fmval[2];
+  TreeElement *active_element = 
outliner_find_element_with_flag(&space_outliner->tree, TSE_ACTIVE);
 
-  /* Rename active element if key pressed, otherwise rename element at cursor 
coordinates */
-  if (event->val == KM_PRESS) {
-TreeElement *active_element = 
outliner_find_element_with_flag(&space_outliner->tree,
-  TSE_ACTIVE);
+  if (!active_element) {
+BKE_report(reports, RPT_WARNING, "No active item to rename");
+return NULL;
+  }
 
-if (active_element) {
-  do_item_rename(region, active_element, TREESTORE(active_element), 
op->reports);
-}
-else {
-  BKE_report(op->reports, RPT_WARNING, "No active item to rename");
-}
+  return active_element;
+}
+
+static TreeElement *outliner_item_rename_find_hovered(const SpaceOutliner 
*space_outliner,
+  ARegion *region,
+  const wmEvent *event)
+{
+  float fmval[2];
+  UI_view2d_region_to_view(®ion->v2d, event->mval[0], event->mval[1], 
&fmval[0], &fmval[1]);
+
+  TreeElement *hovered = outliner_find_item_at_y(space_outliner, 
&space_outliner->tree, fmval[1]);
+  if (hovered && outliner_item_is_co_over_name(hovered, fmval[0])) {
+return hovered;
   }
-  else {
-   

[Bf-blender-cvs] [0a66436fe5f] master: Fix T76597: Support Keyframe: Copy To Selected

2020-10-15 Thread Wayde Moss
Commit: 0a66436fe5f26f8d7b6fb49396f21313fded8654
Author: Wayde Moss
Date:   Thu Oct 15 14:53:26 2020 -0400
Branches: master
https://developer.blender.org/rB0a66436fe5f26f8d7b6fb49396f21313fded8654

Fix T76597: Support Keyframe: Copy To Selected

Reviewed By: Sybren, Luciano Muñoz Sessarego

Differential Revision: https://developer.blender.org/D7783

===

M   source/blender/editors/interface/interface_ops.c
M   source/blender/editors/screen/screen_context.c

===

diff --git a/source/blender/editors/interface/interface_ops.c 
b/source/blender/editors/interface/interface_ops.c
index 4cb8a47690e..2b91d1b273d 100644
--- a/source/blender/editors/interface/interface_ops.c
+++ b/source/blender/editors/interface/interface_ops.c
@@ -816,6 +816,9 @@ bool UI_context_copy_to_selected_list(bContext *C,
   else if (RNA_struct_is_a(ptr->type, &RNA_FCurve)) {
 *r_lb = CTX_data_collection_get(C, "selected_editable_fcurves");
   }
+  else if (RNA_struct_is_a(ptr->type, &RNA_Keyframe)) {
+*r_lb = CTX_data_collection_get(C, "selected_editable_keyframes");
+  }
   else if (RNA_struct_is_a(ptr->type, &RNA_NlaStrip)) {
 *r_lb = CTX_data_collection_get(C, "selected_nla_strips");
   }
diff --git a/source/blender/editors/screen/screen_context.c 
b/source/blender/editors/screen/screen_context.c
index 74621b917c6..0fa19f76fed 100644
--- a/source/blender/editors/screen/screen_context.c
+++ b/source/blender/editors/screen/screen_context.c
@@ -109,6 +109,7 @@ const char *screen_context_dir[] = {
 "selected_visible_fcurves",
 "selected_editable_fcurves",
 "active_editable_fcurve",
+"selected_editable_keyframes",
 NULL,
 };
 
@@ -984,6 +985,46 @@ static eContextResult 
screen_ctx_active_editable_fcurve(const bContext *C,
   }
   return CTX_RESULT_NO_DATA;
 }
+static eContextResult screen_ctx_selected_editable_keyframes(const bContext *C,
+ 
bContextDataResult *result)
+{
+  bAnimContext ac;
+  if (ANIM_animdata_get_context(C, &ac) && ELEM(ac.spacetype, SPACE_ACTION, 
SPACE_GRAPH)) {
+ListBase anim_data = {NULL, NULL};
+
+/* Use keyframes from editable selected FCurves. */
+int filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_NODUPLIS | 
ANIMFILTER_FOREDIT |
+  ANIMFILTER_SEL) |
+ (ac.spacetype == SPACE_GRAPH ? ANIMFILTER_CURVE_VISIBLE :
+ANIMFILTER_LIST_VISIBLE);
+
+ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
+
+int i;
+FCurve *fcurve;
+BezTriple *bezt;
+LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
+  if (!ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE)) {
+continue;
+  }
+
+  fcurve = (FCurve *)ale->data;
+  for (i = 0, bezt = fcurve->bezt; i < fcurve->totvert; i++, bezt++) {
+if ((bezt->f2 & SELECT) == 0) {
+  continue;
+}
+
+CTX_data_list_add(result, ale->fcurve_owner_id, &RNA_Keyframe, bezt);
+  }
+}
+
+ANIM_animdata_freelist(&anim_data);
+
+CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
+return CTX_RESULT_OK;
+  }
+  return CTX_RESULT_NO_DATA;
+}
 
 /* Registry of context callback functions. */
 
@@ -1058,6 +1099,7 @@ static void ensure_ed_screen_context_functions(void)
   register_context_function("selected_editable_fcurves", 
screen_ctx_selected_editable_fcurves);
   register_context_function("selected_visible_fcurves", 
screen_ctx_selected_visible_fcurves);
   register_context_function("active_editable_fcurve", 
screen_ctx_active_editable_fcurve);
+  register_context_function("selected_editable_keyframes", 
screen_ctx_selected_editable_keyframes);
 }
 
 /* Entry point for the screen context. */

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [f9fa24f4bd5] temp-trimesh-sculpt: commit before merging in recent master commits

2020-10-15 Thread Joseph Eagar
Commit: f9fa24f4bd5a0562017825aae4e9e1158acda055
Author: Joseph Eagar
Date:   Thu Oct 15 11:51:55 2020 -0700
Branches: temp-trimesh-sculpt
https://developer.blender.org/rBf9fa24f4bd5a0562017825aae4e9e1158acda055

commit before merging in recent master commits

===

M   source/blender/blenkernel/intern/pbvh.c
M   source/blender/blenkernel/intern/pbvh_trimesh.c
M   source/blender/gpu/intern/gpu_buffers.c

===

diff --git a/source/blender/blenkernel/intern/pbvh.c 
b/source/blender/blenkernel/intern/pbvh.c
index 915e011a19b..be481aa035a 100644
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@ -1375,6 +1375,11 @@ static void pbvh_update_draw_buffers(PBVH *pbvh, 
PBVHNode **nodes, int totnode,
 /* Free buffers uses OpenGL, so not in parallel. */
 for (int n = 0; n < totnode; n++) {
   PBVHNode *node = nodes[n];
+  if (node->flag & PBVH_Delete) {
+printf("corrupted node! %p\n", node);
+return;
+  }
+
   if (node->flag & PBVH_RebuildDrawBuffers) {
 GPU_pbvh_buffers_free(node->draw_buffers);
 node->draw_buffers = NULL;
@@ -2843,7 +2848,7 @@ void BKE_pbvh_draw_cb(PBVH *pbvh,
   for (int a = 0; a < totnode; a++) {
 PBVHNode *node = nodes[a];
 
-if (node->flag & PBVH_UpdateDrawBuffers) {
+if (node->flag & PBVH_UpdateDrawBuffers && node->draw_buffers) {
   /* Flush buffers uses OpenGL, so not in parallel. */
   GPU_pbvh_buffers_update_flush(node->draw_buffers);
 }
diff --git a/source/blender/blenkernel/intern/pbvh_trimesh.c 
b/source/blender/blenkernel/intern/pbvh_trimesh.c
index 57b79d2df02..6331c86c210 100644
--- a/source/blender/blenkernel/intern/pbvh_trimesh.c
+++ b/source/blender/blenkernel/intern/pbvh_trimesh.c
@@ -85,11 +85,18 @@ TMElemSet *TMElemSet_new() {
 }
 
 void TMElemSet_free(TMElemSet *ts) {
+  if (!ts->ptr_to_idx) {
+printf("double call to TMElemSet_free!\n");
+return;
+  }
+
   if (ts->elems) {
 MEM_freeN(ts->elems);
   }
 
   BLI_ghash_free(ts->ptr_to_idx, NULL, NULL);
+  ts->ptr_to_idx = NULL;
+
   MEM_freeN(ts);
 }
 
@@ -2068,7 +2075,7 @@ void BKE_pbvh_build_trimesh(PBVH *bvh,
   bvh->tm_log = log;
 
   /* TODO: choose leaf limit better */
-  bvh->leaf_limit = 1;
+  bvh->leaf_limit = 5000;
 
   if (smooth_shading) {
 bvh->flags |= PBVH_DYNTOPO_SMOOTH_SHADING;
@@ -2449,6 +2456,18 @@ void BKE_pbvh_trimesh_after_stroke(PBVH *bvh)
 n->tm_subtree_tottri = 0;
   }
 
+#if 1
+
+  for (int i=0; itotnode; i++) {
+PBVHNode *n = bvh->nodes + i;
+
+if (n->flag & PBVH_Leaf) {
+  /* Recursively split nodes that have gotten too many
+  * elements */
+  pbvh_trimesh_node_limit_ensure(bvh, i);
+}
+  }
+#else
   pbvh_count_subtree_verts(bvh, bvh->nodes);
 
   BKE_pbvh_trimesh_corect_tree(bvh, bvh->nodes, NULL);
@@ -2509,7 +2528,12 @@ void BKE_pbvh_trimesh_after_stroke(PBVH *bvh)
   int i1 = map[bvh->nodes[i].children_offset];
   int i2 = map[bvh->nodes[i].children_offset+1];
 
-  if (bvh->nodes[j].children_offset && i2 != i1 + 1) {
+  if (bvh->nodes[i].children_offset >= bvh->totnode) {
+printf("bad child node reference %d->%d\n", i, 
bvh->nodes[i].children_offset);
+continue;
+  }
+
+  if (bvh->nodes[i].children_offset && i2 != i1 + 1) {
 printf("  EVIL %d %d\n", i1, i2);
   }
 
@@ -2523,7 +2547,7 @@ void BKE_pbvh_trimesh_after_stroke(PBVH *bvh)
   if (j != totnode) {
 printf("eek!");
   }
-  bvh->totnode = totnode;
+  bvh->totnode = j;
 
   GSetIterator gsiter;
   TMVert *v;
@@ -2557,8 +2581,8 @@ void BKE_pbvh_trimesh_after_stroke(PBVH *bvh)
 }
   }
 
+#endif
   //BKE_pbvh_update_vertex_data(bvh, 
PBVH_UpdateVisibility|PBVH_UpdateMask|PBVH_UpdateColor);
-  return;
 #if 0
   for (int i = 0; i < bvh->totnode; i++) {
 PBVHNode *n = &bvh->nodes[i];
diff --git a/source/blender/gpu/intern/gpu_buffers.c 
b/source/blender/gpu/intern/gpu_buffers.c
index 973178d7945..489b1668566 100644
--- a/source/blender/gpu/intern/gpu_buffers.c
+++ b/source/blender/gpu/intern/gpu_buffers.c
@@ -848,9 +848,10 @@ static void gpu_trimesh_vert_to_buffer_copy(TMVert *v,
   GPU_vertbuf_attr_set(vert_buf, g_vbo_id.nor, v_index, no_short);
 
   if (show_mask) {
-//float effective_mask = fmask ? *fmask : TM_ELEM_CD_GET_FLOAT(v, 
cd_vert_mask_offset);
-int ni = TM_ELEM_CD_GET_INT(v, cd_vert_node_offset);
-float effective_mask = (float)(ni % 64) / 64.0f;
+float effective_mask = fmask ? *fmask : TM_ELEM_CD_GET_FLOAT(v, 
cd_vert_mask_offset);
+//int ni = TM_ELEM_CD_GET_INT(v, cd_vert_node_offset);
+//float effective_mask = (float)(ni % 64) / 64.0f;
+
 uchar cmask = (uchar)(effective_mask * 255);
 GPU_vertbuf_attr_set(vert_buf, g_vbo_id.msk, v_index, &cmask);
 *empty_mask = *empty_mask && (cmask == 0);

_

[Bf-blender-cvs] [a88076e948a] master: Fix error in previous commit

2020-10-15 Thread Julian Eisel
Commit: a88076e948a93c087e1b20bb3d3c424db0f39fbe
Author: Julian Eisel
Date:   Thu Oct 15 20:39:20 2020 +0200
Branches: master
https://developer.blender.org/rBa88076e948a93c087e1b20bb3d3c424db0f39fbe

Fix error in previous commit

Missing null-check, could lead to null-pointer dereference.

===

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 85e841538d6..4a9aa984398 100644
--- a/source/blender/editors/space_outliner/outliner_edit.c
+++ b/source/blender/editors/space_outliner/outliner_edit.c
@@ -387,7 +387,7 @@ static int outliner_item_rename(bContext *C, wmOperator 
*op, const wmEvent *even
 TreeElement *hovered = outliner_find_item_at_y(
 space_outliner, &space_outliner->tree, fmval[1]);
 
-if (outliner_item_is_co_over_name(hovered, fmval[0])) {
+if (hovered && outliner_item_is_co_over_name(hovered, fmval[0])) {
   do_item_rename(region, hovered, TREESTORE(hovered), op->reports);
 }
   }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [5129e2e042a] master: Fix T81675: Renaming collapsed collection in Outliner renames nested items

2020-10-15 Thread Julian Eisel
Commit: 5129e2e042a057a28ea75e4342a664277c74ca34
Author: Julian Eisel
Date:   Thu Oct 15 20:00:18 2020 +0200
Branches: master
https://developer.blender.org/rB5129e2e042a057a28ea75e4342a664277c74ca34

Fix T81675: Renaming collapsed collection in Outliner renames nested items

* `do_outliner_item_rename()` enables the rename mode for the item under the
  cursor. Issue is, collapsed children end up having stored the same coordinate
  as their parent, so they too would get the rename mode enabled (there is no
  early-exit that would hide this).
* The items displayed as inline icons do get the proper coordinates of the
  icons, so they are not mistaken as being under the cursor.

After rBb077de086e14, the Outliner tree is rebuilt less often, so the
coordinates are cleared less often too.

As far as I can see we can always clear coordinates of invisible items now. No
code seems to depend on keeping the old coordinates anymore.

===

M   source/blender/editors/space_outliner/outliner_draw.c

===

diff --git a/source/blender/editors/space_outliner/outliner_draw.c 
b/source/blender/editors/space_outliner/outliner_draw.c
index 22bc0119652..09ccb950c18 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -2915,9 +2915,9 @@ static void outliner_set_coord_tree_element(TreeElement 
*te, int startx, int sta
 
   /* closed items may be displayed in row of parent, don't change their 
coordinate! */
   if ((te->flag & TE_ICONROW) == 0 && (te->flag & TE_ICONROW_MERGED) == 0) {
-/* store coord and continue, we need coordinates for elements outside view 
too */
-te->xs = startx;
-te->ys = starty;
+te->xs = 0;
+te->ys = 0;
+te->xend = 0;
   }
 
   for (ten = te->subtree.first; ten; ten = ten->next) {

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [d4f94d8a310] master: Cleanup: Refactor lookup for hovered Outliner element for renaming

2020-10-15 Thread Julian Eisel
Commit: d4f94d8a31044af489d4821966854a7bc8975d23
Author: Julian Eisel
Date:   Thu Oct 15 20:23:13 2020 +0200
Branches: master
https://developer.blender.org/rBd4f94d8a31044af489d4821966854a7bc8975d23

Cleanup: Refactor lookup for hovered Outliner element for renaming

* Use existing and optimized lookup function, rather than own duplicated logic.
* Move low-level coordinate check into general function, alongside similar
  ones.

===

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_utils.c

===

diff --git a/source/blender/editors/space_outliner/outliner_edit.c 
b/source/blender/editors/space_outliner/outliner_edit.c
index abfec4fc2aa..85e841538d6 100644
--- a/source/blender/editors/space_outliner/outliner_edit.c
+++ b/source/blender/editors/space_outliner/outliner_edit.c
@@ -363,25 +363,6 @@ void item_rename_fn(bContext *C,
   do_item_rename(region, te, tselem, reports);
 }
 
-static void do_outliner_item_rename(ReportList *reports,
-ARegion *region,
-TreeElement *te,
-const float mval[2])
-{
-  if (mval[1] > te->ys && mval[1] < te->ys + UI_UNIT_Y) {
-TreeStoreElem *tselem = TREESTORE(te);
-
-/* click on name */
-if (mval[0] > te->xs + UI_UNIT_X * 2 && mval[0] < te->xend) {
-  do_item_rename(region, te, tselem, reports);
-}
-  }
-
-  LISTBASE_FOREACH (TreeElement *, te_child, &te->subtree) {
-do_outliner_item_rename(reports, region, te_child, mval);
-  }
-}
-
 static int outliner_item_rename(bContext *C, wmOperator *op, const wmEvent 
*event)
 {
   ARegion *region = CTX_wm_region(C);
@@ -403,8 +384,11 @@ static int outliner_item_rename(bContext *C, wmOperator 
*op, const wmEvent *even
   else {
 UI_view2d_region_to_view(®ion->v2d, event->mval[0], event->mval[1], 
&fmval[0], &fmval[1]);
 
-LISTBASE_FOREACH (TreeElement *, te, &space_outliner->tree) {
-  do_outliner_item_rename(op->reports, region, te, fmval);
+TreeElement *hovered = outliner_find_item_at_y(
+space_outliner, &space_outliner->tree, fmval[1]);
+
+if (outliner_item_is_co_over_name(hovered, fmval[0])) {
+  do_item_rename(region, hovered, TREESTORE(hovered), op->reports);
 }
   }
 
diff --git a/source/blender/editors/space_outliner/outliner_intern.h 
b/source/blender/editors/space_outliner/outliner_intern.h
index 2e0ea7a481a..382078f006b 100644
--- a/source/blender/editors/space_outliner/outliner_intern.h
+++ b/source/blender/editors/space_outliner/outliner_intern.h
@@ -286,6 +286,7 @@ void outliner_item_select(struct bContext *C,
   const short select_flag);
 
 bool outliner_item_is_co_over_name_icons(const TreeElement *te, float 
view_co_x);
+bool outliner_item_is_co_over_name(const TreeElement *te, float view_co_x);
 bool outliner_item_is_co_within_close_toggle(const TreeElement *te, float 
view_co_x);
 bool outliner_is_co_within_mode_column(SpaceOutliner *space_outliner, const 
float view_mval[2]);
 
diff --git a/source/blender/editors/space_outliner/outliner_utils.c 
b/source/blender/editors/space_outliner/outliner_utils.c
index 907b9d372af..c1551b5c584 100644
--- a/source/blender/editors/space_outliner/outliner_utils.c
+++ b/source/blender/editors/space_outliner/outliner_utils.c
@@ -429,6 +429,12 @@ bool outliner_item_is_co_over_name_icons(const TreeElement 
*te, float view_co_x)
   return outside_left && (view_co_x < te->xend);
 }
 
+/* Find if x coordinate is over element name. */
+bool outliner_item_is_co_over_name(const TreeElement *te, float view_co_x)
+{
+  return (view_co_x > (te->xs + UI_UNIT_X * 2)) && (view_co_x < te->xend);
+}
+
 /* Find if x coordinate is over element disclosure toggle */
 bool outliner_item_is_co_within_close_toggle(const TreeElement *te, float 
view_co_x)
 {

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [5efb104003d] master: Silence warning

2020-10-15 Thread Dalai Felinto
Commit: 5efb104003d41664d6412279fb546ee53767d384
Author: Dalai Felinto
Date:   Thu Oct 15 20:03:26 2020 +0200
Branches: master
https://developer.blender.org/rB5efb104003d41664d6412279fb546ee53767d384

Silence warning

===

M   source/blender/editors/sculpt_paint/paint_mask.c

===

diff --git a/source/blender/editors/sculpt_paint/paint_mask.c 
b/source/blender/editors/sculpt_paint/paint_mask.c
index 13971f6bec4..cfb73153371 100644
--- a/source/blender/editors/sculpt_paint/paint_mask.c
+++ b/source/blender/editors/sculpt_paint/paint_mask.c
@@ -1079,7 +1079,6 @@ static void 
sculpt_gesture_apply_trim(SculptGestureContext *sgcontext)
 {
 
   SculptGestureTrimOperation *trim_operation = (SculptGestureTrimOperation 
*)sgcontext->operation;
-  Object *object = sgcontext->vc.obact;
   Mesh *sculpt_mesh = BKE_mesh_from_object(sgcontext->vc.obact);
   Mesh *trim_mesh = trim_operation->mesh;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [c866075dfbd] master: Fix T81580: No doversion for Emission Strength

2020-10-15 Thread Dalai Felinto
Commit: c866075dfbd90888705ad5cd68b25d8605febb4a
Author: Dalai Felinto
Date:   Thu Oct 15 12:02:56 2020 +0200
Branches: master
https://developer.blender.org/rBc866075dfbd90888705ad5cd68b25d8605febb4a

Fix T81580: No doversion for Emission Strength

The new parameter made so that previously keyed Alpha values were lost
and instead the new "Emission Strength" was keyed.

Issue introduced with the original commit of Emission Strength: b248ec97769f

Note: Files created since the issue (September 17) that keyframed the
Emission Strength will have to fix their files manually.

Differential Revision: https://developer.blender.org/D9221

===

M   source/blender/blenkernel/BKE_animsys.h
M   source/blender/blenkernel/BKE_blender_version.h
M   source/blender/blenkernel/intern/anim_data.c
M   source/blender/blenloader/intern/versioning_290.c

===

diff --git a/source/blender/blenkernel/BKE_animsys.h 
b/source/blender/blenkernel/BKE_animsys.h
index e9819e6ea87..2007d150c6a 100644
--- a/source/blender/blenkernel/BKE_animsys.h
+++ b/source/blender/blenkernel/BKE_animsys.h
@@ -152,6 +152,16 @@ void BKE_animdata_fix_paths_rename_all(struct ID *ref_id,
const char *oldName,
const char *newName);
 
+/* Fix all the paths for the entire bmain with extra parameters. */
+void BKE_animdata_fix_paths_rename_all_ex(struct Main *bmain,
+  struct ID *ref_id,
+  const char *prefix,
+  const char *oldName,
+  const char *newName,
+  const int oldSubscript,
+  const int newSubscript,
+  const bool verify_paths);
+
 /* Fix the path after removing elements that are not ID (e.g., node).
  * Return true if any animation data was affected. */
 bool BKE_animdata_fix_paths_remove(struct ID *id, const char *path);
diff --git a/source/blender/blenkernel/BKE_blender_version.h 
b/source/blender/blenkernel/BKE_blender_version.h
index bd10deb216b..aed4dad05ad 100644
--- a/source/blender/blenkernel/BKE_blender_version.h
+++ b/source/blender/blenkernel/BKE_blender_version.h
@@ -39,7 +39,7 @@ extern "C" {
 
 /* Blender file format version. */
 #define BLENDER_FILE_VERSION BLENDER_VERSION
-#define BLENDER_FILE_SUBVERSION 7
+#define BLENDER_FILE_SUBVERSION 8
 
 /* Minimum Blender version that supports reading file written with the current
  * version. Older Blender versions will test this and show a warning if the 
file
diff --git a/source/blender/blenkernel/intern/anim_data.c 
b/source/blender/blenkernel/intern/anim_data.c
index 4e24fc27be7..a85509b11db 100644
--- a/source/blender/blenkernel/intern/anim_data.c
+++ b/source/blender/blenkernel/intern/anim_data.c
@@ -1406,13 +1406,30 @@ void BKE_animdata_main_cb(Main *bmain, 
ID_AnimData_Edit_Callback func, void *use
  * NOTE: it is assumed that the structure we're replacing is 
<["><"]>
  *  i.e. pose.bones["Bone"]
  */
-/* TODO: use BKE_animdata_main_cb for looping over all data  */
 void BKE_animdata_fix_paths_rename_all(ID *ref_id,
const char *prefix,
const char *oldName,
const char *newName)
 {
   Main *bmain = G.main; /* XXX UGLY! */
+  BKE_animdata_fix_paths_rename_all_ex(bmain, ref_id, prefix, oldName, 
newName, 0, 0, 1);
+}
+
+/* Fix all RNA-Paths throughout the database
+ * NOTE: it is assumed that the structure we're replacing is 
<["><"]>
+ *  i.e. pose.bones["Bone"]
+ */
+/* TODO: use BKE_animdata_main_cb for looping over all data  */
+void BKE_animdata_fix_paths_rename_all_ex(Main *bmain,
+  ID *ref_id,
+  const char *prefix,
+  const char *oldName,
+  const char *newName,
+  const int oldSubscript,
+  const int newSubscript,
+  const bool verify_paths)
+{
+
   ID *id;
 
   /* macro for less typing
@@ -1422,7 +1439,8 @@ void BKE_animdata_fix_paths_rename_all(ID *ref_id,
 #define RENAMEFIX_ANIM_IDS(first) \
   for (id = first; id; id = id->next) { \
 AnimData *adt = BKE_animdata_from_id(id); \
-BKE_animdata_fix_paths_rename(id, adt, ref_id, prefix, oldName, newName, 
0, 0, 1); \
+BKE_animdata_fix_paths_rename( \
+id, adt, ref_id, prefix, oldName, newName, oldSubscript, newSubscript, 
verify_paths); \
   } \
   (void)0
 
@@ -1433,10 +1451,18 @@ void BKE_animdata_fix_paths_rename_al

[Bf-blender-cvs] [ca55a1b564a] master: Fix Cloth brush grab artifacts in the affected area

2020-10-15 Thread Pablo Dobarro
Commit: ca55a1b564a6ff32784d7c611b4728be400637e8
Author: Pablo Dobarro
Date:   Thu Oct 15 19:54:21 2020 +0200
Branches: master
https://developer.blender.org/rBca55a1b564a6ff32784d7c611b4728be400637e8

Fix Cloth brush grab artifacts in the affected area

The cloth brush grab mode was creating constraints at 1.0 strength in
the area of the brush where the fade was evaluated to 1. This was causing
stability issues in the simulation and not producing ideal results.
Now the constraint strength is scaled with an empirically found factor.

The values in this patch may require further tweaking after experimenting
a little bit more with them.

Reviewed By: sergey, zeddb

Differential Revision: https://developer.blender.org/D9201

===

M   source/blender/editors/sculpt_paint/sculpt_cloth.c

===

diff --git a/source/blender/editors/sculpt_paint/sculpt_cloth.c 
b/source/blender/editors/sculpt_paint/sculpt_cloth.c
index efd80eef0cb..591168fd3a2 100644
--- a/source/blender/editors/sculpt_paint/sculpt_cloth.c
+++ b/source/blender/editors/sculpt_paint/sculpt_cloth.c
@@ -157,6 +157,7 @@ static float cloth_brush_simulation_falloff_get(const Brush 
*brush,
 #define CLOTH_SIMULATION_TIME_STEP 0.01f
 #define CLOTH_DEFORMATION_SNAKEHOOK_STRENGTH 0.35f
 #define CLOTH_DEFORMATION_TARGET_STRENGTH 0.01f
+#define CLOTH_DEFORMATION_GRAB_STRENGTH 0.1f
 
 static bool cloth_brush_sim_has_length_constraint(SculptClothSimulation 
*cloth_sim,
   const int v1,
@@ -381,7 +382,8 @@ static void do_cloth_brush_build_constraints_task_cb_ex(
 /* When the grab brush brush is used as part of the cloth brush, 
deformation constraints
  * are created with different strengths and only inside the radius of 
the brush. */
 const float fade = BKE_brush_curve_strength(brush, sqrtf(len_squared), 
ss->cache->radius);
-cloth_brush_add_deformation_constraint(data->cloth_sim, node_index, 
vd.index, fade);
+cloth_brush_add_deformation_constraint(
+data->cloth_sim, node_index, vd.index, fade * 
CLOTH_DEFORMATION_GRAB_STRENGTH);
   }
   else if (brush->cloth_deform_type == BRUSH_CLOTH_DEFORM_SNAKE_HOOK) {
 /* Cloth Snake Hook creates deformation constraint with fixed strength 
because the strength

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [91af828e8bf] master: Fix T81743: Changed behaviour in RGB Curves node interpolation

2020-10-15 Thread Sybren A. Stüvel
Commit: 91af828e8bfaa04cbd49f1859e06a1f76749102d
Author: Sybren A. Stüvel
Date:   Thu Oct 15 19:38:20 2020 +0200
Branches: master
https://developer.blender.org/rB91af828e8bfaa04cbd49f1859e06a1f76749102d

Fix T81743: Changed behaviour in RGB Curves node interpolation

Restore the old `correct_bezpart()` (pre-rBda95d1d851b4) function as
`BKE_curve_correct_bezpart()`, and use that where the old behaviour was
desired (that is, curve maps like used by the RGB Curves shader node).

The new (post-rBda95d1d851b4) function is also renamed to
`BKE_fcurve_correct_bezpart()` to avoid confusion.

===

M   source/blender/blenkernel/BKE_curve.h
M   source/blender/blenkernel/BKE_fcurve.h
M   source/blender/blenkernel/intern/colortools.c
M   source/blender/blenkernel/intern/curve.c
M   source/blender/blenkernel/intern/fcurve.c
M   source/blender/editors/animation/anim_draw.c
M   source/blender/editors/space_graph/graph_draw.c

===

diff --git a/source/blender/blenkernel/BKE_curve.h 
b/source/blender/blenkernel/BKE_curve.h
index d9138db2769..dcb4a993da1 100644
--- a/source/blender/blenkernel/BKE_curve.h
+++ b/source/blender/blenkernel/BKE_curve.h
@@ -158,6 +158,8 @@ void BKE_curve_rect_from_textbox(const struct Curve *cu,
  const struct TextBox *tb,
  struct rctf *r_rect);
 
+void BKE_curve_correct_bezpart(const float v1[2], float v2[2], float v3[2], 
const float v4[2]);
+
 /* ** Nurbs ** */
 
 bool BKE_nurbList_index_get_co(struct ListBase *editnurb, const int index, 
float r_co[3]);
diff --git a/source/blender/blenkernel/BKE_fcurve.h 
b/source/blender/blenkernel/BKE_fcurve.h
index e0c0f91b34b..c9bc5e83a1f 100644
--- a/source/blender/blenkernel/BKE_fcurve.h
+++ b/source/blender/blenkernel/BKE_fcurve.h
@@ -285,7 +285,7 @@ void testhandles_fcurve(struct FCurve *fcu, eBezTriple_Flag 
sel_flag, const bool
 void sort_time_fcurve(struct FCurve *fcu);
 bool test_time_fcurve(struct FCurve *fcu);
 
-void correct_bezpart(const float v1[2], float v2[2], float v3[2], const float 
v4[2]);
+void BKE_fcurve_correct_bezpart(const float v1[2], float v2[2], float v3[2], 
const float v4[2]);
 
 /*  Evaluation   */
 
diff --git a/source/blender/blenkernel/intern/colortools.c 
b/source/blender/blenkernel/intern/colortools.c
index 77a29bf41b8..34e8e8bc6fb 100644
--- a/source/blender/blenkernel/intern/colortools.c
+++ b/source/blender/blenkernel/intern/colortools.c
@@ -715,7 +715,8 @@ static void curvemap_make_table(const CurveMapping *cumap, 
CurveMap *cuma)
   float *point = allpoints;
 
   for (int a = 0; a < cuma->totpoint - 1; a++, point += 2 * CM_RESOL) {
-correct_bezpart(bezt[a].vec[1], bezt[a].vec[2], bezt[a + 1].vec[0], bezt[a 
+ 1].vec[1]);
+BKE_curve_correct_bezpart(
+bezt[a].vec[1], bezt[a].vec[2], bezt[a + 1].vec[0], bezt[a + 
1].vec[1]);
 BKE_curve_forward_diff_bezier(bezt[a].vec[1][0],
   bezt[a].vec[2][0],
   bezt[a + 1].vec[0][0],
diff --git a/source/blender/blenkernel/intern/curve.c 
b/source/blender/blenkernel/intern/curve.c
index c0da1f41c88..01636c7eb2b 100644
--- a/source/blender/blenkernel/intern/curve.c
+++ b/source/blender/blenkernel/intern/curve.c
@@ -5566,6 +5566,47 @@ void BKE_curve_rect_from_textbox(const struct Curve *cu,
   r_rect->ymin = r_rect->ymax - tb->h;
 }
 
+/* This function is almost the same as BKE_fcurve_correct_bezpart(), but 
doesn't allow as large a
+ * tangent. */
+void BKE_curve_correct_bezpart(const float v1[2], float v2[2], float v3[2], 
const float v4[2])
+{
+  float h1[2], h2[2], len1, len2, len, fac;
+
+  /* Calculate handle deltas. */
+  h1[0] = v1[0] - v2[0];
+  h1[1] = v1[1] - v2[1];
+
+  h2[0] = v4[0] - v3[0];
+  h2[1] = v4[1] - v3[1];
+
+  /* Calculate distances:
+   * - len  = span of time between keyframes
+   * - len1 = length of handle of start key
+   * - len2 = length of handle of end key
+   */
+  len = v4[0] - v1[0];
+  len1 = fabsf(h1[0]);
+  len2 = fabsf(h2[0]);
+
+  /* If the handles have no length, no need to do any corrections. */
+  if ((len1 + len2) == 0.0f) {
+return;
+  }
+
+  /* the two handles cross over each other, so force them
+   * apart using the proportion they overlap
+   */
+  if ((len1 + len2) > len) {
+fac = len / (len1 + len2);
+
+v2[0] = (v1[0] - fac * h1[0]);
+v2[1] = (v1[1] - fac * h1[1]);
+
+v3[0] = (v4[0] - fac * h2[0]);
+v3[1] = (v4[1] - fac * h2[1]);
+  }
+}
+
 /*  Depsgraph evaluation  */
 
 void BKE_curve_eval_geometry(Depsgraph *depsgraph, Curve *curve)
diff --git a/source/blender/blenkernel/intern/fcurve.c 
b/source/blender/blenkernel/intern/fcurve.c
index 18e6479ea07..2287170c29d 100644
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@@ -1355,8 +1355,11 @@

[Bf-blender-cvs] [229b9f1299c] master: Fix brush tip delta orientation with anchored strokes

2020-10-15 Thread Pablo Dobarro
Commit: 229b9f1299c6739db5c08ce84127e6390c3041ed
Author: Pablo Dobarro
Date:   Mon Oct 12 20:32:26 2020 +0200
Branches: master
https://developer.blender.org/rB229b9f1299c6739db5c08ce84127e6390c3041ed

Fix brush tip delta orientation with anchored strokes

When using anchored stroke, the stroke operator was modifying the
coordinates on the "mouse" rna property by setting them to the original
position. Because of this, all the sculpt delta calculation was failing
and the delta for these brushes was set randomly (with a 0 vector) at
the beginning of the stroke.
There is now an extra property that uses the unmodified coordinates of
the mouse to calculate the delta. Now delta orientation works as expected
in all brushes and features that require brush tip orientation.

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D9183

===

M   source/blender/editors/sculpt_paint/paint_stroke.c
M   source/blender/editors/sculpt_paint/sculpt.c
M   source/blender/editors/sculpt_paint/sculpt_intern.h
M   source/blender/makesrna/intern/rna_brush.c

===

diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c 
b/source/blender/editors/sculpt_paint/paint_stroke.c
index da0a8dbd4b8..0da0b191537 100644
--- a/source/blender/editors/sculpt_paint/paint_stroke.c
+++ b/source/blender/editors/sculpt_paint/paint_stroke.c
@@ -621,7 +621,10 @@ static void paint_brush_stroke_add_step(bContext *C,
 RNA_collection_add(op->ptr, "stroke", &itemptr);
 RNA_float_set(&itemptr, "size", ups->pixel_radius);
 RNA_float_set_array(&itemptr, "location", location);
+/* Mouse coordinates modified by the stroke type options. */
 RNA_float_set_array(&itemptr, "mouse", mouse_out);
+/* Original mouse coordinates. */
+RNA_float_set_array(&itemptr, "mouse_event", mouse_in);
 RNA_boolean_set(&itemptr, "pen_flip", stroke->pen_flip);
 RNA_float_set(&itemptr, "pressure", pressure);
 RNA_float_set(&itemptr, "x_tilt", stroke->x_tilt);
diff --git a/source/blender/editors/sculpt_paint/sculpt.c 
b/source/blender/editors/sculpt_paint/sculpt.c
index 078baf0dfc6..16b5d770fa2 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -6607,6 +6607,7 @@ static void sculpt_update_cache_invariants(
   }
 
   copy_v2_v2(cache->mouse, cache->initial_mouse);
+  copy_v2_v2(cache->mouse_event, cache->initial_mouse);
   copy_v2_v2(ups->tex_mouse, cache->initial_mouse);
 
   /* Truly temporary data that isn't stored in properties. */
@@ -6734,8 +6735,8 @@ static void 
sculpt_update_brush_delta(UnifiedPaintSettings *ups, Object *ob, Bru
   SculptSession *ss = ob->sculpt;
   StrokeCache *cache = ss->cache;
   const float mouse[2] = {
-  cache->mouse[0],
-  cache->mouse[1],
+  cache->mouse_event[0],
+  cache->mouse_event[1],
   };
   int tool = brush->sculpt_tool;
 
@@ -6946,6 +6947,7 @@ static void sculpt_update_cache_variants(bContext *C, 
Sculpt *sd, Object *ob, Po
 
   cache->pen_flip = RNA_boolean_get(ptr, "pen_flip");
   RNA_float_get_array(ptr, "mouse", cache->mouse);
+  RNA_float_get_array(ptr, "mouse_event", cache->mouse_event);
 
   /* XXX: Use pressure value from first brush step for brushes which don't 
support strokes (grab,
* thumb). They depends on initial state and brush coord/pressure/etc.
diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h 
b/source/blender/editors/sculpt_paint/sculpt_intern.h
index ec4d594293a..916e7336c37 100644
--- a/source/blender/editors/sculpt_paint/sculpt_intern.h
+++ b/source/blender/editors/sculpt_paint/sculpt_intern.h
@@ -868,12 +868,17 @@ typedef struct StrokeCache {
   bool pen_flip;
   bool invert;
   float pressure;
-  float mouse[2];
   float bstrength;
   float normal_weight; /* from brush (with optional override) */
   float x_tilt;
   float y_tilt;
 
+  /* Position of the mouse corresponding to the stroke location, modified by 
the paint_stroke
+   * operator acording to the stroke type. */
+  float mouse[2];
+  /* Position of the mouse event in screen space, not modified by the stroke 
type. */
+  float mouse_event[2];
+
   float (*prev_colors)[4];
 
   /* The rest is temporary storage that isn't saved as a property */
diff --git a/source/blender/makesrna/intern/rna_brush.c 
b/source/blender/makesrna/intern/rna_brush.c
index eed278c3980..ac876eac7db 100644
--- a/source/blender/makesrna/intern/rna_brush.c
+++ b/source/blender/makesrna/intern/rna_brush.c
@@ -3426,6 +3426,11 @@ static void rna_def_operator_stroke_element(BlenderRNA 
*brna)
   RNA_def_property_array(prop, 2);
   RNA_def_property_ui_text(prop, "Mouse", "");
 
+  prop = RNA_def_property(srna, "mouse_event", PROP_FLOAT, PROP_XYZ);
+  RNA_def_property_flag(prop, PROP_IDPROPERTY);
+  RNA_def_property_array(prop, 2);
+  RNA_def_property_ui_text(prop, "Mouse Event", "");
+
   prop 

[Bf-blender-cvs] [6991b13e41f] master: Fix T81649: Cloth simulation dynamic area mode tearing the mesh

2020-10-15 Thread Pablo Dobarro
Commit: 6991b13e41f39e07e1d6bf4a3ae95249e610afb8
Author: Pablo Dobarro
Date:   Mon Oct 12 19:31:38 2020 +0200
Branches: master
https://developer.blender.org/rB6991b13e41f39e07e1d6bf4a3ae95249e610afb8

Fix T81649: Cloth simulation dynamic area mode tearing the mesh

Dynamic area should use the radius instead of the initial radius to get
the nodes as the radius can now change during the stroke. In case of
anchored strokes, the current radius can be bigger than the initial
radius, simulating vertices outside the falloff area and breaking the
mesh.

Reviewed By: sergey

Maniphest Tasks: T81649

Differential Revision: https://developer.blender.org/D9181

===

M   source/blender/editors/sculpt_paint/sculpt.c

===

diff --git a/source/blender/editors/sculpt_paint/sculpt.c 
b/source/blender/editors/sculpt_paint/sculpt.c
index f512da504eb..078baf0dfc6 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -5684,7 +5684,7 @@ static void do_brush_action(Sculpt *sd, Object *ob, Brush 
*brush, UnifiedPaintSe
   SculptSearchSphereData data = {
   .ss = ss,
   .sd = sd,
-  .radius_squared = square_f(ss->cache->initial_radius * (1.0 + 
brush->cloth_sim_limit)),
+  .radius_squared = square_f(ss->cache->radius * (1.0 + 
brush->cloth_sim_limit)),
   .original = false,
   .ignore_fully_ineffective = false,
   .center = ss->cache->location,

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [ef5f3070315] master: Sculpt: Use mpoly flags to sync Face Sets visibility

2020-10-15 Thread Pablo Dobarro
Commit: ef5f3070315ea130479c1c646ef889c98825b475
Author: Pablo Dobarro
Date:   Mon Oct 12 00:46:50 2020 +0200
Branches: master
https://developer.blender.org/rBef5f3070315ea130479c1c646ef889c98825b475

Sculpt: Use mpoly flags to sync Face Sets visibility

Previously, all Face Set visibility logic was using mvert flags directly
to store the visibility state on the vertices while sculpting. As Face
Sets are a poly attribute, it is much simpler to use mpoly flags and let
BKE_mesh_flush_hidden_from_polys handle the vertex visibility, even for
Multires.

Now all operators that update the Face Set visibility state will always
copy the visibility to the mesh (using poly flags) and the grids, all
using the same code.

This should fix a lot of visibility glitches and bugs like the following:
 - Sculpt visibility reset when changing multires levels.
 - Multires visibility not updating in edit mode.
 - Single face visibible when surrounded by visibile face set, even when
the face set was hidden.

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D9175

===

M   source/blender/blenkernel/BKE_paint.h
M   source/blender/blenkernel/intern/paint.c
M   source/blender/editors/sculpt_paint/sculpt.c
M   source/blender/editors/sculpt_paint/sculpt_face_set.c
M   source/blender/editors/sculpt_paint/sculpt_intern.h
M   source/blender/editors/sculpt_paint/sculpt_undo.c

===

diff --git a/source/blender/blenkernel/BKE_paint.h 
b/source/blender/blenkernel/BKE_paint.h
index 0d3241ba6b8..150d0d9b011 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -612,6 +612,11 @@ void BKE_sculpt_bvh_update_from_ccg(struct PBVH *pbvh, 
struct SubdivCCG *subdiv_
  * updated according to the face sets. */
 void BKE_sculpt_sync_face_set_visibility(struct Mesh *mesh, struct SubdivCCG 
*subdiv_ccg);
 
+/* Individual function to sync the Face Set visibility to mesh and grids. */
+void BKE_sculpt_sync_face_sets_visibility_to_base_mesh(struct Mesh *mesh);
+void BKE_sculpt_sync_face_sets_visibility_to_grids(struct Mesh *mesh,
+   struct SubdivCCG 
*subdiv_ccg);
+
 /* Ensures that a Face Set data-layers exists. If it does not, it creates one 
respecting the
  * visibility stored in the vertices of the mesh. If it does, it copies the 
visibility from the
  * mesh to the Face Sets. */
diff --git a/source/blender/blenkernel/intern/paint.c 
b/source/blender/blenkernel/intern/paint.c
index 2488895c779..88415140a5b 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -1894,63 +1894,41 @@ void 
BKE_sculpt_face_sets_ensure_from_base_mesh_visibility(Mesh *mesh)
 
   int *face_sets = CustomData_get_layer(&mesh->pdata, CD_SCULPT_FACE_SETS);
 
-  /* Show the only the face sets that have all visible vertices. */
   for (int i = 0; i < mesh->totpoly; i++) {
-for (int l = 0; l < mesh->mpoly[i].totloop; l++) {
-  MLoop *loop = &mesh->mloop[mesh->mpoly[i].loopstart + l];
-  if (mesh->mvert[loop->v].flag & ME_HIDE) {
-if (initialize_new_face_sets) {
-  /* When initializing a new Face Set data-layer, assign a new hidden 
Face Set ID to hidden
-   * vertices. This way, we get at initial split in two Face Sets 
between hidden and
-   * visible vertices based on the previous mesh visibly from other 
mode that can be
-   * useful in some cases. */
-  face_sets[i] = face_sets_default_hidden_id;
-}
-else {
-  /* Otherwise, set the already existing Face Set ID to hidden. */
-  face_sets[i] = -abs(face_sets[i]);
-}
-break;
-  }
+if (!(mesh->mpoly[i].flag & ME_HIDE)) {
+  continue;
+}
+
+if (initialize_new_face_sets) {
+  /* When initializing a new Face Set data-layer, assign a new hidden Face 
Set ID to hidden
+   * vertices. This way, we get at initial split in two Face Sets between 
hidden and
+   * visible vertices based on the previous mesh visibly from other mode 
that can be
+   * useful in some cases. */
+  face_sets[i] = face_sets_default_hidden_id;
+}
+else {
+  /* Otherwise, set the already existing Face Set ID to hidden. */
+  face_sets[i] = -abs(face_sets[i]);
 }
   }
 }
 
-static void sculpt_sync_face_sets_visibility_to_base_mesh(Mesh *mesh)
+void BKE_sculpt_sync_face_sets_visibility_to_base_mesh(Mesh *mesh)
 {
   int *face_sets = CustomData_get_layer(&mesh->pdata, CD_SCULPT_FACE_SETS);
   if (!face_sets) {
 return;
   }
 
-  /* Enabled if the vertex should be visible according to the Face Sets. */
-  BLI_bitmap *visible_vertex = BLI_BITMAP_NEW(mesh->totvert, "visible 
vertices");
-  /* Enabled if the visibility of this vertex can be affected by the Face Sets 
to avoid modifying
-   * dis

[Bf-blender-cvs] [750e4e1158b] master: Fix Multires edge adjacency info returning wrong vertex indices

2020-10-15 Thread Pablo Dobarro
Commit: 750e4e1158bb1bd40c1724e24693cb22c6910f86
Author: Pablo Dobarro
Date:   Sun Oct 11 21:39:28 2020 +0200
Branches: master
https://developer.blender.org/rB750e4e1158bb1bd40c1724e24693cb22c6910f86

Fix Multires edge adjacency info returning wrong vertex indices

ME_POLY_LOOP_NEXT and ME_POLY_LOOP_PREV expect the offset of
the loop in the poly as an argument, in other words, corner index of the poly.
This was violated in some places. It didn't cause issues when base mesh consists
of only quads due to the way how modulus worked inside of the macro. However,
if mesh had non-quad faces adjacency information was returning wrong vertex
 indices. This was causing multiple brushes to work erratically, including 
brushes
like Face Set, Boundary automasking, mesh relax, and others.

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D9173

===

M   source/blender/blenkernel/intern/subdiv_ccg.c

===

diff --git a/source/blender/blenkernel/intern/subdiv_ccg.c 
b/source/blender/blenkernel/intern/subdiv_ccg.c
index 0997b42a19f..a59f9e0c633 100644
--- a/source/blender/blenkernel/intern/subdiv_ccg.c
+++ b/source/blender/blenkernel/intern/subdiv_ccg.c
@@ -1878,12 +1878,14 @@ static void 
adjacet_vertices_index_from_adjacent_edge(const SubdivCCG *subdiv_cc
   const int poly_index = BKE_subdiv_ccg_grid_to_face_index(subdiv_ccg, 
coord->grid_index);
   const MPoly *p = &mpoly[poly_index];
   *r_v1 = mloop[coord->grid_index].v;
+
+  const int corner = poly_find_loop_from_vert(p, &mloop[p->loopstart], *r_v1);
   if (coord->x == grid_size_1) {
-const MLoop *next = ME_POLY_LOOP_NEXT(mloop, p, coord->grid_index);
+const MLoop *next = ME_POLY_LOOP_NEXT(mloop, p, corner);
 *r_v2 = next->v;
   }
   if (coord->y == grid_size_1) {
-const MLoop *prev = ME_POLY_LOOP_PREV(mloop, p, coord->grid_index);
+const MLoop *prev = ME_POLY_LOOP_PREV(mloop, p, corner);
 *r_v2 = prev->v;
   }
 }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [6fe3521481b] master: Sculpt: Add global automasking settings support in filters

2020-10-15 Thread Pablo Dobarro
Commit: 6fe3521481b26ad6b6411b0863dfcd4ac2a81132
Author: Pablo Dobarro
Date:   Thu Oct 15 19:34:54 2020 +0200
Branches: master
https://developer.blender.org/rB6fe3521481b26ad6b6411b0863dfcd4ac2a81132

Sculpt: Add global automasking settings support in filters

When using the sculpt filters, global automasking settings that affect
all brushes were ignored because the automasking system was not
implemented for filters, making filters and brushes react differently
to the global sculpt settings which creates confusion.

This makes all filter tools (mesh, cloth, color) use the same general
automasking settings and features as the brush tools. Filters will now
use the settings in the options panel to limit their effect.

This also removes the "use Face Sets" option from the Mesh filter code,
as it was duplicated from the automasking code just to have that
funcitonality. This is now handled by the regular automasking system.

The "Use Face Sets" option is still available in the cloth filter as that
option limits the action of the forces, not the displacement.

After this, it is possible to initialize the automasking system
independently from the StrokeCache and Brush settings, so it can also be
added to more tools and features in the future.

Fixes T81619

Reviewed By: dbystedt, sergey

Maniphest Tasks: T81619

Differential Revision: https://developer.blender.org/D9171

===

M   release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
M   source/blender/editors/sculpt_paint/sculpt.c
M   source/blender/editors/sculpt_paint/sculpt_automasking.c
M   source/blender/editors/sculpt_paint/sculpt_cloth.c
M   source/blender/editors/sculpt_paint/sculpt_filter_color.c
M   source/blender/editors/sculpt_paint/sculpt_filter_mesh.c
M   source/blender/editors/sculpt_paint/sculpt_intern.h

===

diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py 
b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
index 853368c6d1c..9eee69b9a04 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
@@ -1351,7 +1351,6 @@ class _defs_sculpt:
 row = layout.row(align=True)
 row.prop(props, "deform_axis")
 layout.prop(props, "orientation", expand=False)
-layout.prop(props, "use_face_sets")
 if props.type == 'SURFACE_SMOOTH':
 layout.prop(props, "surface_smooth_shape_preservation", 
expand=False)
 layout.prop(props, "surface_smooth_current_vertex", 
expand=False)
diff --git a/source/blender/editors/sculpt_paint/sculpt.c 
b/source/blender/editors/sculpt_paint/sculpt.c
index 8a9d1bba92c..4e15728b081 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -2506,7 +2506,7 @@ float SCULPT_brush_strength_factor(SculptSession *ss,
   avg *= 1.0f - mask;
 
   /* Auto-masking. */
-  avg *= SCULPT_automasking_factor_get(ss, vertex_index);
+  avg *= SCULPT_automasking_factor_get(cache->automasking, ss, vertex_index);
 
   return avg;
 }
@@ -3908,7 +3908,7 @@ static void do_elastic_deform_brush_task_cb_ex(void 
*__restrict userdata,
   mul_v3_fl(final_disp, 1.0f - *vd.mask);
 }
 
-mul_v3_fl(final_disp, SCULPT_automasking_factor_get(ss, vd.index));
+mul_v3_fl(final_disp, 
SCULPT_automasking_factor_get(ss->cache->automasking, ss, vd.index));
 
 copy_v3_v3(proxy[vd.i], final_disp);
 
@@ -5760,7 +5760,7 @@ static void do_brush_action(Sculpt *sd, Object *ob, Brush 
*brush, UnifiedPaintSe
 
 if (SCULPT_stroke_is_first_brush_step(ss->cache)) {
   if (SCULPT_is_automasking_enabled(sd, ss, brush)) {
-SCULPT_automasking_init(sd, ob);
+ss->cache->automasking = SCULPT_automasking_cache_init(sd, brush, ob);
   }
 }
 
@@ -7764,7 +7764,7 @@ static void sculpt_stroke_done(const bContext *C, struct 
PaintStroke *UNUSED(str
 }
 
 if (SCULPT_is_automasking_enabled(sd, ss, brush)) {
-  SCULPT_automasking_end(ob);
+  SCULPT_automasking_cache_free(ss->cache->automasking);
 }
 
 BKE_pbvh_node_color_buffer_free(ss->pbvh);
diff --git a/source/blender/editors/sculpt_paint/sculpt_automasking.c 
b/source/blender/editors/sculpt_paint/sculpt_automasking.c
index 241f1167316..f2fc1bcb3c9 100644
--- a/source/blender/editors/sculpt_paint/sculpt_automasking.c
+++ b/source/blender/editors/sculpt_paint/sculpt_automasking.c
@@ -62,16 +62,30 @@
 #include 
 #include 
 
+AutomaskingCache *SCULPT_automasking_active_cache_get(SculptSession *ss)
+{
+  if (ss->cache) {
+return ss->cache->automasking;
+  }
+  else if (ss->filter_cache) {
+return ss->filter_cache->automasking;
+  }
+  return NULL;
+}
+
 bool SCULPT_is_automasking_mode_enabled(const Sculpt *sd,
 const Brush *br,
  

[Bf-blender-cvs] [da7ace00d5f] master: Sculpt: Use cursor depth in trimming gestures

2020-10-15 Thread Pablo Dobarro
Commit: da7ace00d5fb534d8583c0b70497d7819bc7b273
Author: Pablo Dobarro
Date:   Thu Oct 15 19:13:29 2020 +0200
Branches: master
https://developer.blender.org/rBda7ace00d5fb534d8583c0b70497d7819bc7b273

Sculpt: Use cursor depth in trimming gestures

This adds an operator property to use the paint cursor radius and
position for the depth of the trimming shape created by the trimming
tools.
When enabled, the shape is located in the surface point when the gesture
started and it will have the depth of the cursor radius. When the cursor
is not over the mesh, the shape will be positioned at the center of the
depth of the whole object from the viewport camera.

Reviewed By: dbystedt, sergey

Differential Revision: https://developer.blender.org/D9129

===

M   release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
M   source/blender/blenkernel/BKE_paint.h
M   source/blender/editors/sculpt_paint/paint_mask.c

===

diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py 
b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
index af263bf5d53..853368c6d1c 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
@@ -1307,6 +1307,7 @@ class _defs_sculpt:
 def draw_settings(_context, layout, tool):
 props = tool.operator_properties("sculpt.trim_box_gesture")
 layout.prop(props, "trim_mode", expand=False)
+layout.prop(props, "use_cursor_depth", expand=False)
 return dict(
 idname="builtin.box_trim",
 label="Box Trim",
@@ -1321,6 +1322,7 @@ class _defs_sculpt:
 def draw_settings(_context, layout, tool):
 props = tool.operator_properties("sculpt.trim_lasso_gesture")
 layout.prop(props, "trim_mode", expand=False)
+layout.prop(props, "use_cursor_depth", expand=False)
 return dict(
 idname="builtin.lasso_trim",
 label="Lasso Trim",
diff --git a/source/blender/blenkernel/BKE_paint.h 
b/source/blender/blenkernel/BKE_paint.h
index 614badb59f9..0d3241ba6b8 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -511,6 +511,11 @@ typedef struct SculptSession {
   float cursor_sampled_normal[3];
   float cursor_view_normal[3];
 
+  /* For Sculpt trimming gesture tools, initial raycast data from the position 
of the mouse when
+   * the gesture starts (intersection with the surface and if they ray hit the 
surface or not). */
+  float gesture_initial_location[3];
+  bool gesture_initial_hit;
+
   /* TODO(jbakker): Replace rv3d adn v3d with ViewContext */
   struct RegionView3D *rv3d;
   struct View3D *v3d;
diff --git a/source/blender/editors/sculpt_paint/paint_mask.c 
b/source/blender/editors/sculpt_paint/paint_mask.c
index 826dd80175d..13971f6bec4 100644
--- a/source/blender/editors/sculpt_paint/paint_mask.c
+++ b/source/blender/editors/sculpt_paint/paint_mask.c
@@ -39,6 +39,7 @@
 #include "BLI_task.h"
 #include "BLI_utildefines.h"
 
+#include "BKE_brush.h"
 #include "BKE_ccg.h"
 #include "BKE_context.h"
 #include "BKE_mesh.h"
@@ -861,6 +862,8 @@ typedef struct SculptGestureTrimOperation {
   float depth_front;
   float depth_back;
 
+  bool use_cursor_depth;
+
   eSculptTrimOperationType mode;
 } SculptGestureTrimOperation;
 
@@ -898,7 +901,7 @@ static void 
sculpt_gesture_trim_normals_update(SculptGestureContext *sgcontext)
   trim_operation->mesh = result;
 }
 
-static void sculpt_gesture_trim_calculate_depth(SculptGestureContext 
*sgcontext)
+static void sculpt_gesture_trim_calculate_depth(bContext *C, 
SculptGestureContext *sgcontext)
 {
   SculptGestureTrimOperation *trim_operation = (SculptGestureTrimOperation 
*)sgcontext->operation;
 
@@ -927,6 +930,25 @@ static void 
sculpt_gesture_trim_calculate_depth(SculptGestureContext *sgcontext)
 trim_operation->depth_front = min_ff(dist, trim_operation->depth_front);
 trim_operation->depth_back = max_ff(dist, trim_operation->depth_back);
   }
+
+  if (trim_operation->use_cursor_depth) {
+float world_space_gesture_initial_location[3];
+mul_v3_m4v3(
+world_space_gesture_initial_location, vc->obact->obmat, 
ss->gesture_initial_location);
+const float mid_point_depth = ss->gesture_initial_hit ?
+  
dist_signed_to_plane_v3(world_space_gesture_initial_location,
+  view_plane) :
+  (trim_operation->depth_back + 
trim_operation->depth_front) *
+  0.5f;
+
+Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
+Brush *brush = BKE_paint_brush(&sd->paint);
+Scene *scene = CTX_data_scene(C);
+const float depth_radius = BKE_brush_unprojected_radius_get(scene, brus

[Bf-blender-cvs] [b9e46966418] master: Sculpt: Show paint brush cursor in all tools

2020-10-15 Thread Pablo Dobarro
Commit: b9e469664188ac675f3743e8d3938f34c996957e
Author: Pablo Dobarro
Date:   Thu Oct 1 01:52:40 2020 +0200
Branches: master
https://developer.blender.org/rBb9e469664188ac675f3743e8d3938f34c996957e

Sculpt: Show paint brush cursor in all tools

This patch enables the paint brush cursor with all tools in sculpt mode,
even with the ones that are not brushes. The motivations for this change
are:
- The filters are using the position of the active vertex for certain
features without any visualization of what the active vertex is.

- You can call operators like mask expand (which depends on the brush
cursor position and active vertex) with a non brush tool enabled.

- Having the cursor in the rest of the tools allows to have a scene
scale representation of the radius and a direct control of radius and
strength (using the current brush shortcuts), which will allow to make
features more intuitive without relying on modifying values in the
topbar. For example, the brush radius can be used to control the depth
of the cut in the trimming tools or the size of the sphere in the
sphere mesh filter

Reviewed By: #user_interface, dbystedt, pablovazquez

Differential Revision: https://developer.blender.org/D9071

===

M   source/blender/editors/sculpt_paint/sculpt.c

===

diff --git a/source/blender/editors/sculpt_paint/sculpt.c 
b/source/blender/editors/sculpt_paint/sculpt.c
index 6e99edcf682..8a9d1bba92c 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -8197,7 +8197,7 @@ void ED_object_sculptmode_enter_ex(Main *bmain,
   Paint *paint = BKE_paint_get_active_from_paintmode(scene, PAINT_MODE_SCULPT);
   BKE_paint_init(bmain, scene, PAINT_MODE_SCULPT, PAINT_CURSOR_SCULPT);
 
-  paint_cursor_start(paint, SCULPT_poll_view3d);
+  paint_cursor_start(paint, SCULPT_mode_poll_view3d);
 
   /* Check dynamic-topology flag; re-enter dynamic-topology mode when changing 
modes,
* As long as no data was added that is not supported. */

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [4b99ea17fbd] master: Fix mask expand creating wrong masks when the cursor is not over the mesh

2020-10-15 Thread Pablo Dobarro
Commit: 4b99ea17fbde991b9259dd12bfd36739b7e067a9
Author: Pablo Dobarro
Date:   Sun Oct 4 19:55:27 2020 +0200
Branches: master
https://developer.blender.org/rB4b99ea17fbde991b9259dd12bfd36739b7e067a9

Fix mask expand creating wrong masks when the cursor is not over the mesh

This forces the mask expand modal operator to use the maximum
iteration when the cursor is not over the mesh, masking the entire
connected component.

This fixes the issue for both expanding masks and face sets.

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D9105

===

M   source/blender/editors/sculpt_paint/sculpt_mask_expand.c

===

diff --git a/source/blender/editors/sculpt_paint/sculpt_mask_expand.c 
b/source/blender/editors/sculpt_paint/sculpt_mask_expand.c
index e403bada316..5a921383ac3 100644
--- a/source/blender/editors/sculpt_paint/sculpt_mask_expand.c
+++ b/source/blender/editors/sculpt_paint/sculpt_mask_expand.c
@@ -188,8 +188,14 @@ static int sculpt_mask_expand_modal(bContext *C, 
wmOperator *op, const wmEvent *
 float mouse[2];
 mouse[0] = event->mval[0];
 mouse[1] = event->mval[1];
-SCULPT_cursor_geometry_info_update(C, &sgi, mouse, false);
-mask_expand_update_it = 
ss->filter_cache->mask_update_it[(int)SCULPT_active_vertex_get(ss)];
+if (SCULPT_cursor_geometry_info_update(C, &sgi, mouse, false)) {
+  /* The cursor is over the mesh, get the update iteration from the 
updated active vertex. */
+  mask_expand_update_it = 
ss->filter_cache->mask_update_it[(int)SCULPT_active_vertex_get(ss)];
+}
+else {
+  /* When the cursor is outside the mesh, affect the entire connected 
component. */
+  mask_expand_update_it = ss->filter_cache->mask_update_last_it - 1;
+}
   }
 
   if ((event->type == EVT_ESCKEY && event->val == KM_PRESS) ||

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [0d5ec990a98] master: Sculpt: Experimental Pen Tilt Support

2020-10-15 Thread Pablo Dobarro
Commit: 0d5ec990a9844e639fa6ab989b14b2e051ac8c42
Author: Pablo Dobarro
Date:   Thu Oct 8 00:00:36 2020 +0200
Branches: master
https://developer.blender.org/rB0d5ec990a9844e639fa6ab989b14b2e051ac8c42

Sculpt: Experimental Pen Tilt Support

This adds support for pen tilt in sculpt mode. For now, pen tilt is used
by tweaking the tilt strength property, which controls how much the pen
angle affects the sculpt normal. This is available in Draw, Draw Sharp,
Flatten, Fill, Scrape and Clay Strips brushes, but it can be enabled in
more tools later.

The purpose of this patch is to have a usable implementation of pen tilt
in a painting mode, so users can test and see in which hardware and
platforms this feature is supported and how well it works. If it works
ok, more tools and features that rely on pen tilt can be implemented,
like brushes that blend between two deformations depending on the angle.

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D8893

===

M   release/scripts/startup/bl_ui/properties_paint_common.py
M   release/scripts/startup/bl_ui/space_userpref.py
M   source/blender/editors/sculpt_paint/paint_stroke.c
M   source/blender/editors/sculpt_paint/sculpt.c
M   source/blender/editors/sculpt_paint/sculpt_intern.h
M   source/blender/makesdna/DNA_brush_types.h
M   source/blender/makesdna/DNA_userdef_types.h
M   source/blender/makesrna/intern/rna_brush.c
M   source/blender/makesrna/intern/rna_userdef.c

===

diff --git a/release/scripts/startup/bl_ui/properties_paint_common.py 
b/release/scripts/startup/bl_ui/properties_paint_common.py
index e18651d8e8a..ca93f79df04 100644
--- a/release/scripts/startup/bl_ui/properties_paint_common.py
+++ b/release/scripts/startup/bl_ui/properties_paint_common.py
@@ -547,6 +547,10 @@ def brush_settings(layout, context, brush, popover=False):
 # normal_radius_factor
 layout.prop(brush, "normal_radius_factor", slider=True)
 
+if context.preferences.experimental.use_sculpt_tools_tilt and 
capabilities.has_tilt:
+layout.prop(brush, "tilt_strength_factor", slider=True)
+
+
 row = layout.row(align=True)
 row.prop(brush, "hardness", slider=True)
 row.prop(brush, "invert_hardness_pressure", text="")
diff --git a/release/scripts/startup/bl_ui/space_userpref.py 
b/release/scripts/startup/bl_ui/space_userpref.py
index 576e56c929f..604ec302b60 100644
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@ -2187,6 +2187,7 @@ class 
USERPREF_PT_experimental_new_features(ExperimentalPanel, Panel):
 ({"property": "use_sculpt_vertex_colors"}, "T71947"),
 ({"property": "use_tools_missing_icons"}, "T80331"),
 ({"property": "use_switch_object_operator"}, "T80402"),
+({"property": "use_sculpt_tools_tilt"}, "T0"),
 ),
 )
 
diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c 
b/source/blender/editors/sculpt_paint/paint_stroke.c
index 21b33a4e2ab..da0a8dbd4b8 100644
--- a/source/blender/editors/sculpt_paint/paint_stroke.c
+++ b/source/blender/editors/sculpt_paint/paint_stroke.c
@@ -123,6 +123,10 @@ typedef struct PaintStroke {
   float zoom_2d;
   int pen_flip;
 
+  /* Tilt, as read from the event. */
+  float x_tilt;
+  float y_tilt;
+
   /* line constraint */
   bool constrain_line;
   float constrained_pos[2];
@@ -620,6 +624,8 @@ static void paint_brush_stroke_add_step(bContext *C,
 RNA_float_set_array(&itemptr, "mouse", mouse_out);
 RNA_boolean_set(&itemptr, "pen_flip", stroke->pen_flip);
 RNA_float_set(&itemptr, "pressure", pressure);
+RNA_float_set(&itemptr, "x_tilt", stroke->x_tilt);
+RNA_float_set(&itemptr, "y_tilt", stroke->y_tilt);
 
 stroke->update_step(C, stroke, &itemptr);
 
@@ -1383,6 +1389,12 @@ int paint_stroke_modal(bContext *C, wmOperator *op, 
const wmEvent *event)
   paint_stroke_add_sample(p, stroke, event->mval[0], event->mval[1], pressure);
   paint_stroke_sample_average(stroke, &sample_average);
 
+  /* Tilt. */
+  if (WM_event_is_tablet(event)) {
+stroke->x_tilt = event->tablet.x_tilt;
+stroke->y_tilt = event->tablet.y_tilt;
+  }
+
 #ifdef WITH_INPUT_NDOF
   /* let NDOF motion pass through to the 3D view so we can paint and rotate 
simultaneously!
* this isn't perfect... even when an extra MOUSEMOVE is spoofed, the stroke 
discards it
diff --git a/source/blender/editors/sculpt_paint/sculpt.c 
b/source/blender/editors/sculpt_paint/sculpt.c
index c4c9db69dcd..6e99edcf682 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -2784,6 +2784,20 @@ static void calc_brush_local_mat(const Brush *brush, 
Object *ob, float local_mat
   invert_m4_m4(local_mat, tmat);
 }
 
+#define SCULPT_TILT_S

[Bf-blender-cvs] [6dda0779fcd] master: Fix T80625: Trimming tools not working with transformed objects

2020-10-15 Thread Pablo Dobarro
Commit: 6dda0779fcdef704a17ed3c0150073f77534d5e5
Author: Pablo Dobarro
Date:   Thu Oct 8 00:15:24 2020 +0200
Branches: master
https://developer.blender.org/rB6dda0779fcdef704a17ed3c0150073f77534d5e5

Fix T80625: Trimming tools not working with transformed objects

The code to handle object transforms was wrong. Now the trimming mesh
and depts is calculated in world space, using the real view origin and
normal and then stored in object space in the mesh and in the original
coordinates array. As now both meshes for the boolean operation are in
the same object space, the space conversion code can also be removed
from the boolean function.

Reviewed By: sergey

Maniphest Tasks: T80625

Differential Revision: https://developer.blender.org/D8852

===

M   source/blender/editors/sculpt_paint/paint_mask.c

===

diff --git a/source/blender/editors/sculpt_paint/paint_mask.c 
b/source/blender/editors/sculpt_paint/paint_mask.c
index 622ea82bf25..826dd80175d 100644
--- a/source/blender/editors/sculpt_paint/paint_mask.c
+++ b/source/blender/editors/sculpt_paint/paint_mask.c
@@ -283,6 +283,14 @@ typedef struct SculptGestureContext {
   float true_clip_planes[4][4];
   float clip_planes[4][4];
 
+  /* These store the view origin and normal in world space, which is used in 
some gestures to
+   * generate geometry aligned from the view directly in world space. */
+  /* World space view origin and normal are not affected by object symmetry 
when doing symmetry
+   * passes, so there is no separate variables with the true_ prefix to store 
their original values
+   * without symmetry modifications. */
+  float world_space_view_origin[3];
+  float world_space_view_normal[3];
+
   /* Lasso Gesture. */
   LassoGestureData lasso;
 
@@ -337,11 +345,13 @@ static void sculpt_gesture_context_init_common(bContext 
*C,
   float view_dir[3] = {0.0f, 0.0f, 1.0f};
   copy_m3_m4(mat, sgcontext->vc.rv3d->viewinv);
   mul_m3_v3(mat, view_dir);
+  normalize_v3_v3(sgcontext->world_space_view_normal, view_dir);
   copy_m3_m4(mat, ob->imat);
   mul_m3_v3(mat, view_dir);
   normalize_v3_v3(sgcontext->true_view_normal, view_dir);
 
   /* View Origin. */
+  copy_v3_v3(sgcontext->world_space_view_origin, 
sgcontext->vc.rv3d->viewinv[3]);
   copy_v3_v3(sgcontext->true_view_origin, sgcontext->vc.rv3d->viewinv[3]);
 }
 
@@ -893,17 +903,27 @@ static void 
sculpt_gesture_trim_calculate_depth(SculptGestureContext *sgcontext)
   SculptGestureTrimOperation *trim_operation = (SculptGestureTrimOperation 
*)sgcontext->operation;
 
   SculptSession *ss = sgcontext->ss;
+  ViewContext *vc = &sgcontext->vc;
+
   const int totvert = SCULPT_vertex_count_get(ss);
 
   float view_plane[4];
-  plane_from_point_normal_v3(view_plane, sgcontext->true_view_origin, 
sgcontext->true_view_normal);
+  const float *view_origin = sgcontext->world_space_view_origin;
+  const float *view_normal = sgcontext->world_space_view_normal;
+
+  plane_from_point_normal_v3(view_plane, view_origin, view_normal);
 
   trim_operation->depth_front = FLT_MAX;
   trim_operation->depth_back = -FLT_MAX;
 
   for (int i = 0; i < totvert; i++) {
 const float *vco = SCULPT_vertex_co_get(ss, i);
-const float dist = dist_signed_to_plane_v3(vco, view_plane);
+/* Convert the coordinates to world space to calculate the depth. When 
generating the trimming
+ * mesh, coordinates are first calculated in world space, then converted 
to object space to
+ * store them. */
+float world_space_vco[3];
+mul_v3_m4v3(world_space_vco, vc->obact->obmat, vco);
+const float dist = dist_signed_to_plane_v3(world_space_vco, view_plane);
 trim_operation->depth_front = min_ff(dist, trim_operation->depth_front);
 trim_operation->depth_back = max_ff(dist, trim_operation->depth_back);
   }
@@ -927,18 +947,23 @@ static void 
sculpt_gesture_trim_geometry_generate(SculptGestureContext *sgcontex
   const float depth_front = trim_operation->depth_front - 0.1f;
   const float depth_back = trim_operation->depth_back + 0.1f;
 
-  float *view_origin = sgcontext->true_view_origin;
-  float *view_normal = sgcontext->true_view_normal;
+  /* Use the view origin and normal in world space. The trimming mesh 
coordinates are calculated in
+   * world space, aligned to the view, and then converted to object space to 
store them in the
+   * final trimming mesh which is going to be used in the boolean operation.
+   */
+  const float *view_origin = sgcontext->world_space_view_origin;
+  const float *view_normal = sgcontext->world_space_view_normal;
 
-  /* Write vertices coordinates for the front face. */
+  const float(*ob_imat)[4] = vc->obact->imat;
 
+  /* Write vertices coordinates for the front face. */
   float depth_point[3];
   madd_v3_v3v3fl(depth_point, view_origin, view_normal, depth_front);
   for (int i = 0; i < tot_screen_points; i++) {
 float new_point[3];
 

[Bf-blender-cvs] [0fed1bea65d] master: Improve Voxel Remesher volume projection artifacts on sharp edges

2020-10-15 Thread Leha
Commit: 0fed1bea65d0f7f9e2f7ef58fa2e68ac3595e661
Author: Leha
Date:   Thu Oct 15 18:48:18 2020 +0200
Branches: master
https://developer.blender.org/rB0fed1bea65d0f7f9e2f7ef58fa2e68ac3595e661

Improve Voxel Remesher volume projection artifacts on sharp edges

The voxel remesher was using the voxel size to limit the shrink-wrap
projection distance. Now that distance is increased to help preserving
more detail on hard surface edges.

Reviewed By: pablodp606

Differential Revision: https://developer.blender.org/D6204

===

M   release/datafiles/locale
M   release/scripts/addons
M   release/scripts/addons_contrib
M   source/blender/blenkernel/intern/shrinkwrap.c
M   source/tools

===

diff --git a/release/datafiles/locale b/release/datafiles/locale
index 07106b58838..8f5a0e027f1 16
--- a/release/datafiles/locale
+++ b/release/datafiles/locale
@@ -1 +1 @@
-Subproject commit 07106b588381ef26604934482a6151d9bc26437e
+Subproject commit 8f5a0e027f131104974763d30db36b1a9ffae16a
diff --git a/release/scripts/addons b/release/scripts/addons
index feca8c52897..8ad9de7c1e1 16
--- a/release/scripts/addons
+++ b/release/scripts/addons
@@ -1 +1 @@
-Subproject commit feca8c5289794a70bdd375be76fc4bc59d83c96b
+Subproject commit 8ad9de7c1e1022dee907ddce78f4c357111fc09e
diff --git a/release/scripts/addons_contrib b/release/scripts/addons_contrib
index f2f4a8b3bfa..26a8b2eadc7 16
--- a/release/scripts/addons_contrib
+++ b/release/scripts/addons_contrib
@@ -1 +1 @@
-Subproject commit f2f4a8b3bfa36ee49f7bdb3a1acb40ef4b39ee3a
+Subproject commit 26a8b2eadc7abb2a30fac50eb5505aa24daf5785
diff --git a/source/blender/blenkernel/intern/shrinkwrap.c 
b/source/blender/blenkernel/intern/shrinkwrap.c
index 96f2b8c1095..0c9ee61ca19 100644
--- a/source/blender/blenkernel/intern/shrinkwrap.c
+++ b/source/blender/blenkernel/intern/shrinkwrap.c
@@ -1548,7 +1548,11 @@ void BKE_shrinkwrap_remesh_target_project(Mesh *src_me, 
Mesh *target_me, Object
   ssmd.shrinkMode = MOD_SHRINKWRAP_ON_SURFACE;
   ssmd.shrinkOpts = MOD_SHRINKWRAP_PROJECT_ALLOW_NEG_DIR | 
MOD_SHRINKWRAP_PROJECT_ALLOW_POS_DIR;
   ssmd.keepDist = 0.0f;
-  ssmd.projLimit = target_me->remesh_voxel_size;
+  
+  /* Tolerance value to prevent artifacts on sharp edges of a mesh. 
+   * This constant and based on experimenting with different values. */
+  const float projLimitTolerance = 5.0f;
+  ssmd.projLimit = target_me->remesh_voxel_size * projLimitTolerance;
 
   float(*vertexCos)[3] = BKE_mesh_vert_coords_alloc(src_me, &totvert);
 
diff --git a/source/tools b/source/tools
index 2afbb8ec472..7011d02c292 16
--- a/source/tools
+++ b/source/tools
@@ -1 +1 @@
-Subproject commit 2afbb8ec472cac5102eb239f57b006f8c9387685
+Subproject commit 7011d02c292ac1c91a5c9cc1a075ea2727982cee

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [78ac21c1ae7] greasepencil-object: Merge branch 'master' into greasepencil-object

2020-10-15 Thread Antonio Vazquez
Commit: 78ac21c1ae73d788571af7cad465995fbbfd584b
Author: Antonio Vazquez
Date:   Thu Oct 15 18:43:59 2020 +0200
Branches: greasepencil-object
https://developer.blender.org/rB78ac21c1ae73d788571af7cad465995fbbfd584b

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] [ebf150dca81] greasepencil-edit-curve: Merge branch 'master' into greasepencil-edit-curve

2020-10-15 Thread Antonio Vazquez
Commit: ebf150dca81627fcf46a533354541c91c33030cc
Author: Antonio Vazquez
Date:   Thu Oct 15 18:43:42 2020 +0200
Branches: greasepencil-edit-curve
https://developer.blender.org/rBebf150dca81627fcf46a533354541c91c33030cc

Merge branch 'master' into greasepencil-edit-curve

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [e7ab802ab04] master: Fix T81697: Property search crash with python handlers

2020-10-15 Thread Hans Goudey
Commit: e7ab802ab04d25532ee16153c55eaac290c877b0
Author: Hans Goudey
Date:   Thu Oct 15 10:08:39 2020 -0500
Branches: master
https://developer.blender.org/rBe7ab802ab04d25532ee16153c55eaac290c877b0

Fix T81697: Property search crash with python handlers

Previously I used `CTX_copy` to create a mutable copy of the context in
order to set its area and region fields to temporary variables. This was
a tradeoff to avoid casting away `const` for `bContext`.

However, `bpy.context` is set to this new temporary value, which is fine
for a single `wm_draw_update` pass, but in the next main loop,
`bpy.context` is still set to this value, which was freed at the
end of `property_search_all_tabs`. It would be possible to reset the
`bpy.context` variable ath the end of the function, but this patch
contains an alternate solution: just don't copy the context. It looks
like this was the only use of `CTX_copy` anyway, maybe for good reason.

Differential Revision: https://developer.blender.org/D9216

===

M   source/blender/editors/space_buttons/space_buttons.c

===

diff --git a/source/blender/editors/space_buttons/space_buttons.c 
b/source/blender/editors/space_buttons/space_buttons.c
index 14817a8ce23..3d470b19c1c 100644
--- a/source/blender/editors/space_buttons/space_buttons.c
+++ b/source/blender/editors/space_buttons/space_buttons.c
@@ -393,23 +393,25 @@ static void 
property_search_move_to_next_tab_with_results(SpaceProperties *sbuts
 
 static void property_search_all_tabs(const bContext *C,
  SpaceProperties *sbuts,
- ARegion *main_region,
+ ARegion *region_original,
  const short *context_tabs_array,
  const int tabs_len)
 {
   /* Use local copies of the area and duplicate the region as a 
mainly-paranoid protection
* against changing any of the space / region data while running the search. 
*/
-  ScrArea area_copy = *CTX_wm_area(C);
-  ARegion *region_copy = BKE_area_region_copy(area_copy.type, main_region);
-  bContext *C_copy = CTX_copy(C);
-  CTX_wm_area_set(C_copy, &area_copy);
-  CTX_wm_region_set(C_copy, region_copy);
+  ScrArea *area_original = CTX_wm_area(C);
+  ScrArea area_copy = *area_original;
+  ARegion *region_copy = BKE_area_region_copy(area_copy.type, region_original);
+  CTX_wm_area_set((bContext *)C, &area_copy);
+  CTX_wm_region_set((bContext *)C, region_copy);
+
   SpaceProperties sbuts_copy = *sbuts;
   sbuts_copy.path = NULL;
   sbuts_copy.texuser = NULL;
   sbuts_copy.runtime = MEM_dupallocN(sbuts->runtime);
   sbuts_copy.runtime->tab_search_results = NULL;
-  area_copy.spacedata.first = &sbuts_copy;
+  BLI_listbase_clear(&area_copy.spacedata);
+  BLI_addtail(&area_copy.spacedata, &sbuts_copy);
 
   /* Loop through the tabs added to the properties editor. */
   for (int i = 0; i < tabs_len; i++) {
@@ -428,15 +430,17 @@ static void property_search_all_tabs(const bContext *C,
 /* Actually do the search and store the result in the bitmap. */
 BLI_BITMAP_SET(sbuts->runtime->tab_search_results,
i,
-   property_search_for_context(C_copy, region_copy, 
&sbuts_copy));
+   property_search_for_context(C, region_copy, &sbuts_copy));
 
-UI_blocklist_free(C_copy, ®ion_copy->uiblocks);
+UI_blocklist_free(C, ®ion_copy->uiblocks);
   }
 
   BKE_area_region_free(area_copy.type, region_copy);
   MEM_freeN(region_copy);
   buttons_free((SpaceLink *)&sbuts_copy);
-  MEM_freeN(C_copy);
+
+  CTX_wm_area_set((bContext *)C, area_original);
+  CTX_wm_region_set((bContext *)C, region_original);
 }
 
 /**

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [15d78ea85b6] master: UI: Add reset to default value to keymap

2020-10-15 Thread Hans Goudey
Commit: 15d78ea85b602cfda4e4b825d44bede71a06d86f
Author: Hans Goudey
Date:   Thu Oct 15 10:02:44 2020 -0500
Branches: master
https://developer.blender.org/rB15d78ea85b602cfda4e4b825d44bede71a06d86f

UI: Add reset to default value to keymap

With all the work on DNA defaults for 2.91, it's nice to expose this
convenient operator. This was already hardcoded in the UI code to the
backspace key, adding it to the keymap instead will make the shortcut
automatically show in the button right click menu.

Differential Revision: https://developer.blender.org/D9219

===

M   release/scripts/presets/keyconfig/keymap_data/blender_default.py
M   source/blender/editors/interface/interface.c
M   source/blender/editors/interface/interface_handlers.c
M   source/blender/editors/interface/interface_intern.h

===

diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py 
b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index 0622e9568d1..6674751f9b8 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -715,6 +715,7 @@ def km_user_interface(_params):
 ("anim.driver_button_remove", {"type": 'D', "value": 'PRESS', "ctrl": 
True, "alt": True}, None),
 ("anim.keyingset_button_add", {"type": 'K', "value": 'PRESS'}, None),
 ("anim.keyingset_button_remove", {"type": 'K', "value": 'PRESS', 
"alt": True}, None),
+("ui.reset_default_button", {"type": 'BACK_SPACE', "value": 'PRESS'}, 
{"properties": [("all", True)]}),
 ])
 
 return keymap
diff --git a/source/blender/editors/interface/interface.c 
b/source/blender/editors/interface/interface.c
index 94b93c11f6c..c2a4465af07 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -3123,23 +3123,6 @@ bool ui_but_string_set(bContext *C, uiBut *but, const 
char *str)
   return false;
 }
 
-void ui_but_default_set(bContext *C, const bool all, const bool use_afterfunc)
-{
-  wmOperatorType *ot = WM_operatortype_find("UI_OT_reset_default_button", 
true);
-
-  if (use_afterfunc) {
-PointerRNA *ptr = ui_handle_afterfunc_add_operator(ot, WM_OP_EXEC_DEFAULT, 
true);
-RNA_boolean_set(ptr, "all", all);
-  }
-  else {
-PointerRNA ptr;
-WM_operator_properties_create_ptr(&ptr, ot);
-RNA_boolean_set(&ptr, "all", all);
-WM_operator_name_call_ptr(C, ot, WM_OP_EXEC_DEFAULT, &ptr);
-WM_operator_properties_free(&ptr);
-  }
-}
-
 static double soft_range_round_up(double value, double max)
 {
   /* round up to .., 0.1, 0.2, 0.5, 1, 2, 5, 10, 20, 50, ..
diff --git a/source/blender/editors/interface/interface_handlers.c 
b/source/blender/editors/interface/interface_handlers.c
index 2c1b6d9f9d5..0cc1932d88c 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -7692,19 +7692,6 @@ static int ui_do_button(bContext *C, uiBlock *block, 
uiBut *but, const wmEvent *
   break;
   }
 
-  /* reset to default (generic function, only use if not handled by switch 
above) */
-  /* XXX hardcoded keymap check */
-  data = but->active;
-  if (data && data->state == BUTTON_STATE_HIGHLIGHT) {
-if ((retval == WM_UI_HANDLER_CONTINUE) &&
-(event->type == EVT_BACKSPACEKEY && event->val == KM_PRESS)) {
-  /* ctrl+backspace = reset active button; backspace = reset a whole 
array*/
-  ui_but_default_set(C, !event->ctrl, true);
-  ED_region_tag_redraw(data->region);
-  retval = WM_UI_HANDLER_BREAK;
-}
-  }
-
 #ifdef USE_DRAG_MULTINUM
   if (data) {
 if (ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE) ||
diff --git a/source/blender/editors/interface/interface_intern.h 
b/source/blender/editors/interface/interface_intern.h
index dc1f6cfce50..5da3d9528f8 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -619,8 +619,6 @@ extern uiBut *ui_but_drag_multi_edit_get(uiBut *but);
 void ui_def_but_icon(uiBut *but, const int icon, const int flag);
 void ui_def_but_icon_clear(uiBut *but);
 
-extern void ui_but_default_set(struct bContext *C, const bool all, const bool 
use_afterfunc);
-
 void ui_but_extra_operator_icons_free(uiBut *but);
 
 extern void ui_but_rna_menu_convert_to_panel_type(struct uiBut *but, const 
char *panel_type);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [d1b3439b80f] master: Cleanup: Use DNA defaults for grease pencil modifiers

2020-10-15 Thread Hans Goudey
Commit: d1b3439b80fd6e9a0caa653cd55c7a5def18b122
Author: Hans Goudey
Date:   Thu Oct 15 09:44:39 2020 -0500
Branches: master
https://developer.blender.org/rBd1b3439b80fd6e9a0caa653cd55c7a5def18b122

Cleanup: Use DNA defaults for grease pencil modifiers

This will make "Reset to Default Value" work properly for grease
pencil modifiers. See T80164 for more information.

===

M   source/blender/gpencil_modifiers/CMakeLists.txt
M   source/blender/gpencil_modifiers/intern/MOD_gpencilarmature.c
M   source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c
M   source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c
M   source/blender/gpencil_modifiers/intern/MOD_gpencilcolor.c
M   source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c
M   source/blender/gpencil_modifiers/intern/MOD_gpencillattice.c
M   source/blender/gpencil_modifiers/intern/MOD_gpencilmirror.c
M   source/blender/gpencil_modifiers/intern/MOD_gpencilmultiply.c
M   source/blender/gpencil_modifiers/intern/MOD_gpencilnoise.c
M   source/blender/gpencil_modifiers/intern/MOD_gpenciloffset.c
M   source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c
M   source/blender/gpencil_modifiers/intern/MOD_gpencilsimplify.c
M   source/blender/gpencil_modifiers/intern/MOD_gpencilsmooth.c
M   source/blender/gpencil_modifiers/intern/MOD_gpencilsubdiv.c
M   source/blender/gpencil_modifiers/intern/MOD_gpenciltexture.c
M   source/blender/gpencil_modifiers/intern/MOD_gpencilthick.c
M   source/blender/gpencil_modifiers/intern/MOD_gpenciltime.c
M   source/blender/gpencil_modifiers/intern/MOD_gpenciltint.c
A   source/blender/makesdna/DNA_gpencil_modifier_defaults.h
M   source/blender/makesdna/intern/CMakeLists.txt
M   source/blender/makesdna/intern/dna_defaults.c
M   source/blender/makesrna/intern/rna_gpencil_modifier.c

===

diff --git a/source/blender/gpencil_modifiers/CMakeLists.txt 
b/source/blender/gpencil_modifiers/CMakeLists.txt
index 22f8f01be4b..2cedc5675f7 100644
--- a/source/blender/gpencil_modifiers/CMakeLists.txt
+++ b/source/blender/gpencil_modifiers/CMakeLists.txt
@@ -35,6 +35,9 @@ set(INC
   ../windowmanager
   ../../../intern/eigen
   ../../../intern/guardedalloc
+
+  # dna_type_offsets.h in BLO_read_write.h
+  ${CMAKE_BINARY_DIR}/source/blender/makesdna/intern
 )
 
 set(INC_SYS
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilarmature.c 
b/source/blender/gpencil_modifiers/intern/MOD_gpencilarmature.c
index 7035908605a..aee345757c6 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilarmature.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilarmature.c
@@ -31,6 +31,7 @@
 #include "BLT_translation.h"
 
 #include "DNA_armature_types.h"
+#include "DNA_defaults.h"
 #include "DNA_gpencil_modifier_types.h"
 #include "DNA_gpencil_types.h"
 #include "DNA_meshdata_types.h"
@@ -68,8 +69,10 @@
 static void initData(GpencilModifierData *md)
 {
   ArmatureGpencilModifierData *gpmd = (ArmatureGpencilModifierData *)md;
-  gpmd->object = NULL;
-  gpmd->deformflag = ARM_DEF_VGROUP;
+
+  BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(gpmd, modifier));
+
+  MEMCPY_STRUCT_AFTER(gpmd, 
DNA_struct_default_get(ArmatureGpencilModifierData), modifier);
 }
 
 static void copyData(const GpencilModifierData *md, GpencilModifierData 
*target)
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c 
b/source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c
index 2f6faf5ee6a..dec6ef63ffb 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c
@@ -37,6 +37,7 @@
 
 #include "BLT_translation.h"
 
+#include "DNA_defaults.h"
 #include "DNA_gpencil_modifier_types.h"
 #include "DNA_gpencil_types.h"
 #include "DNA_object_types.h"
@@ -79,16 +80,10 @@ typedef struct tmpStrokes {
 static void initData(GpencilModifierData *md)
 {
   ArrayGpencilModifierData *gpmd = (ArrayGpencilModifierData *)md;
-  gpmd->count = 2;
-  gpmd->shift[0] = 1.0f;
-  gpmd->shift[1] = 0.0f;
-  gpmd->shift[2] = 0.0f;
-  zero_v3(gpmd->offset);
-  zero_v3(gpmd->rnd_scale);
-  gpmd->object = NULL;
-  gpmd->flag |= GP_ARRAY_USE_RELATIVE;
-  gpmd->seed = 1;
-  gpmd->material = NULL;
+
+  BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(gpmd, modifier));
+
+  MEMCPY_STRUCT_AFTER(gpmd, DNA_struct_default_get(ArrayGpencilModifierData), 
modifier);
 
   /* Open the first subpanel too, because it's activated by default. */
   md->ui_expand_flag = (1 << 0) | (1 << 1);
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c 
b/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c
index 7995381ac71..5b5cc61bedc 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c
@@ -32,6 +32,7 @@
 
 #inclu

[Bf-blender-cvs] [bac91956ae9] master: CMake/macOS: set package_ROOT for PNG, JPEG, TIFF

2020-10-15 Thread Ankit Meel
Commit: bac91956ae9755722b81da4b6a0a394f9f77b2e1
Author: Ankit Meel
Date:   Thu Oct 15 18:49:45 2020 +0530
Branches: master
https://developer.blender.org/rBbac91956ae9755722b81da4b6a0a394f9f77b2e1

CMake/macOS: set package_ROOT for PNG, JPEG, TIFF

https://devtalk.blender.org/t/libpng-version-mismatch/15799/

In this case, CMake finds libraries in `LIBDIR`, but picks headers from
`/Library/Frameworks/` (Mono framework).

CMP0074 is already enabled, so use it.

===

M   build_files/cmake/platform/platform_apple.cmake

===

diff --git a/build_files/cmake/platform/platform_apple.cmake 
b/build_files/cmake/platform/platform_apple.cmake
index 020f8defdc0..b22adbc68d5 100644
--- a/build_files/cmake/platform/platform_apple.cmake
+++ b/build_files/cmake/platform/platform_apple.cmake
@@ -227,10 +227,15 @@ if(WITH_SDL)
   set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework ForceFeedback")
 endif()
 
+# Use CMP0074 for our benefit. Stop CMake from searching libraries in one
+# place and headers in another.
+set(PNG_ROOT ${LIBDIR}/png)
 find_package(PNG REQUIRED)
 
+set(JPEG_ROOT ${LIBDIR}/jpeg)
 find_package(JPEG REQUIRED)
 
+set(TIFF_ROOT ${LIBDIR}/tiff)
 find_package(TIFF REQUIRED)
 
 if(WITH_BOOST)

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [78d1aa4d521] master: Cleanup: Animation, simplify channel selection code

2020-10-15 Thread Sybren A. Stüvel
Commit: 78d1aa4d521cff25b07af2f6f8790d51b8b26064
Author: Sybren A. Stüvel
Date:   Tue Oct 13 14:43:19 2020 +0200
Branches: master
https://developer.blender.org/rB78d1aa4d521cff25b07af2f6f8790d51b8b26064

Cleanup: Animation, simplify channel selection code

Split up `ANIM_deselect_anim_channels()` into
`ANIM_anim_channels_select_set()` and
`ANIM_anim_channels_select_toggle()`.

`ANIM_anim_channels_select_set()` is equivalent to the old
`ANIM_deselect_anim_channels(..., false, ACHANNEL_SETFLAG_xxx)`.

`ANIM_anim_channels_select_toggle()` is equivalent to the old
`ANIM_deselect_anim_channels(..., true, ACHANNEL_SETFLAG_ADD)`.

`ANIM_deselect_anim_channels(..., true, ACHANNEL_SETFLAG_CLEAR)` was
also called once. The `true` parameter suggested the "toggle" behaviour
was intended, but the `ACHANNEL_SETFLAG_CLEAR` argument prevented any
toggling. This is now replaced with `ANIM_anim_channels_select_set(ac,
ACHANNEL_SETFLAG_CLEAR)` to make this explicit.

No functional changes, just a cleanup in order to better understand how
the selection works.

===

M   source/blender/editors/animation/anim_channels_edit.c
M   source/blender/editors/include/ED_anim_api.h
M   source/blender/editors/screen/screen_ops.c
M   source/blender/editors/space_action/action_select.c
M   source/blender/editors/space_graph/graph_select.c
M   source/blender/editors/space_nla/nla_channels.c
M   source/blender/editors/space_nla/nla_select.c

===

diff --git a/source/blender/editors/animation/anim_channels_edit.c 
b/source/blender/editors/animation/anim_channels_edit.c
index 8a13872ca61..5bed6175ebc 100644
--- a/source/blender/editors/animation/anim_channels_edit.c
+++ b/source/blender/editors/animation/anim_channels_edit.c
@@ -253,109 +253,107 @@ static void select_pchan_for_action_group(bAnimContext 
*ac, bActionGroup *agrp,
   }
 }
 
-/* Deselect all animation channels
- * - data: pointer to datatype, as contained in bAnimContext
- * - datatype: the type of data that 'data' represents (eAnimCont_Types)
- * - test: check if deselecting instead of selecting
- * - sel: eAnimChannels_SetFlag;
- */
-void ANIM_deselect_anim_channels(
-bAnimContext *ac, void *data, eAnimCont_Types datatype, bool test, 
eAnimChannels_SetFlag sel)
+static ListBase /* bAnimListElem */ anim_channels_for_selection(bAnimContext 
*ac)
 {
   ListBase anim_data = {NULL, NULL};
-  bAnimListElem *ale;
-  int filter;
 
   /* filter data */
   /* NOTE: no list visible, otherwise, we get dangling */
-  filter = ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_CHANNELS;
-  ANIM_animdata_filter(ac, &anim_data, filter, data, datatype);
+  const int filter = ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_CHANNELS;
+  ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
 
-  /* See if we should be selecting or deselecting */
-  if (test) {
-for (ale = anim_data.first; ale; ale = ale->next) {
-  if (sel == 0) {
-break;
-  }
+  return anim_data;
+}
 
-  switch (ale->type) {
-case ANIMTYPE_SCENE:
-  if (ale->flag & SCE_DS_SELECTED) {
-sel = ACHANNEL_SETFLAG_CLEAR;
-  }
-  break;
-case ANIMTYPE_OBJECT:
+static eAnimChannels_SetFlag anim_channels_selection_flag_for_toggle(const 
ListBase anim_data)
+{
+  /* See if we should be selecting or deselecting. */
+  for (bAnimListElem *ale = anim_data.first; ale; ale = ale->next) {
+switch (ale->type) {
+  case ANIMTYPE_SCENE:
+if (ale->flag & SCE_DS_SELECTED) {
+  return ACHANNEL_SETFLAG_CLEAR;
+}
+break;
+  case ANIMTYPE_OBJECT:
 #if 0 /* for now, do not take object selection into account, since it gets too 
annoying */
   if (ale->flag & SELECT) {
-sel = ACHANNEL_SETFLAG_CLEAR;
+return ACHANNEL_SETFLAG_CLEAR;
   }
 #endif
-  break;
-case ANIMTYPE_GROUP:
-  if (ale->flag & AGRP_SELECTED) {
-sel = ACHANNEL_SETFLAG_CLEAR;
-  }
-  break;
-case ANIMTYPE_FCURVE:
-case ANIMTYPE_NLACURVE:
-  if (ale->flag & FCURVE_SELECTED) {
-sel = ACHANNEL_SETFLAG_CLEAR;
-  }
-  break;
-case ANIMTYPE_SHAPEKEY:
-  if (ale->flag & KEYBLOCK_SEL) {
-sel = ACHANNEL_SETFLAG_CLEAR;
-  }
-  break;
-case ANIMTYPE_NLATRACK:
-  if (ale->flag & NLATRACK_SELECTED) {
-sel = ACHANNEL_SETFLAG_CLEAR;
-  }
-  break;
+break;
+  case ANIMTYPE_GROUP:
+if (ale->flag & AGRP_SELECTED) {
+  return ACHANNEL_SETFLAG_CLEAR;
+}
+break;
+  case ANIMTYPE_FCURVE:
+  case ANIMTYPE_NLACURVE:
+if (ale->flag & FCURVE_SELECTED) {
+  return ACHANNEL_SETFLAG_CLEAR;
+}
+break;
+  case ANIMTYPE_SHAPEKEY:
+  

[Bf-blender-cvs] [1ec1e36ac1d] master: Cleanup: Animation, rename function to match operator

2020-10-15 Thread Sybren A. Stüvel
Commit: 1ec1e36ac1d87c0404509204a332da797e8fc831
Author: Sybren A. Stüvel
Date:   Tue Oct 13 12:45:08 2020 +0200
Branches: master
https://developer.blender.org/rB1ec1e36ac1d87c0404509204a332da797e8fc831

Cleanup: Animation, rename function to match operator

Rename `animchannels_deselectall_exec` → `animchannels_selectall_exec` so
that it matches the operator `ANIM_OT_channels_select_all`.

No functional changes.

===

M   source/blender/editors/animation/anim_channels_edit.c

===

diff --git a/source/blender/editors/animation/anim_channels_edit.c 
b/source/blender/editors/animation/anim_channels_edit.c
index 92b37628263..8a13872ca61 100644
--- a/source/blender/editors/animation/anim_channels_edit.c
+++ b/source/blender/editors/animation/anim_channels_edit.c
@@ -2526,7 +2526,7 @@ static void ANIM_OT_channels_find(wmOperatorType *ot)
 
 /* ** Select All Operator *** */
 
-static int animchannels_deselectall_exec(bContext *C, wmOperator *op)
+static int animchannels_selectall_exec(bContext *C, wmOperator *op)
 {
   bAnimContext ac;
 
@@ -2569,7 +2569,7 @@ static void ANIM_OT_channels_select_all(wmOperatorType 
*ot)
   ot->description = "Toggle selection of all animation channels";
 
   /* api callbacks */
-  ot->exec = animchannels_deselectall_exec;
+  ot->exec = animchannels_selectall_exec;
   ot->poll = animedit_poll_channels_nla_tweakmode_off;
 
   /* flags */

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [d6fd03616ec] master: Fix part of T74918: 3D Viewport: Jump, when mouse crosses a window corner.

2020-10-15 Thread Bastien Montagne
Commit: d6fd03616ec2fab836610422f177d54ab3e2fd85
Author: Bastien Montagne
Date:   Wed Oct 14 12:49:56 2020 +0200
Branches: master
https://developer.blender.org/rBd6fd03616ec2fab836610422f177d54ab3e2fd85

Fix part of T74918: 3D Viewport: Jump, when mouse crosses a window corner.

We need a separate time stamp for each axis, and we have to add a few
milliseconds of padding to those, to ensure wrapping on both axes get
properly performed when it happens almost simultaneously, and avoid
extra wrapping caused by very close events sometimes.

This only addresses the Linux (X11 backend) case.

Differential Revision: https://developer.blender.org/D9209

===

M   intern/ghost/intern/GHOST_SystemX11.cpp
M   intern/ghost/intern/GHOST_SystemX11.h

===

diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp 
b/intern/ghost/intern/GHOST_SystemX11.cpp
index 8d4b7ff767c..1906ec67c33 100644
--- a/intern/ghost/intern/GHOST_SystemX11.cpp
+++ b/intern/ghost/intern/GHOST_SystemX11.cpp
@@ -175,7 +175,8 @@ GHOST_SystemX11::GHOST_SystemX11() : GHOST_System(), 
m_xkb_descr(NULL), m_start_
 #undef GHOST_INTERN_ATOM_IF_EXISTS
 #undef GHOST_INTERN_ATOM
 
-  m_last_warp = 0;
+  m_last_warp_x = 0;
+  m_last_warp_y = 0;
   m_last_release_keycode = 0;
   m_last_release_time = 0;
 
@@ -981,17 +982,24 @@ void GHOST_SystemX11::processEvent(XEvent *xe)
 window->getCursorGrabAccum(x_accum, y_accum);
 
 if (x_new != xme.x_root || y_new != xme.y_root) {
-  if (xme.time > m_last_warp) {
-/* when wrapping we don't need to add an event because the
- * setCursorPosition call will cause a new event after */
-setCursorPosition(x_new, y_new); /* wrap */
-window->setCursorGrabAccum(x_accum + (xme.x_root - x_new),
-   y_accum + (xme.y_root - y_new));
-m_last_warp = lastEventTime(xme.time);
+  /* Use time of last event to avoid wrapping several times on the 
'same' actual wrap.
+   * Note that we need to deal with X and Y separately as those might 
wrap at the same time
+   * but still in two different events (corner case, see T74918).
+   * We also have to add a few extra milliseconds of 'padding', as 
sometimes we get two
+   * close events that will generate extra wrap on the same axis 
within those few
+   * milliseconds. */
+  if (x_new != xme.x_root && xme.time > m_last_warp_x) {
+x_accum += (xme.x_root - x_new);
+m_last_warp_x = lastEventTime(xme.time) + 25;
   }
-  else {
-setCursorPosition(x_new, y_new); /* wrap but don't accumulate */
+  if (y_new != xme.y_root && xme.time > m_last_warp_y) {
+y_accum += (xme.y_root - y_new);
+m_last_warp_y = lastEventTime(xme.time) + 25;
   }
+  window->setCursorGrabAccum(x_accum, y_accum);
+  /* When wrapping we don't need to add an event because the
+   * #setCursorPosition call will cause a new event after. */
+  setCursorPosition(x_new, y_new); /* wrap */
 }
 else {
   g_event = new GHOST_EventCursor(getMilliSeconds(),
diff --git a/intern/ghost/intern/GHOST_SystemX11.h 
b/intern/ghost/intern/GHOST_SystemX11.h
index a852675acfb..ee29f463fb6 100644
--- a/intern/ghost/intern/GHOST_SystemX11.h
+++ b/intern/ghost/intern/GHOST_SystemX11.h
@@ -361,7 +361,8 @@ class GHOST_SystemX11 : public GHOST_System {
* To prevent multiple warp, we store the time of the last warp event
* and stop accumulating all events generated before that.
*/
-  Time m_last_warp;
+  Time m_last_warp_x;
+  Time m_last_warp_y;
 
   /* Detect auto-repeat glitch. */
   unsigned int m_last_release_keycode;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [717c9f06825] lanpr-under-gp: LineArt: apply camera scale before matrix

2020-10-15 Thread YimingWu
Commit: 717c9f068258e59c71a1f552b1806615ac218093
Author: YimingWu
Date:   Thu Oct 15 19:38:53 2020 +0800
Branches: lanpr-under-gp
https://developer.blender.org/rB717c9f068258e59c71a1f552b1806615ac218093

LineArt: apply camera scale before matrix

===

M   source/blender/editors/lineart/lineart_cpu.c

===

diff --git a/source/blender/editors/lineart/lineart_cpu.c 
b/source/blender/editors/lineart/lineart_cpu.c
index 27fa7dd9303..ac6ed8d9985 100644
--- a/source/blender/editors/lineart/lineart_cpu.c
+++ b/source/blender/editors/lineart/lineart_cpu.c
@@ -913,13 +913,13 @@ static void 
lineart_main_cull_triangles(LineartRenderBuffer *rb, bool clip_far)
 #define REMOVE_ORIGINAL_LINES \
   BLI_remlink(&rb->all_render_lines, (void *)rt->rl[0]); \
   rt->rl[0]->next = rt->rl[0]->prev = 0; \
-  rt->rl[0]->flags |= LRT_EDGE_FLAG_CHAIN_PICKED; \
+  rt->rl[0]->flags |= LRT_EDGE_FLAG_CHAIN_PICKED;\
   BLI_remlink(&rb->all_render_lines, (void *)rt->rl[1]); \
   rt->rl[1]->next = rt->rl[1]->prev = 0; \
-  rt->rl[1]->flags |= LRT_EDGE_FLAG_CHAIN_PICKED; \
+  rt->rl[1]->flags |= LRT_EDGE_FLAG_CHAIN_PICKED;\
   BLI_remlink(&rb->all_render_lines, (void *)rt->rl[2]); \
   rt->rl[2]->next = rt->rl[2]->prev = 0; \
-  rt->rl[2]->flags |= LRT_EDGE_FLAG_CHAIN_PICKED;
+  rt->rl[2]->flags |= LRT_EDGE_FLAG_CHAIN_PICKED;\
 
   switch (in0 + in1 + in2) {
 case 0: /* ignore this triangle. */
@@ -1811,7 +1811,7 @@ static void lineart_main_load_geometries(Depsgraph 
*depsgraph,
   double w = cam->ortho_scale / 2;
   lineart_matrix_ortho_44d(proj, -w, w, -w / asp, w / asp, 
cam->clip_start, cam->clip_end);
 }
-invert_m4_m4(inv, camera->obmat);
+invert_m4_m4(inv, rb->cam_obmat);
 mul_m4db_m4db_m4fl_uniq(result, proj, inv);
 copy_m4_m4_db(proj, result);
 copy_m4_m4_db(rb->view_projection, proj);
@@ -2449,6 +2449,8 @@ static void 
lineart_main_get_view_vector(LineartRenderBuffer *rb)
   float direction[3] = {0, 0, 1};
   float trans[3];
   float inv[4][4];
+  float obmat_no_scale[4][4];
+  float scale[3];
 
   BLI_spin_lock(&lineart_share.lock_render_status);
   if (lineart_share.viewport_camera_override) {
@@ -2460,11 +2462,16 @@ static void 
lineart_main_get_view_vector(LineartRenderBuffer *rb)
 }
   }
   else {
-invert_m4_m4(inv, rb->cam_obmat);
+copy_m4_m4(obmat_no_scale,rb->cam_obmat);
   }
   BLI_spin_unlock(&lineart_share.lock_render_status);
+  normalize_v3(obmat_no_scale[0]);
+  normalize_v3(obmat_no_scale[1]);
+  normalize_v3(obmat_no_scale[2]);
+  invert_m4_m4(inv, obmat_no_scale);
   transpose_m4(inv);
   mul_v3_mat3_m4v3(trans, inv, direction);
+  copy_m4_m4(rb->cam_obmat,obmat_no_scale);
   copy_v3db_v3fl(rb->view_vector, trans);
 }
 
@@ -3840,6 +3847,7 @@ int ED_lineart_compute_feature_lines_internal(Depsgraph 
*depsgraph, const int sh
 
   LRT_PROGRESS(0, "LRT: Loading geometries.");
 
+  lineart_main_get_view_vector(rb);
   lineart_main_load_geometries(depsgraph, scene, scene->camera, rb);
 
   /** We had everything we need,
@@ -3854,7 +3862,6 @@ int ED_lineart_compute_feature_lines_internal(Depsgraph 
*depsgraph, const int sh
 
   LRT_CANCEL_STAGE
 
-  lineart_main_get_view_vector(rb);
   lineart_main_cull_triangles(rb, false);
   lineart_main_cull_triangles(rb, true);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [8bfaf0152ba] lanpr-under-gp: Merge remote-tracking branch 'origin/master' into lanpr-under-gp

2020-10-15 Thread YimingWu
Commit: 8bfaf0152bad77c280d26901832ea3913db228a1
Author: YimingWu
Date:   Thu Oct 15 18:39:09 2020 +0800
Branches: lanpr-under-gp
https://developer.blender.org/rB8bfaf0152bad77c280d26901832ea3913db228a1

Merge remote-tracking branch 'origin/master' into lanpr-under-gp

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [40ba7e7392f] lanpr-under-gp: LineArt: Clipped crease line does not show. Fixed.

2020-10-15 Thread YimingWu
Commit: 40ba7e7392f7aff3ded8f4bd798ea9fd7ed621c6
Author: YimingWu
Date:   Thu Oct 15 19:50:21 2020 +0800
Branches: lanpr-under-gp
https://developer.blender.org/rB40ba7e7392f7aff3ded8f4bd798ea9fd7ed621c6

LineArt: Clipped crease line does not show. Fixed.

===

M   source/blender/editors/lineart/lineart_cpu.c

===

diff --git a/source/blender/editors/lineart/lineart_cpu.c 
b/source/blender/editors/lineart/lineart_cpu.c
index ac6ed8d9985..a68b81eae87 100644
--- a/source/blender/editors/lineart/lineart_cpu.c
+++ b/source/blender/editors/lineart/lineart_cpu.c
@@ -713,6 +713,7 @@ static LineartRenderElementLinkNode 
*lineart_memory_get_line_space(LineartRender
   render_lines,
   
sizeof(LineartRenderElementLinkNode));
   reln->element_count = 64;
+  reln->crease_threshold = rb->crease_threshold;
   reln->flags |= LRT_ELEMENT_IS_ADDITIONAL;
 
   return reln;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [f1aa55b6e9c] master: Cleanup: rename BPy_GetContext -> BPY_context_get

2020-10-15 Thread Campbell Barton
Commit: f1aa55b6e9cd8ec4d7eb7fead853a4436b35d4cd
Author: Campbell Barton
Date:   Thu Oct 15 18:20:15 2020 +1100
Branches: master
https://developer.blender.org/rBf1aa55b6e9cd8ec4d7eb7fead853a4436b35d4cd

Cleanup: rename BPy_GetContext -> BPY_context_get

Matching BPY_context_set.

===

M   source/blender/python/intern/bpy_interface.c
M   source/blender/python/intern/bpy_interface_atexit.c
M   source/blender/python/intern/bpy_library_load.c
M   source/blender/python/intern/bpy_msgbus.c
M   source/blender/python/intern/bpy_operator.c
M   source/blender/python/intern/bpy_rna.c
M   source/blender/python/intern/bpy_rna_anim.c
M   source/blender/python/intern/bpy_rna_gizmo.c

===

diff --git a/source/blender/python/intern/bpy_interface.c 
b/source/blender/python/intern/bpy_interface.c
index 468abd7b575..49a17bbf1bf 100644
--- a/source/blender/python/intern/bpy_interface.c
+++ b/source/blender/python/intern/bpy_interface.c
@@ -239,7 +239,7 @@ void BPY_modules_update(void)
   BPY_update_rna_module();
 }
 
-bContext *BPy_GetContext(void)
+bContext *BPY_context_get(void)
 {
   return bpy_context_module->ptr.data;
 }
diff --git a/source/blender/python/intern/bpy_interface_atexit.c 
b/source/blender/python/intern/bpy_interface_atexit.c
index e69914671dd..8e5a6dc530b 100644
--- a/source/blender/python/intern/bpy_interface_atexit.c
+++ b/source/blender/python/intern/bpy_interface_atexit.c
@@ -34,7 +34,7 @@
 static PyObject *bpy_atexit(PyObject *UNUSED(self), PyObject *UNUSED(args), 
PyObject *UNUSED(kw))
 {
   /* close down enough of blender at least not to crash */
-  struct bContext *C = BPy_GetContext();
+  struct bContext *C = BPY_context_get();
 
   WM_exit_ex(C, false);
 
diff --git a/source/blender/python/intern/bpy_library_load.c 
b/source/blender/python/intern/bpy_library_load.c
index a3750d348f5..061595a6c5d 100644
--- a/source/blender/python/intern/bpy_library_load.c
+++ b/source/blender/python/intern/bpy_library_load.c
@@ -180,7 +180,7 @@ PyDoc_STRVAR(
 "   :type relative: bool\n");
 static PyObject *bpy_lib_load(PyObject *UNUSED(self), PyObject *args, PyObject 
*kw)
 {
-  Main *bmain = CTX_data_main(BPy_GetContext());
+  Main *bmain = CTX_data_main(BPY_context_get());
   BPy_Library *ret;
   const char *filename = NULL;
   bool is_rel = false, is_link = false;
@@ -319,7 +319,7 @@ static void bpy_lib_exit_warn_type(BPy_Library *self, 
PyObject *item)
 
 static PyObject *bpy_lib_exit(BPy_Library *self, PyObject *UNUSED(args))
 {
-  Main *bmain = CTX_data_main(BPy_GetContext());
+  Main *bmain = CTX_data_main(BPY_context_get());
   Main *mainl = NULL;
   const int err = 0;
   const bool do_append = ((self->flag & FILE_LINK) == 0);
diff --git a/source/blender/python/intern/bpy_msgbus.c 
b/source/blender/python/intern/bpy_msgbus.c
index 3739f56dc79..df45007b68f 100644
--- a/source/blender/python/intern/bpy_msgbus.c
+++ b/source/blender/python/intern/bpy_msgbus.c
@@ -265,7 +265,7 @@ static PyObject *bpy_msgbus_subscribe_rna(PyObject 
*UNUSED(self), PyObject *args
   }
 
   /* Note: we may want to have a way to pass this in. */
-  bContext *C = (bContext *)BPy_GetContext();
+  bContext *C = BPY_context_get();
   struct wmMsgBus *mbus = CTX_wm_message_bus(C);
   wmMsgParams_RNA msg_key_params = {{0}};
 
@@ -340,7 +340,7 @@ static PyObject *bpy_msgbus_publish_rna(PyObject 
*UNUSED(self), PyObject *args,
   }
 
   /* Note: we may want to have a way to pass this in. */
-  bContext *C = (bContext *)BPy_GetContext();
+  bContext *C = BPY_context_get();
   struct wmMsgBus *mbus = CTX_wm_message_bus(C);
   wmMsgParams_RNA msg_key_params = {{0}};
 
@@ -359,7 +359,7 @@ PyDoc_STRVAR(bpy_msgbus_clear_by_owner_doc,
  "   Clear all subscribers using this owner.\n");
 static PyObject *bpy_msgbus_clear_by_owner(PyObject *UNUSED(self), PyObject 
*py_owner)
 {
-  bContext *C = (bContext *)BPy_GetContext();
+  bContext *C = BPY_context_get();
   struct wmMsgBus *mbus = CTX_wm_message_bus(C);
   WM_msgbus_clear_by_owner(mbus, py_owner);
   Py_RETURN_NONE;
diff --git a/source/blender/python/intern/bpy_operator.c 
b/source/blender/python/intern/bpy_operator.c
index f263fd549da..8b65bb22889 100644
--- a/source/blender/python/intern/bpy_operator.c
+++ b/source/blender/python/intern/bpy_operator.c
@@ -84,7 +84,7 @@ static PyObject *pyop_poll(PyObject *UNUSED(self), PyObject 
*args)
 
   /* XXX Todo, work out a better solution for passing on context,
* could make a tuple from self and pack the name and Context into it... */
-  bContext *C = (bContext *)BPy_GetContext();
+  bContext *C = BPY_context_get();
 
   if (C == NULL) {
 PyErr_SetString(PyExc_RuntimeError, "Context is None, cant poll any 
operators");
@@ -171,7 +171,7 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject 
*args)
 
   /* XXX Todo, work out a better solution for passing on contex

[Bf-blender-cvs] [5531697f6d4] master: Cleanup: remove duplicate context variable (__py_context)

2020-10-15 Thread Campbell Barton
Commit: 5531697f6d4a27137dd91996ee80d452b7147a02
Author: Campbell Barton
Date:   Thu Oct 15 18:12:03 2020 +1100
Branches: master
https://developer.blender.org/rB5531697f6d4a27137dd91996ee80d452b7147a02

Cleanup: remove duplicate context variable (__py_context)

The context was stored both in __py_context & bpy_context_module.

This avoids duplicate functions to update them too.

===

M   source/blender/blenkernel/intern/blendfile.c
M   source/blender/python/BPY_extern.h
M   source/blender/python/BPY_extern_python.h
M   source/blender/python/intern/bpy.c
M   source/blender/python/intern/bpy.h
M   source/blender/python/intern/bpy_capi_utils.c
M   source/blender/python/intern/bpy_capi_utils.h
M   source/blender/python/intern/bpy_interface.c
M   source/blender/python/intern/bpy_operator.c
M   source/blender/python/intern/bpy_rna.c
M   source/blender/windowmanager/intern/wm_init_exit.c

===

diff --git a/source/blender/blenkernel/intern/blendfile.c 
b/source/blender/blenkernel/intern/blendfile.c
index 9dabbb021b6..567773507cf 100644
--- a/source/blender/blenkernel/intern/blendfile.c
+++ b/source/blender/blenkernel/intern/blendfile.c
@@ -330,7 +330,9 @@ static void setup_app_data(bContext *C,
 
 #ifdef WITH_PYTHON
   /* let python know about new main */
-  BPY_context_update(C);
+  if (CTX_py_init_get(C)) {
+BPY_context_update(C);
+  }
 #endif
 
   /* FIXME: this version patching should really be part of the file-reading 
code,
diff --git a/source/blender/python/BPY_extern.h 
b/source/blender/python/BPY_extern.h
index 6ed403bb21a..46b4dbc96d7 100644
--- a/source/blender/python/BPY_extern.h
+++ b/source/blender/python/BPY_extern.h
@@ -68,8 +68,7 @@ void BPY_thread_restore(BPy_ThreadStatePtr tstate);
   (void)0
 
 void BPY_text_free_code(struct Text *text);
-void BPY_modules_update(
-struct bContext *C); /* XXX - annoying, need this for pointers that get 
out of date */
+void BPY_modules_update(void);
 void BPY_modules_load_user(struct bContext *C);
 
 void BPY_app_handlers_reset(const short do_all);
diff --git a/source/blender/python/BPY_extern_python.h 
b/source/blender/python/BPY_extern_python.h
index 70b5cd679b9..c321fd93379 100644
--- a/source/blender/python/BPY_extern_python.h
+++ b/source/blender/python/BPY_extern_python.h
@@ -32,7 +32,7 @@ extern "C" {
 #include 
 
 /* bpy_interface.c */
-void BPY_python_start(int argc, const char **argv);
+void BPY_python_start(struct bContext *C, int argc, const char **argv);
 void BPY_python_end(void);
 void BPY_python_reset(struct bContext *C);
 void BPY_python_use_system_env(void);
diff --git a/source/blender/python/intern/bpy.c 
b/source/blender/python/intern/bpy.c
index 75314e4e2ea..804a28d0ebc 100644
--- a/source/blender/python/intern/bpy.c
+++ b/source/blender/python/intern/bpy.c
@@ -349,7 +349,7 @@ static PyObject *bpy_import_test(const char *modname)
 /**
  * Description: Creates the bpy module and adds it to sys.modules for importing
  
**/
-void BPy_init_modules(void)
+void BPy_init_modules(struct bContext *C)
 {
   PointerRNA ctx_ptr;
   PyObject *mod;
@@ -400,8 +400,7 @@ void BPy_init_modules(void)
   PyModule_AddObject(mod, "_utils_previews", BPY_utils_previews_module());
   PyModule_AddObject(mod, "msgbus", BPY_msgbus_module());
 
-  /* bpy context */
-  RNA_pointer_create(NULL, &RNA_Context, (void *)BPy_GetContext(), &ctx_ptr);
+  RNA_pointer_create(NULL, &RNA_Context, C, &ctx_ptr);
   bpy_context_module = (BPy_StructRNA *)pyrna_struct_CreatePyObject(&ctx_ptr);
   /* odd that this is needed, 1 ref on creation and another for the module
* but without we get a crash on exit */
diff --git a/source/blender/python/intern/bpy.h 
b/source/blender/python/intern/bpy.h
index 744bf903443..e2fe84f71c7 100644
--- a/source/blender/python/intern/bpy.h
+++ b/source/blender/python/intern/bpy.h
@@ -24,7 +24,9 @@
 extern "C" {
 #endif
 
-void BPy_init_modules(void);
+struct bContext;
+
+void BPy_init_modules(struct bContext *C);
 extern PyObject *bpy_package_py;
 
 /* bpy_interface_atexit.c */
diff --git a/source/blender/python/intern/bpy_capi_utils.c 
b/source/blender/python/intern/bpy_capi_utils.c
index 8eb44e918d7..57dc4c0a679 100644
--- a/source/blender/python/intern/bpy_capi_utils.c
+++ b/source/blender/python/intern/bpy_capi_utils.c
@@ -38,16 +38,6 @@
 
 #include "../generic/py_capi_utils.h"
 
-static bContext *__py_context = NULL;
-bContext *BPy_GetContext(void)
-{
-  return __py_context;
-}
-void BPy_SetContext(bContext *C)
-{
-  __py_context = C;
-}
-
 char *BPy_enum_as_string(const EnumPropertyItem *item)
 {
   DynStr *dynstr = BLI_dynstr_new();
diff --git a/source/blender/python/intern/bpy_capi_utils.h 
b/source/blender/python/intern

[Bf-blender-cvs] [1cc3abca701] master: Fix T80768: Subdivision Surface modifier uses viewport subdivision settings when rendering in edit mode

2020-10-15 Thread Janusch Patas
Commit: 1cc3abca701775e0ddb0756a262df99b8e7a0276
Author: Janusch Patas
Date:   Thu Oct 15 09:32:13 2020 +0200
Branches: master
https://developer.blender.org/rB1cc3abca701775e0ddb0756a262df99b8e7a0276

Fix T80768: Subdivision Surface modifier uses viewport subdivision settings 
when rendering in edit mode

Being in render 'context'was not taken into account in code evaluating
modifiers for meshes in Edit mode.

Reviewed By: #modeling, mont29

Differential Revision: https://developer.blender.org/D9217

===

M   source/blender/blenkernel/intern/DerivedMesh.c

===

diff --git a/source/blender/blenkernel/intern/DerivedMesh.c 
b/source/blender/blenkernel/intern/DerivedMesh.c
index 88d8073b989..d551eaf04e4 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -1488,8 +1488,10 @@ static void editbmesh_calc_modifiers(struct Depsgraph 
*depsgraph,
   /* Modifier evaluation modes. */
   const int required_mode = eModifierMode_Realtime | eModifierMode_Editmode;
 
+  const bool use_render = (DEG_get_mode(depsgraph) == DAG_EVAL_RENDER);
   /* Modifier evaluation contexts for different types of modifiers. */
-  const ModifierEvalContext mectx = {depsgraph, ob, MOD_APPLY_USECACHE};
+  ModifierApplyFlag apply_render = use_render ? MOD_APPLY_RENDER : 0;
+  const ModifierEvalContext mectx = {depsgraph, ob, MOD_APPLY_USECACHE | 
apply_render};
   const ModifierEvalContext mectx_orco = {depsgraph, ob, MOD_APPLY_ORCO};
 
   /* Get effective list of modifiers to execute. Some effects like shape keys

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [7b951ba5c32] master: Cleanup: Do not compare bool value to 0.

2020-10-15 Thread Bastien Montagne
Commit: 7b951ba5c32a5b78a958e22aa310e7489b39ae00
Author: Bastien Montagne
Date:   Thu Oct 15 09:31:04 2020 +0200
Branches: master
https://developer.blender.org/rB7b951ba5c32a5b78a958e22aa310e7489b39ae00

Cleanup: Do not compare bool value to 0.

===

M   source/blender/blenloader/intern/readfile.c

===

diff --git a/source/blender/blenloader/intern/readfile.c 
b/source/blender/blenloader/intern/readfile.c
index 5623f8e5eea..c72788c01da 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -8144,7 +8144,7 @@ static void add_loose_objects_to_scene(Main *mainvar,
 if (ob->id.us == 0) {
   do_it = true;
 }
-else if ((ob->id.lib == lib) && (object_in_any_collection(bmain, ob) 
== 0)) {
+else if ((ob->id.lib == lib) && !object_in_any_collection(bmain, ob)) {
   /* When appending, make sure any indirectly loaded object gets a 
base,
* when they are not part of any collection yet. */
   do_it = true;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs