[Bf-blender-cvs] [fc0b1627ebb] master: Fix T100953: Zooming with NDOF is inverted in the camera view

2022-10-06 Thread Campbell Barton
Commit: fc0b1627ebb821b1897cbca7f6ba9be29e52359a
Author: Campbell Barton
Date:   Fri Oct 7 17:44:17 2022 +1100
Branches: master
https://developer.blender.org/rBfc0b1627ebb821b1897cbca7f6ba9be29e52359a

Fix T100953: Zooming with NDOF is inverted in the camera view

Use convention for applying zoom in other 2D views.

===

M   source/blender/editors/space_view3d/view3d_navigate_ndof.c

===

diff --git a/source/blender/editors/space_view3d/view3d_navigate_ndof.c 
b/source/blender/editors/space_view3d/view3d_navigate_ndof.c
index 22b3a4b968e..893c9008f23 100644
--- a/source/blender/editors/space_view3d/view3d_navigate_ndof.c
+++ b/source/blender/editors/space_view3d/view3d_navigate_ndof.c
@@ -376,6 +376,9 @@ static int view3d_ndof_cameraview_pan_zoom(bContext *C, 
const wmEvent *event)
   float pan_vec[3];
   WM_event_ndof_pan_get(ndof, pan_vec, true);
 
+  mul_v2_fl(pan_vec, ndof->dt);
+  pan_vec[2] *= -ndof->dt;
+
   /* NOTE(@campbellbarton): In principle rotating could pass through to regular
* non-camera NDOF behavior (exiting the camera-view and rotating).
* Disabled this block since in practice it's difficult to control NDOF 
devices
@@ -390,7 +393,7 @@ static int view3d_ndof_cameraview_pan_zoom(bContext *C, 
const wmEvent *event)
   bool changed = false;
 
   if (has_translate) {
-const float speed = ndof->dt * NDOF_PIXELS_PER_SECOND;
+const float speed = NDOF_PIXELS_PER_SECOND;
 float event_ofs[2] = {pan_vec[0] * speed, pan_vec[1] * speed};
 if (ED_view3d_camera_view_pan(region, event_ofs)) {
   changed = true;
@@ -398,7 +401,7 @@ static int view3d_ndof_cameraview_pan_zoom(bContext *C, 
const wmEvent *event)
   }
 
   if (has_zoom) {
-const float scale = 1.0f + (ndof->dt * pan_vec[2]);
+const float scale = 1.0f + pan_vec[2];
 if (ED_view3d_camera_view_zoom_scale(rv3d, scale)) {
   changed = true;
 }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [3522c6e59c3] master: Cleanup: replace static variables with arguments

2022-10-06 Thread Campbell Barton
Commit: 3522c6e59c34a1ed6143840c250e1b7b446b8a4e
Author: Campbell Barton
Date:   Fri Oct 7 16:31:32 2022 +1100
Branches: master
https://developer.blender.org/rB3522c6e59c34a1ed6143840c250e1b7b446b8a4e

Cleanup: replace static variables with arguments

Functions in vfontdata_freetype.c used static variables instead of
argument parsing. This originates from initial freetype support [0].

This didn't cause problems as callers use a global lock, however it
makes the code more difficult to follow means we can more easily remove
the lock in the future.

[0]: d4f9678b3939a3b480005fee3b82ad8843de51e0

===

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

===

diff --git a/source/blender/blenkernel/intern/vfontdata_freetype.c 
b/source/blender/blenkernel/intern/vfontdata_freetype.c
index 5fcf81c8810..9fe83ce7aa0 100644
--- a/source/blender/blenkernel/intern/vfontdata_freetype.c
+++ b/source/blender/blenkernel/intern/vfontdata_freetype.c
@@ -34,10 +34,6 @@
 #include "DNA_packedFile_types.h"
 #include "DNA_vfont_types.h"
 
-/* local variables */
-static FT_Library library;
-static FT_Error err;
-
 static VChar *freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData 
*vfd)
 {
   const float scale = vfd->scale;
@@ -60,7 +56,7 @@ static VChar *freetypechar_to_vchar(FT_Face face, FT_ULong 
charcode, VFontData *
*
* Get the FT Glyph index and load the Glyph */
   glyph_index = FT_Get_Char_Index(face, charcode);
-  err = FT_Load_Glyph(face, glyph_index, FT_LOAD_NO_SCALE | FT_LOAD_NO_BITMAP);
+  FT_Error err = FT_Load_Glyph(face, glyph_index, FT_LOAD_NO_SCALE | 
FT_LOAD_NO_BITMAP);
 
   /* If loading succeeded, convert the FT glyph to the internal format */
   if (!err) {
@@ -240,7 +236,7 @@ static VChar *freetypechar_to_vchar(FT_Face face, FT_ULong 
charcode, VFontData *
   return NULL;
 }
 
-static VChar *objchr_to_ftvfontdata(VFont *vfont, FT_ULong charcode)
+static VChar *objchr_to_ftvfontdata(FT_Library library, VFont *vfont, FT_ULong 
charcode)
 {
   VChar *che;
 
@@ -249,13 +245,13 @@ static VChar *objchr_to_ftvfontdata(VFont *vfont, 
FT_ULong charcode)
 
   /* Load the font to memory */
   if (vfont->temp_pf) {
-err = FT_New_Memory_Face(library, vfont->temp_pf->data, 
vfont->temp_pf->size, 0, &face);
+FT_Error err = FT_New_Memory_Face(
+library, vfont->temp_pf->data, vfont->temp_pf->size, 0, &face);
 if (err) {
   return NULL;
 }
   }
   else {
-err = true;
 return NULL;
   }
 
@@ -266,7 +262,7 @@ static VChar *objchr_to_ftvfontdata(VFont *vfont, FT_ULong 
charcode)
   return che;
 }
 
-static FT_Face vfont_face_load_from_packed_file(PackedFile *pf)
+static FT_Face vfont_face_load_from_packed_file(FT_Library library, PackedFile 
*pf)
 {
   FT_Face face = NULL;
   FT_New_Memory_Face(library, pf->data, pf->size, 0, &face);
@@ -281,14 +277,14 @@ static FT_Face 
vfont_face_load_from_packed_file(PackedFile *pf)
   }
 
   /* Select a character map. */
-  FT_Error err_charmap = FT_Select_Charmap(face, FT_ENCODING_UNICODE);
-  if (err_charmap) {
-err_charmap = FT_Select_Charmap(face, FT_ENCODING_APPLE_ROMAN);
+  FT_Error err = FT_Select_Charmap(face, FT_ENCODING_UNICODE);
+  if (err) {
+err = FT_Select_Charmap(face, FT_ENCODING_APPLE_ROMAN);
   }
-  if (err_charmap && face->num_charmaps > 0) {
-err_charmap = FT_Select_Charmap(face, face->charmaps[0]->encoding);
+  if (err && face->num_charmaps > 0) {
+err = FT_Select_Charmap(face, face->charmaps[0]->encoding);
   }
-  if (err_charmap) {
+  if (err) {
 FT_Done_Face(face);
 return NULL;
   }
@@ -307,11 +303,12 @@ static FT_Face 
vfont_face_load_from_packed_file(PackedFile *pf)
 
 VFontData *BKE_vfontdata_from_freetypefont(PackedFile *pf)
 {
+  FT_Library library = NULL;
   if (FT_Init_FreeType(&library) != FT_Err_Ok) {
 return NULL;
   }
 
-  FT_Face face = vfont_face_load_from_packed_file(pf);
+  FT_Face face = vfont_face_load_from_packed_file(library, pf);
   if (!face) {
 FT_Done_FreeType(library);
 return NULL;
@@ -399,14 +396,15 @@ VChar *BKE_vfontdata_char_from_freetypefont(VFont *vfont, 
ulong character)
   }
 
   /* Init Freetype */
-  err = FT_Init_FreeType(&library);
+  FT_Library library = NULL;
+  FT_Error err = FT_Init_FreeType(&library);
   if (err) {
 /* XXX error("Failed to load the Freetype font library"); */
 return NULL;
   }
 
   /* Load the character */
-  che = objchr_to_ftvfontdata(vfont, character);
+  che = objchr_to_ftvfontdata(library, vfont, character);
 
   /* Free Freetype */
   FT_Done_FreeType(library);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [0d16625d35d] master: Cleanup: use doxy sections

2022-10-06 Thread Campbell Barton
Commit: 0d16625d35d4028daa43e516e99b16e083252c8b
Author: Campbell Barton
Date:   Fri Oct 7 16:05:17 2022 +1100
Branches: master
https://developer.blender.org/rB0d16625d35d4028daa43e516e99b16e083252c8b

Cleanup: use doxy sections

Also use doxy syntax for some comments.

===

M   intern/ghost/intern/GHOST_SystemWayland.cpp
M   source/blender/editors/include/UI_view2d.h

===

diff --git a/intern/ghost/intern/GHOST_SystemWayland.cpp 
b/intern/ghost/intern/GHOST_SystemWayland.cpp
index c54d9769eeb..0721ca78603 100644
--- a/intern/ghost/intern/GHOST_SystemWayland.cpp
+++ b/intern/ghost/intern/GHOST_SystemWayland.cpp
@@ -68,6 +68,12 @@ static void keyboard_handle_key_repeat_cancel(struct 
GWL_Seat *seat);
 
 static void output_handle_done(void *data, struct wl_output *wl_output);
 
+/*  */
+/** \name Local Defines
+ *
+ * Control local functionality, compositors specific workarounds.
+ * \{ */
+
 /**
  * GNOME (mutter 42.2 had a bug with confine not respecting scale - Hi-DPI), 
See: T98793.
  * Even though this has been fixed, at time of writing it's not yet in a 
release.
@@ -100,6 +106,8 @@ static bool use_gnome_confine_hack = false;
  */
 #define USE_GNOME_KEYBOARD_SUPPRESS_WARNING
 
+/** \} */
+
 /*  */
 /** \name Inline Event Codes
  *
diff --git a/source/blender/editors/include/UI_view2d.h 
b/source/blender/editors/include/UI_view2d.h
index bdd830e0046..c357b67722d 100644
--- a/source/blender/editors/include/UI_view2d.h
+++ b/source/blender/editors/include/UI_view2d.h
@@ -16,37 +16,39 @@
 extern "C" {
 #endif
 
-/* -- */
-/* Settings and Defines:  */
+/*  */
+/** \name General Defines
+ * \{ */
 
-/*  General Defines  */
-
-/* generic value to use when coordinate lies out of view when converting */
+/** Generic value to use when coordinate lies out of view when converting. */
 #define V2D_IS_CLIPPED 12000
 
-/* Common View2D view types
- * NOTE: only define a type here if it completely sets all (+/- a few) of the 
relevant flags
- *   and settings for a View2D region, and that set of settings is used in 
more
- *   than one specific place
+/**
+ * Common View2D view types.
+ *
+ * \note only define a type here if it completely sets all (+/- a few) of the 
relevant flags and
+ * settings for a View2D region, and that set of settings is used in more than 
one specific place.
  */
 enum eView2D_CommonViewTypes {
-  /* custom view type (region has defined all necessary flags already) */
+  /** custom view type (region has defined all necessary flags already). */
   V2D_COMMONVIEW_CUSTOM = -1,
-  /* standard (only use this when setting up a new view, as a sensible base 
for most settings) */
+  /** standard (only use this when setting up a new view, as a sensible base 
for most settings). */
   V2D_COMMONVIEW_STANDARD,
-  /* listview (i.e. Outliner) */
+  /** List-view (i.e. Outliner). */
   V2D_COMMONVIEW_LIST,
-  /* Stack-view (this is basically a list where new items are added at the 
top). */
+  /** Stack-view (this is basically a list where new items are added at the 
top). */
   V2D_COMMONVIEW_STACK,
-  /* headers (this is basically the same as listview, but no y-panning) */
+  /** headers (this is basically the same as list-view, but no Y-panning). */
   V2D_COMMONVIEW_HEADER,
-  /* ui region containing panels */
+  /** UI region containing panels. */
   V2D_COMMONVIEW_PANELS_UI,
 };
 
-/*  Defines for Scroller Arguments - */
+/** \} */
 
-/* -- Defines for Scrollers - */
+/*  */
+/** \name Defines for Scroll Bars
+ * \{ */
 
 /** Scroll bar area. */
 
@@ -74,15 +76,22 @@ enum eView2D_CommonViewTypes {
 /** Don't allow scroll thumb to show below this size (so it's never too small 
to click on). */
 #define V2D_SCROLL_THUMB_SIZE_MIN (30.0 * UI_DPI_FAC)
 
-/* -- Define for UI_view2d_sync - */
+/** \} */
+
+/*  */
+/** \name Define for #UI_view2d_sync
+ * \{ */
 
 /* means copy it from another v2d */
 #define V2D_LOCK_SET 0
 /* means copy it to the other v2ds */
 #define V2D_LOCK_COPY 1
 
-/* -- */
-/* Macros:*/
+/** \} */
+
+/*  */
+/** \name Macros
+ * \{ */
 
 /* Test if mouse in a scroll-bar (assume that scroller availability has been 
tested). */
 #define IN_2D_VERT_SCROLL(v2d, co) (BLI_rcti_isect_pt_v(&v2d->vert, co))
@@ -91,8 +100,11 @@ enum eView2D_CommonViewTypes {
 #define IN_2D_VERT_SCROLL_

[Bf-blender-cvs] [650beef4b67] master: GHOST/Wayland: silence warnings for modifier key handling in GNOME

2022-10-06 Thread Campbell Barton
Commit: 650beef4b670392eb3cb80dd4b8e3c3ba586d5f2
Author: Campbell Barton
Date:   Fri Oct 7 15:53:47 2022 +1100
Branches: master
https://developer.blender.org/rB650beef4b670392eb3cb80dd4b8e3c3ba586d5f2

GHOST/Wayland: silence warnings for modifier key handling in GNOME

GNOME (mutter) intentionally doesn't follow the Wayland spec for the
keyboard_enter events (held keys are always an empty array).

This means we can't know which keys are held on window activation,
making the result of getModifierKeys invalid (in that we don't know
which modifiers are held).

Detect this situation and suppress warnings as the issue has been
reported and it doesn't help for users to see noisy warnings for
a known problem.

===

M   intern/ghost/intern/GHOST_SystemWayland.cpp

===

diff --git a/intern/ghost/intern/GHOST_SystemWayland.cpp 
b/intern/ghost/intern/GHOST_SystemWayland.cpp
index d569d24926d..c54d9769eeb 100644
--- a/intern/ghost/intern/GHOST_SystemWayland.cpp
+++ b/intern/ghost/intern/GHOST_SystemWayland.cpp
@@ -86,6 +86,20 @@ static void output_handle_done(void *data, struct wl_output 
*wl_output);
 static bool use_gnome_confine_hack = false;
 #endif
 
+/**
+ * GNOME (mutter 42.5) doesn't follow the WAYLAND spec regarding keyboard 
handling,
+ * unlike (other compositors: KDE-plasma, River & Sway which work without 
problems).
+ *
+ * This means GNOME can't know which modifiers are held when activating 
windows,
+ * so we guess the left modifiers are held.
+ *
+ * This define could be removed without changing any functionality,
+ * it just means GNOME users will see verbose warning messages that alert them 
about
+ * a known problem that needs to be fixed up-stream.
+ * See: https://gitlab.gnome.org/GNOME/mutter/-/issues/2457
+ */
+#define USE_GNOME_KEYBOARD_SUPPRESS_WARNING
+
 /*  */
 /** \name Inline Event Codes
  *
@@ -385,6 +399,13 @@ struct GWL_Seat {
   /** Keys held matching `xkb_state`. */
   struct WGL_KeyboardDepressedState key_depressed;
 
+#ifdef USE_GNOME_KEYBOARD_SUPPRESS_WARNING
+  struct {
+bool any_mod_held = false;
+bool any_keys_held_on_enter = false;
+  } key_depressed_suppress_warning;
+#endif
+
   /**
* Cache result of `xkb_keymap_mod_get_index`
* so every time a modifier is accessed a string lookup isn't required.
@@ -2312,6 +2333,10 @@ static void keyboard_handle_enter(void *data,
   }
 
   keyboard_depressed_state_push_events_from_change(seat, key_depressed_prev);
+
+#ifdef USE_GNOME_KEYBOARD_SUPPRESS_WARNING
+  seat->key_depressed_suppress_warning.any_keys_held_on_enter = keys->size != 
0;
+#endif
 }
 
 /**
@@ -2337,6 +2362,11 @@ static void keyboard_handle_leave(void *data,
   if (seat->key_repeat.timer) {
 keyboard_handle_key_repeat_cancel(seat);
   }
+
+#ifdef USE_GNOME_KEYBOARD_SUPPRESS_WARNING
+  seat->key_depressed_suppress_warning.any_mod_held = false;
+  seat->key_depressed_suppress_warning.any_keys_held_on_enter = false;
+#endif
 }
 
 /**
@@ -2555,6 +2585,10 @@ static void keyboard_handle_modifiers(void *data,
   if (seat->key_repeat.timer) {
 keyboard_handle_key_repeat_reset(seat, true);
   }
+
+#ifdef USE_GNOME_KEYBOARD_SUPPRESS_WARNING
+  seat->key_depressed_suppress_warning.any_mod_held = mods_depressed != 0;
+#endif
 }
 
 static void keyboard_repeat_handle_info(void *data,
@@ -3164,6 +3198,15 @@ GHOST_TSuccess 
GHOST_SystemWayland::getModifierKeys(GHOST_ModifierKeys &keys) co
 
   const xkb_mod_mask_t state = xkb_state_serialize_mods(seat->xkb_state, 
XKB_STATE_MODS_DEPRESSED);
 
+  bool show_warning = true;
+#ifdef USE_GNOME_KEYBOARD_SUPPRESS_WARNING
+  if ((seat->key_depressed_suppress_warning.any_mod_held == true) &&
+  (seat->key_depressed_suppress_warning.any_keys_held_on_enter == false)) {
+/* The compositor gave us invalid information, don't show a warning. */
+show_warning = false;
+  }
+#endif
+
   /* Use local #WGL_KeyboardDepressedState to check which key is pressed.
* Use XKB as the source of truth, if there is any discrepancy. */
   for (int i = 0; i < MOD_INDEX_NUM; i++) {
@@ -3179,18 +3222,22 @@ GHOST_TSuccess 
GHOST_SystemWayland::getModifierKeys(GHOST_ModifierKeys &keys) co
  * Warn so if this happens it can be investigated. */
 if (val) {
   if (UNLIKELY(!(val_l || val_r))) {
-CLOG_WARN(&LOG_WL_KEYBOARD_DEPRESSED_STATE,
-  "modifier (%s) state is inconsistent (GHOST held keys do not 
match XKB)",
-  mod_info.display_name);
+if (show_warning) {
+  CLOG_WARN(&LOG_WL_KEYBOARD_DEPRESSED_STATE,
+"modifier (%s) state is inconsistent (GHOST held keys do 
not match XKB)",
+mod_info.display_name);
+}
 /* Picking the left is arbitrary. */
 val_l = true;
   }
 }
 else {
   if (UNLIKELY(va

[Bf-blender-cvs] [a0af1e3971c] master: GHOST/Wayland: improve logging messages for keyboard events

2022-10-06 Thread Campbell Barton
Commit: a0af1e3971ce7e95d9d1c0cd9d239e7826452965
Author: Campbell Barton
Date:   Fri Oct 7 15:53:46 2022 +1100
Branches: master
https://developer.blender.org/rBa0af1e3971ce7e95d9d1c0cd9d239e7826452965

GHOST/Wayland: improve logging messages for keyboard events

===

M   intern/ghost/intern/GHOST_SystemWayland.cpp

===

diff --git a/intern/ghost/intern/GHOST_SystemWayland.cpp 
b/intern/ghost/intern/GHOST_SystemWayland.cpp
index 48401abd6b6..d569d24926d 100644
--- a/intern/ghost/intern/GHOST_SystemWayland.cpp
+++ b/intern/ghost/intern/GHOST_SystemWayland.cpp
@@ -2303,6 +2303,7 @@ static void keyboard_handle_enter(void *data,
   uint32_t *key;
   WL_ARRAY_FOR_EACH (key, keys) {
 const xkb_keycode_t key_code = *key + EVDEV_OFFSET;
+CLOG_INFO(LOG, 2, "enter (key_held=%d)", int(key_code));
 const xkb_keysym_t sym = xkb_state_key_get_one_sym(seat->xkb_state, 
key_code);
 const GHOST_TKey gkey = xkb_map_gkey_or_scan_code(sym, *key);
 if (gkey != GHOST_kKeyUnknown) {
@@ -2407,10 +2408,10 @@ static void keyboard_handle_key(void *data,
   const xkb_keysym_t sym = xkb_state_key_get_one_sym_without_modifiers(
   seat->xkb_state_empty, seat->xkb_state_empty_with_numlock, key_code);
   if (sym == XKB_KEY_NoSymbol) {
-CLOG_INFO(LOG, 2, "key (no symbol, skipped)");
+CLOG_INFO(LOG, 2, "key (code=%d, state=%u, no symbol, skipped)", 
int(key_code), state);
 return;
   }
-  CLOG_INFO(LOG, 2, "key");
+  CLOG_INFO(LOG, 2, "key (code=%d, state=%u)", int(key_code), state);
 
   GHOST_TEventType etype = GHOST_kEventUnknown;
   switch (state) {
@@ -3179,7 +3180,7 @@ GHOST_TSuccess 
GHOST_SystemWayland::getModifierKeys(GHOST_ModifierKeys &keys) co
 if (val) {
   if (UNLIKELY(!(val_l || val_r))) {
 CLOG_WARN(&LOG_WL_KEYBOARD_DEPRESSED_STATE,
-  "modifier (%s) state is inconsistent (held keys do not match 
XKB)",
+  "modifier (%s) state is inconsistent (GHOST held keys do not 
match XKB)",
   mod_info.display_name);
 /* Picking the left is arbitrary. */
 val_l = true;
@@ -3188,7 +3189,7 @@ GHOST_TSuccess 
GHOST_SystemWayland::getModifierKeys(GHOST_ModifierKeys &keys) co
 else {
   if (UNLIKELY(val_l || val_r)) {
 CLOG_WARN(&LOG_WL_KEYBOARD_DEPRESSED_STATE,
-  "modifier (%s) state is inconsistent (released keys do not 
match XKB)",
+  "modifier (%s) state is inconsistent (GHOST released keys do 
not match XKB)",
   mod_info.display_name);
 val_l = false;
 val_r = false;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [2c803124d37] refactor-mesh-position-generic: Merge branch 'master' into refactor-mesh-position-generic

2022-10-06 Thread Hans Goudey
Commit: 2c803124d371bbbd564dd4c5051258f53b799d36
Author: Hans Goudey
Date:   Thu Oct 6 23:26:44 2022 -0500
Branches: refactor-mesh-position-generic
https://developer.blender.org/rB2c803124d371bbbd564dd4c5051258f53b799d36

Merge branch 'master' into refactor-mesh-position-generic

===



===

diff --cc source/blender/blenkernel/intern/mball_tessellate.cc
index 00778ce2d79,5e8d2bc6d76..cab736a9a8c
--- a/source/blender/blenkernel/intern/mball_tessellate.cc
+++ b/source/blender/blenkernel/intern/mball_tessellate.cc
@@@ -1461,10 -1461,13 +1461,10 @@@ Mesh *BKE_mball_polygonize(Depsgraph *d
  
Mesh *mesh = (Mesh *)BKE_id_new_nomain(ID_ME, ((ID *)ob->data)->name + 2);
  
 -  mesh->totvert = int(process.curvertex);
 -  MVert *mvert = static_cast(
 -  CustomData_add_layer(&mesh->vdata, CD_MVERT, CD_CONSTRUCT, nullptr, 
mesh->totvert));
 -  for (int i = 0; i < mesh->totvert; i++) {
 -copy_v3_v3(mvert[i].co, process.co[i]);
 -  }
 -  MEM_freeN(process.co);
 +  mesh->totvert = (int)process.curvertex;
 +  CustomData_add_layer_named(
 +  &mesh->vdata, CD_PROP_FLOAT3, CD_ASSIGN, process.co, mesh->totvert, 
"position");
-   process.co = NULL;
++  process.co = nullptr;
  
mesh->totpoly = int(process.curindex);
MPoly *mpoly = static_cast(
diff --cc source/blender/blenkernel/intern/mesh_evaluate.cc
index 0c33767ba72,9a199c9c768..7ee76c8ba5a
--- a/source/blender/blenkernel/intern/mesh_evaluate.cc
+++ b/source/blender/blenkernel/intern/mesh_evaluate.cc
@@@ -530,8 -527,8 +530,8 @@@ bool BKE_mesh_center_of_volume(const Me
  /** \name Mesh Volume Calculation
   * \{ */
  
 -static bool mesh_calc_center_centroid_ex(const MVert *mverts,
 +static bool mesh_calc_center_centroid_ex(const float (*positions)[3],
-  int UNUSED(mverts_num),
+  int /*mverts_num*/,
   const MLoopTri *looptri,
   int looptri_num,
   const MLoop *mloop,
diff --cc source/blender/blenkernel/intern/mesh_mapping.cc
index 310905a7e46,667802d5f48..0abad8bed61
--- a/source/blender/blenkernel/intern/mesh_mapping.cc
+++ b/source/blender/blenkernel/intern/mesh_mapping.cc
@@@ -1178,12 -1181,11 +1178,12 @@@ bool BKE_mesh_calc_islands_loop_poly_ed
const int totloop,
MeshIslandStore *r_island_store)
  {
 +  UNUSED_VARS(positions, totvert);
return mesh_calc_islands_loop_poly_uv(
-   edges, totedge, polys, totpoly, loops, totloop, NULL, r_island_store);
 -  verts, totvert, edges, totedge, polys, totpoly, loops, totloop, 
nullptr, r_island_store);
++  edges, totedge, polys, totpoly, loops, totloop, nullptr, 
r_island_store);
  }
  
 -bool BKE_mesh_calc_islands_loop_poly_uvmap(MVert *verts,
 +bool BKE_mesh_calc_islands_loop_poly_uvmap(float (*positions)[3],
 const int totvert,
 MEdge *edges,
 const int totedge,
@@@ -1194,10 -1196,9 +1194,10 @@@
 const MLoopUV *luvs,
 MeshIslandStore *r_island_store)
  {
 +  UNUSED_VARS(positions, totvert);
-   BLI_assert(luvs != NULL);
+   BLI_assert(luvs != nullptr);
return mesh_calc_islands_loop_poly_uv(
 -  verts, totvert, edges, totedge, polys, totpoly, loops, totloop, luvs, 
r_island_store);
 +  edges, totedge, polys, totpoly, loops, totloop, luvs, r_island_store);
  }
  
  /** \} */
diff --cc source/blender/blenkernel/intern/mesh_normals.cc
index 2607b9ec6a4,e589aff1c73..1fc71ae762b
--- a/source/blender/blenkernel/intern/mesh_normals.cc
+++ b/source/blender/blenkernel/intern/mesh_normals.cc
@@@ -186,13 -185,13 +186,13 @@@ static void mesh_calc_normals_poly_fn(v
  {
const MeshCalcNormalsData_Poly *data = (MeshCalcNormalsData_Poly *)userdata;
const MPoly *mp = &data->mpoly[pidx];
 -  BKE_mesh_calc_poly_normal(mp, data->mloop + mp->loopstart, data->mvert, 
data->pnors[pidx]);
 +  BKE_mesh_calc_poly_normal(mp, data->mloop + mp->loopstart, data->positions, 
data->pnors[pidx]);
  }
  
 -void BKE_mesh_calc_normals_poly(const MVert *mvert,
 +void BKE_mesh_calc_normals_poly(const float (*positions)[3],
- int UNUSED(mvert_len),
+ int /*mvert_len*/,
  const MLoop *mloop,
- int UNUSED(mloop_len),
+ int /*mloop_len*/,
  const MPoly *mpoly,
  int mpoly_len,
  float (*r_poly_normals)[3])
@@@ -307,10 -308,10 +30

[Bf-blender-cvs] [c0f754d9b12] refactor-mesh-position-generic: Merge branch 'master' into refactor-mesh-position-generic

2022-10-06 Thread Hans Goudey
Commit: c0f754d9b125543e590f0302e92085836d216f64
Author: Hans Goudey
Date:   Sun Oct 2 23:34:27 2022 -0500
Branches: refactor-mesh-position-generic
https://developer.blender.org/rBc0f754d9b125543e590f0302e92085836d216f64

Merge branch 'master' into refactor-mesh-position-generic

===



===

diff --cc source/blender/blenkernel/BKE_collision.h
index 44c1b2a3cbd,c390d0a8802..1aaddebed91
--- a/source/blender/blenkernel/BKE_collision.h
+++ b/source/blender/blenkernel/BKE_collision.h
@@@ -84,10 -85,10 +84,10 @@@ typedef struct FaceCollPair 
  /
  
  /
- // used in modifier.c from collision.c
+ // used in modifier.cc from collision.c
  /
  
 -struct BVHTree *bvhtree_build_from_mvert(const struct MVert *mvert,
 +struct BVHTree *bvhtree_build_from_mvert(const float (*positions)[3],
   const struct MVertTri *tri,
   int tri_num,
   float epsilon);
diff --cc source/blender/blenkernel/intern/mball_tessellate.cc
index dd10a6f8646,9b32456c6c1..00778ce2d79
--- a/source/blender/blenkernel/intern/mball_tessellate.cc
+++ b/source/blender/blenkernel/intern/mball_tessellate.cc
@@@ -1439,15 -1461,19 +1461,16 @@@ Mesh *BKE_mball_polygonize(Depsgraph *d
  
Mesh *mesh = (Mesh *)BKE_id_new_nomain(ID_ME, ((ID *)ob->data)->name + 2);
  
 -  mesh->totvert = int(process.curvertex);
 -  MVert *mvert = static_cast(
 -  CustomData_add_layer(&mesh->vdata, CD_MVERT, CD_CONSTRUCT, NULL, 
mesh->totvert));
 -  for (int i = 0; i < mesh->totvert; i++) {
 -copy_v3_v3(mvert[i].co, process.co[i]);
 -  }
 -  MEM_freeN(process.co);
 +  mesh->totvert = (int)process.curvertex;
 +  CustomData_add_layer_named(
 +  &mesh->vdata, CD_PROP_FLOAT3, CD_ASSIGN, process.co, mesh->totvert, 
"position");
 +  process.co = NULL;
  
-   mesh->totpoly = (int)process.curindex;
-   MPoly *mpoly = CustomData_add_layer(&mesh->pdata, CD_MPOLY, CD_CONSTRUCT, 
NULL, mesh->totpoly);
-   MLoop *mloop = CustomData_add_layer(
-   &mesh->ldata, CD_MLOOP, CD_CONSTRUCT, NULL, mesh->totpoly * 4);
+   mesh->totpoly = int(process.curindex);
+   MPoly *mpoly = static_cast(
+   CustomData_add_layer(&mesh->pdata, CD_MPOLY, CD_CONSTRUCT, NULL, 
mesh->totpoly));
+   MLoop *mloop = static_cast(
+   CustomData_add_layer(&mesh->ldata, CD_MLOOP, CD_CONSTRUCT, NULL, 
mesh->totpoly * 4));
  
int loop_offset = 0;
for (int i = 0; i < mesh->totpoly; i++) {
diff --cc source/blender/blenkernel/intern/mesh_fair.cc
index 1a219c0b83e,df61169fa5c..2647b3b4990
--- a/source/blender/blenkernel/intern/mesh_fair.cc
+++ b/source/blender/blenkernel/intern/mesh_fair.cc
@@@ -26,7 -26,7 +26,8 @@@
  #include "MEM_guardedalloc.h"
  #include "eigen_capi.h"
  
+ using blender::Array;
 +using blender::float3;
  using blender::Map;
  using blender::MutableSpan;
  using blender::Span;
diff --cc source/blender/blenkernel/intern/mesh_iterators.cc
index 50a27836c74,46f9780f891..d983cc440b3
--- a/source/blender/blenkernel/intern/mesh_iterators.cc
+++ b/source/blender/blenkernel/intern/mesh_iterators.cc
@@@ -65,15 -65,15 +65,15 @@@ void BKE_mesh_foreach_mapped_vert
  }
}
else {
 -const MVert *mv = BKE_mesh_verts(mesh);
 +const float(*positions)[3] = BKE_mesh_positions(mesh);
- const int *index = CustomData_get_layer(&mesh->vdata, CD_ORIGINDEX);
+ const int *index = static_cast(CustomData_get_layer(&mesh->vdata, CD_ORIGINDEX));
  const float(*vert_normals)[3] = (flag & MESH_FOREACH_USE_NORMAL) ?
  BKE_mesh_vertex_normals_ensure(mesh) :
- NULL;
+ nullptr;
  
  if (index) {
 -  for (int i = 0; i < mesh->totvert; i++, mv++) {
 +  for (int i = 0; i < mesh->totvert; i++) {
- const float *no = (flag & MESH_FOREACH_USE_NORMAL) ? vert_normals[i] 
: NULL;
+ const float *no = (flag & MESH_FOREACH_USE_NORMAL) ? vert_normals[i] 
: nullptr;
  const int orig = *index++;
  if (orig == ORIGINDEX_NONE) {
continue;
@@@ -82,9 -82,9 +82,9 @@@
}
  }
  else {
 -  for (int i = 0; i < mesh->totvert; i++, mv++) {
 +  for (int i = 0; i < mesh->totvert; i++) {
- const float *no = (flag & MESH_FOREACH_USE_NORMAL) ? vert_normals[i] 
: NULL;
+ const float *no = (flag & MESH_FOREACH_USE_NORMAL) ? vert_normals[i] 
: nullptr;
 -func(userData, i, mv->co, no);
 +func(userData, i, positions[i], no);
}
  }
}
@@@ -120,9 -120,9 +120,9 @@@ void BKE_mesh_foreach_mapped_edge
  }
}
else {
 -const MVert *mv = BKE_mesh_verts(mesh);
 +const float(*position

[Bf-blender-cvs] [846d8ef8568] refactor-mesh-position-generic: Progress

2022-10-06 Thread Hans Goudey
Commit: 846d8ef8568c035cd7d4e1a8168a4ba391de9119
Author: Hans Goudey
Date:   Mon Oct 3 08:18:14 2022 -0500
Branches: refactor-mesh-position-generic
https://developer.blender.org/rB846d8ef8568c035cd7d4e1a8168a4ba391de9119

Progress

===

M   source/blender/draw/DRW_pbvh.h
M   source/blender/draw/intern/draw_pbvh.cc

===

diff --git a/source/blender/draw/DRW_pbvh.h b/source/blender/draw/DRW_pbvh.h
index ffd4b92d87b..fa51afe786f 100644
--- a/source/blender/draw/DRW_pbvh.h
+++ b/source/blender/draw/DRW_pbvh.h
@@ -41,7 +41,7 @@ typedef struct PBVH_GPU_Args {
 
   struct BMesh *bm;
   const struct Mesh *me;
-  const struct MVert *mvert;
+  const float (*mesh_positions)[3];
   const struct MLoop *mloop;
   const struct MPoly *mpoly;
   int mesh_verts_num, mesh_faces_num, mesh_grids_num;
diff --git a/source/blender/draw/intern/draw_pbvh.cc 
b/source/blender/draw/intern/draw_pbvh.cc
index 287270079e5..9cb7c3aa71e 100644
--- a/source/blender/draw/intern/draw_pbvh.cc
+++ b/source/blender/draw/intern/draw_pbvh.cc
@@ -307,7 +307,7 @@ struct PBVHBatches {
 
 if (!(mp->flag & ME_SMOOTH)) {
   smooth = true;
-  BKE_mesh_calc_poly_normal(mp, args->mloop + mp->loopstart, 
args->mvert, fno);
+  BKE_mesh_calc_poly_normal(mp, args->mloop + mp->loopstart, 
args->mesh_positions, fno);
   normal_float_to_short_v3(no, fno);
 }
 else {
@@ -537,7 +537,8 @@ struct PBVHBatches {
   case CD_PBVH_CO_TYPE:
 foreach_faces(
 [&](int /*buffer_i*/, int /*tri_i*/, int vertex_i, const MLoopTri 
* /*tri*/) {
-  *static_cast(GPU_vertbuf_raw_step(&access)) = 
args->mvert[vertex_i].co;
+  *static_cast(
+  GPU_vertbuf_raw_step(&access)) = 
args->mesh_positions[vertex_i];
 });
 break;
   case CD_PBVH_NO_TYPE:

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [cafd204af6d] master: Cleanup: remove redundant 'using'

2022-10-06 Thread Campbell Barton
Commit: cafd204af6d9969654bdee5ae14fef220640487c
Author: Campbell Barton
Date:   Fri Oct 7 14:36:35 2022 +1100
Branches: master
https://developer.blender.org/rBcafd204af6d9969654bdee5ae14fef220640487c

Cleanup: remove redundant 'using'

clang-tidy converts C-style typedefs to this style,
but the "using ..." isn't needed.

===

M   source/blender/editors/space_view3d/view3d_select.cc

===

diff --git a/source/blender/editors/space_view3d/view3d_select.cc 
b/source/blender/editors/space_view3d/view3d_select.cc
index 94b1573ceda..cba85097071 100644
--- a/source/blender/editors/space_view3d/view3d_select.cc
+++ b/source/blender/editors/space_view3d/view3d_select.cc
@@ -1601,7 +1601,7 @@ static bool object_mouse_select_menu(bContext *C,
   const float dist_threshold_sq = square_f(15 * U.pixelsize);
   int base_count = 0;
 
-  using BaseRefWithDepth = struct BaseRefWithDepth {
+  struct BaseRefWithDepth {
 struct BaseRefWithDepth *next, *prev;
 Base *base;
 /** The scale isn't defined, simply use for sorting. */
@@ -1812,7 +1812,7 @@ static bool bone_mouse_select_menu(bContext *C,
 
   int bone_count = 0;
 
-  using BoneRefWithDepth = struct BoneRefWithDepth {
+  struct BoneRefWithDepth {
 struct BoneRefWithDepth *next, *prev;
 Base *base;
 union {

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [47d3e765679] master: 3D View: depth sort candidates in the selection menu

2022-10-06 Thread Campbell Barton
Commit: 47d3e765679e54c09ecc4ded812e89483a1e1d9b
Author: Campbell Barton
Date:   Fri Oct 7 13:19:15 2022 +1100
Branches: master
https://developer.blender.org/rB47d3e765679e54c09ecc4ded812e89483a1e1d9b

3D View: depth sort candidates in the selection menu

Objects/bones in the selection menu weren't ordered usefully,
worse, the closest items could be left out of the menu since items
would stop being added once the menu-size limit was reached.

Resolve this by sorting the menu items by depth, removing the most
distant when the number of items exceeds the limit.

When Ctrl is held, order by the distance to the object center
instead of depth.

===

M   source/blender/editors/space_view3d/view3d_select.cc

===

diff --git a/source/blender/editors/space_view3d/view3d_select.cc 
b/source/blender/editors/space_view3d/view3d_select.cc
index b14536213b7..94b1573ceda 100644
--- a/source/blender/editors/space_view3d/view3d_select.cc
+++ b/source/blender/editors/space_view3d/view3d_select.cc
@@ -28,6 +28,7 @@
 #include "BLI_linklist.h"
 #include "BLI_listbase.h"
 #include "BLI_math.h"
+#include "BLI_math_bits.h"
 #include "BLI_rect.h"
 #include "BLI_string.h"
 #include "BLI_utildefines.h"
@@ -1597,14 +1598,21 @@ static bool object_mouse_select_menu(bContext *C,
 
   const float mval_fl[2] = {float(mval[0]), float(mval[1])};
   /* Distance from object center to use for selection. */
-  const float dist_threshold = 15 * U.pixelsize;
+  const float dist_threshold_sq = square_f(15 * U.pixelsize);
   int base_count = 0;
-  bool ok;
-  LinkNodePair linklist = {nullptr, nullptr};
+
+  using BaseRefWithDepth = struct BaseRefWithDepth {
+struct BaseRefWithDepth *next, *prev;
+Base *base;
+/** The scale isn't defined, simply use for sorting. */
+uint depth_id;
+  };
+  ListBase base_ref_list = {nullptr, nullptr}; /* List of #BaseRefWithDepth. */
 
   /* handle base->object->select_id */
   CTX_DATA_BEGIN (C, Base *, base, selectable_bases) {
-ok = false;
+bool ok = false;
+uint depth_id;
 
 /* two selection methods, the CTRL select uses max dist of 15 */
 if (buffer) {
@@ -1612,6 +1620,7 @@ static bool object_mouse_select_menu(bContext *C,
 /* index was converted */
 if (base->object->runtime.select_id == (buffer[a].id & ~0x)) {
   ok = true;
+  depth_id = buffer[a].depth;
   break;
 }
   }
@@ -1619,19 +1628,21 @@ static bool object_mouse_select_menu(bContext *C,
 else {
   float region_co[2];
   if (ED_view3d_project_base(vc->region, base, region_co) == 
V3D_PROJ_RET_OK) {
-if (len_manhattan_v2v2(mval_fl, region_co) < dist_threshold) {
+const float dist_test_sq = len_squared_v2v2(mval_fl, region_co);
+if (dist_test_sq < dist_threshold_sq) {
   ok = true;
+  /* Match GPU depth logic, as the float is always positive, it can be 
sorted as an int. */
+  depth_id = float_as_uint(dist_test_sq);
 }
   }
 }
 
 if (ok) {
   base_count++;
-  BLI_linklist_append(&linklist, base);
-
-  if (base_count == SEL_MENU_SIZE) {
-break;
-  }
+  BaseRefWithDepth *base_ref = MEM_new(__func__);
+  base_ref->base = base;
+  base_ref->depth_id = depth_id;
+  BLI_addtail(&base_ref_list, (void *)base_ref);
 }
   }
   CTX_DATA_END;
@@ -1642,20 +1653,30 @@ static bool object_mouse_select_menu(bContext *C,
 return false;
   }
   if (base_count == 1) {
-Base *base = (Base *)linklist.list->link;
-BLI_linklist_free(linklist.list, nullptr);
+Base *base = ((BaseRefWithDepth *)base_ref_list.first)->base;
+BLI_freelistN(&base_ref_list);
 *r_basact = base;
 return false;
   }
 
+  /* Sort by depth or distance to cursor. */
+  BLI_listbase_sort(&base_ref_list, [](const void *a, const void *b) {
+return int(static_cast(a)->depth_id >
+   static_cast(b)->depth_id);
+  });
+
+  while (base_count > SEL_MENU_SIZE) {
+BLI_freelinkN(&base_ref_list, base_ref_list.last);
+base_count -= 1;
+  }
+
   /* UI, full in static array values that we later use in an enum function */
-  LinkNode *node;
-  int i;
 
   memset(object_mouse_select_menu_data, 0, 
sizeof(object_mouse_select_menu_data));
 
-  for (node = linklist.list, i = 0; node; node = node->next, i++) {
-Base *base = static_cast(node->link);
+  int i;
+  LISTBASE_FOREACH_INDEX (BaseRefWithDepth *, base_ref, &base_ref_list, i) {
+Base *base = base_ref->base;
 Object *ob = base->object;
 const char *name = ob->id.name + 2;
 
@@ -1673,7 +1694,7 @@ static bool object_mouse_select_menu(bContext *C,
   WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, &ptr, nullptr);
   WM_operator_properties_free(&ptr);
 
-  BLI_linklist_free(linklist.list, nullptr);
+  BLI_freelistN(&base_ref_list);
   return true;
 }
 
@@ -17

[Bf-blender-cvs] [3b77d60b6cf] master: Cleanup: share factory reset properties

2022-10-06 Thread Campbell Barton
Commit: 3b77d60b6cf9d86f8889b637ffe5c06eeefe0519
Author: Campbell Barton
Date:   Fri Oct 7 13:19:13 2022 +1100
Branches: master
https://developer.blender.org/rB3b77d60b6cf9d86f8889b637ffe5c06eeefe0519

Cleanup: share factory reset properties

===

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

===

diff --git a/source/blender/windowmanager/intern/wm_files.c 
b/source/blender/windowmanager/intern/wm_files.c
index e835a5db57b..7ac55b2c27a 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -2044,6 +2044,26 @@ void wm_autosave_delete(void)
 
 /** \} */
 
+/*  */
+/** \name Shared Operator Properties
+ * \{ */
+
+/** Use for loading factory startup & preferences. */
+static void read_factory_reset_props(wmOperatorType *ot)
+{
+  PropertyRNA *prop;
+
+  /* So it's possible to reset app-template settings without resetting other 
defaults. */
+  prop = RNA_def_boolean(ot->srna,
+ "use_factory_startup_app_template_only",
+ false,
+ "Factory Startup App-Template Only",
+ "");
+  RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
+}
+
+/** \} */
+
 /*  */
 /** \name Initialize `WM_OT_open_*` Properties
  *
@@ -2322,15 +2342,7 @@ void WM_OT_read_factory_userpref(wmOperatorType *ot)
   ot->invoke = WM_operator_confirm;
   ot->exec = wm_userpref_read_exec;
 
-  PropertyRNA *prop;
-
-  /* So it's possible to reset app-template settings without resetting other 
defaults. */
-  prop = RNA_def_boolean(ot->srna,
- "use_factory_startup_app_template_only",
- false,
- "Factory Startup App-Template Only",
- "");
-  RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
+  read_factory_reset_props(ot);
 }
 
 /** \} */
@@ -2489,14 +2501,6 @@ static void read_homefile_props(wmOperatorType *ot)
 
   prop = RNA_def_boolean(ot->srna, "use_empty", false, "Empty", "");
   RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
-
-  /* So it's possible to reset app-template settings without resetting other 
defaults. */
-  prop = RNA_def_boolean(ot->srna,
- "use_factory_startup_app_template_only",
- false,
- "Factory Startup App-Template Only",
- "");
-  RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
 }
 
 void WM_OT_read_homefile(wmOperatorType *ot)
@@ -2527,6 +2531,7 @@ void WM_OT_read_homefile(wmOperatorType *ot)
* Match naming for `--factory-startup` command line argument. */
   prop = RNA_def_boolean(ot->srna, "use_factory_startup", false, "Factory 
Startup", "");
   RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
+  read_factory_reset_props(ot);
 
   read_homefile_props(ot);
 
@@ -2543,9 +2548,11 @@ void WM_OT_read_factory_settings(wmOperatorType *ot)
 
   ot->invoke = WM_operator_confirm;
   ot->exec = wm_homefile_read_exec;
+  /* Omit poll to run in background mode. */
+
+  read_factory_reset_props(ot);
 
   read_homefile_props(ot);
-  /* omit poll to run in background mode */
 }
 
 /** \} */

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [db2b8896189] master: Cleanup: quiet compiler shadowed variable warning

2022-10-06 Thread Campbell Barton
Commit: db2b8896189502de101d6aaeb15ba2ab978aef6a
Author: Campbell Barton
Date:   Fri Oct 7 13:19:12 2022 +1100
Branches: master
https://developer.blender.org/rBdb2b8896189502de101d6aaeb15ba2ab978aef6a

Cleanup: quiet compiler shadowed variable warning

===

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

===

diff --git a/source/blender/blenkernel/intern/vfontdata_freetype.c 
b/source/blender/blenkernel/intern/vfontdata_freetype.c
index 37e85e70bdb..5fcf81c8810 100644
--- a/source/blender/blenkernel/intern/vfontdata_freetype.c
+++ b/source/blender/blenkernel/intern/vfontdata_freetype.c
@@ -281,14 +281,14 @@ static FT_Face 
vfont_face_load_from_packed_file(PackedFile *pf)
   }
 
   /* Select a character map. */
-  FT_Error err = FT_Select_Charmap(face, FT_ENCODING_UNICODE);
-  if (err) {
-err = FT_Select_Charmap(face, FT_ENCODING_APPLE_ROMAN);
+  FT_Error err_charmap = FT_Select_Charmap(face, FT_ENCODING_UNICODE);
+  if (err_charmap) {
+err_charmap = FT_Select_Charmap(face, FT_ENCODING_APPLE_ROMAN);
   }
-  if (err && face->num_charmaps > 0) {
-err = FT_Select_Charmap(face, face->charmaps[0]->encoding);
+  if (err_charmap && face->num_charmaps > 0) {
+err_charmap = FT_Select_Charmap(face, face->charmaps[0]->encoding);
   }
-  if (err) {
+  if (err_charmap) {
 FT_Done_Face(face);
 return NULL;
   }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [104fd82f742] master: Fix for T101481: Improved VFont Loading

2022-10-06 Thread Harley Acheson
Commit: 104fd82f74281471d69e61d06de44fca8fdf269c
Author: Harley Acheson
Date:   Thu Oct 6 18:02:40 2022 -0700
Branches: master
https://developer.blender.org/rB104fd82f74281471d69e61d06de44fca8fdf269c

Fix for T101481: Improved VFont Loading

Remove redundancy in the testing and loading of VFont fonts. Includes
improved setting of character map for using Wingding and Symbol fonts.

See D16174 for more details.

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

Reviewed by Campbell Barton

===

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

===

diff --git a/source/blender/blenkernel/intern/vfontdata_freetype.c 
b/source/blender/blenkernel/intern/vfontdata_freetype.c
index 91ca3100f8c..37e85e70bdb 100644
--- a/source/blender/blenkernel/intern/vfontdata_freetype.c
+++ b/source/blender/blenkernel/intern/vfontdata_freetype.c
@@ -266,30 +266,22 @@ static VChar *objchr_to_ftvfontdata(VFont *vfont, 
FT_ULong charcode)
   return che;
 }
 
-static VFontData *objfnt_to_ftvfontdata(PackedFile *pf)
+static FT_Face vfont_face_load_from_packed_file(PackedFile *pf)
 {
-  /* Variables */
-  FT_Face face;
-  VFontData *vfd;
-
-  /* load the freetype font */
-  err = FT_New_Memory_Face(library, pf->data, pf->size, 0, &face);
-
-  if (err) {
+  FT_Face face = NULL;
+  FT_New_Memory_Face(library, pf->data, pf->size, 0, &face);
+  if (!face) {
 return NULL;
   }
 
-  /* allocate blender font */
-  vfd = MEM_callocN(sizeof(*vfd), "FTVFontData");
-
-  /* Get the name. */
-  if (face->family_name) {
-BLI_snprintf(vfd->name, sizeof(vfd->name), "%s %s", face->family_name, 
face->style_name);
-BLI_str_utf8_invalid_strip(vfd->name, strlen(vfd->name));
+  /* Font must contain vectors, not bitmaps. */
+  if (!(face->face_flags & FT_FACE_FLAG_SCALABLE)) {
+FT_Done_Face(face);
+return NULL;
   }
 
   /* Select a character map. */
-  err = FT_Select_Charmap(face, FT_ENCODING_UNICODE);
+  FT_Error err = FT_Select_Charmap(face, FT_ENCODING_UNICODE);
   if (err) {
 err = FT_Select_Charmap(face, FT_ENCODING_APPLE_ROMAN);
   }
@@ -298,10 +290,42 @@ static VFontData *objfnt_to_ftvfontdata(PackedFile *pf)
   }
   if (err) {
 FT_Done_Face(face);
-MEM_freeN(vfd);
 return NULL;
   }
 
+  /* Test that we can load glyphs from this font. */
+  FT_UInt glyph_index = 0;
+  FT_Get_First_Char(face, &glyph_index);
+  if (!glyph_index ||
+  FT_Load_Glyph(face, glyph_index, FT_LOAD_NO_SCALE | FT_LOAD_NO_BITMAP) 
!= FT_Err_Ok) {
+FT_Done_Face(face);
+return NULL;
+  }
+
+  return face;
+}
+
+VFontData *BKE_vfontdata_from_freetypefont(PackedFile *pf)
+{
+  if (FT_Init_FreeType(&library) != FT_Err_Ok) {
+return NULL;
+  }
+
+  FT_Face face = vfont_face_load_from_packed_file(pf);
+  if (!face) {
+FT_Done_FreeType(library);
+return NULL;
+  }
+
+  /* allocate blender font */
+  VFontData *vfd = MEM_callocN(sizeof(*vfd), "FTVFontData");
+
+  /* Get the name. */
+  if (face->family_name) {
+BLI_snprintf(vfd->name, sizeof(vfd->name), "%s %s", face->family_name, 
face->style_name);
+BLI_str_utf8_invalid_strip(vfd->name, strlen(vfd->name));
+  }
+
   /* Blender default BFont is not "complete". */
   const bool complete_font = (face->ascender != 0) && (face->descender != 0) &&
  (face->ascender != face->descender);
@@ -344,50 +368,6 @@ static VFontData *objfnt_to_ftvfontdata(PackedFile *pf)
 freetypechar_to_vchar(face, charcode, vfd);
   }
 
-  return vfd;
-}
-
-static bool check_freetypefont(PackedFile *pf)
-{
-  FT_Face face = NULL;
-  FT_UInt glyph_index = 0;
-  bool success = false;
-
-  err = FT_New_Memory_Face(library, pf->data, pf->size, 0, &face);
-  if (err) {
-return false;
-// XXX error("This is not a valid font");
-  }
-
-  FT_Get_First_Char(face, &glyph_index);
-  if (glyph_index) {
-err = FT_Load_Glyph(face, glyph_index, FT_LOAD_NO_SCALE | 
FT_LOAD_NO_BITMAP);
-if (!err) {
-  success = (face->glyph->format == ft_glyph_format_outline);
-}
-  }
-
-  FT_Done_Face(face);
-
-  return success;
-}
-
-VFontData *BKE_vfontdata_from_freetypefont(PackedFile *pf)
-{
-  VFontData *vfd = NULL;
-
-  /* init Freetype */
-  err = FT_Init_FreeType(&library);
-  if (err) {
-/* XXX error("Failed to load the Freetype font library"); */
-return NULL;
-  }
-
-  if (check_freetypefont(pf)) {
-vfd = objfnt_to_ftvfontdata(pf);
-  }
-
-  /* free Freetype */
   FT_Done_FreeType(library);
 
   return vfd;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [781d03efe4b] master: Preferences: support loading factory settings only for app-templates

2022-10-06 Thread Campbell Barton
Commit: 781d03efe4b889089c261de68bf25263454ddf29
Author: Campbell Barton
Date:   Wed Oct 5 17:08:28 2022 +1100
Branches: master
https://developer.blender.org/rB781d03efe4b889089c261de68bf25263454ddf29

Preferences: support loading factory settings only for app-templates

When app-templates are enabled, support resetting defaults only for the
app-templates.

Without this, it's not possible to reset app-template preferences
without also resetting the default preferences for all settings the
app-template does not override (used when there is no application
template loaded, and other app-templates).

These additional menu items are shown in menus when an app-template has
been loaded.

Address issue raised by T96427.

Reviewed By: mont29, brecht

Ref D16150

===

M   release/scripts/startup/bl_ui/space_topbar.py
M   release/scripts/startup/bl_ui/space_userpref.py
M   source/blender/windowmanager/intern/wm_files.c
M   source/blender/windowmanager/wm_files.h

===

diff --git a/release/scripts/startup/bl_ui/space_topbar.py 
b/release/scripts/startup/bl_ui/space_topbar.py
index b1ddd2c611d..3320e1e24a7 100644
--- a/release/scripts/startup/bl_ui/space_topbar.py
+++ b/release/scripts/startup/bl_ui/space_topbar.py
@@ -411,9 +411,16 @@ class TOPBAR_MT_file_defaults(Menu):
 app_template, has_ext=False))
 
 layout.operator("wm.save_homefile")
-props = layout.operator("wm.read_factory_settings")
 if app_template:
+display_name = bpy.path.display_name(iface_(app_template))
+props = layout.operator("wm.read_factory_settings", text="Load 
Factory Blender Settings")
 props.app_template = app_template
+props = layout.operator("wm.read_factory_settings", text="Load 
Factory %s Settings" % display_name)
+props.app_template = app_template
+props.use_factory_startup_app_template_only = True
+del display_name
+else:
+layout.operator("wm.read_factory_settings")
 
 
 # Include technical operators here which would otherwise have no way for users 
to access.
diff --git a/release/scripts/startup/bl_ui/space_userpref.py 
b/release/scripts/startup/bl_ui/space_userpref.py
index 441babefd60..a9736feb057 100644
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@ -109,7 +109,16 @@ class USERPREF_MT_save_load(Menu):
 sub_revert.operator("wm.read_userpref", text="Revert to Saved 
Preferences")
 
 layout.operator_context = 'INVOKE_AREA'
-layout.operator("wm.read_factory_userpref", text="Load Factory 
Preferences")
+
+app_template = prefs.app_template
+if app_template:
+display_name = bpy.path.display_name(iface_(app_template))
+layout.operator("wm.read_factory_userpref", text="Load Factory 
Blender Preferences")
+props = layout.operator("wm.read_factory_userpref", text="Load 
Factory %s Preferences" % display_name)
+props.use_factory_startup_app_template_only = True
+del display_name
+else:
+layout.operator("wm.read_factory_userpref", text="Load Factory 
Preferences")
 
 
 class USERPREF_PT_save_preferences(Panel):
diff --git a/source/blender/windowmanager/intern/wm_files.c 
b/source/blender/windowmanager/intern/wm_files.c
index 92844dddf4c..e835a5db57b 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -1068,6 +1068,12 @@ void wm_homefile_read_ex(bContext *C,
   const bool use_data = params_homefile->use_data;
   const bool use_userdef = params_homefile->use_userdef;
   bool use_factory_settings = params_homefile->use_factory_settings;
+  /* Currently this only impacts preferences as it doesn't make much sense to 
keep the default
+   * startup open in the case the app-template doesn't happen to define it's 
own startup.
+   * Unlike preferences where we might want to only reset the app-template 
part of the preferences
+   * so as not to reset the preferences for all other Blender instances, see: 
T96427. */
+  const bool use_factory_settings_app_template_only =
+  params_homefile->use_factory_settings_app_template_only;
   const bool use_empty_data = params_homefile->use_empty_data;
   const char *filepath_startup_override = 
params_homefile->filepath_startup_override;
   const char *app_template_override = params_homefile->app_template_override;
@@ -1180,7 +1186,11 @@ void wm_homefile_read_ex(bContext *C,
 
   /* load preferences before startup.blend */
   if (use_userdef) {
-if (!use_factory_settings && BLI_exists(filepath_userdef)) {
+if (use_factory_settings_app_template_only) {
+  /* Use the current preferences as-is (only load in the app_template 
preferences). */
+  skip_flags |= BLO_READ_SKIP_

[Bf-blender-cvs] [ecc404ea1a3] master: Cleanup: spelling in comments

2022-10-06 Thread Campbell Barton
Commit: ecc404ea1a37a682c0b75ec10fcece9325a15e9d
Author: Campbell Barton
Date:   Fri Oct 7 10:32:02 2022 +1100
Branches: master
https://developer.blender.org/rBecc404ea1a37a682c0b75ec10fcece9325a15e9d

Cleanup: spelling in comments

===

M   intern/cycles/kernel/integrator/init_from_bake.h
M   source/blender/blenkernel/intern/cdderivedmesh.c
M   source/blender/blenkernel/intern/layer.c
M   source/blender/blenkernel/intern/lib_override.cc
M   source/blender/blenkernel/intern/multires.cc
M   source/blender/blenkernel/intern/shrinkwrap.cc
M   source/blender/blenkernel/intern/subdiv_ccg.cc
M   source/blender/bmesh/intern/bmesh_query.h
M   source/blender/draw/intern/draw_pbvh.cc
M   source/blender/editors/sculpt_paint/paint_image_proj.c
M   source/blender/modifiers/intern/MOD_multires.cc
M   source/blender/sequencer/SEQ_time.h

===

diff --git a/intern/cycles/kernel/integrator/init_from_bake.h 
b/intern/cycles/kernel/integrator/init_from_bake.h
index 15968670ac2..667ba949760 100644
--- a/intern/cycles/kernel/integrator/init_from_bake.h
+++ b/intern/cycles/kernel/integrator/init_from_bake.h
@@ -239,7 +239,7 @@ ccl_device bool integrator_init_from_bake(KernelGlobals kg,
   }
 
   /* We don't want to bake the back face, so make sure the ray direction 
never
-   * goes behind the geometry (flat) normal. This is a failsafe, and 
should rarely happen. */
+   * goes behind the geometry (flat) normal. This is a fail-safe, and 
should rarely happen. */
   const float true_normal_epsilon = 0.1f;
 
   if (dot(D, Ng) <= true_normal_epsilon) {
diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c 
b/source/blender/blenkernel/intern/cdderivedmesh.c
index 1f97f8a848c..41993764c0c 100644
--- a/source/blender/blenkernel/intern/cdderivedmesh.c
+++ b/source/blender/blenkernel/intern/cdderivedmesh.c
@@ -198,7 +198,7 @@ static DerivedMesh *cdDM_from_mesh_ex(Mesh *mesh,
   DM_TYPE_CDDM,
   mesh->totvert,
   mesh->totedge,
-  0 /* mesh->totface */,
+  0 /* `mesh->totface` */,
   mesh->totloop,
   mesh->totpoly);
 
@@ -213,7 +213,7 @@ static DerivedMesh *cdDM_from_mesh_ex(Mesh *mesh,
&dm->faceData,
cddata_masks.fmask | CD_MASK_ORIGINDEX,
alloctype,
-   0 /* mesh->totface */);
+   0 /* `mesh->totface` */);
   CustomData_merge(&mesh->ldata, &dm->loopData, cddata_masks.lmask, alloctype, 
mesh->totloop);
   CustomData_merge(&mesh->pdata, &dm->polyData, cddata_masks.pmask, alloctype, 
mesh->totpoly);
 
diff --git a/source/blender/blenkernel/intern/layer.c 
b/source/blender/blenkernel/intern/layer.c
index fe11dc99bac..fcb0adfde34 100644
--- a/source/blender/blenkernel/intern/layer.c
+++ b/source/blender/blenkernel/intern/layer.c
@@ -988,7 +988,7 @@ void BKE_main_view_layers_synced_ensure(const Main *bmain)
 BKE_scene_view_layers_synced_ensure(scene);
   }
 
-  /* NOTE: This is not (yet?) covered by the dirty tag and deffered resync 
system */
+  /* NOTE: This is not (yet?) covered by the dirty tag and differed re-sync 
system */
   BKE_layer_collection_local_sync_all(bmain);
 }
 
diff --git a/source/blender/blenkernel/intern/lib_override.cc 
b/source/blender/blenkernel/intern/lib_override.cc
index 04679b72b2d..07eb4741b1f 100644
--- a/source/blender/blenkernel/intern/lib_override.cc
+++ b/source/blender/blenkernel/intern/lib_override.cc
@@ -1389,7 +1389,7 @@ bool BKE_lib_override_library_create(Main *bmain,
 id_hierarchy_root_reference = id_root_reference;
   }
 
-  /* While in theory it _should_ be enough to ensure sync of given viewlayer 
(if any), or at least
+  /* While in theory it _should_ be enough to ensure sync of given view-layer 
(if any), or at least
* of given scene, think for now it's better to get a fully synced Main at 
this point, this code
* may do some very wide remapping/data access in some cases. */
   BKE_main_view_layers_synced_ensure(bmain);
diff --git a/source/blender/blenkernel/intern/multires.cc 
b/source/blender/blenkernel/intern/multires.cc
index 83189adfcdb..61cfe043927 100644
--- a/source/blender/blenkernel/intern/multires.cc
+++ b/source/blender/blenkernel/intern/multires.cc
@@ -69,8 +69,8 @@ void multires_customdata_delete(Mesh *me)
   if (me->edit_mesh) {
 BMEditMesh *em = me->edit_mesh;
 /* CustomData_external_remove is used here only to mark layer
- * as non-external for further free-ing, so zero element count
- * looks safer than em->totface */
+ * as non-external for further freeing, so zero element count
+ * looks safer than `em->bm->totface`. */
 CustomData_external_remove(&em->bm->ldata, &me->id, CD_MDISPS, 0);
 
 if (CustomData_has_layer(&em->bm->ldata, CD_MDISPS)) {
@@ -1359,11 +1359,9 @@ static vo

[Bf-blender-cvs] [4eb3e7ff861] master: Cleanup: compiler warning

2022-10-06 Thread Campbell Barton
Commit: 4eb3e7ff8612c89909cb6ec3944924979e8a15c5
Author: Campbell Barton
Date:   Fri Oct 7 10:40:25 2022 +1100
Branches: master
https://developer.blender.org/rB4eb3e7ff8612c89909cb6ec3944924979e8a15c5

Cleanup: compiler warning

===

M   source/blender/blenkernel/intern/subdiv_modifier.cc

===

diff --git a/source/blender/blenkernel/intern/subdiv_modifier.cc 
b/source/blender/blenkernel/intern/subdiv_modifier.cc
index f072b1415f8..a5529e9b8fa 100644
--- a/source/blender/blenkernel/intern/subdiv_modifier.cc
+++ b/source/blender/blenkernel/intern/subdiv_modifier.cc
@@ -170,5 +170,5 @@ int BKE_subsurf_modifier_eval_required_mode(bool 
is_final_render, bool is_edit_m
 return eModifierMode_Render;
   }
 
-  return eModifierMode_Realtime | (is_edit_mode ? eModifierMode_Editmode : 0);
+  return eModifierMode_Realtime | (is_edit_mode ? int(eModifierMode_Editmode) 
: 0);
 }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [b04b87b3224] master: Cleanup: Avoid inconsistent naming in mesh topology API

2022-10-06 Thread Hans Goudey
Commit: b04b87b32244fe1aa00878ca596b3c763dc7297b
Author: Hans Goudey
Date:   Thu Oct 6 17:34:53 2022 -0500
Branches: master
https://developer.blender.org/rBb04b87b32244fe1aa00878ca596b3c763dc7297b

Cleanup: Avoid inconsistent naming in mesh topology API

Mesh corners are called "loops" in the code currently. Avoid diverging
naming and just use that convention in some newly added code.

===

M   source/blender/blenkernel/BKE_mesh_mapping.h
M   source/blender/blenkernel/intern/mesh_fair.cc
M   source/blender/blenkernel/intern/mesh_mapping.cc
M   
source/blender/nodes/geometry/nodes/node_geo_mesh_topology_corners_of_vertex.cc
M   
source/blender/nodes/geometry/nodes/node_geo_mesh_topology_edges_of_corner.cc
M   
source/blender/nodes/geometry/nodes/node_geo_mesh_topology_face_of_corner.cc
M   
source/blender/nodes/geometry/nodes/node_geo_mesh_topology_offset_corner_in_face.cc
M   source/blender/render/intern/texture_margin.cc

===

diff --git a/source/blender/blenkernel/BKE_mesh_mapping.h 
b/source/blender/blenkernel/BKE_mesh_mapping.h
index 350c4c4bb36..da8431d4f27 100644
--- a/source/blender/blenkernel/BKE_mesh_mapping.h
+++ b/source/blender/blenkernel/BKE_mesh_mapping.h
@@ -338,14 +338,14 @@ int *BKE_mesh_calc_smoothgroups(const struct MEdge *medge,
 #ifdef __cplusplus
 namespace blender::mesh_topology {
 
-Array build_corner_to_poly_map(Span polys, int loops_num);
+Array build_loop_to_poly_map(Span polys, int loops_num);
 
 Array> build_vert_to_edge_map(Span edges, int verts_num);
-Array> build_vert_to_corner_map(Span loops, int verts_num);
+Array> build_vert_to_loop_map(Span loops, int verts_num);
 
-inline int previous_poly_corner(const MPoly &poly, int corner_i)
+inline int previous_poly_loop(const MPoly &poly, int loop_i)
 {
-  return corner_i - 1 + (corner_i == poly.loopstart) * poly.totloop;
+  return loop_i - 1 + (loop_i == poly.loopstart) * poly.totloop;
 }
 
 }  // namespace blender::mesh_topology
diff --git a/source/blender/blenkernel/intern/mesh_fair.cc 
b/source/blender/blenkernel/intern/mesh_fair.cc
index 501f01e3368..5369bc782b6 100644
--- a/source/blender/blenkernel/intern/mesh_fair.cc
+++ b/source/blender/blenkernel/intern/mesh_fair.cc
@@ -221,7 +221,7 @@ class MeshFairingContext : public FairingContext {
   }
 }
 
-loop_to_poly_map_ = 
blender::mesh_topology::build_corner_to_poly_map(mpoly_, mloop_.size());
+loop_to_poly_map_ = blender::mesh_topology::build_loop_to_poly_map(mpoly_, 
mloop_.size());
   }
 
   ~MeshFairingContext() override
diff --git a/source/blender/blenkernel/intern/mesh_mapping.cc 
b/source/blender/blenkernel/intern/mesh_mapping.cc
index bb9f8274b72..667802d5f48 100644
--- a/source/blender/blenkernel/intern/mesh_mapping.cc
+++ b/source/blender/blenkernel/intern/mesh_mapping.cc
@@ -555,7 +555,7 @@ void BKE_mesh_origindex_map_create_looptri(MeshElemMap 
**r_map,
 
 namespace blender::mesh_topology {
 
-Array build_corner_to_poly_map(const Span polys, const int 
loops_num)
+Array build_loop_to_poly_map(const Span polys, const int loops_num)
 {
   Array map(loops_num);
   threading::parallel_for(polys.index_range(), 1024, [&](IndexRange range) {
@@ -577,7 +577,7 @@ Array> build_vert_to_edge_map(const Span 
edges, const int ver
   return map;
 }
 
-Array> build_vert_to_corner_map(const Span loops, const int 
verts_num)
+Array> build_vert_to_loop_map(const Span loops, const int 
verts_num)
 {
   Array> map(verts_num);
   for (const int64_t i : loops.index_range()) {
diff --git 
a/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_corners_of_vertex.cc
 
b/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_corners_of_vertex.cc
index 7c80e9fdf67..f45ff826a60 100644
--- 
a/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_corners_of_vertex.cc
+++ 
b/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_corners_of_vertex.cc
@@ -60,8 +60,8 @@ class CornersOfVertInput final : public bke::MeshFieldInput {
   {
 const IndexRange vert_range(mesh.totvert);
 const Span loops = mesh.loops();
-Array> vert_to_corner_map = 
mesh_topology::build_vert_to_corner_map(loops,
-   
 mesh.totvert);
+Array> vert_to_loop_map = 
mesh_topology::build_vert_to_loop_map(loops,
+   
 mesh.totvert);
 
 const bke::MeshFieldContext context{mesh, domain};
 fn::FieldEvaluator evaluator{context, &mask};
@@ -92,7 +92,7 @@ class CornersOfVertInput final : public bke::MeshFieldInput {
   continue;
 }
 
-const Span corners = vert_to_corner_map[vert_i];
+const Span corners = vert_to_loop_map[vert_i];
 
 /* Retrieve the connected edge indices as 64 bit integers for 
#materialize_compressed. */

[Bf-blender-cvs] [79b1e267ef9] master: Cleanup: Move subdiv_ccg.c to C++

2022-10-06 Thread Hans Goudey
Commit: 79b1e267ef9ab21afccd4a569d83ae2b8c9d4654
Author: Hans Goudey
Date:   Thu Oct 6 17:24:16 2022 -0500
Branches: master
https://developer.blender.org/rB79b1e267ef9ab21afccd4a569d83ae2b8c9d4654

Cleanup: Move subdiv_ccg.c to C++

In preparation for moving mesh runtime data to C++

===

M   source/blender/blenkernel/CMakeLists.txt
R091source/blender/blenkernel/intern/subdiv_ccg.c   
source/blender/blenkernel/intern/subdiv_ccg.cc

===

diff --git a/source/blender/blenkernel/CMakeLists.txt 
b/source/blender/blenkernel/CMakeLists.txt
index 12fb6792f93..97bdff217d0 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -266,7 +266,7 @@ set(SRC
   intern/speaker.c
   intern/studiolight.c
   intern/subdiv.c
-  intern/subdiv_ccg.c
+  intern/subdiv_ccg.cc
   intern/subdiv_ccg_mask.c
   intern/subdiv_ccg_material.c
   intern/subdiv_converter.c
diff --git a/source/blender/blenkernel/intern/subdiv_ccg.c 
b/source/blender/blenkernel/intern/subdiv_ccg.cc
similarity index 91%
rename from source/blender/blenkernel/intern/subdiv_ccg.c
rename to source/blender/blenkernel/intern/subdiv_ccg.cc
index e7f89a625b3..8c44d53e5bd 100644
--- a/source/blender/blenkernel/intern/subdiv_ccg.c
+++ b/source/blender/blenkernel/intern/subdiv_ccg.cc
@@ -38,7 +38,7 @@ static void subdiv_ccg_average_inner_face_grids(SubdivCCG 
*subdiv_ccg,
 
 void subdiv_ccg_average_faces_boundaries_and_corners(SubdivCCG *subdiv_ccg,
  CCGKey *key,
- struct CCGFace 
**effected_faces,
+ CCGFace **effected_faces,
  int num_effected_faces);
 
 /** \} */
@@ -126,20 +126,21 @@ static void subdiv_ccg_alloc_elements(SubdivCCG 
*subdiv_ccg, Subdiv *subdiv)
   const int grid_area = grid_size * grid_size;
   subdiv_ccg->grid_element_size = element_size;
   subdiv_ccg->num_grids = num_grids;
-  subdiv_ccg->grids = MEM_calloc_arrayN(num_grids, sizeof(CCGElem *), "subdiv 
ccg grids");
-  subdiv_ccg->grids_storage = MEM_calloc_arrayN(
-  num_grids, ((size_t)grid_area) * element_size, "subdiv ccg grids 
storage");
+  subdiv_ccg->grids = static_cast(
+  MEM_calloc_arrayN(num_grids, sizeof(CCGElem *), "subdiv ccg grids"));
+  subdiv_ccg->grids_storage = static_cast(MEM_calloc_arrayN(
+  num_grids, ((size_t)grid_area) * element_size, "subdiv ccg grids 
storage"));
   const size_t grid_size_in_bytes = (size_t)grid_area * element_size;
   for (int grid_index = 0; grid_index < num_grids; grid_index++) {
 const size_t grid_offset = grid_size_in_bytes * grid_index;
 subdiv_ccg->grids[grid_index] = (CCGElem 
*)&subdiv_ccg->grids_storage[grid_offset];
   }
   /* Grid material flags. */
-  subdiv_ccg->grid_flag_mats = MEM_calloc_arrayN(
-  num_grids, sizeof(DMFlagMat), "ccg grid material flags");
+  subdiv_ccg->grid_flag_mats = static_cast(
+  MEM_calloc_arrayN(num_grids, sizeof(DMFlagMat), "ccg grid material 
flags"));
   /* Grid hidden flags. */
-  subdiv_ccg->grid_hidden = MEM_calloc_arrayN(
-  num_grids, sizeof(BLI_bitmap *), "ccg grid material flags");
+  subdiv_ccg->grid_hidden = static_cast(
+  MEM_calloc_arrayN(num_grids, sizeof(BLI_bitmap *), "ccg grid material 
flags"));
   for (int grid_index = 0; grid_index < num_grids; grid_index++) {
 subdiv_ccg->grid_hidden[grid_index] = BLI_BITMAP_NEW(grid_area, "ccg grid 
hidden");
   }
@@ -147,9 +148,10 @@ static void subdiv_ccg_alloc_elements(SubdivCCG 
*subdiv_ccg, Subdiv *subdiv)
   /* Allocate memory for faces. */
   subdiv_ccg->num_faces = num_faces;
   if (num_faces) {
-subdiv_ccg->faces = MEM_calloc_arrayN(num_faces, sizeof(SubdivCCGFace), 
"Subdiv CCG faces");
-subdiv_ccg->grid_faces = MEM_calloc_arrayN(
-num_grids, sizeof(SubdivCCGFace *), "Subdiv CCG grid faces");
+subdiv_ccg->faces = static_cast(
+MEM_calloc_arrayN(num_faces, sizeof(SubdivCCGFace), "Subdiv CCG 
faces"));
+subdiv_ccg->grid_faces = static_cast(
+MEM_calloc_arrayN(num_grids, sizeof(SubdivCCGFace *), "Subdiv CCG grid 
faces"));
   }
 }
 
@@ -159,13 +161,13 @@ static void subdiv_ccg_alloc_elements(SubdivCCG 
*subdiv_ccg, Subdiv *subdiv)
 /** \name Grids evaluation
  * \{ */
 
-typedef struct CCGEvalGridsData {
+struct CCGEvalGridsData {
   SubdivCCG *subdiv_ccg;
   Subdiv *subdiv;
   int *face_ptex_offset;
   SubdivCCGMaskEvaluator *mask_evaluator;
   SubdivCCGMaterialFlagsEvaluator *material_flags_evaluator;
-} CCGEvalGridsData;
+};
 
 static void subdiv_ccg_eval_grid_element_limit(CCGEvalGridsData *data,
const int ptex_face_index,
@@ -175,7 +177,7 @@ static void 
subdiv_ccg_eval_grid_element_limit(CCGEvalGridsData *data,
 {
   Subdiv *subdiv = da

[Bf-blender-cvs] [406a98aff89] master: Cleanup: Move eight modifier files to C++

2022-10-06 Thread Hans Goudey
Commit: 406a98aff893570eef1f2d217b87a5997a7a60d6
Author: Hans Goudey
Date:   Thu Oct 6 16:05:56 2022 -0500
Branches: master
https://developer.blender.org/rB406a98aff893570eef1f2d217b87a5997a7a60d6

Cleanup: Move eight modifier files to C++

In preparation for moving mesh runtime data to C++.

===

M   source/blender/modifiers/CMakeLists.txt
M   source/blender/modifiers/MOD_modifiertypes.h
R088source/blender/modifiers/intern/MOD_multires.c  
source/blender/modifiers/intern/MOD_multires.cc
R089source/blender/modifiers/intern/MOD_util.c  
source/blender/modifiers/intern/MOD_util.cc
R087source/blender/modifiers/intern/MOD_uvproject.c 
source/blender/modifiers/intern/MOD_uvproject.cc
R086source/blender/modifiers/intern/MOD_uvwarp.c
source/blender/modifiers/intern/MOD_uvwarp.cc
R081source/blender/modifiers/intern/MOD_weighted_normal.c   
source/blender/modifiers/intern/MOD_weighted_normal.cc
M   source/blender/modifiers/intern/MOD_weightvg_util.h
R088source/blender/modifiers/intern/MOD_weightvgedit.c  
source/blender/modifiers/intern/MOD_weightvgedit.cc
R087source/blender/modifiers/intern/MOD_weightvgmix.c   
source/blender/modifiers/intern/MOD_weightvgmix.cc
R085source/blender/modifiers/intern/MOD_weightvgproximity.c 
source/blender/modifiers/intern/MOD_weightvgproximity.cc

===

diff --git a/source/blender/modifiers/CMakeLists.txt 
b/source/blender/modifiers/CMakeLists.txt
index 90ae3c8093c..e3a88e61cbd 100644
--- a/source/blender/modifiers/CMakeLists.txt
+++ b/source/blender/modifiers/CMakeLists.txt
@@ -63,7 +63,7 @@ set(SRC
   intern/MOD_meshdeform.c
   intern/MOD_meshsequencecache.cc
   intern/MOD_mirror.c
-  intern/MOD_multires.c
+  intern/MOD_multires.cc
   intern/MOD_nodes.cc
   intern/MOD_none.c
   intern/MOD_normal_edit.cc
@@ -86,18 +86,18 @@ set(SRC
   intern/MOD_surfacedeform.c
   intern/MOD_triangulate.c
   intern/MOD_ui_common.c
-  intern/MOD_util.c
-  intern/MOD_uvproject.c
-  intern/MOD_uvwarp.c
+  intern/MOD_util.cc
+  intern/MOD_uvproject.cc
+  intern/MOD_uvwarp.cc
   intern/MOD_volume_displace.cc
   intern/MOD_volume_to_mesh.cc
   intern/MOD_warp.c
   intern/MOD_wave.cc
-  intern/MOD_weighted_normal.c
+  intern/MOD_weighted_normal.cc
   intern/MOD_weightvg_util.c
-  intern/MOD_weightvgedit.c
-  intern/MOD_weightvgmix.c
-  intern/MOD_weightvgproximity.c
+  intern/MOD_weightvgedit.cc
+  intern/MOD_weightvgmix.cc
+  intern/MOD_weightvgproximity.cc
   intern/MOD_weld.cc
   intern/MOD_wireframe.c
 
diff --git a/source/blender/modifiers/MOD_modifiertypes.h 
b/source/blender/modifiers/MOD_modifiertypes.h
index 70d6cb9ff76..62b496017c4 100644
--- a/source/blender/modifiers/MOD_modifiertypes.h
+++ b/source/blender/modifiers/MOD_modifiertypes.h
@@ -76,7 +76,7 @@ extern ModifierTypeInfo modifierType_MeshToVolume;
 extern ModifierTypeInfo modifierType_VolumeDisplace;
 extern ModifierTypeInfo modifierType_VolumeToMesh;
 
-/* MOD_util.c */
+/* MOD_util.cc */
 
 /**
  * Only called by `BKE_modifier.h/modifier.cc`
diff --git a/source/blender/modifiers/intern/MOD_multires.c 
b/source/blender/modifiers/intern/MOD_multires.cc
similarity index 88%
rename from source/blender/modifiers/intern/MOD_multires.c
rename to source/blender/modifiers/intern/MOD_multires.cc
index 87108836a90..6342ff384a4 100644
--- a/source/blender/modifiers/intern/MOD_multires.c
+++ b/source/blender/modifiers/intern/MOD_multires.cc
@@ -5,7 +5,7 @@
  * \ingroup modifiers
  */
 
-#include 
+#include 
 
 #include "MEM_guardedalloc.h"
 
@@ -45,10 +45,10 @@
 #include "MOD_modifiertypes.h"
 #include "MOD_ui_common.h"
 
-typedef struct MultiresRuntimeData {
+struct MultiresRuntimeData {
   /* Cached subdivision surface descriptor, with topology and settings. */
   struct Subdiv *subdiv;
-} MultiresRuntimeData;
+};
 
 static void initData(ModifierData *md)
 {
@@ -87,11 +87,11 @@ static void copyData(const ModifierData *md_src, 
ModifierData *md_dst, const int
 
 static void freeRuntimeData(void *runtime_data_v)
 {
-  if (runtime_data_v == NULL) {
+  if (runtime_data_v == nullptr) {
 return;
   }
   MultiresRuntimeData *runtime_data = (MultiresRuntimeData *)runtime_data_v;
-  if (runtime_data->subdiv != NULL) {
+  if (runtime_data->subdiv != nullptr) {
 BKE_subdiv_free(runtime_data->subdiv);
   }
   MEM_freeN(runtime_data);
@@ -106,8 +106,9 @@ static void freeData(ModifierData *md)
 static MultiresRuntimeData *multires_ensure_runtime(MultiresModifierData *mmd)
 {
   MultiresRuntimeData *runtime_data = (MultiresRuntimeData 
*)mmd->modifier.runtime;
-  if (runtime_data == NULL) {
-runtime_data = MEM_callocN(sizeof(*runtime_data), "subsurf runtime");
+  if (runtime_data == nullptr) {
+runtime_data = static_cast(
+MEM_callocN(sizeof(*runtime_data), __func__));
 mmd->modifier.runtime = runtime_data;
   }
   return runtime_data;
@@ -189,8 +190

[Bf-blender-cvs] [53d937a1700] master: Sculpt: Raise pbvh->leaf_limit to 400 for dyntopo

2022-10-06 Thread Joseph Eagar
Commit: 53d937a1700021e0cb7a52aa0c45da0014974e81
Author: Joseph Eagar
Date:   Thu Oct 6 14:06:16 2022 -0700
Branches: master
https://developer.blender.org/rB53d937a1700021e0cb7a52aa0c45da0014974e81

Sculpt: Raise pbvh->leaf_limit to 400 for dyntopo

Setting pbvh->leaf_limit (the max triangles per node)
too low results in lots of distinct GPU meshes, which
can be slow for even moderately sized sculpt meshes
(starts to be a problem around 100-150k triangles).

===

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

===

diff --git a/source/blender/blenkernel/intern/pbvh_bmesh.c 
b/source/blender/blenkernel/intern/pbvh_bmesh.c
index de908adac79..516e1fb4639 100644
--- a/source/blender/blenkernel/intern/pbvh_bmesh.c
+++ b/source/blender/blenkernel/intern/pbvh_bmesh.c
@@ -1884,7 +1884,7 @@ void BKE_pbvh_build_bmesh(PBVH *pbvh,
   pbvh->bm_log = log;
 
   /* TODO: choose leaf limit better */
-  pbvh->leaf_limit = 100;
+  pbvh->leaf_limit = 400;
 
   BKE_pbvh_update_bmesh_offsets(pbvh, cd_vert_node_offset, 
cd_face_node_offset);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [dfa0eb298ed] master: Sculpt: Fix T101502: GPU tris miscounted for dyntopo

2022-10-06 Thread Joseph Eagar
Commit: dfa0eb298ed3fa08cc70a472eb9427b515040457
Author: Joseph Eagar
Date:   Thu Oct 6 14:03:17 2022 -0700
Branches: master
https://developer.blender.org/rBdfa0eb298ed3fa08cc70a472eb9427b515040457

Sculpt: Fix T101502: GPU tris miscounted for dyntopo

Dyntopo PBVH draw was miscounting the number of triangles.

===

M   source/blender/draw/intern/draw_pbvh.cc

===

diff --git a/source/blender/draw/intern/draw_pbvh.cc 
b/source/blender/draw/intern/draw_pbvh.cc
index 6b807222079..02e7f937987 100644
--- a/source/blender/draw/intern/draw_pbvh.cc
+++ b/source/blender/draw/intern/draw_pbvh.cc
@@ -707,26 +707,14 @@ struct PBVHBatches {
 }
 
 BMLoop *l = f->l_first;
-do {
-  callback(l);
-} while ((l = l->next) != f->l_first);
+callback(l->prev);
+callback(l);
+callback(l->next);
   }
   GSET_FOREACH_END();
 };
 
-faces_count = 0;
-GSET_FOREACH_BEGIN (BMFace *, f, args->bm_faces) {
-  if (BM_elem_flag_test(f, BM_ELEM_HIDDEN)) {
-continue;
-  }
-
-  BMLoop *l = f->l_first;
-  do {
-faces_count++;
-  } while ((l = l->next) != f->l_first);
-}
-GSET_FOREACH_END();
-tris_count = faces_count;
+faces_count = tris_count = count_faces(args);
 
 int existing_num = GPU_vertbuf_get_vertex_len(vbo.vert_buf);
 void *existing_data = GPU_vertbuf_get_data(vbo.vert_buf);
@@ -741,7 +729,24 @@ struct PBVHBatches {
 GPUVertBufRaw access;
 GPU_vertbuf_attr_get_raw_data(vbo.vert_buf, 0, &access);
 
+#if 0 /* Enable to fuzz gpu data (to check for overallocation). */
+existing_data = GPU_vertbuf_get_data(vbo.vert_buf);
+uchar *c = static_cast(existing_data);
+for (int i : IndexRange(vert_count * access.stride)) {
+  *c++ = i & 255;
+}
+#endif
+
 switch (vbo.type) {
+  case CD_PROP_COLOR:
+  case CD_PROP_BYTE_COLOR: {
+ushort4 white = {USHRT_MAX, USHRT_MAX, USHRT_MAX, USHRT_MAX};
+
+foreach_bmesh([&](BMLoop * /*l*/) {
+  *static_cast(GPU_vertbuf_raw_step(&access)) = white;
+});
+break;
+  }
   case CD_PBVH_CO_TYPE:
 foreach_bmesh(
 [&](BMLoop *l) { *static_cast(GPU_vertbuf_raw_step(&access)) = l->v->co; });

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [d4f77c22661] master: Cleanup: Move shrinkwrap.c to C++

2022-10-06 Thread Hans Goudey
Commit: d4f77c22661c316bdaada2ff053f1484412ccb83
Author: Hans Goudey
Date:   Thu Oct 6 15:15:49 2022 -0500
Branches: master
https://developer.blender.org/rBd4f77c22661c316bdaada2ff053f1484412ccb83

Cleanup: Move shrinkwrap.c to C++

===

M   source/blender/blenkernel/CMakeLists.txt
R090source/blender/blenkernel/intern/shrinkwrap.c   
source/blender/blenkernel/intern/shrinkwrap.cc

===

diff --git a/source/blender/blenkernel/CMakeLists.txt 
b/source/blender/blenkernel/CMakeLists.txt
index 192acbf8338..a58fc22b880 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -259,7 +259,7 @@ set(SRC
   intern/scene.cc
   intern/screen.c
   intern/shader_fx.c
-  intern/shrinkwrap.c
+  intern/shrinkwrap.cc
   intern/simulation.cc
   intern/softbody.c
   intern/sound.c
diff --git a/source/blender/blenkernel/intern/shrinkwrap.c 
b/source/blender/blenkernel/intern/shrinkwrap.cc
similarity index 90%
rename from source/blender/blenkernel/intern/shrinkwrap.c
rename to source/blender/blenkernel/intern/shrinkwrap.cc
index f94836551bb..2b8af00d281 100644
--- a/source/blender/blenkernel/intern/shrinkwrap.c
+++ b/source/blender/blenkernel/intern/shrinkwrap.cc
@@ -5,12 +5,12 @@
  * \ingroup bke
  */
 
-#include 
-#include 
+#include 
+#include 
+#include 
+#include 
+#include 
 #include 
-#include 
-#include 
-#include 
 
 #include "DNA_gpencil_modifier_types.h"
 #include "DNA_mesh_types.h"
@@ -54,30 +54,30 @@
 /* Util macros */
 #define OUT_OF_MEMORY() ((void)printf("Shrinkwrap: Out of memory\n"))
 
-typedef struct ShrinkwrapCalcData {
+struct ShrinkwrapCalcData {
   ShrinkwrapModifierData *smd; /* shrinkwrap modifier data */
 
-  struct Object *ob; /* object we are applying shrinkwrap to */
+  Object *ob; /* object we are applying shrinkwrap to */
 
-  struct MVert *vert; /* Array of verts being projected. */
+  MVert *vert; /* Array of verts being projected. */
   const float (*vert_normals)[3];
   float (*vertexCos)[3]; /* vertexs being shrinkwraped */
   int numVerts;
 
-  const struct MDeformVert *dvert; /* Pointer to mdeform array */
-  int vgroup;  /* Vertex group num */
-  bool invert_vgroup;  /* invert vertex group influence */
+  const MDeformVert *dvert; /* Pointer to mdeform array */
+  int vgroup;   /* Vertex group num */
+  bool invert_vgroup;   /* invert vertex group influence */
 
-  struct Mesh *target;/* mesh we are shrinking to */
-  struct SpaceTransform local2target; /* transform to move between local and 
target space */
-  struct ShrinkwrapTreeData *tree;/* mesh BVH tree data */
+  Mesh *target;/* mesh we are shrinking to */
+  SpaceTransform local2target; /* transform to move between local and target 
space */
+  ShrinkwrapTreeData *tree;/* mesh BVH tree data */
 
-  struct Object *aux_target;
+  Object *aux_target;
 
   float keepDist; /* Distance to keep above target surface (units are in local 
space) */
-} ShrinkwrapCalcData;
+};
 
-typedef struct ShrinkwrapCalcCBData {
+struct ShrinkwrapCalcCBData {
   ShrinkwrapCalcData *calc;
 
   ShrinkwrapTreeData *tree;
@@ -85,7 +85,7 @@ typedef struct ShrinkwrapCalcCBData {
 
   float *proj_axis;
   SpaceTransform *local2aux;
-} ShrinkwrapCalcCBData;
+};
 
 bool BKE_shrinkwrap_needs_normals(int shrinkType, int shrinkMode)
 {
@@ -99,7 +99,7 @@ bool BKE_shrinkwrap_init_tree(
 {
   memset(data, 0, sizeof(*data));
 
-  if (mesh == NULL) {
+  if (mesh == nullptr) {
 return false;
   }
 
@@ -118,7 +118,7 @@ bool BKE_shrinkwrap_init_tree(
   if (shrinkType == MOD_SHRINKWRAP_NEAREST_VERTEX) {
 data->bvh = BKE_bvhtree_from_mesh_get(&data->treeData, mesh, 
BVHTREE_FROM_VERTS, 2);
 
-return data->bvh != NULL;
+return data->bvh != nullptr;
   }
 
   if (mesh->totpoly <= 0) {
@@ -127,14 +127,14 @@ bool BKE_shrinkwrap_init_tree(
 
   data->bvh = BKE_bvhtree_from_mesh_get(&data->treeData, mesh, 
BVHTREE_FROM_LOOPTRI, 4);
 
-  if (data->bvh == NULL) {
+  if (data->bvh == nullptr) {
 return false;
   }
 
   if (force_normals || BKE_shrinkwrap_needs_normals(shrinkType, shrinkMode)) {
 data->pnors = BKE_mesh_poly_normals_ensure(mesh);
 if ((mesh->flag & ME_AUTOSMOOTH) != 0) {
-  data->clnors = CustomData_get_layer(&mesh->ldata, CD_NORMAL);
+  data->clnors = static_cast(CustomData_get_layer(&mesh->ldata, CD_NORMAL));
 }
   }
 
@@ -150,11 +150,11 @@ void BKE_shrinkwrap_free_tree(ShrinkwrapTreeData *data)
   free_bvhtree_from_mesh(&data->treeData);
 }
 
-void BKE_shrinkwrap_discard_boundary_data(struct Mesh *mesh)
+void BKE_shrinkwrap_discard_boundary_data(Mesh *mesh)
 {
-  struct ShrinkwrapBoundaryData *data = mesh->runtime.shrinkwrap_data;
+  ShrinkwrapBoundaryData *data = mesh->runtime.shrinkwrap_data;
 
-  if (data != NULL) {
+  if (data != nullptr) {
 MEM_freeN((voi

[Bf-blender-cvs] [eae3fa8730d] master: Cleanup: Move subdiv_modifier.c to C++

2022-10-06 Thread Hans Goudey
Commit: eae3fa8730dfa820a81c0f1fb95d4df601408639
Author: Hans Goudey
Date:   Thu Oct 6 15:23:22 2022 -0500
Branches: master
https://developer.blender.org/rBeae3fa8730dfa820a81c0f1fb95d4df601408639

Cleanup: Move subdiv_modifier.c to C++

In preparation for moving mesh runtime data to a C++ type

===

M   source/blender/blenkernel/CMakeLists.txt
R095source/blender/blenkernel/intern/subdiv_modifier.c  
source/blender/blenkernel/intern/subdiv_modifier.cc

===

diff --git a/source/blender/blenkernel/CMakeLists.txt 
b/source/blender/blenkernel/CMakeLists.txt
index a58fc22b880..12fb6792f93 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -277,7 +277,7 @@ set(SRC
   intern/subdiv_eval.c
   intern/subdiv_foreach.c
   intern/subdiv_mesh.cc
-  intern/subdiv_modifier.c
+  intern/subdiv_modifier.cc
   intern/subdiv_stats.c
   intern/subdiv_topology.c
   intern/subsurf_ccg.c
diff --git a/source/blender/blenkernel/intern/subdiv_modifier.c 
b/source/blender/blenkernel/intern/subdiv_modifier.cc
similarity index 95%
rename from source/blender/blenkernel/intern/subdiv_modifier.c
rename to source/blender/blenkernel/intern/subdiv_modifier.cc
index 2271fd90bda..f072b1415f8 100644
--- a/source/blender/blenkernel/intern/subdiv_modifier.c
+++ b/source/blender/blenkernel/intern/subdiv_modifier.cc
@@ -46,8 +46,8 @@ bool BKE_subsurf_modifier_runtime_init(SubsurfModifierData 
*smd, const bool use_
   }
 
   /* Allocate runtime data if it did not exist yet. */
-  if (runtime_data == NULL) {
-runtime_data = MEM_callocN(sizeof(*runtime_data), "subsurf runtime");
+  if (runtime_data == nullptr) {
+runtime_data = MEM_cnew(__func__);
 smd->modifier.runtime = runtime_data;
   }
   runtime_data->settings = settings;
@@ -58,7 +58,7 @@ static ModifierData *modifier_get_last_enabled_for_mode(const 
Scene *scene,
 const Object *ob,
 int required_mode)
 {
-  ModifierData *md = ob->modifiers.last;
+  ModifierData *md = static_cast(ob->modifiers.last);
 
   while (md) {
 if (BKE_modifier_is_enabled(scene, md, required_mode)) {
@@ -83,7 +83,7 @@ static bool 
subsurf_modifier_use_autosmooth_or_split_normals(const SubsurfModifi
   return (mesh->flag & ME_AUTOSMOOTH) || 
BKE_subsurf_modifier_use_custom_loop_normals(smd, mesh);
 }
 
-static bool is_subdivision_evaluation_possible_on_gpu(void)
+static bool is_subdivision_evaluation_possible_on_gpu()
 {
   /* Only OpenGL is supported for OpenSubdiv evaluation for now. */
   if (GPU_backend_get_type() != GPU_BACKEND_OPENGL) {
@@ -147,7 +147,7 @@ bool BKE_subsurf_modifier_has_gpu_subdiv(const Mesh *mesh)
   return runtime_data && runtime_data->has_gpu_subdiv;
 }
 
-void (*BKE_subsurf_modifier_free_gpu_cache_cb)(Subdiv *subdiv) = NULL;
+void (*BKE_subsurf_modifier_free_gpu_cache_cb)(Subdiv *subdiv) = nullptr;
 
 Subdiv *BKE_subsurf_modifier_subdiv_descriptor_ensure(SubsurfRuntimeData 
*runtime_data,
   const Mesh *mesh,
@@ -155,7 +155,7 @@ Subdiv 
*BKE_subsurf_modifier_subdiv_descriptor_ensure(SubsurfRuntimeData *runtim
 {
   if (runtime_data->subdiv && runtime_data->set_by_draw_code != for_draw_code) 
{
 BKE_subdiv_free(runtime_data->subdiv);
-runtime_data->subdiv = NULL;
+runtime_data->subdiv = nullptr;
   }
   Subdiv *subdiv = BKE_subdiv_update_from_mesh(
   runtime_data->subdiv, &runtime_data->settings, mesh);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [0a35a7bd311] bevelv2: Some edge data structures added.

2022-10-06 Thread Howard Trickey
Commit: 0a35a7bd311ebffef2ea1542297349e13a7872da
Author: Howard Trickey
Date:   Thu Oct 6 16:34:41 2022 -0400
Branches: bevelv2
https://developer.blender.org/rB0a35a7bd311ebffef2ea1542297349e13a7872da

Some edge data structures added.

===

M   source/blender/nodes/geometry/nodes/node_geo_bevel_mesh.cc

===

diff --git a/source/blender/nodes/geometry/nodes/node_geo_bevel_mesh.cc 
b/source/blender/nodes/geometry/nodes/node_geo_bevel_mesh.cc
index cf1602f964c..91898834baf 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_bevel_mesh.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_bevel_mesh.cc
@@ -718,6 +718,10 @@ class BevelData {
* an Array of size equal to the number of mesh vertices here.
*/
   Map vert_to_bvd_index_;
+  /* All the BevelEdges, when edge beveling. */
+  Array bevel_edge_;
+  /* Map from mesh edge indiex inot bevel_edge_. */
+  Map edge_to_bevel_edge_;
 
  public:
   MeshTopology topo;
@@ -808,6 +812,14 @@ void BevelData::calculate_vertex_bevels(const IndexMask 
to_bevel, VArray
  */
 void BevelData::calculate_edge_bevels(const IndexMask to_bevel, VArray 
amounts)
 {
+  bevel_edge_.reinitialize(to_bevel.size());
+  Set need_vert;
+  for (const int e : to_bevel) {
+need_vert.add(topo.edge_v1(e));
+need_vert.add(topo.edge_v2(e));
+  }
+  const int tot_need_vert = need_vert.size();
+  bevel_vert_data_.reinitialize(tot_need_vert);
 }
 
 /** IndexAlloc allocates sequential integers, starting from a given start 
value. */

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [71e26f6eff2] temp-gpencil-automask: GPencil: New Automasking modes and fix bug

2022-10-06 Thread Antonio Vazquez
Commit: 71e26f6eff230b20d52d7ff6be3329ad09fe30c6
Author: Antonio Vazquez
Date:   Thu Oct 6 22:29:45 2022 +0200
Branches: temp-gpencil-automask
https://developer.blender.org/rB71e26f6eff230b20d52d7ff6be3329ad09fe30c6

GPencil: New Automasking modes and fix bug

* New Layer and Material of the stroke Masking.
* Fixed Automasking with modifiers.

===

M   release/scripts/startup/bl_ui/properties_grease_pencil_common.py
M   source/blender/editors/gpencil/gpencil_sculpt_paint.c
M   source/blender/makesdna/DNA_scene_types.h
M   source/blender/makesrna/intern/rna_sculpt_paint.c

===

diff --git a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py 
b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
index 2576f38ceb7..b85d9624d59 100644
--- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
+++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
@@ -53,8 +53,10 @@ class GreasePencilSculptAdvancedPanel:
 
 col = layout.column(heading="Auto-Masking", align=True)
 col.prop(tool_settings.gpencil_sculpt, "use_automasking_stroke", 
text="Stroke")
-col.prop(tool_settings.gpencil_sculpt, "use_automasking_layer", 
text="Layer")
-col.prop(tool_settings.gpencil_sculpt, "use_automasking_material", 
text="Material")
+col.prop(tool_settings.gpencil_sculpt, "use_automasking_layer_stroke", 
text="Layer")
+col.prop(tool_settings.gpencil_sculpt, 
"use_automasking_material_stroke", text="Material")
+col.prop(tool_settings.gpencil_sculpt, "use_automasking_layer_active", 
text="Layer Active")
+col.prop(tool_settings.gpencil_sculpt, 
"use_automasking_material_active", text="Material Active")
 
 if tool in {'SMOOTH', 'RANDOMIZE'}:
 col = layout.column(heading="Affect", align=True)
diff --git a/source/blender/editors/gpencil/gpencil_sculpt_paint.c 
b/source/blender/editors/gpencil/gpencil_sculpt_paint.c
index 749a4bd2853..e81a3ef8b49 100644
--- a/source/blender/editors/gpencil/gpencil_sculpt_paint.c
+++ b/source/blender/editors/gpencil/gpencil_sculpt_paint.c
@@ -68,6 +68,8 @@
 
 #include "gpencil_intern.h"
 
+#define SEARCH_RADIUS_PIXEL 20
+
 /*  */
 /* General Brush Editing Context */
 
@@ -78,6 +80,7 @@ typedef struct tGP_BrushEditData {
   Main *bmain;
   Scene *scene;
   Object *object;
+  Object *ob_eval;
 
   ScrArea *area;
   ARegion *region;
@@ -1181,6 +1184,8 @@ static bool gpencil_sculpt_brush_init(bContext *C, 
wmOperator *op)
 }
 /* Check if some modifier can transform the stroke. */
 gso->is_transformed = BKE_gpencil_has_transform_modifiers(ob);
+
+gso->ob_eval = (Object *)DEG_get_evaluated_id(gso->depsgraph, &ob->id);
   }
   else {
 unit_m4(gso->inv_mat);
@@ -1196,9 +1201,12 @@ static bool gpencil_sculpt_brush_init(bContext *C, 
wmOperator *op)
   gso->brush = brush;
   BKE_curvemapping_init(gso->brush->curve);
 
-  const bool is_automasking = (ts->gp_sculpt.flag & 
(GP_SCULPT_SETT_FLAG_AUTOMASK_STROKE |
- 
GP_SCULPT_SETT_FLAG_AUTOMASK_LAYER |
- 
GP_SCULPT_SETT_FLAG_AUTOMASK_MATERIAL)) != 0;
+  const bool is_automasking = (ts->gp_sculpt.flag &
+   (GP_SCULPT_SETT_FLAG_AUTOMASK_STROKE |
+GP_SCULPT_SETT_FLAG_AUTOMASK_LAYER_STROKE |
+GP_SCULPT_SETT_FLAG_AUTOMASK_MATERIAL_STROKE |
+GP_SCULPT_SETT_FLAG_AUTOMASK_LAYER_ACTIVE |
+GP_SCULPT_SETT_FLAG_AUTOMASK_MATERIAL_ACTIVE)) 
!= 0;
   if (is_automasking) {
 gso->automasking_strokes = BLI_ghash_ptr_new(__func__);
   }
@@ -1602,9 +1610,12 @@ static bool gpencil_sculpt_brush_do_frame(bContext *C,
   Brush *brush = gso->brush;
   const int radius = (brush->flag & GP_BRUSH_USE_PRESSURE) ? gso->brush->size 
* gso->pressure :
  gso->brush->size;
-  const bool is_automasking = (ts->gp_sculpt.flag & 
(GP_SCULPT_SETT_FLAG_AUTOMASK_STROKE |
- 
GP_SCULPT_SETT_FLAG_AUTOMASK_LAYER |
- 
GP_SCULPT_SETT_FLAG_AUTOMASK_MATERIAL)) != 0;
+  const bool is_automasking = (ts->gp_sculpt.flag &
+   (GP_SCULPT_SETT_FLAG_AUTOMASK_STROKE |
+GP_SCULPT_SETT_FLAG_AUTOMASK_LAYER_STROKE |
+GP_SCULPT_SETT_FLAG_AUTOMASK_MATERIAL_STROKE |
+GP_SCULPT_SETT_FLAG_AUTOMASK_LAYER_ACTIVE |
+GP_SCULPT_SETT_FLAG_AUTOMASK_MATERIAL_ACTIVE)) 
!= 0;
   /* Calc bound box matrix. */
   float bound_mat[4][4];

[Bf-blender-cvs] [f58b5246695] master: Sculpt: Fix bug in sculpt attribute api

2022-10-06 Thread Joseph Eagar
Commit: f58b5246695f1fc9b8545c84569566685a64c8cb
Author: Joseph Eagar
Date:   Thu Oct 6 01:06:30 2022 -0700
Branches: master
https://developer.blender.org/rBf58b5246695f1fc9b8545c84569566685a64c8cb

Sculpt: Fix bug in sculpt attribute api

SculptAttribute.domain wasn't being set
when creating from an existing CustomData
attribute.

===

M   source/blender/blenkernel/intern/paint.cc

===

diff --git a/source/blender/blenkernel/intern/paint.cc 
b/source/blender/blenkernel/intern/paint.cc
index 7b3ad170339..00535ea5528 100644
--- a/source/blender/blenkernel/intern/paint.cc
+++ b/source/blender/blenkernel/intern/paint.cc
@@ -2677,6 +2677,7 @@ SculptAttribute *BKE_sculpt_attribute_get(struct Object 
*ob,
   attr = sculpt_alloc_attr(ss);
 
   attr->used = true;
+  attr->domain = domain;
   attr->proptype = proptype;
   attr->data = cdata->layers[index].data;
   attr->bmesh_cd_offset = cdata->layers[index].offset;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [701b6b8aab8] node-add-asset-menu: Merge branch 'master' into node-add-asset-menu

2022-10-06 Thread Hans Goudey
Commit: 701b6b8aab83361970c64e95439a08014681a59d
Author: Hans Goudey
Date:   Thu Oct 6 15:07:50 2022 -0500
Branches: node-add-asset-menu
https://developer.blender.org/rB701b6b8aab83361970c64e95439a08014681a59d

Merge branch 'master' into node-add-asset-menu

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [14de57713d7] master: Cleanup: Remove unnecessary MOD_nodes.h includes

2022-10-06 Thread Hans Goudey
Commit: 14de57713d7610b6645b1611255869da19f3f11d
Author: Hans Goudey
Date:   Thu Oct 6 15:00:29 2022 -0500
Branches: master
https://developer.blender.org/rB14de57713d7610b6645b1611255869da19f3f11d

Cleanup: Remove unnecessary MOD_nodes.h includes

===

M   source/blender/blenkernel/intern/node.cc
M   source/blender/editors/object/object_modifier.cc

===

diff --git a/source/blender/blenkernel/intern/node.cc 
b/source/blender/blenkernel/intern/node.cc
index 1d68a2e2b80..654eb06a781 100644
--- a/source/blender/blenkernel/intern/node.cc
+++ b/source/blender/blenkernel/intern/node.cc
@@ -84,8 +84,6 @@
 
 #include "BLO_read_write.h"
 
-#include "MOD_nodes.h"
-
 #define NODE_DEFAULT_MAX_WIDTH 700
 
 using blender::Array;
diff --git a/source/blender/editors/object/object_modifier.cc 
b/source/blender/editors/object/object_modifier.cc
index 0fc97f96dbf..4581c6a6502 100644
--- a/source/blender/editors/object/object_modifier.cc
+++ b/source/blender/editors/object/object_modifier.cc
@@ -85,8 +85,6 @@
 #include "ED_screen.h"
 #include "ED_sculpt.h"
 
-#include "MOD_nodes.h"
-
 #include "UI_interface.h"
 
 #include "WM_api.h"

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [65c8c836792] master: Fix: Properly free non-trivial node editor runtime type

2022-10-06 Thread Hans Goudey
Commit: 65c8c8367929d14a9036f86ddb3796f620832730
Author: Hans Goudey
Date:   Thu Oct 6 15:01:16 2022 -0500
Branches: master
https://developer.blender.org/rB65c8c8367929d14a9036f86ddb3796f620832730

Fix: Properly free non-trivial node editor runtime type

===

M   source/blender/editors/space_node/space_node.cc

===

diff --git a/source/blender/editors/space_node/space_node.cc 
b/source/blender/editors/space_node/space_node.cc
index 47d117ea81f..ac49115959c 100644
--- a/source/blender/editors/space_node/space_node.cc
+++ b/source/blender/editors/space_node/space_node.cc
@@ -300,7 +300,7 @@ static void node_free(SpaceLink *sl)
 
   if (snode->runtime) {
 snode->runtime->linkdrag.reset();
-MEM_freeN(snode->runtime);
+MEM_delete(snode->runtime);
   }
 }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [02e92af3efb] node-add-asset-menu: Remove unrelated change

2022-10-06 Thread Hans Goudey
Commit: 02e92af3efb5f0aa23521ecd880830f768ab6d08
Author: Hans Goudey
Date:   Thu Oct 6 14:57:54 2022 -0500
Branches: node-add-asset-menu
https://developer.blender.org/rB02e92af3efb5f0aa23521ecd880830f768ab6d08

Remove unrelated change

===

M   source/blender/windowmanager/WM_api.h

===

diff --git a/source/blender/windowmanager/WM_api.h 
b/source/blender/windowmanager/WM_api.h
index b6c7b0faedf..5b6f7939ab9 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -823,7 +823,7 @@ bool WM_operator_properties_id_lookup_is_set(PointerRNA 
*ptr);
  * with the same name and type may be present). The "name" property is only 
kept to not break
  * compatibility with old scripts using some previously existing operators.
  */
-void WM_operator_properties_id_lookup(wmOperatorType *ot, bool add_name_prop);
+void WM_operator_properties_id_lookup(wmOperatorType *ot, const bool 
add_name_prop);
 
 /**
  * Disable using cursor position,

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [13951cde59b] node-add-asset-menu: Remove some unnecessary changes

2022-10-06 Thread Hans Goudey
Commit: 13951cde59b14d35ce583f1d2fcc012d7c3c72b2
Author: Hans Goudey
Date:   Thu Oct 6 14:45:46 2022 -0500
Branches: node-add-asset-menu
https://developer.blender.org/rB13951cde59b14d35ce583f1d2fcc012d7c3c72b2

Remove some unnecessary changes

===

M   source/blender/blenkernel/BKE_asset_catalog.hh
M   source/blender/blenkernel/intern/asset_catalog.cc
M   source/blender/makesdna/DNA_asset_types.h

===

diff --git a/source/blender/blenkernel/BKE_asset_catalog.hh 
b/source/blender/blenkernel/BKE_asset_catalog.hh
index 18f0debfd6c..73c2e00c4c4 100644
--- a/source/blender/blenkernel/BKE_asset_catalog.hh
+++ b/source/blender/blenkernel/BKE_asset_catalog.hh
@@ -124,10 +124,7 @@ class AssetCatalogService {
*
* \see #AssetCatalogFilter
*/
-  AssetCatalogFilter create_catalog_filter(const AssetCatalogPath &path) const;
-  AssetCatalogFilter create_catalog_filter(CatalogID catalog_id) const;
-
-  Set catalogs_for_path(const AssetCatalogPath &path) const;
+  AssetCatalogFilter create_catalog_filter(CatalogID active_catalog_id) const;
 
   /** Create a catalog with some sensible auto-generated catalog ID.
* The catalog will be saved to the default catalog file. */
@@ -150,7 +147,6 @@ class AssetCatalogService {
   void update_catalog_path(CatalogID catalog_id, const AssetCatalogPath 
&new_catalog_path);
 
   AssetCatalogTree *get_catalog_tree();
-  const AssetCatalogTree *get_catalog_tree() const;
 
   /** Return true only if there are no catalogs known. */
   bool is_empty() const;
diff --git a/source/blender/blenkernel/intern/asset_catalog.cc 
b/source/blender/blenkernel/intern/asset_catalog.cc
index b9fe7469ead..8a28e209c6a 100644
--- a/source/blender/blenkernel/intern/asset_catalog.cc
+++ b/source/blender/blenkernel/intern/asset_catalog.cc
@@ -149,10 +149,14 @@ bool AssetCatalogService::is_catalog_known(CatalogID 
catalog_id) const
   return catalog_collection_->catalogs_.contains(catalog_id);
 }
 
-AssetCatalogFilter AssetCatalogService::create_catalog_filter(const 
AssetCatalogPath &path) const
+AssetCatalogFilter AssetCatalogService::create_catalog_filter(
+const CatalogID active_catalog_id) const
 {
   Set matching_catalog_ids;
   Set known_catalog_ids;
+  matching_catalog_ids.add(active_catalog_id);
+
+  const AssetCatalog *active_catalog = find_catalog(active_catalog_id);
 
   /* This cannot just iterate over tree items to get all the required data, 
because tree items only
* represent single UUIDs. It could be used to get the main UUIDs of the 
children, though, and
@@ -160,7 +164,7 @@ AssetCatalogFilter 
AssetCatalogService::create_catalog_filter(const AssetCatalog
* call). Without an extra indexed-by-path acceleration structure, this is 
still going to require
* a linear search, though. */
   for (const auto &catalog_uptr : catalog_collection_->catalogs_.values()) {
-if (catalog_uptr->path.is_contained_in(path)) {
+if (active_catalog && 
catalog_uptr->path.is_contained_in(active_catalog->path)) {
   matching_catalog_ids.add(catalog_uptr->catalog_id);
 }
 known_catalog_ids.add(catalog_uptr->catalog_id);
@@ -169,27 +173,6 @@ AssetCatalogFilter 
AssetCatalogService::create_catalog_filter(const AssetCatalog
   return AssetCatalogFilter(std::move(matching_catalog_ids), 
std::move(known_catalog_ids));
 }
 
-Set AssetCatalogService::catalogs_for_path(const AssetCatalogPath 
&path) const
-{
-  Set catalog_ids;
-  for (const auto &catalog_uptr : catalog_collection_->catalogs_.values()) {
-if (catalog_uptr->path == path) {
-  catalog_ids.add(catalog_uptr->catalog_id);
-}
-  }
-  return catalog_ids;
-}
-
-AssetCatalogFilter AssetCatalogService::create_catalog_filter(const CatalogID 
catalog_id) const
-{
-  const AssetCatalog *catalog = this->find_catalog(catalog_id);
-  if (!catalog) {
-return AssetCatalogFilter({catalog_id}, {});
-  }
-
-  return this->create_catalog_filter(catalog->path);
-}
-
 void AssetCatalogService::delete_catalog_by_id_soft(const CatalogID catalog_id)
 {
   std::unique_ptr *catalog_uptr_ptr = 
catalog_collection_->catalogs_.lookup_ptr(
@@ -564,11 +547,6 @@ AssetCatalogTree *AssetCatalogService::get_catalog_tree()
   return catalog_tree_.get();
 }
 
-const AssetCatalogTree *AssetCatalogService::get_catalog_tree() const
-{
-  return catalog_tree_.get();
-}
-
 std::unique_ptr AssetCatalogService::read_into_tree()
 {
   auto tree = std::make_unique();
diff --git a/source/blender/makesdna/DNA_asset_types.h 
b/source/blender/makesdna/DNA_asset_types.h
index c63e74dedc0..29795519719 100644
--- a/source/blender/makesdna/DNA_asset_types.h
+++ b/source/blender/makesdna/DNA_asset_types.h
@@ -53,7 +53,7 @@ typedef struct AssetMetaData {
* Mapped to a path in the asset catalog hierarchy by an 
#AssetCatalogService.
* Use #BKE_asset_metadata_catalog_id_set() to ensure a valid ID is set.
*/

[Bf-blender-cvs] [67f907a2c50] node-add-asset-menu: Avoid duplication of builtin menus with hack

2022-10-06 Thread Hans Goudey
Commit: 67f907a2c50b9150bc06ab24a0eab1606215bf63
Author: Hans Goudey
Date:   Thu Oct 6 14:51:51 2022 -0500
Branches: node-add-asset-menu
https://developer.blender.org/rB67f907a2c50b9150bc06ab24a0eab1606215bf63

Avoid duplication of builtin menus with hack

===

M   source/blender/editors/space_node/add_menu_assets.cc

===

diff --git a/source/blender/editors/space_node/add_menu_assets.cc 
b/source/blender/editors/space_node/add_menu_assets.cc
index 8fd3bfcd1f6..c0d448f352a 100644
--- a/source/blender/editors/space_node/add_menu_assets.cc
+++ b/source/blender/editors/space_node/add_menu_assets.cc
@@ -187,7 +187,44 @@ static void add_root_catalogs_draw(const bContext *C, Menu 
*menu)
   uiLayout *layout = menu->layout;
   uiItemS(layout);
 
+  /* Avoid adding a separate root catalog when the assets have already been 
added to one of the
+   * builtin menus.
+   * TODO: The need to define the builtin menu labels here is completely 
non-ideal. We don't have
+   * any UI introspection that can do this though. This can be solved in the 
near future by
+   * removing the need to define the add menu completely, instead using a 
per-node-type path which
+   * can be merged with catalog tree.
+   */
+  static Set all_builtin_menus = []() {
+Set menus;
+menus.add_new("Attribute");
+menus.add_new("Color");
+menus.add_new("Curve");
+menus.add_new("Curve Primitives");
+menus.add_new("Curve Topology");
+menus.add_new("Geometry");
+menus.add_new("Input");
+menus.add_new("Instances");
+menus.add_new("Material");
+menus.add_new("Mesh");
+menus.add_new("Mesh Primitives");
+menus.add_new("Mesh Topology");
+menus.add_new("Output");
+menus.add_new("Point");
+menus.add_new("Text");
+menus.add_new("Texture");
+menus.add_new("Utilities");
+menus.add_new("UV");
+menus.add_new("Vector");
+menus.add_new("Volume");
+menus.add_new("Group");
+menus.add_new("Layout");
+return menus;
+  }();
+
   tree.catalogs.foreach_root_item([&](bke::AssetCatalogTreeItem &item) {
+if (all_builtin_menus.contains(item.get_name())) {
+  return;
+}
 const bke::AssetCatalogPath &path = 
tree.full_catalog_per_tree_item.lookup(&item);
 PointerRNA path_ptr{
 &screen.id, &RNA_AssetCatalogPath, const_cast(&path)};

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [bd04c4aef2a] node-add-asset-menu: Also add items to existing menus

2022-10-06 Thread Hans Goudey
Commit: bd04c4aef2aa007d55084e049e8575354ea5344d
Author: Hans Goudey
Date:   Thu Oct 6 14:38:15 2022 -0500
Branches: node-add-asset-menu
https://developer.blender.org/rBbd04c4aef2aa007d55084e049e8575354ea5344d

Also add items to existing menus

===

M   release/scripts/startup/bl_ui/node_add_menu.py
M   source/blender/blenkernel/BKE_asset_catalog.hh
M   source/blender/blenkernel/intern/asset_catalog.cc
M   source/blender/editors/include/UI_interface.h
M   source/blender/editors/space_node/add_menu_assets.cc
M   source/blender/makesrna/intern/rna_ui_api.c

===

diff --git a/release/scripts/startup/bl_ui/node_add_menu.py 
b/release/scripts/startup/bl_ui/node_add_menu.py
index debed301904..d393dc04963 100644
--- a/release/scripts/startup/bl_ui/node_add_menu.py
+++ b/release/scripts/startup/bl_ui/node_add_menu.py
@@ -58,8 +58,8 @@ def draw_node_group_add_menu(context, layout):
 ops.name = "node_tree"
 ops.value = "bpy.data.node_groups[%r]" % group.name
 
-def draw_assets_for_catalog(layout, catalog):
-layout.menu_contents("NODE_MT_node_add_catalog_assets")
+def draw_assets_for_catalog(layout, catalog_path):
+layout.template_node_asset_menu_items(catalog_path=catalog_path)
 
 def draw_root_assets(layout):
 layout.menu_contents("NODE_MT_node_add_root_catalogs")
diff --git a/source/blender/blenkernel/BKE_asset_catalog.hh 
b/source/blender/blenkernel/BKE_asset_catalog.hh
index 0ca2b27b5a0..18f0debfd6c 100644
--- a/source/blender/blenkernel/BKE_asset_catalog.hh
+++ b/source/blender/blenkernel/BKE_asset_catalog.hh
@@ -357,6 +357,7 @@ class AssetCatalogTree {
   bool is_empty() const;
 
   AssetCatalogTreeItem *find_item(const AssetCatalogPath &path);
+  AssetCatalogTreeItem *find_root_item(const AssetCatalogPath &path);
 
  protected:
   /** Child tree items, ordered by their names. */
diff --git a/source/blender/blenkernel/intern/asset_catalog.cc 
b/source/blender/blenkernel/intern/asset_catalog.cc
index c69deac059e..b9fe7469ead 100644
--- a/source/blender/blenkernel/intern/asset_catalog.cc
+++ b/source/blender/blenkernel/intern/asset_catalog.cc
@@ -821,7 +821,22 @@ AssetCatalogTreeItem *AssetCatalogTree::find_item(const 
AssetCatalogPath &path)
   AssetCatalogTreeItem *result = nullptr;
   this->foreach_item([&](AssetCatalogTreeItem &item) {
 if (result) {
-  /* TODO: Add a way to stop iteration. */
+  /* There is no way to stop iteration. */
+  return;
+}
+if (item.catalog_path() == path) {
+  result = &item;
+}
+  });
+  return result;
+}
+
+AssetCatalogTreeItem *AssetCatalogTree::find_root_item(const AssetCatalogPath 
&path)
+{
+  AssetCatalogTreeItem *result = nullptr;
+  this->foreach_root_item([&](AssetCatalogTreeItem &item) {
+if (result) {
+  /* There is no way to stop iteration. */
   return;
 }
 if (item.catalog_path() == path) {
diff --git a/source/blender/editors/include/UI_interface.h 
b/source/blender/editors/include/UI_interface.h
index 2a1941f0d9e..9f378644b9a 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -2524,6 +2524,7 @@ void uiTemplateNodeView(uiLayout *layout,
 struct bNodeTree *ntree,
 struct bNode *node,
 struct bNodeSocket *input);
+void uiTemplateNodeAssetMenuItems(uiLayout *layout, struct bContext *C, const 
char *catalog_path);
 void uiTemplateTextureUser(uiLayout *layout, struct bContext *C);
 /**
  * Button to quickly show texture in Properties Editor texture tab.
diff --git a/source/blender/editors/space_node/add_menu_assets.cc 
b/source/blender/editors/space_node/add_menu_assets.cc
index d20eb635bd3..8fd3bfcd1f6 100644
--- a/source/blender/editors/space_node/add_menu_assets.cc
+++ b/source/blender/editors/space_node/add_menu_assets.cc
@@ -215,4 +215,25 @@ MenuType add_root_catalogs_menu_type()
   return type;
 }
 
-}  // namespace blender::ed::space_node
\ No newline at end of file
+}  // namespace blender::ed::space_node
+
+/* Note: This is only necessary because Python can't set an asset catalog path 
context item. */
+void uiTemplateNodeAssetMenuItems(uiLayout *layout, bContext *C, const char 
*catalog_path)
+{
+  using namespace blender;
+  using namespace blender::ed::space_node;
+  bScreen &screen = *CTX_wm_screen(C);
+  SpaceNode &snode = *CTX_wm_space_node(C);
+  AssetItemTree &tree = *snode.runtime->assets_for_menu;
+  const bke::AssetCatalogTreeItem *item = 
tree.catalogs.find_root_item(catalog_path);
+  if (!item) {
+return;
+  }
+  const bke::AssetCatalogPath &path = 
tree.full_catalog_per_tree_item.lookup(item);
+  PointerRNA path_ptr{
+  &screen.id, &RNA_AssetCatalogPath, const_cast(&path)};
+  uiItemS(layout);
+  uiLayout *row = uiLayoutRow(layout, false);
+  uiLayoutSetContextPoi

[Bf-blender-cvs] [0d0e2dc0a8d] master: DRW: fix use of potentially uninitialized variable

2022-10-06 Thread Germano Cavalcante
Commit: 0d0e2dc0a8de1ba8d5adb71d3495fc35d0f399ba
Author: Germano Cavalcante
Date:   Thu Oct 6 15:00:35 2022 -0300
Branches: master
https://developer.blender.org/rB0d0e2dc0a8de1ba8d5adb71d3495fc35d0f399ba

DRW: fix use of potentially uninitialized variable

Bug introduced in rB6774cae3f25b.

This causes undefined behavior in `DRW_state_draw_support()` making
overlay depth drawing unpredictable.

===

M   source/blender/draw/DRW_engine.h
M   source/blender/draw/intern/draw_manager.c
M   source/blender/editors/space_view3d/view3d_draw.cc

===

diff --git a/source/blender/draw/DRW_engine.h b/source/blender/draw/DRW_engine.h
index dec7a22aadb..8c5f1b70cc0 100644
--- a/source/blender/draw/DRW_engine.h
+++ b/source/blender/draw/DRW_engine.h
@@ -126,14 +126,10 @@ void DRW_draw_select_loop(struct Depsgraph *depsgraph,
 void DRW_draw_depth_loop(struct Depsgraph *depsgraph,
  struct ARegion *region,
  struct View3D *v3d,
- struct GPUViewport *viewport);
-/**
- * Converted from #ED_view3d_draw_depth_gpencil (legacy drawing).
- */
-void DRW_draw_depth_loop_gpencil(struct Depsgraph *depsgraph,
- struct ARegion *region,
- struct View3D *v3d,
- struct GPUViewport *viewport);
+ struct GPUViewport *viewport,
+ const bool use_gpencil,
+ const bool use_basic,
+ const bool use_overlay);
 /**
  * Clears the Depth Buffer and draws only the specified object.
  */
diff --git a/source/blender/draw/intern/draw_manager.c 
b/source/blender/draw/intern/draw_manager.c
index b6ca56d36fc..3272edef750 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -2592,13 +2592,13 @@ void DRW_draw_select_loop(struct Depsgraph *depsgraph,
 /**
  * object mode select-loop, see: ED_view3d_draw_depth_loop (legacy drawing).
  */
-static void drw_draw_depth_loop_impl(struct Depsgraph *depsgraph,
- ARegion *region,
- View3D *v3d,
- GPUViewport *viewport,
- const bool use_gpencil,
- const bool use_basic,
- const bool use_overlay)
+void DRW_draw_depth_loop(struct Depsgraph *depsgraph,
+ ARegion *region,
+ View3D *v3d,
+ GPUViewport *viewport,
+ const bool use_gpencil,
+ const bool use_basic,
+ const bool use_overlay)
 {
   Scene *scene = DEG_get_evaluated_scene(depsgraph);
   RenderEngineType *engine_type = ED_view3d_engine_type(scene, 
v3d->shading.type);
@@ -2714,23 +2714,6 @@ static void drw_draw_depth_loop_impl(struct Depsgraph 
*depsgraph,
   drw_manager_exit(&DST);
 }
 
-void DRW_draw_depth_loop(struct Depsgraph *depsgraph,
- ARegion *region,
- View3D *v3d,
- GPUViewport *viewport)
-{
-  drw_draw_depth_loop_impl(
-  depsgraph, region, v3d, viewport, false, true, DRW_state_draw_support());
-}
-
-void DRW_draw_depth_loop_gpencil(struct Depsgraph *depsgraph,
- ARegion *region,
- View3D *v3d,
- GPUViewport *viewport)
-{
-  drw_draw_depth_loop_impl(depsgraph, region, v3d, viewport, true, false, 
false);
-}
-
 void DRW_draw_select_id(Depsgraph *depsgraph, ARegion *region, View3D *v3d, 
const rcti *rect)
 {
   SELECTID_Context *sel_ctx = DRW_select_engine_context_get();
diff --git a/source/blender/editors/space_view3d/view3d_draw.cc 
b/source/blender/editors/space_view3d/view3d_draw.cc
index 33129dfff5d..8a86889f2d0 100644
--- a/source/blender/editors/space_view3d/view3d_draw.cc
+++ b/source/blender/editors/space_view3d/view3d_draw.cc
@@ -2362,10 +2362,11 @@ void ED_view3d_depth_override(Depsgraph *depsgraph,
   if (viewport != nullptr) {
 switch (mode) {
   case V3D_DEPTH_NO_GPENCIL:
-DRW_draw_depth_loop(depsgraph, region, v3d, viewport);
+DRW_draw_depth_loop(
+depsgraph, region, v3d, viewport, false, true, (v3d->flag2 & 
V3D_HIDE_OVERLAYS) == 0);
 break;
   case V3D_DEPTH_GPENCIL_ONLY:
-DRW_draw_depth_loop_gpencil(depsgraph, region, v3d, viewport);
+DRW_draw_depth_loop(depsgraph, region, v3d, viewport, true, false, 
false);
 break;
   case V3D_DEPTH_OBJECT_ONLY:
 DRW_draw_depth_object(

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, sub

[Bf-blender-cvs] [f100fd4609d] node-add-asset-menu: Fix memory leaks

2022-10-06 Thread Hans Goudey
Commit: f100fd4609d15a09ae8331c4b26382a53fd33cec
Author: Hans Goudey
Date:   Thu Oct 6 13:57:10 2022 -0500
Branches: node-add-asset-menu
https://developer.blender.org/rBf100fd4609d15a09ae8331c4b26382a53fd33cec

Fix memory leaks

The storage is owned by the node editor until the asset system is more complete

===

M   source/blender/editors/space_node/add_menu_assets.cc
M   source/blender/editors/space_node/node_intern.hh
M   source/blender/editors/space_node/space_node.cc

===

diff --git a/source/blender/editors/space_node/add_menu_assets.cc 
b/source/blender/editors/space_node/add_menu_assets.cc
index cf72f00bf79..d20eb635bd3 100644
--- a/source/blender/editors/space_node/add_menu_assets.cc
+++ b/source/blender/editors/space_node/add_menu_assets.cc
@@ -38,6 +38,7 @@ struct LibraryCatalog {
 struct AssetItemTree {
   bke::AssetCatalogTree catalogs;
   MultiValueMap assets_per_path;
+  Map 
full_catalog_per_tree_item;
 };
 
 static AssetItemTree build_catalog_tree(const bContext &C, const bNodeTree 
&node_tree)
@@ -100,13 +101,28 @@ static AssetItemTree build_catalog_tree(const bContext 
&C, const bNodeTree &node
 }
   });
 
-  return {std::move(catalogs_with_node_assets), std::move(assets_per_path)};
+  /* Build another map storing full asset paths for each tree item, in order 
to have stable
+   * pointers to asset catalog paths to use for context pointers. This is 
necessary because
+   * #bke::AssetCatalogTreeItem doesn't store its full path directly. */
+  Map 
full_catalog_per_tree_item;
+  catalogs_with_node_assets.foreach_item([&](bke::AssetCatalogTreeItem &item) {
+full_catalog_per_tree_item.add_new(&item, item.catalog_path());
+  });
+
+  return {std::move(catalogs_with_node_assets),
+  std::move(assets_per_path),
+  std::move(full_catalog_per_tree_item)};
 }
 
 static void node_add_catalog_assets_draw(const bContext *C, Menu *menu)
 {
   bScreen &screen = *CTX_wm_screen(C);
   const SpaceNode &snode = *CTX_wm_space_node(C);
+  if (!snode.runtime->assets_for_menu) {
+BLI_assert_unreachable();
+return;
+  }
+  AssetItemTree &tree = *snode.runtime->assets_for_menu;
   const bNodeTree *edit_tree = snode.edittree;
   if (!edit_tree) {
 return;
@@ -119,7 +135,6 @@ static void node_add_catalog_assets_draw(const bContext *C, 
Menu *menu)
   const bke::AssetCatalogPath &menu_path = *static_cast(
   menu_path_ptr.data);
 
-  AssetItemTree tree = build_catalog_tree(*C, *edit_tree);
   const Span asset_items = 
tree.assets_per_path.lookup(menu_path);
   bke::AssetCatalogTreeItem *catalog_item = tree.catalogs.find_item(menu_path);
   BLI_assert(catalog_item != nullptr);
@@ -137,18 +152,18 @@ static void node_add_catalog_assets_draw(const bContext 
*C, Menu *menu)
 &screen.id, &RNA_FileSelectEntry, const_cast(item.handle.file_data)};
 uiLayoutSetContextPointer(row, "active_file", &file);
 
-PointerRNA library_ptr{
-&screen.id, &RNA_AssetLibraryReference, new 
AssetLibraryReference(item.library_ref)};
+PointerRNA library_ptr{&screen.id,
+   &RNA_AssetLibraryReference,
+   const_cast(&item.library_ref)};
 uiLayoutSetContextPointer(row, "asset_library_ref", &library_ptr);
 
 uiItemO(row, ED_asset_handle_get_name(&item.handle), ICON_NONE, 
"NODE_OT_add_group_asset");
   }
 
   catalog_item->foreach_child([&](bke::AssetCatalogTreeItem &child_item) {
-const bke::AssetCatalogPath path = child_item.catalog_path();
-
-/* TODO: Where should this memory live? */
-PointerRNA path_ptr{&screen.id, &RNA_AssetCatalogPath, new 
bke::AssetCatalogPath(path)};
+const bke::AssetCatalogPath &path = 
tree.full_catalog_per_tree_item.lookup(&child_item);
+PointerRNA path_ptr{
+&screen.id, &RNA_AssetCatalogPath, const_cast(&path)};
 uiLayout *row = uiLayoutRow(layout, false);
 uiLayoutSetContextPointer(row, "asset_catalog_path", &path_ptr);
 uiItemM(row, "NODE_MT_node_add_catalog_assets", path.name().c_str(), 
ICON_NONE);
@@ -158,10 +173,13 @@ static void node_add_catalog_assets_draw(const bContext 
*C, Menu *menu)
 static void add_root_catalogs_draw(const bContext *C, Menu *menu)
 {
   bScreen &screen = *CTX_wm_screen(C);
-  const SpaceNode &snode = *CTX_wm_space_node(C);
+  SpaceNode &snode = *CTX_wm_space_node(C);
   const bNodeTree *edit_tree = snode.edittree;
 
-  AssetItemTree tree = build_catalog_tree(*C, *edit_tree);
+  snode.runtime->assets_for_menu.reset();
+  snode.runtime->assets_for_menu = std::make_shared(
+  build_catalog_tree(*C, *edit_tree));
+  AssetItemTree &tree = *snode.runtime->assets_for_menu;
   if (tree.catalogs.is_empty()) {
 return;
   }
@@ -170,10 +188,9 @@ static void add_root_catalogs_draw(const bContext *C, Menu 
*menu)
   uiItemS(layout);
 
   tree.catalogs.foreach_root_item([&](bke::AssetCatalogT

[Bf-blender-cvs] [d80dc33fe5b] node-add-asset-menu: Merge branch 'master' into node-add-asset-menu

2022-10-06 Thread Hans Goudey
Commit: d80dc33fe5b2b5c7352d6b01cb8a40ec986f6a4e
Author: Hans Goudey
Date:   Thu Oct 6 12:20:14 2022 -0500
Branches: node-add-asset-menu
https://developer.blender.org/rBd80dc33fe5b2b5c7352d6b01cb8a40ec986f6a4e

Merge branch 'master' into node-add-asset-menu

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [106c6db1b56] tmp-workbench-rewrite2: fix ssbo binding

2022-10-06 Thread Miguel Pozo
Commit: 106c6db1b569311768b9940f9b6be17bee7277c3
Author: Miguel Pozo
Date:   Thu Oct 6 20:08:47 2022 +0200
Branches: tmp-workbench-rewrite2
https://developer.blender.org/rB106c6db1b569311768b9940f9b6be17bee7277c3

fix ssbo binding

===

M   source/blender/draw/engines/workbench/workbench_engine.cc

===

diff --git a/source/blender/draw/engines/workbench/workbench_engine.cc 
b/source/blender/draw/engines/workbench/workbench_engine.cc
index 9069ec2dc34..b09949b53a3 100644
--- a/source/blender/draw/engines/workbench/workbench_engine.cc
+++ b/source/blender/draw/engines/workbench/workbench_engine.cc
@@ -336,7 +336,7 @@ class MeshPass : public PassMain {
 this->PassMain::init();
 this->state_set(state);
 this->bind_texture(WB_MATCAP_SLOT, resources.matcap_tx);
-this->bind_ssbo(WB_MATERIAL_SLOT, resources.material_buf);
+this->bind_ssbo(WB_MATERIAL_SLOT, &resources.material_buf);
 this->bind_ubo(WB_WORLD_SLOT, resources.world_buf);
 
 color_type_ = color_type;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [cde0faf4dd4] tmp-workbench-rewrite2: add support for background color

2022-10-06 Thread Miguel Pozo
Commit: cde0faf4dd44b8fc71fb9f883affc44cf32a302d
Author: Miguel Pozo
Date:   Thu Oct 6 20:09:18 2022 +0200
Branches: tmp-workbench-rewrite2
https://developer.blender.org/rBcde0faf4dd44b8fc71fb9f883affc44cf32a302d

add support for background color

===

M   
source/blender/draw/engines/workbench/shaders/workbench_composite_comp.glsl
M   source/blender/draw/engines/workbench/workbench_engine.cc
M   source/blender/draw/engines/workbench/workbench_shader_shared.h

===

diff --git 
a/source/blender/draw/engines/workbench/shaders/workbench_composite_comp.glsl 
b/source/blender/draw/engines/workbench/shaders/workbench_composite_comp.glsl
index fbfedab7f78..5297559aa60 100644
--- 
a/source/blender/draw/engines/workbench/shaders/workbench_composite_comp.glsl
+++ 
b/source/blender/draw/engines/workbench/shaders/workbench_composite_comp.glsl
@@ -21,8 +21,7 @@ void main()
   float roughness, metallic;
   workbench_float_pair_decode(mat_data.a, roughness, metallic);
 
-  /* TODO(fclem): Pass background color as uniform. */
-  vec4 color = vec4(0.0, 0.0, 0.0, 1.0);
+  vec4 color = world_data.background_color;
 
   /* Background pixels. */
   if (depth != 1.0) {
diff --git a/source/blender/draw/engines/workbench/workbench_engine.cc 
b/source/blender/draw/engines/workbench/workbench_engine.cc
index b09949b53a3..147953ee985 100644
--- a/source/blender/draw/engines/workbench/workbench_engine.cc
+++ b/source/blender/draw/engines/workbench/workbench_engine.cc
@@ -263,6 +263,13 @@ struct SceneResources {
   StorageVectorBuffer material_buf = {"material_buf"};
   UniformBuffer world_buf;
 
+  void init(int2 output_res, float4 background_color)
+  {
+world_buf.background_color = background_color;
+matcap_tx.ensure_2d_array(GPU_RGBA16F, int2(1), 1);
+depth_tx.ensure_2d(GPU_DEPTH24_STENCIL8, output_res);
+  }
+
   void world_sync(StudioLight *studio_light)
   {
 float4x4 rot_matrix = float4x4::identity();
@@ -642,15 +649,12 @@ class Instance {
   void init(const int2 &output_res,
 const Depsgraph *depsgraph,
 const Object * /*camera*/,
-const View3D * /*v3d*/,
-const RegionView3D * /*rv3d*/)
+const View3D *v3d,
+const RegionView3D *rv3d)
   {
 Scene *scene = DEG_get_evaluated_scene(depsgraph);
 View3DShading &shading = scene->display.shading;
 
-resources.matcap_tx.ensure_2d_array(GPU_RGBA16F, int2(1), 1);
-resources.depth_tx.ensure_2d(GPU_DEPTH24_STENCIL8, output_res);
-
 cull_state = DRW_STATE_NO_DRAW;
 if (shading.flag & V3D_SHADING_BACKFACE_CULLING) {
   cull_state |= DRW_STATE_CULL_BACK;
@@ -709,7 +713,24 @@ class Instance {
 break;
 }
 
-// TODO(pragma37): Create resources.init() to store the relevant settings;
+float4 background_color = float4(0.0f);
+
+/*TODO(pragma37): Replace when Workbench next is complete*/
+// bool is_workbench_render = BKE_scene_uses_blender_workbench(scene);
+bool is_workbench_render = std::string(scene->r.engine) ==
+   std::string("BLENDER_WORKBENCH_NEXT");
+
+/* TODO(pragma37):
+ * Check why Workbench Next exposes OB_MATERIAL, and Workbench exposes 
OB_RENDER */
+if (!v3d || (ELEM(v3d->shading.type, OB_RENDER, OB_MATERIAL) && 
is_workbench_render)) {
+  if (scene->r.alphamode != R_ALPHAPREMUL) {
+World *w = scene->world;
+background_color = w ? float4(w->horr, w->horg, w->horb, 1.0f) :
+   float4(0.0f, 0.0f, 0.0f, 1.0f);
+  }
+}
+
+resources.init(output_res, background_color);
 
 studio_light = nullptr;
 if (shading_type == eShadingType::MATCAP) {
diff --git a/source/blender/draw/engines/workbench/workbench_shader_shared.h 
b/source/blender/draw/engines/workbench/workbench_shader_shared.h
index b2e8fa30d85..ad06c838846 100644
--- a/source/blender/draw/engines/workbench/workbench_shader_shared.h
+++ b/source/blender/draw/engines/workbench/workbench_shader_shared.h
@@ -24,6 +24,9 @@ struct WorldData {
   LightData lights[4];
   float4 ambient_color;
 
+  /* TODO(pragma37): Check why this breaks Workbench rendering*/
+  float4 background_color;
+
   int cavity_sample_start;
   int cavity_sample_end;
   float cavity_sample_count_inv;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [e4919873bce] tmp-vfx-platform-2023: cmake: fix stray endif in platform_apple.cmake

2022-10-06 Thread Ray Molenkamp
Commit: e4919873bce5839d2e73cba2ba13a56a3d261af2
Author: Ray Molenkamp
Date:   Thu Oct 6 12:37:35 2022 -0600
Branches: tmp-vfx-platform-2023
https://developer.blender.org/rBe4919873bce5839d2e73cba2ba13a56a3d261af2

cmake: fix stray endif in platform_apple.cmake

Likely the result of a merge I did yesterday that had
some conflicts.

===

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 a94986a010b..bb4aeb1cc02 100644
--- a/build_files/cmake/platform/platform_apple.cmake
+++ b/build_files/cmake/platform/platform_apple.cmake
@@ -21,7 +21,6 @@ function(print_found_status
   endif()
 endfunction()
 
-  endif()
 # 
 # Find system provided libraries.

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [be8ee05dcba] master: Fix for T53332: BFont 43 Inaccessible Glyphs

2022-10-06 Thread Harley Acheson
Commit: be8ee05dcba6987fd4098cc61d414b0b8cef4b3e
Author: Harley Acheson
Date:   Thu Oct 6 10:35:36 2022 -0700
Branches: master
https://developer.blender.org/rBbe8ee05dcba6987fd4098cc61d414b0b8cef4b3e

Fix for T53332: BFont 43 Inaccessible Glyphs

Preloading of BFont (default for 3D Text Objects) glyphs will not load
any with a character code greater than 256, resulting in 43 characters
that are inaccessible. This patch corrects that preloading code.

See D16122 for more details

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

Reviewed by Campbell Barton

===

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

===

diff --git a/source/blender/blenkernel/intern/vfontdata_freetype.c 
b/source/blender/blenkernel/intern/vfontdata_freetype.c
index 30e5f29e6a8..91ca3100f8c 100644
--- a/source/blender/blenkernel/intern/vfontdata_freetype.c
+++ b/source/blender/blenkernel/intern/vfontdata_freetype.c
@@ -270,9 +270,6 @@ static VFontData *objfnt_to_ftvfontdata(PackedFile *pf)
 {
   /* Variables */
   FT_Face face;
-  const FT_ULong charcode_reserve = 256;
-  FT_ULong charcode = 0, lcode;
-  FT_UInt glyph_index;
   VFontData *vfd;
 
   /* load the freetype font */
@@ -305,9 +302,6 @@ static VFontData *objfnt_to_ftvfontdata(PackedFile *pf)
 return NULL;
   }
 
-  /* Extract the first 256 character from TTF */
-  lcode = charcode = FT_Get_First_Char(face, &glyph_index);
-
   /* Blender default BFont is not "complete". */
   const bool complete_font = (face->ascender != 0) && (face->descender != 0) &&
  (face->ascender != face->descender);
@@ -335,21 +329,19 @@ static VFontData *objfnt_to_ftvfontdata(PackedFile *pf)
 vfd->scale = 1.0f / 1000.0f;
   }
 
-  /* Load characters */
-  vfd->characters = BLI_ghash_int_new_ex(__func__, charcode_reserve);
+  /* Load the first 256 glyphs. */
 
-  while (charcode < charcode_reserve) {
-/* Generate the font data */
-freetypechar_to_vchar(face, charcode, vfd);
+  const FT_ULong preload_count = 256;
+  vfd->characters = BLI_ghash_int_new_ex(__func__, preload_count);
 
-/* Next glyph */
+  FT_ULong charcode = 0;
+  FT_UInt glyph_index;
+  for (int i = 0; i < preload_count; i++) {
 charcode = FT_Get_Next_Char(face, charcode, &glyph_index);
-
-/* Check that we won't start infinite loop */
-if (charcode <= lcode) {
+if (!charcode || !glyph_index) {
   break;
 }
-lcode = charcode;
+freetypechar_to_vchar(face, charcode, vfd);
   }
 
   return vfd;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [4441e3b791d] blender-projects-basics: Fix incorrect setting of initial file browser location

2022-10-06 Thread Julian Eisel
Commit: 4441e3b791dc3ab4ab5a30d61794b772d09fa390
Author: Julian Eisel
Date:   Thu Oct 6 19:36:23 2022 +0200
Branches: blender-projects-basics
https://developer.blender.org/rB4441e3b791dc3ab4ab5a30d61794b772d09fa390

Fix incorrect setting of initial file browser location

===

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

===

diff --git a/source/blender/windowmanager/intern/wm_files.c 
b/source/blender/windowmanager/intern/wm_files.c
index 35b7a4d61e6..4a0be0eb591 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -2396,7 +2396,7 @@ static int wm_new_project_invoke(bContext *C, wmOperator 
*op, const wmEvent *UNU
   const char *blendfile_path = BKE_main_blendfile_path(bmain);
   if (blendfile_path[0]) {
 /* Open at the .blend file location if any. */
-RNA_string_set(op->ptr, "filepath", blendfile_path);
+RNA_string_set(op->ptr, "directory", blendfile_path);
   }
 
   WM_event_add_fileselect(C, op);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [3013cf0b376] blender-projects-basics: Add menu with operator to delete project configuration

2022-10-06 Thread Julian Eisel
Commit: 3013cf0b376aceb4b14325a58becfe29455c76ba
Author: Julian Eisel
Date:   Thu Oct 6 19:32:06 2022 +0200
Branches: blender-projects-basics
https://developer.blender.org/rB3013cf0b376aceb4b14325a58becfe29455c76ba

Add menu with operator to delete project configuration

Deletes the active project's .blender_project directory, but leaves all
actual project files (.blends and such) untouched.

===

M   release/scripts/startup/bl_ui/space_project_settings.py
M   source/blender/blenkernel/BKE_blender_project.h
M   source/blender/blenkernel/BKE_blender_project.hh
M   source/blender/blenkernel/intern/blender_project.cc
M   source/blender/blenkernel/intern/blender_project_test.cc
M   source/blender/windowmanager/intern/wm_files.c
M   source/blender/windowmanager/intern/wm_operators.c
M   source/blender/windowmanager/wm_files.h

===

diff --git a/release/scripts/startup/bl_ui/space_project_settings.py 
b/release/scripts/startup/bl_ui/space_project_settings.py
index cfed8889580..899218acf87 100644
--- a/release/scripts/startup/bl_ui/space_project_settings.py
+++ b/release/scripts/startup/bl_ui/space_project_settings.py
@@ -80,6 +80,15 @@ class PROJECTSETTINGS_MT_view(Menu):
 layout.menu("INFO_MT_area")
 
 
+class PROJECTSETTINGS_MT_advanced_operations(Menu):
+bl_label = "Advanced Project Settings Operations"
+
+def draw(self, _context):
+layout = self.layout
+
+layout.operator("wm.delete_project_setup")
+
+
 class PROJECTSETTINGS_PT_save_project_settings(Panel):
 bl_label = "Save Project Settings"
 bl_space_type = 'PROJECT_SETTINGS'
@@ -99,6 +108,8 @@ class PROJECTSETTINGS_PT_save_project_settings(Panel):
 layout = self.layout.row()
 layout.operator_context = 'EXEC_AREA'
 
+layout.menu("PROJECTSETTINGS_MT_advanced_operations", text="", 
icon='COLLAPSEMENU')
+
 PROJECTSETTINGS_HT_header.draw_buttons(layout, context)
 
 
@@ -138,6 +149,7 @@ classes = (
 PROJECTSETTINGS_HT_header,
 PROJECTSETTINGS_MT_editor_menus,
 PROJECTSETTINGS_MT_view,
+PROJECTSETTINGS_MT_advanced_operations,
 PROJECTSETTINGS_PT_navigation_bar,
 PROJECTSETTINGS_PT_save_project_settings,
 PROJECTSETTINGS_PT_no_project,
diff --git a/source/blender/blenkernel/BKE_blender_project.h 
b/source/blender/blenkernel/BKE_blender_project.h
index 6eb7cca19fb..0646e017d1f 100644
--- a/source/blender/blenkernel/BKE_blender_project.h
+++ b/source/blender/blenkernel/BKE_blender_project.h
@@ -19,6 +19,8 @@ typedef struct BlenderProject BlenderProject;
 
 /** See #bke::ProjectSettings::create_settings_directory(). */
 bool BKE_project_create_settings_directory(const char *project_root_path) 
ATTR_NONNULL();
+/** See #bke::ProjectSettings::delete_settings_directory(). */
+bool BKE_project_delete_settings_directory(const BlenderProject *project) 
ATTR_NONNULL();
 
 BlenderProject *BKE_project_active_get(void) ATTR_WARN_UNUSED_RESULT;
 /**
diff --git a/source/blender/blenkernel/BKE_blender_project.hh 
b/source/blender/blenkernel/BKE_blender_project.hh
index c4f836e0578..c77e2513b51 100644
--- a/source/blender/blenkernel/BKE_blender_project.hh
+++ b/source/blender/blenkernel/BKE_blender_project.hh
@@ -78,6 +78,12 @@ class ProjectSettings {
* failure.
*/
   auto save_to_disk(StringRef project_path) -> bool;
+  /**
+   * Remove the .blender_project directory with all of its contents. Does not 
unload the active
+   * project but marks it as having unsaved changes. Runtime project data is 
still valid.
+   * \return True on success.
+   */
+  auto delete_settings_directory() -> bool;
 
   explicit ProjectSettings(StringRef project_root_path);
 
diff --git a/source/blender/blenkernel/intern/blender_project.cc 
b/source/blender/blenkernel/intern/blender_project.cc
index 339ec71dd4c..7b5027bb487 100644
--- a/source/blender/blenkernel/intern/blender_project.cc
+++ b/source/blender/blenkernel/intern/blender_project.cc
@@ -254,6 +254,20 @@ bool ProjectSettings::save_to_disk(StringRef project_path)
   return true;
 }
 
+bool ProjectSettings::delete_settings_directory()
+{
+  BLI_assert(project_root_path_[0] == SEP);
+  std::string dot_blender_project_dir_path = project_root_path_ + 
SETTINGS_DIRNAME;
+
+  /* Returns 0 on success. */
+  if (BLI_delete(dot_blender_project_dir_path.c_str(), true, true)) {
+return false;
+  }
+
+  has_unsaved_changes_ = true;
+  return true;
+}
+
 StringRefNull ProjectSettings::project_root_path() const
 {
   return project_root_path_;
@@ -286,6 +300,14 @@ bool BKE_project_create_settings_directory(const char 
*project_root_path)
   return bke::ProjectSettings::create_settings_directory(project_root_path);
 }
 
+bool BKE_project_delete_settings_directory(const BlenderProject 
*project_handle)
+{
+  const bke::BlenderProject *project = reinterpret_cast(
+  project_handle)

[Bf-blender-cvs] [46c40d7fa1e] master: Fix: Use after free in geometry node group logger

2022-10-06 Thread Hans Goudey
Commit: 46c40d7fa1ec6fd230acb0b1e1f6cd01a32a05d2
Author: Hans Goudey
Date:   Thu Oct 6 11:48:05 2022 -0500
Branches: master
https://developer.blender.org/rB46c40d7fa1ec6fd230acb0b1e1f6cd01a32a05d2

Fix: Use after free in geometry node group logger

The name of the node group in the geometry nodes logger is created
in `GeoModifierLog::get_local_tree_logger`, where it references the
compute context. However, the compute context is a local variable
that doesn't live as long as the log. Therefore the log needs to own
the node group name.

Removing the ownership from `NodeGroupComputeContext` may be
possible as well, but seems less obviously correct. This can be a
temporary solution until we can completely avoid storing strings
in the logger (see D15775).

Fixes T101599

===

M   source/blender/nodes/NOD_geometry_nodes_log.hh

===

diff --git a/source/blender/nodes/NOD_geometry_nodes_log.hh 
b/source/blender/nodes/NOD_geometry_nodes_log.hh
index 2b0c16c8656..5a2203a76b7 100644
--- a/source/blender/nodes/NOD_geometry_nodes_log.hh
+++ b/source/blender/nodes/NOD_geometry_nodes_log.hh
@@ -169,7 +169,7 @@ using TimePoint = Clock::time_point;
 class GeoTreeLogger {
  public:
   std::optional parent_hash;
-  std::optional group_node_name;
+  std::optional group_node_name;
   Vector children_hashes;
 
   LinearAllocator<> *allocator = nullptr;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [1e286d7f8f5] temp-gpencil-automask: GPencil: Keep old bit value

2022-10-06 Thread Antonio Vazquez
Commit: 1e286d7f8f510bc2d93b1c0558815ceae218bad3
Author: Antonio Vazquez
Date:   Thu Oct 6 18:46:13 2022 +0200
Branches: temp-gpencil-automask
https://developer.blender.org/rB1e286d7f8f510bc2d93b1c0558815ceae218bad3

GPencil: Keep old bit value

===

M   source/blender/makesdna/DNA_scene_types.h

===

diff --git a/source/blender/makesdna/DNA_scene_types.h 
b/source/blender/makesdna/DNA_scene_types.h
index 43682d1c793..f93cfa232da 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -1153,13 +1153,13 @@ typedef enum eGP_Sculpt_SettingsFlag {
   /** Apply primitive curve. */
   GP_SCULPT_SETT_FLAG_PRIMITIVE_CURVE = (1 << 1),
   /** Scale thickness. */
-  GP_SCULPT_SETT_FLAG_SCALE_THICKNESS = (1 << 2),
+  GP_SCULPT_SETT_FLAG_SCALE_THICKNESS = (1 << 3),
   /* Stroke Auto-Masking for sculpt. */
-  GP_SCULPT_SETT_FLAG_AUTOMASK_STROKE = (1 << 3),
+  GP_SCULPT_SETT_FLAG_AUTOMASK_STROKE = (1 << 4),
   /* Layer Auto-Masking for sculpt. */
-  GP_SCULPT_SETT_FLAG_AUTOMASK_LAYER = (1 << 4),
+  GP_SCULPT_SETT_FLAG_AUTOMASK_LAYER = (1 << 5),
   /* Material Auto-Masking for sculpt. */
-  GP_SCULPT_SETT_FLAG_AUTOMASK_MATERIAL = (1 << 5),
+  GP_SCULPT_SETT_FLAG_AUTOMASK_MATERIAL = (1 << 6),
 
 } eGP_Sculpt_SettingsFlag;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [2ec1e38b91c] temp-gpencil-automask: GPencil: Move the automasking options to ToolSettings

2022-10-06 Thread Antonio Vazquez
Commit: 2ec1e38b91cf10b5a281cefeb21cfe0ade87c0a8
Author: Antonio Vazquez
Date:   Thu Oct 6 18:37:32 2022 +0200
Branches: temp-gpencil-automask
https://developer.blender.org/rB2ec1e38b91cf10b5a281cefeb21cfe0ade87c0a8

GPencil: Move the automasking options to ToolSettings

Still pending move out Brush panel

===

M   release/scripts/startup/bl_ui/properties_grease_pencil_common.py
M   source/blender/editors/gpencil/gpencil_sculpt_paint.c
M   source/blender/makesdna/DNA_brush_enums.h
M   source/blender/makesdna/DNA_scene_types.h
M   source/blender/makesrna/intern/rna_brush.c
M   source/blender/makesrna/intern/rna_sculpt_paint.c

===

diff --git a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py 
b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
index 38522a1bf84..2576f38ceb7 100644
--- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
+++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
@@ -52,9 +52,9 @@ class GreasePencilSculptAdvancedPanel:
 gp_settings = brush.gpencil_settings
 
 col = layout.column(heading="Auto-Masking", align=True)
-col.prop(gp_settings, "use_automasking_stroke", text="Stroke")
-col.prop(gp_settings, "use_automasking_layer", text="Layer")
-col.prop(gp_settings, "use_automasking_material", text="Material")
+col.prop(tool_settings.gpencil_sculpt, "use_automasking_stroke", 
text="Stroke")
+col.prop(tool_settings.gpencil_sculpt, "use_automasking_layer", 
text="Layer")
+col.prop(tool_settings.gpencil_sculpt, "use_automasking_material", 
text="Material")
 
 if tool in {'SMOOTH', 'RANDOMIZE'}:
 col = layout.column(heading="Affect", align=True)
diff --git a/source/blender/editors/gpencil/gpencil_sculpt_paint.c 
b/source/blender/editors/gpencil/gpencil_sculpt_paint.c
index 1df106d2754..749a4bd2853 100644
--- a/source/blender/editors/gpencil/gpencil_sculpt_paint.c
+++ b/source/blender/editors/gpencil/gpencil_sculpt_paint.c
@@ -1196,9 +1196,10 @@ static bool gpencil_sculpt_brush_init(bContext *C, 
wmOperator *op)
   gso->brush = brush;
   BKE_curvemapping_init(gso->brush->curve);
 
-  if (brush->gpencil_settings->sculpt_mode_flag &
-  (GP_SCULPT_FLAGMODE_AUTOMASK_STROKE | GP_SCULPT_FLAGMODE_AUTOMASK_LAYER |
-   GP_SCULPT_FLAGMODE_AUTOMASK_MATERIAL)) {
+  const bool is_automasking = (ts->gp_sculpt.flag & 
(GP_SCULPT_SETT_FLAG_AUTOMASK_STROKE |
+ 
GP_SCULPT_SETT_FLAG_AUTOMASK_LAYER |
+ 
GP_SCULPT_SETT_FLAG_AUTOMASK_MATERIAL)) != 0;
+  if (is_automasking) {
 gso->automasking_strokes = BLI_ghash_ptr_new(__func__);
   }
   else {
@@ -1597,13 +1598,13 @@ static bool gpencil_sculpt_brush_do_frame(bContext *C,
   bGPdata *gpd = ob->data;
   const char tool = gso->brush->gpencil_sculpt_tool;
   GP_SpaceConversion *gsc = &gso->gsc;
+  ToolSettings *ts = gso->scene->toolsettings;
   Brush *brush = gso->brush;
   const int radius = (brush->flag & GP_BRUSH_USE_PRESSURE) ? gso->brush->size 
* gso->pressure :
  gso->brush->size;
-  const bool is_automasking = (brush->gpencil_settings->sculpt_mode_flag &
-   (GP_SCULPT_FLAGMODE_AUTOMASK_STROKE |
-GP_SCULPT_FLAGMODE_AUTOMASK_LAYER |
-GP_SCULPT_FLAGMODE_AUTOMASK_MATERIAL)) != 0;
+  const bool is_automasking = (ts->gp_sculpt.flag & 
(GP_SCULPT_SETT_FLAG_AUTOMASK_STROKE |
+ 
GP_SCULPT_SETT_FLAG_AUTOMASK_LAYER |
+ 
GP_SCULPT_SETT_FLAG_AUTOMASK_MATERIAL)) != 0;
   /* Calc bound box matrix. */
   float bound_mat[4][4];
   BKE_gpencil_layer_transform_matrix_get(gso->depsgraph, gso->object, gpl, 
bound_mat);
@@ -1742,15 +1743,14 @@ static bool 
get_automasking_strokes_list(tGP_BrushEditData *gso)
   bGPdata *gpd = gso->gpd;
   GP_SpaceConversion *gsc = &gso->gsc;
   Brush *brush = gso->brush;
+  ToolSettings *ts = gso->scene->toolsettings;
   Object *ob = gso->object;
   Material *mat_active = BKE_gpencil_material(ob, ob->actcol);
   const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd);
-  const bool is_masking_stroke = (brush->gpencil_settings->sculpt_mode_flag &
-  GP_SCULPT_FLAGMODE_AUTOMASK_STROKE) != 0;
-  const bool is_masking_layer = (brush->gpencil_settings->sculpt_mode_flag &
- GP_SCULPT_FLAGMODE_AUTOMASK_LAYER) != 0;
-  const bool is_masking_material = (brush->gpencil_settings->sculpt_mode_flag &
-GP_SCULPT_FLAGMODE_AUTOMASK_MATERIAL) != 0;
+  const bool is_masking_stroke = (ts->gp_sculp

[Bf-blender-cvs] [8b6946c911b] node-add-asset-menu: Merge branch 'master' into node-add-asset-menu

2022-10-06 Thread Hans Goudey
Commit: 8b6946c911b8763f7155004b3d7ee529a2192b58
Author: Hans Goudey
Date:   Thu Oct 6 11:03:06 2022 -0500
Branches: node-add-asset-menu
https://developer.blender.org/rB8b6946c911b8763f7155004b3d7ee529a2192b58

Merge branch 'master' into node-add-asset-menu

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [bd77cdde586] master: Build Environment: Update Ubuntu instructions to include bison

2022-10-06 Thread Dalai Felinto
Commit: bd77cdde5865ff311a5af05b1dd0d5a8aa36bb37
Author: Dalai Felinto
Date:   Thu Oct 6 18:09:21 2022 +0200
Branches: master
https://developer.blender.org/rBbd77cdde5865ff311a5af05b1dd0d5a8aa36bb37

Build Environment: Update Ubuntu instructions to include bison

Ubuntu also requires bison (just like macOS seems to do).

===

M   build_files/build_environment/cmake/check_software.cmake

===

diff --git a/build_files/build_environment/cmake/check_software.cmake 
b/build_files/build_environment/cmake/check_software.cmake
index cc8fead6f81..bdb9036e3f9 100644
--- a/build_files/build_environment/cmake/check_software.cmake
+++ b/build_files/build_environment/cmake/check_software.cmake
@@ -46,7 +46,7 @@ if(UNIX)
   "  ${_software_missing}\n"
   "\n"
   "On Debian and Ubuntu:\n"
-  "  apt install autoconf automake libtool yasm tcl ninja-build meson 
python3-mako\n"
+  "  apt install autoconf automake bison libtool yasm tcl ninja-build 
meson python3-mako\n"
   "\n"
   "On macOS (with homebrew):\n"
   "  brew install autoconf automake bison flex libtool meson ninja 
pkg-config yasm\n"

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [0f224ceedba] master: Cleanup: Move multires.c to C++

2022-10-06 Thread Hans Goudey
Commit: 0f224ceedba8575a7373938987c7ed18f3e565de
Author: Hans Goudey
Date:   Wed Oct 5 20:51:05 2022 -0500
Branches: master
https://developer.blender.org/rB0f224ceedba8575a7373938987c7ed18f3e565de

Cleanup: Move multires.c to C++

===

M   source/blender/blenkernel/BKE_modifier.h
M   source/blender/blenkernel/BKE_multires.h
M   source/blender/blenkernel/BKE_subsurf.h
M   source/blender/blenkernel/CMakeLists.txt
R085source/blender/blenkernel/intern/multires.c 
source/blender/blenkernel/intern/multires.cc

===

diff --git a/source/blender/blenkernel/BKE_modifier.h 
b/source/blender/blenkernel/BKE_modifier.h
index f46672a5033..ce2f9e878f8 100644
--- a/source/blender/blenkernel/BKE_modifier.h
+++ b/source/blender/blenkernel/BKE_modifier.h
@@ -127,6 +127,7 @@ typedef enum ModifierApplyFlag {
* See `OBJECT_OT_modifier_apply` operator. */
   MOD_APPLY_TO_BASE_MESH = 1 << 4,
 } ModifierApplyFlag;
+ENUM_OPERATORS(ModifierApplyFlag, MOD_APPLY_TO_BASE_MESH);
 
 typedef struct ModifierUpdateDepsgraphContext {
   struct Scene *scene;
diff --git a/source/blender/blenkernel/BKE_multires.h 
b/source/blender/blenkernel/BKE_multires.h
index dfa330ff508..53dfaf953ea 100644
--- a/source/blender/blenkernel/BKE_multires.h
+++ b/source/blender/blenkernel/BKE_multires.h
@@ -8,7 +8,7 @@
  */
 
 #include "BKE_subsurf.h"
-#include "BLI_compiler_compat.h"
+#include "BLI_utildefines.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -53,12 +53,13 @@ void multires_modifier_update_hidden(struct DerivedMesh 
*dm);
  */
 void multiresModifier_set_levels_from_disps(struct MultiresModifierData *mmd, 
struct Object *ob);
 
-typedef enum {
+typedef enum MultiresFlags {
   MULTIRES_USE_LOCAL_MMD = 1,
   MULTIRES_USE_RENDER_PARAMS = 2,
   MULTIRES_ALLOC_PAINT_MASK = 4,
   MULTIRES_IGNORE_SIMPLIFY = 8,
 } MultiresFlags;
+ENUM_OPERATORS(MultiresFlags, MULTIRES_IGNORE_SIMPLIFY);
 
 struct DerivedMesh *multires_make_derived_from_derived(struct DerivedMesh *dm,
struct 
MultiresModifierData *mmd,
diff --git a/source/blender/blenkernel/BKE_subsurf.h 
b/source/blender/blenkernel/BKE_subsurf.h
index f32a78c3015..557a71fd06b 100644
--- a/source/blender/blenkernel/BKE_subsurf.h
+++ b/source/blender/blenkernel/BKE_subsurf.h
@@ -11,6 +11,7 @@
 
 /* Thread sync primitives used directly. */
 #include "BLI_threads.h"
+#include "BLI_utildefines.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -32,7 +33,7 @@ struct SubsurfModifierData;
 
 / External */
 
-typedef enum {
+typedef enum SubsurfFlags {
   SUBSURF_USE_RENDER_PARAMS = 1,
   SUBSURF_IS_FINAL_CALC = 2,
   SUBSURF_FOR_EDIT_MODE = 4,
@@ -41,6 +42,7 @@ typedef enum {
   SUBSURF_USE_GPU_BACKEND = 32,
   SUBSURF_IGNORE_SIMPLIFY = 64,
 } SubsurfFlags;
+ENUM_OPERATORS(SubsurfFlags, SUBSURF_IGNORE_SIMPLIFY);
 
 struct DerivedMesh *subsurf_make_derived_from_derived(struct DerivedMesh *dm,
   struct 
SubsurfModifierData *smd,
diff --git a/source/blender/blenkernel/CMakeLists.txt 
b/source/blender/blenkernel/CMakeLists.txt
index d0e2d945c2f..192acbf8338 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -216,7 +216,7 @@ set(SRC
   intern/mesh_wrapper.cc
   intern/modifier.cc
   intern/movieclip.c
-  intern/multires.c
+  intern/multires.cc
   intern/multires_reshape.c
   intern/multires_reshape_apply_base.c
   intern/multires_reshape_ccg.c
diff --git a/source/blender/blenkernel/intern/multires.c 
b/source/blender/blenkernel/intern/multires.cc
similarity index 85%
rename from source/blender/blenkernel/intern/multires.c
rename to source/blender/blenkernel/intern/multires.cc
index ce61ca483e9..83189adfcdb 100644
--- a/source/blender/blenkernel/intern/multires.c
+++ b/source/blender/blenkernel/intern/multires.cc
@@ -43,8 +43,8 @@
 
 #include "multires_reshape.h"
 
-#include 
-#include 
+#include 
+#include 
 
 /* MULTIRES MODIFIER */
 static const int multires_grid_tot[] = {
@@ -53,11 +53,11 @@ static const int multires_side_tot[] = {
 0, 2, 3, 5, 9, 17, 33, 65, 129, 257, 513, 1025, 2049, 4097};
 
 /* See multiresModifier_disp_run for description of each operation */
-typedef enum {
+enum DispOp {
   APPLY_DISPLACEMENTS,
   CALC_DISPLACEMENTS,
   ADD_DISPLACEMENTS,
-} DispOp;
+};
 
 static void multiresModifier_disp_run(
 DerivedMesh *dm, Mesh *me, DerivedMesh *dm2, DispOp op, CCGElem 
**oldGridData, int totlvl);
@@ -107,7 +107,7 @@ static BLI_bitmap 
*multires_mdisps_upsample_hidden(BLI_bitmap *lo_hidden,
 
   /* fast case */
   if (lo_level == hi_level) {
-return MEM_dupallocN(lo_hidden);
+return static_cast(MEM_dupallocN(lo_hidden));
   }
 
   subd = BLI_BITMAP_NEW(square_i(hi_gridsize), "MDisps.hidden upsample");
@@ -184,7 +184,7 @@ static BLI_bitma

[Bf-blender-cvs] [2578c0ba924] blender-projects-basics: Show warning when saving files outside the active project

2022-10-06 Thread Julian Eisel
Commit: 2578c0ba924b970ba558fb9b4c57562c6fdeae59
Author: Julian Eisel
Date:   Thu Oct 6 17:35:05 2022 +0200
Branches: blender-projects-basics
https://developer.blender.org/rB2578c0ba924b970ba558fb9b4c57562c6fdeae59

Show warning when saving files outside the active project

===

M   source/blender/blenkernel/BKE_blender_project.h
M   source/blender/blenkernel/intern/blender_project.cc
M   source/blender/windowmanager/intern/wm_files.c

===

diff --git a/source/blender/blenkernel/BKE_blender_project.h 
b/source/blender/blenkernel/BKE_blender_project.h
index 8241747a93a..6eb7cca19fb 100644
--- a/source/blender/blenkernel/BKE_blender_project.h
+++ b/source/blender/blenkernel/BKE_blender_project.h
@@ -27,12 +27,17 @@ BlenderProject *BKE_project_active_get(void) 
ATTR_WARN_UNUSED_RESULT;
  */
 void BKE_project_active_unset(void);
 /**
- * Attempt to load and activate a project based on the given path. If the path 
doesn't lead into a
- * project, the active project is unset. Note that the project will be unset 
on any failure when
- * loading the project.
+ * Check if \a path points into the project root path (i.e. if one of the 
ancestors of the
+ * referenced file/directory is a project root directory).
+ */
+bool BKE_project_contains_path(const char *path) ATTR_WARN_UNUSED_RESULT 
ATTR_NONNULL();
+/**
+ * Attempt to load and activate a project based on the given path. If the path 
doesn't lead
+ * into a project, the active project is unset. Note that the project will be 
unset on any
+ * failure when loading the project.
  *
- * \note: When setting an active project, the previously active one will be 
destroyed, so pointers
- *may dangle.
+ * \note: When setting an active project, the previously active one will be 
destroyed, so
+ * pointers may dangle.
  */
 BlenderProject *BKE_project_active_load_from_path(const char *path) 
ATTR_NONNULL();
 
diff --git a/source/blender/blenkernel/intern/blender_project.cc 
b/source/blender/blenkernel/intern/blender_project.cc
index 146f3f0bef6..339ec71dd4c 100644
--- a/source/blender/blenkernel/intern/blender_project.cc
+++ b/source/blender/blenkernel/intern/blender_project.cc
@@ -296,6 +296,12 @@ void BKE_project_active_unset(void)
   bke::BlenderProject::set_active_from_settings(nullptr);
 }
 
+bool BKE_project_contains_path(const char *path)
+{
+  const StringRef found_root_path = 
bke::BlenderProject::project_root_path_find_from_path(path);
+  return !found_root_path.is_empty();
+}
+
 BlenderProject *BKE_project_active_load_from_path(const char *path)
 {
   /* Project should be unset if the path doesn't contain a project root. Unset 
in the beginning so
diff --git a/source/blender/windowmanager/intern/wm_files.c 
b/source/blender/windowmanager/intern/wm_files.c
index ef16a91fef5..f0e95285451 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -3152,6 +3152,16 @@ static int wm_save_as_mainfile_exec(bContext *C, 
wmOperator *op)
 return OPERATOR_CANCELLED;
   }
 
+  const BlenderProject *active_project = CTX_wm_project();
+  if (active_project && !BKE_project_contains_path(path)) {
+BKE_reportf(
+op->reports,
+RPT_WARNING,
+"File saved outside of the active project's path (\"%s\"). Active 
project changed.",
+BKE_project_root_path_get(active_project));
+/* Don't cancel. Otherwise there's no way to save files outside of the 
active project. */
+  }
+
   const int fileflags_orig = G.fileflags;
   int fileflags = G.fileflags;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [3ad67152659] blender-projects-basics: Cleanup: Move project operators closer together

2022-10-06 Thread Julian Eisel
Commit: 3ad67152659e745748a8a286213021ceaf85ed83
Author: Julian Eisel
Date:   Thu Oct 6 17:39:53 2022 +0200
Branches: blender-projects-basics
https://developer.blender.org/rB3ad67152659e745748a8a286213021ceaf85ed83

Cleanup: Move project operators closer together

===

M   source/blender/windowmanager/intern/wm_files.c
M   source/blender/windowmanager/wm_files.h

===

diff --git a/source/blender/windowmanager/intern/wm_files.c 
b/source/blender/windowmanager/intern/wm_files.c
index f0e95285451..16a0076084a 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -2348,6 +2348,82 @@ void WM_OT_save_project_settings(wmOperatorType *ot)
 
 /** \} */
 
+/*  */
+/** \name New project operator
+ * \{ */
+
+static int wm_new_project_exec(bContext *C, wmOperator *op)
+{
+  const Main *bmain = CTX_data_main(C);
+  const char *blendfile_path = BKE_main_blendfile_path(bmain);
+
+  if (!RNA_struct_property_is_set(op->ptr, "directory")) {
+BKE_report(op->reports, RPT_ERROR, "No path defined for creating a new 
project in");
+return OPERATOR_CANCELLED;
+  }
+  char project_root_dir[FILE_MAXDIR];
+  RNA_string_get(op->ptr, "directory", project_root_dir);
+
+  if (!BKE_project_create_settings_directory(project_root_dir)) {
+BKE_reportf(op->reports,
+RPT_ERROR,
+"Failed to create project with unknown error. Is the directory 
read-only?");
+return OPERATOR_CANCELLED;
+  }
+
+  BKE_reportf(op->reports, RPT_INFO, "Project created and loaded 
successfully");
+
+  if (blendfile_path[0] && BLI_path_contains(project_root_dir, 
blendfile_path)) {
+BKE_project_active_load_from_path(blendfile_path);
+
+WM_main_add_notifier(NC_PROJECT, NULL);
+/* Update the window title. */
+WM_event_add_notifier_ex(CTX_wm_manager(C), CTX_wm_window(C), NC_WM | 
ND_DATACHANGED, NULL);
+  }
+  else {
+BKE_reportf(op->reports,
+RPT_INFO,
+"The current file is not located inside of the new project. 
This means the new "
+"project is not active");
+  }
+
+  return OPERATOR_FINISHED;
+}
+
+static int wm_new_project_invoke(bContext *C, wmOperator *op, const wmEvent 
*UNUSED(event))
+{
+  const Main *bmain = CTX_data_main(C);
+  const char *blendfile_path = BKE_main_blendfile_path(bmain);
+  if (blendfile_path[0]) {
+/* Open at the .blend file location if any. */
+RNA_string_set(op->ptr, "filepath", blendfile_path);
+  }
+
+  WM_event_add_fileselect(C, op);
+  return OPERATOR_RUNNING_MODAL;
+}
+
+void WM_OT_new_project(wmOperatorType *ot)
+{
+  ot->name = "New Project";
+  ot->idname = "WM_OT_new_project";
+  ot->description = "Choose a directory to use as the root of a project";
+
+  ot->invoke = wm_new_project_invoke;
+  ot->exec = wm_new_project_exec;
+  /* omit window poll so this can work in background mode */
+
+  WM_operator_properties_filesel(ot,
+ FILE_TYPE_FOLDER,
+ FILE_BLENDER,
+ FILE_OPENFILE,
+ WM_FILESEL_DIRECTORY,
+ FILE_DEFAULTDISPLAY,
+ FILE_SORT_DEFAULT);
+}
+
+/** \} */
+
 /*  */
 /** \name Read File History Operator
  * \{ */
@@ -3330,82 +3406,6 @@ void WM_OT_save_mainfile(wmOperatorType *ot)
 
 /** \} */
 
-/*  */
-/** \name New project operator
- * \{ */
-
-static int wm_new_project_exec(bContext *C, wmOperator *op)
-{
-  const Main *bmain = CTX_data_main(C);
-  const char *blendfile_path = BKE_main_blendfile_path(bmain);
-
-  if (!RNA_struct_property_is_set(op->ptr, "directory")) {
-BKE_report(op->reports, RPT_ERROR, "No path defined for creating a new 
project in");
-return OPERATOR_CANCELLED;
-  }
-  char project_root_dir[FILE_MAXDIR];
-  RNA_string_get(op->ptr, "directory", project_root_dir);
-
-  if (!BKE_project_create_settings_directory(project_root_dir)) {
-BKE_reportf(op->reports,
-RPT_ERROR,
-"Failed to create project with unknown error. Is the directory 
read-only?");
-return OPERATOR_CANCELLED;
-  }
-
-  BKE_reportf(op->reports, RPT_INFO, "Project created and loaded 
successfully");
-
-  if (blendfile_path[0] && BLI_path_contains(project_root_dir, 
blendfile_path)) {
-BKE_project_active_load_from_path(blendfile_path);
-
-WM_main_add_notifier(NC_PROJECT, NULL);
-/* Update the window title. */
-WM_event_add_notifier_ex(CTX_wm_manager(C), CTX_wm_window(C), NC_WM | 
ND_DATACHANGED, NULL);
-  }
-  else {
-BKE_reportf(op->reports,
-RPT_INFO,
-   

[Bf-blender-cvs] [3002bd6e88b] blender-projects-basics: Show warning popup when creating project not containing the current file

2022-10-06 Thread Julian Eisel
Commit: 3002bd6e88b5ece60a5da5ef172cdeebfada7ebf
Author: Julian Eisel
Date:   Thu Oct 6 17:42:49 2022 +0200
Branches: blender-projects-basics
https://developer.blender.org/rB3002bd6e88b5ece60a5da5ef172cdeebfada7ebf

Show warning popup when creating project not containing the current file

===

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

===

diff --git a/source/blender/windowmanager/intern/wm_files.c 
b/source/blender/windowmanager/intern/wm_files.c
index 16a0076084a..07254a5a4a3 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -2382,7 +2382,7 @@ static int wm_new_project_exec(bContext *C, wmOperator 
*op)
   }
   else {
 BKE_reportf(op->reports,
-RPT_INFO,
+RPT_WARNING,
 "The current file is not located inside of the new project. 
This means the new "
 "project is not active");
   }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [dc93235797d] master: GPencil: Use new icons for Envelope and Outline modifiers

2022-10-06 Thread Antonio Vazquez
Commit: dc93235797d12f3793646570ef61e07eb4ec1c2b
Author: Antonio Vazquez
Date:   Thu Oct 6 17:25:38 2022 +0200
Branches: master
https://developer.blender.org/rBdc93235797d12f3793646570ef61e07eb4ec1c2b

GPencil: Use new icons for Envelope and Outline modifiers

Before both modifiers were using Skin icon.

===

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

===

diff --git a/source/blender/makesrna/intern/rna_gpencil_modifier.c 
b/source/blender/makesrna/intern/rna_gpencil_modifier.c
index bbc7ce0d896..4a36443ca42 100644
--- a/source/blender/makesrna/intern/rna_gpencil_modifier.c
+++ b/source/blender/makesrna/intern/rna_gpencil_modifier.c
@@ -82,7 +82,7 @@ const EnumPropertyItem 
rna_enum_object_greasepencil_modifier_type_items[] = {
  "Generate dot-dash styled strokes"},
 {eGpencilModifierType_Envelope,
  "GP_ENVELOPE",
- ICON_MOD_SKIN,
+ ICON_MOD_ENVELOPE,
  "Envelope",
  "Create an envelope shape"},
 {eGpencilModifierType_Length,
@@ -107,7 +107,7 @@ const EnumPropertyItem 
rna_enum_object_greasepencil_modifier_type_items[] = {
  "Produce multiple strokes along one stroke"},
 {eGpencilModifierType_Outline,
  "GP_OUTLINE",
- ICON_MOD_SKIN,
+ ICON_MOD_OUTLINE,
  "Outline",
  "Convert stroke to perimeter"},
 {eGpencilModifierType_Simplify,
@@ -2139,8 +2139,7 @@ static void rna_def_modifier_gpenciloutline(BlenderRNA 
*brna)
   srna = RNA_def_struct(brna, "OutlineGpencilModifier", "GpencilModifier");
   RNA_def_struct_ui_text(srna, "Outline Modifier", "Outline of Strokes 
modifier from camera view");
   RNA_def_struct_sdna(srna, "OutlineGpencilModifierData");
-  // TODO: add new icon
-  RNA_def_struct_ui_icon(srna, ICON_MOD_SKIN);
+  RNA_def_struct_ui_icon(srna, ICON_MOD_OUTLINE);
 
   RNA_define_lib_overridable(true);
 
@@ -4431,7 +4430,7 @@ static void rna_def_modifier_gpencilenvelope(BlenderRNA 
*brna)
   srna = RNA_def_struct(brna, "EnvelopeGpencilModifier", "GpencilModifier");
   RNA_def_struct_ui_text(srna, "Envelope Modifier", "Envelope stroke effect 
modifier");
   RNA_def_struct_sdna(srna, "EnvelopeGpencilModifierData");
-  RNA_def_struct_ui_icon(srna, ICON_MOD_SKIN);
+  RNA_def_struct_ui_icon(srna, ICON_MOD_ENVELOPE);
 
   RNA_define_lib_overridable(true);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [6942f05848e] master: UI: New modifier Icons Envelope and Outline

2022-10-06 Thread Antonio Vazquez
Commit: 6942f05848ee12b3c47dd9e748c50e2013d4304e
Author: Antonio Vazquez
Date:   Thu Oct 6 16:53:51 2022 +0200
Branches: master
https://developer.blender.org/rB6942f05848ee12b3c47dd9e748c50e2013d4304e

UI: New modifier Icons Envelope and Outline

Task: T101155

Designed by: Matias Mendiola
Reviewed by : Pablo Vazquez

===

M   release/datafiles/blender_icons.svg
A   release/datafiles/blender_icons16/icon16_mod_envelope.dat
A   release/datafiles/blender_icons16/icon16_mod_outline.dat
A   release/datafiles/blender_icons32/icon32_mod_envelope.dat
A   release/datafiles/blender_icons32/icon32_mod_outline.dat
M   source/blender/editors/datafiles/CMakeLists.txt
M   source/blender/editors/include/UI_icons.h

===

diff --git a/release/datafiles/blender_icons.svg 
b/release/datafiles/blender_icons.svg
index 41707261ac6..9dc7b184b12 100644
--- a/release/datafiles/blender_icons.svg
+++ b/release/datafiles/blender_icons.svg
@@ -18997,6 +18997,36 @@
  id="path4817-4"
  inkscape:connector-curvature="0" />
 
+
+  
+  
+
+
+  
+  
+  
+
   
   https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [525f24f1ba5] blender-projects-basics: Disable buttons if no project is loaded, always show hint then

2022-10-06 Thread Julian Eisel
Commit: 525f24f1ba54e56ad8f85837af1a905c12332384
Author: Julian Eisel
Date:   Thu Oct 6 16:58:57 2022 +0200
Branches: blender-projects-basics
https://developer.blender.org/rB525f24f1ba54e56ad8f85837af1a905c12332384

Disable buttons if no project is loaded, always show hint then

Disable the navigation and "Save Settings" buttons when there is no
active project.

The message saying that no project is loaded always shows up now, even
if the UI somehow displays a section that is not the "General" one.

===

M   release/scripts/startup/bl_ui/space_project_settings.py
M   source/blender/editors/space_project_settings/space_project_settings.cc
M   source/blender/windowmanager/intern/wm_files.c

===

diff --git a/release/scripts/startup/bl_ui/space_project_settings.py 
b/release/scripts/startup/bl_ui/space_project_settings.py
index 0a099cf2c1a..cfed8889580 100644
--- a/release/scripts/startup/bl_ui/space_project_settings.py
+++ b/release/scripts/startup/bl_ui/space_project_settings.py
@@ -52,8 +52,10 @@ class PROJECTSETTINGS_PT_navigation_bar(Panel):
 layout = self.layout
 
 space_data = context.space_data
+project = context.project
 
 col = layout.column()
+col.enabled = project is not None
 
 col.scale_x = 1.3
 col.scale_y = 1.3
@@ -99,6 +101,25 @@ class PROJECTSETTINGS_PT_save_project_settings(Panel):
 
 PROJECTSETTINGS_HT_header.draw_buttons(layout, context)
 
+
+class PROJECTSETTINGS_PT_no_project(CenterAlignMixIn, Panel):
+bl_space_type = 'PROJECT_SETTINGS'
+bl_region_type = 'WINDOW'
+# Special hardcoded context.
+bl_context = "no_project"
+bl_label = "No Project"
+bl_options = {'HIDE_HEADER'}
+
+@classmethod
+def poll(cls, context):
+return (context.project is None)
+
+def draw_centered(self, context, layout):
+layout = self.layout
+
+layout.label(text="No active project.", icon='INFO')
+
+
 class PROJECTSETTINGS_PT_setup(CenterAlignMixIn, Panel):
 bl_space_type = 'PROJECT_SETTINGS'
 bl_region_type = 'WINDOW'
@@ -109,10 +130,6 @@ class PROJECTSETTINGS_PT_setup(CenterAlignMixIn, Panel):
 def draw_centered(self, context, layout):
 project = context.project
 
-if not project:
-layout.label(text="No active project.", icon='INFO')
-return
-
 layout.prop(project, "name")
 layout.prop(project, "root_path", text="Location")
 
@@ -123,6 +140,7 @@ classes = (
 PROJECTSETTINGS_MT_view,
 PROJECTSETTINGS_PT_navigation_bar,
 PROJECTSETTINGS_PT_save_project_settings,
+PROJECTSETTINGS_PT_no_project,
 PROJECTSETTINGS_PT_setup,
 )
 
diff --git 
a/source/blender/editors/space_project_settings/space_project_settings.cc 
b/source/blender/editors/space_project_settings/space_project_settings.cc
index f58c600977b..3c62bbaf3e4 100644
--- a/source/blender/editors/space_project_settings/space_project_settings.cc
+++ b/source/blender/editors/space_project_settings/space_project_settings.cc
@@ -129,8 +129,12 @@ static void project_settings_main_region_layout(const 
bContext *C, ARegion *regi
   char id_lower[64];
   const char *contexts[2] = {id_lower, NULL};
 
-  /* Avoid duplicating identifiers, use existing RNA enum. */
-  {
+  if (!CTX_wm_project()) {
+/* Special context for when there is no project. UI can draw a special 
panel then. */
+STRNCPY(id_lower, "no_project");
+  }
+  else {
+/* Avoid duplicating identifiers, use existing RNA enum. */
 const EnumPropertyItem *items = rna_enum_project_settings_section_items;
 int i = RNA_enum_from_value(items, sproject_settings->active_section);
 /* Enum value not found: File is from the future. */
diff --git a/source/blender/windowmanager/intern/wm_files.c 
b/source/blender/windowmanager/intern/wm_files.c
index bc9163bf490..ef16a91fef5 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -2316,13 +2316,17 @@ void WM_OT_read_factory_userpref(wmOperatorType *ot)
 /** \name Write Project Settings Operator
  * \{ */
 
+static bool wm_save_project_settings_poll(bContext *C)
+{
+  const BlenderProject *active_project = CTX_wm_project();
+  CTX_wm_operator_poll_msg_set(C, TIP_("No active project loaded"));
+  return active_project != NULL;
+}
+
 /* Only save the prefs block. operator entry */
 static int wm_save_project_settings_exec(bContext *UNUSED(C), wmOperator 
*UNUSED(op))
 {
   BlenderProject *active_project = CTX_wm_project();
-  if (!active_project) {
-return OPERATOR_CANCELLED;
-  }
 
   if (!BKE_project_settings_save(active_project)) {
 return OPERATOR_CANCELLED;
@@ -2338,6 +2342,7 @@ void WM_OT_save_project_settings(wmOperatorType *ot)
   ot->description = "Make the current changes to the project settings 
permanent";
 
   ot->invoke = WM_ope

[Bf-blender-cvs] [871bdb5d1fe] blender-projects-basics: Keep track of unsaved changes, indicate in "Save Settings" button

2022-10-06 Thread Julian Eisel
Commit: 871bdb5d1fec6a010801dbe90c78b327a9f685b0
Author: Julian Eisel
Date:   Thu Oct 6 16:42:59 2022 +0200
Branches: blender-projects-basics
https://developer.blender.org/rB871bdb5d1fec6a010801dbe90c78b327a9f685b0

Keep track of unsaved changes, indicate in "Save Settings" button

===

M   release/scripts/startup/bl_ui/space_project_settings.py
M   source/blender/blenkernel/BKE_blender_project.h
M   source/blender/blenkernel/BKE_blender_project.hh
M   source/blender/blenkernel/intern/blender_project.cc
M   source/blender/blenkernel/intern/blender_project_test.cc
M   source/blender/makesrna/intern/rna_blender_project.c

===

diff --git a/release/scripts/startup/bl_ui/space_project_settings.py 
b/release/scripts/startup/bl_ui/space_project_settings.py
index fcc1d51be8d..0a099cf2c1a 100644
--- a/release/scripts/startup/bl_ui/space_project_settings.py
+++ b/release/scripts/startup/bl_ui/space_project_settings.py
@@ -13,11 +13,13 @@ class PROJECTSETTINGS_HT_header(Header):
 
 @staticmethod
 def draw_buttons(layout, context):
+project = context.project
+
 layout.operator_context = 'EXEC_AREA'
-is_dirty = True
+
+is_dirty = project and project.is_dirty
 
 # Show '*' to let users know the settings have been modified.
-# TODO, wrong operator
 layout.operator(
 "wm.save_project_settings",
 text=iface_("Save Settings") + (" *" if is_dirty else ""),
diff --git a/source/blender/blenkernel/BKE_blender_project.h 
b/source/blender/blenkernel/BKE_blender_project.h
index 2451e2d9f29..8241747a93a 100644
--- a/source/blender/blenkernel/BKE_blender_project.h
+++ b/source/blender/blenkernel/BKE_blender_project.h
@@ -46,6 +46,8 @@ const char *BKE_project_root_path_get(const BlenderProject 
*project) ATTR_WARN_U
 void BKE_project_name_set(const BlenderProject *project_handle, const char 
*name) ATTR_NONNULL();
 const char *BKE_project_name_get(const BlenderProject *project) 
ATTR_WARN_UNUSED_RESULT
 ATTR_NONNULL();
+bool BKE_project_has_unsaved_changes(const BlenderProject *project) 
ATTR_WARN_UNUSED_RESULT
+ATTR_NONNULL();
 
 #ifdef __cplusplus
 }
diff --git a/source/blender/blenkernel/BKE_blender_project.hh 
b/source/blender/blenkernel/BKE_blender_project.hh
index bc93af92129..c4f836e0578 100644
--- a/source/blender/blenkernel/BKE_blender_project.hh
+++ b/source/blender/blenkernel/BKE_blender_project.hh
@@ -48,6 +48,7 @@ class ProjectSettings {
   /* Path to the project root using slashes in the OS native format. */
   std::string project_root_path_;
   std::string project_name_;
+  bool has_unsaved_changes_ = false;
 
  public:
   inline static const StringRefNull SETTINGS_DIRNAME = ".blender_project";
@@ -76,13 +77,14 @@ class ProjectSettings {
* \return True on success. If the .blender_project directory doesn't exist, 
that's treated as
* failure.
*/
-  auto save_to_disk(StringRef project_path) const -> bool;
+  auto save_to_disk(StringRef project_path) -> bool;
 
   explicit ProjectSettings(StringRef project_root_path);
 
   auto project_root_path [[nodiscard]] () const -> StringRefNull;
   void project_name(StringRef new_name);
   auto project_name [[nodiscard]] () const -> StringRefNull;
+  auto has_unsaved_changes [[nodiscard]] () const -> bool;
 
  private:
   auto to_dictionary() const -> 
std::unique_ptr;
diff --git a/source/blender/blenkernel/intern/blender_project.cc 
b/source/blender/blenkernel/intern/blender_project.cc
index 452bc950db2..146f3f0bef6 100644
--- a/source/blender/blenkernel/intern/blender_project.cc
+++ b/source/blender/blenkernel/intern/blender_project.cc
@@ -235,7 +235,7 @@ static void write_settings_file(StringRef settings_filepath,
   os.close();
 }
 
-bool ProjectSettings::save_to_disk(StringRef project_path) const
+bool ProjectSettings::save_to_disk(StringRef project_path)
 {
   ResolvedPaths paths = resolve_paths_from_project_path(project_path);
 
@@ -249,6 +249,8 @@ bool ProjectSettings::save_to_disk(StringRef project_path) 
const
   std::unique_ptr settings_as_dict = to_dictionary();
   write_settings_file(paths.settings_filepath, std::move(settings_as_dict));
 
+  has_unsaved_changes_ = false;
+
   return true;
 }
 
@@ -260,6 +262,7 @@ StringRefNull ProjectSettings::project_root_path() const
 void ProjectSettings::project_name(StringRef new_name)
 {
   project_name_ = new_name;
+  has_unsaved_changes_ = true;
 }
 
 StringRefNull ProjectSettings::project_name() const
@@ -267,6 +270,11 @@ StringRefNull ProjectSettings::project_name() const
   return project_name_;
 }
 
+bool ProjectSettings::has_unsaved_changes() const
+{
+  return has_unsaved_changes_;
+}
+
 }  // namespace blender::bke
 
 /* -- */
@@ -313,7 +321,7 @@ bool BKE_project_settings_save(const Blende

[Bf-blender-cvs] [2739e186b69] tmp-workbench-rewrite2: Workbench Next: Add color modes, flat shading and backface culling

2022-10-06 Thread Miguel Pozo
Commit: 2739e186b692d9f290f45fdeac3aa35f4d4498da
Author: Miguel Pozo
Date:   Thu Oct 6 16:50:08 2022 +0200
Branches: tmp-workbench-rewrite2
https://developer.blender.org/rB2739e186b692d9f290f45fdeac3aa35f4d4498da

Workbench Next: Add color modes, flat shading and backface culling

Adds support for Material, Random, Single and Object color modes.
Adds flat shading support.
Adds backaface culling support.
prepass_shader_cache_ is actually used now.

===

M   source/blender/draw/engines/workbench/workbench_engine.cc

===

diff --git a/source/blender/draw/engines/workbench/workbench_engine.cc 
b/source/blender/draw/engines/workbench/workbench_engine.cc
index 3ab3bed1972..9069ec2dc34 100644
--- a/source/blender/draw/engines/workbench/workbench_engine.cc
+++ b/source/blender/draw/engines/workbench/workbench_engine.cc
@@ -73,6 +73,16 @@ enum class eColorType {
 };
 static constexpr int color_type_len = static_cast(eColorType::TEXTURE) + 
1;
 
+enum class eMaterialSubType {
+  NONE = 0,
+  MATERIAL,
+  RANDOM,
+  SINGLE,
+  OBJECT,
+  ATTRIBUTE,
+};
+static constexpr int material_subtype_len = 
static_cast(eMaterialSubType::ATTRIBUTE) + 1;
+
 struct Material {
   float3 base_color;
   /* Packed data into a int. Decoded in the shader. */
@@ -85,9 +95,19 @@ struct Material {
 base_color = color;
 packed_data = Material::pack_data(0.0f, 0.4f, 1.0f);
   }
-  Material(::Object &ob)
+  Material(::Object &ob, bool random = false)
   {
-base_color = ob.color;
+if (random) {
+  uint hash = BLI_ghashutil_strhash_p_murmur(ob.id.name);
+  if (ob.id.lib) {
+hash = (hash * 13) ^ 
BLI_ghashutil_strhash_p_murmur(ob.id.lib->filepath);
+  }
+  float3 hsv = float3(BLI_hash_int_01(hash), 0.5f, 0.8f);
+  hsv_to_rgb_v(hsv, base_color);
+}
+else {
+  base_color = ob.color;
+}
 packed_data = Material::pack_data(0.0f, 0.4f, ob.color[3]);
   }
   Material(::Material &mat)
@@ -190,6 +210,8 @@ class ShaderCache {
 /* TODO Clipping */
 info_name += "_no_clip";
 shader_ptr = GPU_shader_create_from_info_name(info_name.c_str());
+prepass_shader_cache_[static_cast(pipeline_type)][static_cast(
+
geometry_type)][static_cast(color_type)][static_cast(shading_type)] = 
shader_ptr;
 return shader_ptr;
   }
 
@@ -608,10 +630,12 @@ class Instance {
   DRWState cull_state;
 
   bool use_per_material_batches = false;
-  bool use_single_color = false;
   eColorType color_type = eColorType::MATERIAL;
-  eShadingType shading_type = eShadingType::STUDIO;
+  eMaterialSubType material_subtype = eMaterialSubType::MATERIAL;
+  /** Used when material_subtype == eMaterialSubType::SINGLE */
   Material material_override = Material(float3(1.0f));
+
+  eShadingType shading_type = eShadingType::STUDIO;
   /** Chosen studiolight or matcap. */
   StudioLight *studio_light;
 
@@ -621,17 +645,74 @@ class Instance {
 const View3D * /*v3d*/,
 const RegionView3D * /*rv3d*/)
   {
-use_per_material_batches = false;  // ELEM(color_type, V3D_COLOR_TEXTURE, 
V3D_COLOR_MATERIAL);
-color_type = eColorType::MATERIAL;
-shading_type = eShadingType::STUDIO;
+Scene *scene = DEG_get_evaluated_scene(depsgraph);
+View3DShading &shading = scene->display.shading;
 
 resources.matcap_tx.ensure_2d_array(GPU_RGBA16F, int2(1), 1);
 resources.depth_tx.ensure_2d(GPU_DEPTH24_STENCIL8, output_res);
 
-Scene *scene = DEG_get_evaluated_scene(depsgraph);
-View3DShading &shading = scene->display.shading;
+cull_state = DRW_STATE_NO_DRAW;
+if (shading.flag & V3D_SHADING_BACKFACE_CULLING) {
+  cull_state |= DRW_STATE_CULL_BACK;
+}
+
+use_per_material_batches = ELEM(
+shading.color_type, V3D_SHADING_TEXTURE_COLOR, 
V3D_SHADING_MATERIAL_COLOR);
+
+color_type = shading.color_type == V3D_SHADING_TEXTURE_COLOR ? 
eColorType::TEXTURE :
+   
eColorType::MATERIAL;
+
+if (color_type == eColorType::MATERIAL) {
+  switch (shading.color_type) {
+case V3D_SHADING_MATERIAL_COLOR:
+  material_subtype = eMaterialSubType::MATERIAL;
+  break;
+case V3D_SHADING_RANDOM_COLOR:
+  material_subtype = eMaterialSubType::RANDOM;
+  break;
+case V3D_SHADING_SINGLE_COLOR:
+  material_subtype = eMaterialSubType::SINGLE;
+  break;
+case V3D_SHADING_TEXTURE_COLOR:
+  BLI_assert_msg(false, "V3D_SHADING_TEXTURE_COLOR is not an 
eMaterialSubType");
+  break;
+case V3D_SHADING_OBJECT_COLOR:
+  material_subtype = eMaterialSubType::OBJECT;
+  break;
+case V3D_SHADING_VERTEX_COLOR:
+  material_subtype = eMaterialSubType::ATTRIBUTE;
+  break;
+default:
+  BLI_assert_msg(false, "Unhandled V3D_SHADING type");
+

[Bf-blender-cvs] [8703e17ace0] tmp_usd_import_unbound_mtls: USD import: fixed compiler warnings.

2022-10-06 Thread Michael Kowalski
Commit: 8703e17ace01fe2fdac1d8fc8fe3f607a589c0ca
Author: Michael Kowalski
Date:   Thu Oct 6 10:33:43 2022 -0400
Branches: tmp_usd_import_unbound_mtls
https://developer.blender.org/rB8703e17ace01fe2fdac1d8fc8fe3f607a589c0ca

USD import: fixed compiler warnings.

Removed unused function and assignment in
a conditional expression.

===

M   source/blender/io/usd/intern/usd_reader_mesh.cc
M   source/blender/io/usd/intern/usd_reader_stage.cc

===

diff --git a/source/blender/io/usd/intern/usd_reader_mesh.cc 
b/source/blender/io/usd/intern/usd_reader_mesh.cc
index 3dbdd5d486b..3f7d51e3e76 100644
--- a/source/blender/io/usd/intern/usd_reader_mesh.cc
+++ b/source/blender/io/usd/intern/usd_reader_mesh.cc
@@ -48,20 +48,6 @@ static const pxr::TfToken normalsPrimvar("normals", 
pxr::TfToken::Immortal);
 }  // namespace usdtokens
 
 namespace utils {
-/* Very similar to #blender::io::alembic::utils. */
-static void build_mat_map(const Main *bmain, std::map 
*r_mat_map)
-{
-  if (r_mat_map == nullptr) {
-return;
-  }
-
-  Material *material = static_cast(bmain->materials.first);
-
-  for (; material; material = static_cast(material->id.next)) {
-/* We have to do this because the stored material name is coming directly 
from USD. */
-(*r_mat_map)[pxr::TfMakeValidIdentifier(material->id.name + 2)] = material;
-  }
-}
 
 static pxr::UsdShadeMaterial compute_bound_material(const pxr::UsdPrim &prim)
 {
diff --git a/source/blender/io/usd/intern/usd_reader_stage.cc 
b/source/blender/io/usd/intern/usd_reader_stage.cc
index 0533cbbffee..aaa14dad51b 100644
--- a/source/blender/io/usd/intern/usd_reader_stage.cc
+++ b/source/blender/io/usd/intern/usd_reader_stage.cc
@@ -332,8 +332,8 @@ void USDStageReader::import_all_materials(Main *bmain)
   }
 
   /* Add the material now. */
-  if (blend_mtl = mtl_reader.add_material(usd_mtl)) {
-
+  blend_mtl = mtl_reader.add_material(usd_mtl);
+  if (blend_mtl) {
 if (params_.mtl_name_collision_mode == 
USD_MTL_NAME_COLLISION_MAKE_UNIQUE) {
   /* Record the name of the Blender material we created for the USD 
material
* with the given path, so we don't import the material again if the

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [818a3d37433] blender-projects-basics: Merge branch 'master' into blender-projects-basics

2022-10-06 Thread Julian Eisel
Commit: 818a3d37433d4a42ab8c718402f473c5e96c016a
Author: Julian Eisel
Date:   Thu Oct 6 16:03:40 2022 +0200
Branches: blender-projects-basics
https://developer.blender.org/rB818a3d37433d4a42ab8c718402f473c5e96c016a

Merge branch 'master' into blender-projects-basics

===



===

diff --cc release/scripts/startup/bl_ui/space_topbar.py
index e42e6c80fd6,b1ddd2c611d..c9b007624cf
--- a/release/scripts/startup/bl_ui/space_topbar.py
+++ b/release/scripts/startup/bl_ui/space_topbar.py
@@@ -269,8 -272,8 +272,8 @@@ class TOPBAR_MT_file(Menu)
  layout = self.layout
  
  layout.operator_context = 'INVOKE_AREA'
- layout.menu("TOPBAR_MT_file_new", text="New", icon='FILE_NEW')
+ layout.menu("TOPBAR_MT_file_new", text="New", 
text_ctxt=i18n_contexts.id_windowmanager, icon='FILE_NEW')
 -layout.operator("wm.open_mainfile", text="Open...", 
icon='FILE_FOLDER')
 +layout.operator("wm.open_mainfile", text="Open File...", 
icon='FILE_FOLDER')
  layout.menu("TOPBAR_MT_file_open_recent")
  layout.operator("wm.revert_mainfile")
  layout.menu("TOPBAR_MT_file_recover")

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [483a70eeb5f] blender-projects-basics: Support changing project name in Project Settings UI + show location

2022-10-06 Thread Julian Eisel
Commit: 483a70eeb5f94361c0807b4b1e1bf1c1681db71e
Author: Julian Eisel
Date:   Thu Oct 6 15:53:04 2022 +0200
Branches: blender-projects-basics
https://developer.blender.org/rB483a70eeb5f94361c0807b4b1e1bf1c1681db71e

Support changing project name in Project Settings UI + show location

Adds basic access to the active project and its properties to BPY
(`context.project`).

===

M   release/scripts/startup/bl_ui/space_project_settings.py
M   source/blender/blenkernel/BKE_blender_project.h
M   source/blender/blenkernel/BKE_blender_project.hh
M   source/blender/blenkernel/intern/blender_project.cc
M   source/blender/editors/space_project_settings/space_project_settings.cc
M   source/blender/makesrna/intern/CMakeLists.txt
M   source/blender/makesrna/intern/makesrna.c
A   source/blender/makesrna/intern/rna_blender_project.c
M   source/blender/makesrna/intern/rna_context.c
M   source/blender/makesrna/intern/rna_internal.h
M   source/blender/windowmanager/WM_types.h
M   source/blender/windowmanager/intern/wm_draw.c
M   source/blender/windowmanager/intern/wm_files.c
M   source/blender/windowmanager/intern/wm_window.c
M   source/blender/windowmanager/wm_window.h

===

diff --git a/release/scripts/startup/bl_ui/space_project_settings.py 
b/release/scripts/startup/bl_ui/space_project_settings.py
index b2a543e9e07..fcc1d51be8d 100644
--- a/release/scripts/startup/bl_ui/space_project_settings.py
+++ b/release/scripts/startup/bl_ui/space_project_settings.py
@@ -105,7 +105,14 @@ class PROJECTSETTINGS_PT_setup(CenterAlignMixIn, Panel):
 bl_options = {'HIDE_HEADER'}
 
 def draw_centered(self, context, layout):
-layout.label(text="Testing")
+project = context.project
+
+if not project:
+layout.label(text="No active project.", icon='INFO')
+return
+
+layout.prop(project, "name")
+layout.prop(project, "root_path", text="Location")
 
 
 classes = (
diff --git a/source/blender/blenkernel/BKE_blender_project.h 
b/source/blender/blenkernel/BKE_blender_project.h
index eff87d4aef5..2451e2d9f29 100644
--- a/source/blender/blenkernel/BKE_blender_project.h
+++ b/source/blender/blenkernel/BKE_blender_project.h
@@ -40,6 +40,10 @@ bool BKE_project_settings_save(const BlenderProject 
*project) ATTR_NONNULL();
 
 const char *BKE_project_root_path_get(const BlenderProject *project) 
ATTR_WARN_UNUSED_RESULT
 ATTR_NONNULL();
+/**
+ * \param name The new name to set, expected to be 0 terminated.
+ */
+void BKE_project_name_set(const BlenderProject *project_handle, const char 
*name) ATTR_NONNULL();
 const char *BKE_project_name_get(const BlenderProject *project) 
ATTR_WARN_UNUSED_RESULT
 ATTR_NONNULL();
 
diff --git a/source/blender/blenkernel/BKE_blender_project.hh 
b/source/blender/blenkernel/BKE_blender_project.hh
index 9ddecdfc729..bc93af92129 100644
--- a/source/blender/blenkernel/BKE_blender_project.hh
+++ b/source/blender/blenkernel/BKE_blender_project.hh
@@ -81,6 +81,7 @@ class ProjectSettings {
   explicit ProjectSettings(StringRef project_root_path);
 
   auto project_root_path [[nodiscard]] () const -> StringRefNull;
+  void project_name(StringRef new_name);
   auto project_name [[nodiscard]] () const -> StringRefNull;
 
  private:
diff --git a/source/blender/blenkernel/intern/blender_project.cc 
b/source/blender/blenkernel/intern/blender_project.cc
index 429980774e4..452bc950db2 100644
--- a/source/blender/blenkernel/intern/blender_project.cc
+++ b/source/blender/blenkernel/intern/blender_project.cc
@@ -257,6 +257,11 @@ StringRefNull ProjectSettings::project_root_path() const
   return project_root_path_;
 }
 
+void ProjectSettings::project_name(StringRef new_name)
+{
+  project_name_ = new_name;
+}
+
 StringRefNull ProjectSettings::project_name() const
 {
   return project_name_;
@@ -319,6 +324,13 @@ const char *BKE_project_root_path_get(const BlenderProject 
*project_handle)
   return project->get_settings().project_root_path().c_str();
 }
 
+void BKE_project_name_set(const BlenderProject *project_handle, const char 
*name)
+{
+  const bke::BlenderProject *project = reinterpret_cast(
+  project_handle);
+  project->get_settings().project_name(name);
+}
+
 const char *BKE_project_name_get(const BlenderProject *project_handle)
 {
   const bke::BlenderProject *project = reinterpret_cast(
diff --git 
a/source/blender/editors/space_project_settings/space_project_settings.cc 
b/source/blender/editors/space_project_settings/space_project_settings.cc
index ec70a0a2721..f58c600977b 100644
--- a/source/blender/editors/space_project_settings/space_project_settings.cc
+++ b/source/blender/editors/space_project_settings/space_project_settings.cc
@@ -85,6 +85,18 @@ static SpaceLink *project_settings_duplicate(SpaceLink *sl)
   return reinterpret_cast(sproject_settings_new);
 }
 

[Bf-blender-cvs] [cd15fbbed62] blender-projects-basics: Support saving project settings to .blender_project/settings.json

2022-10-06 Thread Julian Eisel
Commit: cd15fbbed622873e9347b48b36931f99c1c6def5
Author: Julian Eisel
Date:   Thu Oct 6 15:51:10 2022 +0200
Branches: blender-projects-basics
https://developer.blender.org/rBcd15fbbed622873e9347b48b36931f99c1c6def5

Support saving project settings to .blender_project/settings.json

===

M   release/scripts/startup/bl_ui/space_project_settings.py
M   source/blender/blenkernel/BKE_blender_project.h
M   source/blender/blenkernel/BKE_blender_project.hh
M   source/blender/blenkernel/intern/blender_project.cc
M   source/blender/blenkernel/intern/blender_project_test.cc
M   source/blender/windowmanager/intern/wm_files.c
M   source/blender/windowmanager/intern/wm_operators.c
M   source/blender/windowmanager/wm_files.h

===

diff --git a/release/scripts/startup/bl_ui/space_project_settings.py 
b/release/scripts/startup/bl_ui/space_project_settings.py
index 9fa42334e87..b2a543e9e07 100644
--- a/release/scripts/startup/bl_ui/space_project_settings.py
+++ b/release/scripts/startup/bl_ui/space_project_settings.py
@@ -19,8 +19,8 @@ class PROJECTSETTINGS_HT_header(Header):
 # Show '*' to let users know the settings have been modified.
 # TODO, wrong operator
 layout.operator(
-"wm.save_userpref",
-text=iface_("Save Project Settings") + (" *" if is_dirty else ""),
+"wm.save_project_settings",
+text=iface_("Save Settings") + (" *" if is_dirty else ""),
 translate=False,
 )
 
diff --git a/source/blender/blenkernel/BKE_blender_project.h 
b/source/blender/blenkernel/BKE_blender_project.h
index e1bcced6cdd..eff87d4aef5 100644
--- a/source/blender/blenkernel/BKE_blender_project.h
+++ b/source/blender/blenkernel/BKE_blender_project.h
@@ -36,6 +36,8 @@ void BKE_project_active_unset(void);
  */
 BlenderProject *BKE_project_active_load_from_path(const char *path) 
ATTR_NONNULL();
 
+bool BKE_project_settings_save(const BlenderProject *project) ATTR_NONNULL();
+
 const char *BKE_project_root_path_get(const BlenderProject *project) 
ATTR_WARN_UNUSED_RESULT
 ATTR_NONNULL();
 const char *BKE_project_name_get(const BlenderProject *project) 
ATTR_WARN_UNUSED_RESULT
diff --git a/source/blender/blenkernel/BKE_blender_project.hh 
b/source/blender/blenkernel/BKE_blender_project.hh
index 221e3c34d2c..bd1a232b592 100644
--- a/source/blender/blenkernel/BKE_blender_project.hh
+++ b/source/blender/blenkernel/BKE_blender_project.hh
@@ -10,6 +10,10 @@
 
 #include "BLI_string_ref.hh"
 
+namespace blender::io::serialize {
+class DictionaryValue;
+}
+
 namespace blender::bke {
 
 class ProjectSettings;
@@ -60,16 +64,27 @@ class ProjectSettings {
   /**
* Read project settings from the given \a project_path, which may be either 
a project root
* directory or the .blender_project directory.
-   * Both Unix and Windows style slashes are allowed.
+   * Both Unix and Windows style slashes are allowed. Path is expected to be 
normalized.
* \return The read project settings or null in case of failure.
*/
   static auto load_from_disk [[nodiscard]] (StringRef project_path)
   -> std::unique_ptr;
+  /**
+   * Write project settings to the given \a project_path, which may be either 
a project root
+   * directory or the .blender_project directory. The .blender_project 
directory must exist.
+   * Both Unix and Windows style slashes are allowed. Path is expected to be 
normalized.
+   * \return True on success. If the .blender_project directory doesn't exist, 
that's treated as
+   * failure.
+   */
+  auto save_to_disk(StringRef project_path) const -> bool;
 
   explicit ProjectSettings(StringRef project_root_path);
 
   auto project_root_path [[nodiscard]] () const -> StringRefNull;
   auto project_name [[nodiscard]] () const -> StringRefNull;
+
+ private:
+  auto to_dictionary() const -> 
std::unique_ptr;
 };
 
 }  // namespace blender::bke
diff --git a/source/blender/blenkernel/intern/blender_project.cc 
b/source/blender/blenkernel/intern/blender_project.cc
index 5fe10df4cc9..99d92138ca5 100644
--- a/source/blender/blenkernel/intern/blender_project.cc
+++ b/source/blender/blenkernel/intern/blender_project.cc
@@ -152,36 +152,55 @@ static std::unique_ptr 
extract_settings(
   return extracted_settings;
 }
 
-std::unique_ptr ProjectSettings::load_from_disk(StringRef 
project_path)
+struct ResolvedPaths {
+  std::string settings_filepath;
+  std::string project_root_path;
+};
+
+/**
+ * Returned paths can be assumed to use native slashes.
+ */
+static ResolvedPaths resolve_paths_from_project_path(StringRef project_path)
 {
   std::string project_path_native = project_path;
   BLI_path_slash_native(project_path_native.data());
 
-  if (!BLI_exists(project_path_native.c_str())) {
-return nullptr;
-  }
-
-  StringRef project_root_path = project_path_native;
+  ResolvedPaths resolved_pat

[Bf-blender-cvs] [6fde8ab8db1] blender-projects-basics: Cleanup: variable names, memory debug names

2022-10-06 Thread Julian Eisel
Commit: 6fde8ab8db1f3410846ef03016bfe6dff3114661
Author: Julian Eisel
Date:   Thu Oct 6 15:52:22 2022 +0200
Branches: blender-projects-basics
https://developer.blender.org/rB6fde8ab8db1f3410846ef03016bfe6dff3114661

Cleanup: variable names, memory debug names

===

M   source/blender/blenkernel/BKE_blender_project.hh
M   source/blender/blenkernel/intern/blender_project.cc
M   source/blender/editors/space_project_settings/space_project_settings.cc

===

diff --git a/source/blender/blenkernel/BKE_blender_project.hh 
b/source/blender/blenkernel/BKE_blender_project.hh
index bd1a232b592..9ddecdfc729 100644
--- a/source/blender/blenkernel/BKE_blender_project.hh
+++ b/source/blender/blenkernel/BKE_blender_project.hh
@@ -19,7 +19,7 @@ namespace blender::bke {
 class ProjectSettings;
 
 class BlenderProject {
-  inline static std::unique_ptr instance_;
+  inline static std::unique_ptr active_;
 
   std::unique_ptr settings_;
 
diff --git a/source/blender/blenkernel/intern/blender_project.cc 
b/source/blender/blenkernel/intern/blender_project.cc
index 99d92138ca5..429980774e4 100644
--- a/source/blender/blenkernel/intern/blender_project.cc
+++ b/source/blender/blenkernel/intern/blender_project.cc
@@ -33,18 +33,18 @@ 
BlenderProject::BlenderProject(std::unique_ptr settings)
 BlenderProject 
*BlenderProject::set_active_from_settings(std::unique_ptr 
settings)
 {
   if (settings) {
-instance_ = 
std::make_unique(BlenderProject(std::move(settings)));
+active_ = 
std::make_unique(BlenderProject(std::move(settings)));
   }
   else {
-instance_ = nullptr;
+active_ = nullptr;
   }
 
-  return instance_.get();
+  return active_.get();
 }
 
 BlenderProject *BlenderProject::get_active()
 {
-  return instance_.get();
+  return active_.get();
 }
 
 StringRef BlenderProject::project_root_path_find_from_path(StringRef path)
diff --git 
a/source/blender/editors/space_project_settings/space_project_settings.cc 
b/source/blender/editors/space_project_settings/space_project_settings.cc
index f9fcceca074..ec70a0a2721 100644
--- a/source/blender/editors/space_project_settings/space_project_settings.cc
+++ b/source/blender/editors/space_project_settings/space_project_settings.cc
@@ -216,7 +216,7 @@ void ED_spacetype_project_settings()
   BLI_addhead(&st->regiontypes, art);
 
   /* regions: navigation window */
-  art = MEM_cnew("spacetype project settings region");
+  art = MEM_cnew("spacetype project settings navigation region");
   art->regionid = RGN_TYPE_NAV_BAR;
   art->prefsizex = UI_NAVIGATION_REGION_WIDTH;
   art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_NAVBAR;
@@ -227,7 +227,7 @@ void ED_spacetype_project_settings()
   BLI_addhead(&st->regiontypes, art);
 
   /* regions: execution window */
-  art = MEM_cnew("spacetype project settings region");
+  art = MEM_cnew("spacetype project settings execute region");
   art->regionid = RGN_TYPE_EXECUTE;
   art->prefsizey = HEADERY;
   art->keymapflag = ED_KEYMAP_UI;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [1608abd78c3] refactor-mesh-uv-map-generic: Move the get_uv_map_vert/edge/pin_selection_name() functions to C from C++ and avoid std::string.

2022-10-06 Thread Martijn Versteegh
Commit: 1608abd78c3064d3079d74ef6beca1d3864a8d26
Author: Martijn Versteegh
Date:   Thu Oct 6 15:45:22 2022 +0200
Branches: refactor-mesh-uv-map-generic
https://developer.blender.org/rB1608abd78c3064d3079d74ef6beca1d3864a8d26

Move the get_uv_map_vert/edge/pin_selection_name() functions to C from C++ and 
avoid std::string.

We need these functions both in C and in C code, also the std::string
concatenation was quite slow because it onvolves allocation. It now
uses a (stack allocated) char buffer passed in from the caller.

This alos gives us a single place in the code to handle overflowing
MAX_CUSTOMDATA_LAYER_NAME (to be done in a future commit).

===

M   source/blender/blenkernel/BKE_attribute.h
M   source/blender/blenkernel/BKE_attribute.hh
M   source/blender/blenkernel/intern/attribute.cc
M   source/blender/blenkernel/intern/mesh_legacy_convert.cc
M   source/blender/bmesh/intern/bmesh_interp.c
M   source/blender/bmesh/intern/bmesh_query_uv.cc
M   source/blender/editors/mesh/mesh_data.cc

===

diff --git a/source/blender/blenkernel/BKE_attribute.h 
b/source/blender/blenkernel/BKE_attribute.h
index 13eefd27bec..cc25bc3b897 100644
--- a/source/blender/blenkernel/BKE_attribute.h
+++ b/source/blender/blenkernel/BKE_attribute.h
@@ -8,6 +8,9 @@
 
 #pragma once
 
+#include 
+
+#include "BLI_string.h"
 #include "BLI_sys_types.h"
 
 #include "BKE_customdata.h"
@@ -138,6 +141,44 @@ struct CustomDataLayer *BKE_id_attributes_color_find(const 
struct ID *id, const
 
 bool BKE_id_attribute_calc_unique_name(struct ID *id, const char *name, char 
*outname);
 
+
+inline char const *get_uv_map_vert_selection_name(char const *uv_map_name, 
char *buffer)
+{
+  size_t len = strlen(uv_map_name);
+
+  BLI_assert(strlen(UV_VERTSEL_NAME) == 2);
+  if (len >= MAX_CUSTOMDATA_LAYER_NAME - 5) {
+/* TODO(martijn) come up with a way to generate a non-colliding 
shortening... */
+  }
+  BLI_snprintf(buffer, MAX_CUSTOMDATA_LAYER_NAME, ".%s.%s", UV_VERTSEL_NAME, 
uv_map_name);
+  return buffer;
+}
+
+inline char const *get_uv_map_edge_selection_name(char const *uv_map_name, 
char *buffer)
+{
+  size_t len = strlen(uv_map_name);
+
+  BLI_assert(strlen(UV_VERTSEL_NAME) == 2);
+  if (len >= MAX_CUSTOMDATA_LAYER_NAME - 5) {
+/* TODO(martijn) come up with a way to generate a non-colliding 
shortening... */
+  }
+  BLI_snprintf(buffer, MAX_CUSTOMDATA_LAYER_NAME, ".%s.%s", UV_EDGESEL_NAME, 
uv_map_name);
+  return buffer;
+}
+
+inline char const *get_uv_map_pin_name(char const *uv_map_name, char *buffer)
+{
+  size_t len = strlen(uv_map_name);
+
+  BLI_assert(strlen(UV_VERTSEL_NAME) == 2);
+  if (len >= MAX_CUSTOMDATA_LAYER_NAME - 5) {
+/* TODO(martijn) come up with a way to generate a non-colliding 
shortening... */
+  }
+  BLI_snprintf(buffer, MAX_CUSTOMDATA_LAYER_NAME, ".%s.%s", UV_PINNED_NAME, 
uv_map_name);
+  return buffer;
+}
+
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/source/blender/blenkernel/BKE_attribute.hh 
b/source/blender/blenkernel/BKE_attribute.hh
index 4021de039ff..7b13b8a2b09 100644
--- a/source/blender/blenkernel/BKE_attribute.hh
+++ b/source/blender/blenkernel/BKE_attribute.hh
@@ -827,21 +827,6 @@ class CustomDataAttributes {
   bool foreach_attribute(const AttributeForeachCallback callback, eAttrDomain 
domain) const;
 };
 
-inline std::string get_uv_map_vert_selection_name(const StringRef uv_map_name)
-{
-  return std::string(".") + UV_VERTSEL_NAME + "." + uv_map_name;
-}
-
-inline std::string get_uv_map_edge_selection_name(const StringRef uv_map_name)
-{
-  return std::string(".") + UV_EDGESEL_NAME + "." + uv_map_name;
-}
-
-inline std::string get_uv_map_pin_name(const StringRef uv_map_name)
-{
-  return std::string(".") + UV_PINNED_NAME + "." + uv_map_name;
-}
-
 /*  */
 /** \name #AttributeIDRef Inline Methods
  * \{ */
diff --git a/source/blender/blenkernel/intern/attribute.cc 
b/source/blender/blenkernel/intern/attribute.cc
index 93405166534..a8eea24cdb6 100644
--- a/source/blender/blenkernel/intern/attribute.cc
+++ b/source/blender/blenkernel/intern/attribute.cc
@@ -170,17 +170,19 @@ bool BKE_id_attribute_rename(ID *id,
 
   if (layer->type == CD_PROP_FLOAT2) {
 /* Rename UV sub-attributes. */
+char buffer_src[MAX_CUSTOMDATA_LAYER_NAME];
+char buffer_dst[MAX_CUSTOMDATA_LAYER_NAME];
 BKE_id_attribute_rename(id,
-
get_uv_map_vert_selection_name(layer->name).c_str(),
-
get_uv_map_vert_selection_name(result_name).c_str(),
+get_uv_map_vert_selection_name(layer->name, 
buffer_src),
+get_uv_map_vert_selection_name(result_name, 
buffer_dst),
 reports);
 BKE_id_attribute_rename(id,
-
get_uv_map_edge_sele

[Bf-blender-cvs] [846fc7fa229] refactor-mesh-uv-map-generic: Cleanup: Remove unused function.

2022-10-06 Thread Martijn Versteegh
Commit: 846fc7fa229adb9edacc2c580f54adbd3a93b565
Author: Martijn Versteegh
Date:   Thu Oct 6 15:32:28 2022 +0200
Branches: refactor-mesh-uv-map-generic
https://developer.blender.org/rB846fc7fa229adb9edacc2c580f54adbd3a93b565

Cleanup: Remove unused function.

BKE_mesh_calc_poly_uv_area( ) was already removed earlier in the branch, but
accidentally added back when merging with master.

===

M   source/blender/blenkernel/intern/mesh_evaluate.cc

===

diff --git a/source/blender/blenkernel/intern/mesh_evaluate.cc 
b/source/blender/blenkernel/intern/mesh_evaluate.cc
index 60365860583..247122fd061 100644
--- a/source/blender/blenkernel/intern/mesh_evaluate.cc
+++ b/source/blender/blenkernel/intern/mesh_evaluate.cc
@@ -216,24 +216,6 @@ float BKE_mesh_calc_area(const Mesh *me)
   return total_area;
 }
 
-float BKE_mesh_calc_poly_uv_area(const MPoly *mpoly, const float 
(*uv_array)[2] )
-{
-
-  int i, l_iter = mpoly->loopstart;
-  float area;
-  float(*vertexcos)[2] = (float(*)[2])BLI_array_alloca(vertexcos, 
size_t(mpoly->totloop));
-
-  /* pack vertex cos into an array for area_poly_v2 */
-  for (i = 0; i < mpoly->totloop; i++, l_iter++) {
-copy_v2_v2(vertexcos[i], uv_array[l_iter]);
-  }
-
-  /* finally calculate the area */
-  area = area_poly_v2(vertexcos, uint(mpoly->totloop));
-
-  return area;
-}
-
 static float UNUSED_FUNCTION(mesh_calc_poly_volume_centroid)(const MPoly 
*mpoly,
  const MLoop 
*loopstart,
  const MVert 
*mvarray,

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [88c5d2c9a54] refactor-mesh-uv-map-generic: Cleanup: Suppress warning about unused parameter.

2022-10-06 Thread Martijn Versteegh
Commit: 88c5d2c9a548c52a3cd1a2650463cfbe381fa867
Author: Martijn Versteegh
Date:   Thu Sep 29 20:25:39 2022 +0200
Branches: refactor-mesh-uv-map-generic
https://developer.blender.org/rB88c5d2c9a548c52a3cd1a2650463cfbe381fa867

Cleanup: Suppress warning about unused parameter.

===

M   source/blender/draw/intern/draw_pbvh.cc

===

diff --git a/source/blender/draw/intern/draw_pbvh.cc 
b/source/blender/draw/intern/draw_pbvh.cc
index 629aa5883dc..c9adc67d1b5 100644
--- a/source/blender/draw/intern/draw_pbvh.cc
+++ b/source/blender/draw/intern/draw_pbvh.cc
@@ -580,7 +580,7 @@ struct PBVHBatches {
   uchar fset_color[3] = {255, 255, 255};
 
   foreach_faces(
-  [&](int /*buffer_i*/, int /*tri_i*/, int /*vertex_i*/, const 
MLoopTri *tri) {
+  [&](int /*buffer_i*/, int /*tri_i*/, int /*vertex_i*/, const 
MLoopTri *UNUSED(tri)) {
 *static_cast(GPU_vertbuf_raw_step(&access)) = 
fset_color;
   });
 }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [c2c160f0093] asset-lite-greasepencil: Merge branch 'master' into asset-lite-greasepencil

2022-10-06 Thread Antonio Vazquez
Commit: c2c160f00934ead4ead6705730ea1da5cf7a642a
Author: Antonio Vazquez
Date:   Thu Oct 6 15:52:26 2022 +0200
Branches: asset-lite-greasepencil
https://developer.blender.org/rBc2c160f00934ead4ead6705730ea1da5cf7a642a

Merge branch 'master' into asset-lite-greasepencil

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [82056b26b04] cycles_path_guiding: Merge branch 'master' into cycles_path_guiding

2022-10-06 Thread Sebastian Herholz
Commit: 82056b26b046f3cc21598124ee996d145ba8e01e
Author: Sebastian Herholz
Date:   Thu Oct 6 14:40:37 2022 +0200
Branches: cycles_path_guiding
https://developer.blender.org/rB82056b26b046f3cc21598124ee996d145ba8e01e

Merge branch 'master' into cycles_path_guiding

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [e1a33487556] master: Fix T101458: Changing volume density when pg is enabled causes crash

2022-10-06 Thread Sebastian Herholz
Commit: e1a334875567418ab7a878d7ffac77f083ad8b10
Author: Sebastian Herholz
Date:   Thu Oct 6 14:39:44 2022 +0200
Branches: master
https://developer.blender.org/rBe1a334875567418ab7a878d7ffac77f083ad8b10

Fix T101458: Changing volume density when pg is enabled causes crash

Changing volume parameters during rendering could cause a crash
when guiding was enabled. It was due to an unintialized state paramter
at the beginning of the path tracing process.

In addition guiding is disabled when dealing with almost delta volumes
(i.e., g close to 1.0 or -1.0).

===

M   intern/cycles/cmake/external_libs.cmake
M   intern/cycles/kernel/integrator/guiding.h
M   intern/cycles/kernel/integrator/path_state.h

===

diff --git a/intern/cycles/cmake/external_libs.cmake 
b/intern/cycles/cmake/external_libs.cmake
index 9335024f2eb..9524cda54f5 100644
--- a/intern/cycles/cmake/external_libs.cmake
+++ b/intern/cycles/cmake/external_libs.cmake
@@ -274,7 +274,7 @@ endif()
 ###
 
 if(CYCLES_STANDALONE_REPOSITORY AND WITH_CYCLES_PATH_GUIDING)
-  if(EXISTS ${_cycles_lib_dir})
+  if(NOT openpgl_DIR AND EXISTS ${_cycles_lib_dir})
 set(openpgl_DIR ${_cycles_lib_dir}/openpgl/lib/cmake/openpgl)
   endif()
 
diff --git a/intern/cycles/kernel/integrator/guiding.h 
b/intern/cycles/kernel/integrator/guiding.h
index 5904b69b046..634bba2a9b4 100644
--- a/intern/cycles/kernel/integrator/guiding.h
+++ b/intern/cycles/kernel/integrator/guiding.h
@@ -501,6 +501,11 @@ ccl_device_forceinline bool 
guiding_phase_init(KernelGlobals kg,
ccl_private float &rand)
 {
 #if defined(__PATH_GUIDING__) && PATH_GUIDING_LEVEL >= 4
+  /* we do not need to guide almost delta phase functions */
+  if (fabsf(g) >= 0.99f) {
+return false;
+  }
+
   if (kg->opgl_volume_sampling_distribution->Init(
   kg->opgl_guiding_field, guiding_point3f(P), rand, true)) {
 
kg->opgl_volume_sampling_distribution->ApplySingleLobeHenyeyGreensteinProduct(guiding_vec3f(D),
diff --git a/intern/cycles/kernel/integrator/path_state.h 
b/intern/cycles/kernel/integrator/path_state.h
index dbc6fc5a883..7197f0f2f3a 100644
--- a/intern/cycles/kernel/integrator/path_state.h
+++ b/intern/cycles/kernel/integrator/path_state.h
@@ -59,6 +59,13 @@ ccl_device_inline void 
path_state_init_integrator(KernelGlobals kg,
 #ifdef __PATH_GUIDING__
   INTEGRATOR_STATE_WRITE(state, path, unguided_throughput) = 1.0f;
   INTEGRATOR_STATE_WRITE(state, guiding, path_segment) = nullptr;
+  INTEGRATOR_STATE_WRITE(state, guiding, use_surface_guiding) = false;
+  INTEGRATOR_STATE_WRITE(state, guiding, sample_surface_guiding_rand) = 0.5f;
+  INTEGRATOR_STATE_WRITE(state, guiding, surface_guiding_sampling_prob) = 0.0f;
+  INTEGRATOR_STATE_WRITE(state, guiding, bssrdf_sampling_prob) = 0.0f;
+  INTEGRATOR_STATE_WRITE(state, guiding, use_volume_guiding) = false;
+  INTEGRATOR_STATE_WRITE(state, guiding, sample_volume_guiding_rand) = 0.5f;
+  INTEGRATOR_STATE_WRITE(state, guiding, volume_guiding_sampling_prob) = 0.0f;
 #endif
 
 #ifdef __MNEE__

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [423c1366b05] master: Fix T101618: Freeze when reloading a library in certain situation

2022-10-06 Thread Philipp Oeser
Commit: 423c1366b05e1024f771ca0b5e2cfde65cbb9edc
Author: Philipp Oeser
Date:   Thu Oct 6 12:10:26 2022 +0200
Branches: master
https://developer.blender.org/rB423c1366b05e1024f771ca0b5e2cfde65cbb9edc

Fix T101618: Freeze when reloading a library in certain situation

Freeze happened when reloading a library while having an Object property
with a custom getter function defined in Python.

Just piggybacking on rB62eb21e3ce87, this just applies the same fix (use
the BPy_BEGIN/END_ALLOW_THREADS macros) to relading from RNA/py.

All credit goes to @brecht and @mont29.

Maniphest Tasks: T101618

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

===

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

===

diff --git a/source/blender/makesrna/intern/rna_ID.c 
b/source/blender/makesrna/intern/rna_ID.c
index c91e0e1805e..b2c57846a08 100644
--- a/source/blender/makesrna/intern/rna_ID.c
+++ b/source/blender/makesrna/intern/rna_ID.c
@@ -1392,6 +1392,19 @@ static void rna_Library_version_get(PointerRNA *ptr, int 
*value)
   value[2] = lib->subversionfile;
 }
 
+static void rna_Library_reload(Library *lib, bContext *C, ReportList *reports)
+{
+#  ifdef WITH_PYTHON
+  BPy_BEGIN_ALLOW_THREADS;
+#  endif
+
+  WM_lib_reload(lib, C, reports);
+
+#  ifdef WITH_PYTHON
+  BPy_END_ALLOW_THREADS;
+#  endif
+}
+
 #else
 
 static void rna_def_ID_properties(BlenderRNA *brna)
@@ -2239,7 +2252,7 @@ static void rna_def_library(BlenderRNA *brna)
   RNA_def_property_clear_flag(prop, PROP_EDITABLE);
   RNA_def_property_flag(prop, PROP_THICK_WRAP);
 
-  func = RNA_def_function(srna, "reload", "WM_lib_reload");
+  func = RNA_def_function(srna, "reload", "rna_Library_reload");
   RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_CONTEXT);
   RNA_def_function_ui_description(func, "Reload this library and all its 
linked data-blocks");
 }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [a01ab2b4e09] master: Fix T101492: UV stitch crash (more than 32 objects selected)

2022-10-06 Thread Philipp Oeser
Commit: a01ab2b4e093a35b56888cf646d84686bccb0fbd
Author: Philipp Oeser
Date:   Fri Sep 30 13:41:07 2022 +0200
Branches: master
https://developer.blender.org/rBa01ab2b4e093a35b56888cf646d84686bccb0fbd

Fix T101492: UV stitch crash (more than 32 objects selected)

Crash happened when adjusting operator props in Adjust Last Operation
panel.

When there are more than 32 objects selected in muti-object-editmode, we
are running into RNA array limit (`objects_selection_count` is defined as
an RNA array (which can only hold 32 entries, see
`RNA_MAX_ARRAY_LENGTH`), leading to reading random memory errors.

While there might be ways to make this work with more than 32 selected
objects (e.g. by instead using a collection, or investigate supporting
dynamic sized arrays for run-time RNA), this patch only cancels the
operator with a report message (instead of crashing).

Maniphest Tasks: T101492

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

===

M   source/blender/editors/uvedit/uvedit_smart_stitch.c

===

diff --git a/source/blender/editors/uvedit/uvedit_smart_stitch.c 
b/source/blender/editors/uvedit/uvedit_smart_stitch.c
index 05b98ab9627..865262e6947 100644
--- a/source/blender/editors/uvedit/uvedit_smart_stitch.c
+++ b/source/blender/editors/uvedit/uvedit_smart_stitch.c
@@ -14,6 +14,7 @@
 #include "DNA_meshdata_types.h"
 #include "DNA_object_types.h"
 #include "DNA_scene_types.h"
+#include "DNA_windowmanager_types.h"
 
 #include "BLI_ghash.h"
 #include "BLI_math.h"
@@ -28,6 +29,7 @@
 #include "BKE_editmesh.h"
 #include "BKE_layer.h"
 #include "BKE_mesh_mapping.h"
+#include "BKE_report.h"
 
 #include "DEG_depsgraph.h"
 
@@ -2174,6 +2176,28 @@ static int stitch_init_all(bContext *C, wmOperator *op)
   Scene *scene = CTX_data_scene(C);
   ToolSettings *ts = scene->toolsettings;
 
+  ViewLayer *view_layer = CTX_data_view_layer(C);
+  View3D *v3d = CTX_wm_view3d(C);
+  uint objects_len = 0;
+  Object **objects = 
BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(
+  scene, view_layer, v3d, &objects_len);
+
+  if (objects_len == 0) {
+MEM_freeN(objects);
+BKE_report(op->reports, RPT_ERROR, "No objects selected");
+return 0;
+  }
+
+  if (objects_len > RNA_MAX_ARRAY_LENGTH) {
+MEM_freeN(objects);
+BKE_reportf(op->reports,
+RPT_ERROR,
+"Stitching only works with less than %i objects selected (%u 
selected)",
+RNA_MAX_ARRAY_LENGTH,
+objects_len);
+return 0;
+  }
+
   StitchStateContainer *ssc = MEM_callocN(sizeof(StitchStateContainer), 
"stitch collection");
 
   op->customdata = ssc;
@@ -2208,21 +2232,6 @@ static int stitch_init_all(bContext *C, wmOperator *op)
 }
   }
 
-  ssc->objects_len = 0;
-  ssc->states = NULL;
-
-  ViewLayer *view_layer = CTX_data_view_layer(C);
-  View3D *v3d = CTX_wm_view3d(C);
-  uint objects_len = 0;
-  Object **objects = 
BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(
-  scene, view_layer, v3d, &objects_len);
-
-  if (objects_len == 0) {
-MEM_freeN(objects);
-state_delete_all(ssc);
-return 0;
-  }
-
   ssc->objects = MEM_callocN(sizeof(Object *) * objects_len, "Object 
*ssc->objects");
   ssc->states = MEM_callocN(sizeof(StitchState *) * objects_len, 
"StitchState");
   ssc->objects_len = 0;
@@ -2288,6 +2297,7 @@ static int stitch_init_all(bContext *C, wmOperator *op)
 
   if (ssc->objects_len == 0) {
 state_delete_all(ssc);
+BKE_report(op->reports, RPT_ERROR, "Could not initialize stitching on any 
selected object");
 return 0;
   }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [25533ac22d7] master: Fix T101517: GPencil strokes snap to origin in a Scale value is on 0

2022-10-06 Thread Antonio Vazquez
Commit: 25533ac22d73086fb8841a7fc96018338fff44c5
Author: Antonio Vazquez
Date:   Thu Oct 6 13:29:56 2022 +0200
Branches: master
https://developer.blender.org/rB25533ac22d73086fb8841a7fc96018338fff44c5

Fix T101517: GPencil strokes snap to origin in a Scale value is on 0

The problem was the conversion to object space converted the
points to zero.

Now, the new function `zero_axis_bias_m4` is used in order to add
a small bias in the inverse matrix and avoid the zero points.

A known math issue is the stroke can be offsetted if the scale is set to 1 
again. In this case apply the scale to reset to 1.

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

===

M   source/blender/editors/gpencil/gpencil_sculpt_paint.c
M   source/blender/editors/gpencil/gpencil_utils.c

===

diff --git a/source/blender/editors/gpencil/gpencil_sculpt_paint.c 
b/source/blender/editors/gpencil/gpencil_sculpt_paint.c
index c2e548397e3..1df106d2754 100644
--- a/source/blender/editors/gpencil/gpencil_sculpt_paint.c
+++ b/source/blender/editors/gpencil/gpencil_sculpt_paint.c
@@ -544,8 +544,10 @@ static void 
gpencil_brush_grab_apply_cached(tGP_BrushEditData *gso,
 return;
   }
 
-  float inverse_diff_mat[4][4];
-  invert_m4_m4(inverse_diff_mat, diff_mat);
+  float matrix[4][4], inverse_diff_mat[4][4];
+  copy_m4_m4(matrix, diff_mat);
+  zero_axis_bias_m4(matrix);
+  invert_m4_m4(inverse_diff_mat, matrix);
 
   /* Apply dvec to all of the stored points */
   for (int i = 0; i < data->size; i++) {
@@ -1169,7 +1171,10 @@ static bool gpencil_sculpt_brush_init(bContext *C, 
wmOperator *op)
   gso->scene = scene;
   gso->object = ob;
   if (ob) {
-invert_m4_m4(gso->inv_mat, ob->obmat);
+float matrix[4][4];
+copy_m4_m4(matrix, ob->obmat);
+zero_axis_bias_m4(matrix);
+invert_m4_m4(gso->inv_mat, matrix);
 gso->vrgroup = gso->gpd->vertex_group_active_index - 1;
 if (!BLI_findlink(&gso->gpd->vertex_group_names, gso->vrgroup)) {
   gso->vrgroup = -1;
diff --git a/source/blender/editors/gpencil/gpencil_utils.c 
b/source/blender/editors/gpencil/gpencil_utils.c
index 98d5192a632..1849614b403 100644
--- a/source/blender/editors/gpencil/gpencil_utils.c
+++ b/source/blender/editors/gpencil/gpencil_utils.c
@@ -632,6 +632,7 @@ void gpencil_world_to_object_space(Depsgraph *depsgraph,
   float inverse_diff_mat[4][4];
 
   BKE_gpencil_layer_transform_matrix_get(depsgraph, obact, gpl, diff_mat);
+  zero_axis_bias_m4(diff_mat);
   invert_m4_m4(inverse_diff_mat, diff_mat);
 
   for (i = 0; i < gps->totpoints; i++) {
@@ -650,6 +651,7 @@ void gpencil_world_to_object_space_point(Depsgraph 
*depsgraph,
   float inverse_diff_mat[4][4];
 
   BKE_gpencil_layer_transform_matrix_get(depsgraph, obact, gpl, diff_mat);
+  zero_axis_bias_m4(diff_mat);
   invert_m4_m4(inverse_diff_mat, diff_mat);
 
   mul_m4_v3(inverse_diff_mat, &pt->x);
@@ -930,6 +932,7 @@ void ED_gpencil_project_stroke_to_view(bContext *C, 
bGPDlayer *gpl, bGPDstroke *
   gpencil_point_conversion_init(C, &gsc);
 
   BKE_gpencil_layer_transform_matrix_get(depsgraph, ob, gpl, diff_mat);
+  zero_axis_bias_m4(diff_mat);
   invert_m4_m4(inverse_diff_mat, diff_mat);
 
   /* Adjust each point */
@@ -1046,6 +1049,7 @@ void ED_gpencil_stroke_reproject(Depsgraph *depsgraph,
 
   float diff_mat[4][4], inverse_diff_mat[4][4];
   BKE_gpencil_layer_transform_matrix_get(depsgraph, gsc->ob, gpl, diff_mat);
+  zero_axis_bias_m4(diff_mat);
   invert_m4_m4(inverse_diff_mat, diff_mat);
 
   float origin[3];

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [7163a834506] master: Fix addons submodule ref

2022-10-06 Thread Sebastian Parborg
Commit: 7163a83450655316900a91c6a24c8abf155c3e71
Author: Sebastian Parborg
Date:   Thu Oct 6 12:51:34 2022 +0200
Branches: master
https://developer.blender.org/rB7163a83450655316900a91c6a24c8abf155c3e71

Fix addons submodule ref

Was downgraded to a version from 2019 by mistake

===

M   release/scripts/addons

===

diff --git a/release/scripts/addons b/release/scripts/addons
index 67f1fbca148..eb09be71a96 16
--- a/release/scripts/addons
+++ b/release/scripts/addons
@@ -1 +1 @@
-Subproject commit 67f1fbca1482d9d9362a4001332e785c3fd5d230
+Subproject commit eb09be71a96c4fe910fdc43373be5ec08b419d2c

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [5e2b2348559] sculpt-dev: sculpt-dev: fix draw face sets brush

2022-10-06 Thread Joseph Eagar
Commit: 5e2b2348559989866ac30c4f1f207cb784f0b8f3
Author: Joseph Eagar
Date:   Thu Oct 6 02:18:21 2022 -0700
Branches: sculpt-dev
https://developer.blender.org/rB5e2b2348559989866ac30c4f1f207cb784f0b8f3

sculpt-dev: fix draw face sets brush

===

M   source/blender/draw/intern/draw_pbvh.cc
M   source/blender/editors/sculpt_paint/sculpt_automasking.cc
M   source/blender/editors/sculpt_paint/sculpt_face_set.cc

===

diff --git a/source/blender/draw/intern/draw_pbvh.cc 
b/source/blender/draw/intern/draw_pbvh.cc
index 9e4779eca81..cc0b6a3c005 100644
--- a/source/blender/draw/intern/draw_pbvh.cc
+++ b/source/blender/draw/intern/draw_pbvh.cc
@@ -975,7 +975,13 @@ struct PBVHBatches {
 uchar face_set_color[4];
 int fset = BM_ELEM_CD_GET_INT(l->f, cd_fset);
 
-BKE_paint_face_set_overlay_color_get(fset, 
args->face_sets_color_seed, face_set_color);
+if (fset != args->face_sets_color_default) {
+  BKE_paint_face_set_overlay_color_get(
+  fset, args->face_sets_color_seed, face_set_color);
+}
+else {
+  face_set_color[0] = face_set_color[1] = face_set_color[2] = 255;
+}
 
 *static_cast(GPU_vertbuf_raw_step(&access)) = 
face_set_color;
   });
diff --git a/source/blender/editors/sculpt_paint/sculpt_automasking.cc 
b/source/blender/editors/sculpt_paint/sculpt_automasking.cc
index 41767d4857a..cd8d9823527 100644
--- a/source/blender/editors/sculpt_paint/sculpt_automasking.cc
+++ b/source/blender/editors/sculpt_paint/sculpt_automasking.cc
@@ -83,9 +83,6 @@ bool SCULPT_is_automasking_mode_enabled(const Sculpt *sd,
 
 bool SCULPT_is_automasking_enabled(const Sculpt *sd, const SculptSession *ss, 
const Brush *br)
 {
-  if (br && SCULPT_stroke_is_dynamic_topology(ss, br)) {
-return false;
-  }
   if (SCULPT_is_automasking_mode_enabled(sd, br, BRUSH_AUTOMASKING_TOPOLOGY)) {
 return true;
   }
@@ -746,7 +743,6 @@ void 
SCULPT_automasking_cache_settings_update(AutomaskingCache *automasking,
   const Brush *brush)
 {
   automasking->settings.flags = sculpt_automasking_mode_effective_bits(sd, 
brush);
-  automasking->settings.initial_face_set = SCULPT_active_face_set_get(ss);
 
   automasking->settings.view_normal_limit = sd->automasking_view_normal_limit;
   automasking->settings.view_normal_falloff = 
sd->automasking_view_normal_falloff;
@@ -820,6 +816,10 @@ AutomaskingCache *SCULPT_automasking_cache_init(Sculpt 
*sd, const Brush *brush,
 
   AutomaskingCache *automasking = (AutomaskingCache 
*)MEM_callocN(sizeof(AutomaskingCache),
   "automasking 
cache");
+
+  automasking->settings.initial_face_set = SCULPT_active_face_set_get(ss);
+  automasking->settings.current_face_set = 
automasking->settings.initial_face_set;
+
   SCULPT_automasking_cache_settings_update(automasking, ss, sd, brush);
   SCULPT_boundary_info_ensure(ob);
 
diff --git a/source/blender/editors/sculpt_paint/sculpt_face_set.cc 
b/source/blender/editors/sculpt_paint/sculpt_face_set.cc
index daf0d3e66b1..8b4c298dadd 100644
--- a/source/blender/editors/sculpt_paint/sculpt_face_set.cc
+++ b/source/blender/editors/sculpt_paint/sculpt_face_set.cc
@@ -306,9 +306,9 @@ static int new_fset_apply_curve(SculptSession *ss,
   return new_fset;
 }
 
-void do_draw_face_sets_brush_task_cb_ex(void *__restrict userdata,
-const int n,
-const TaskParallelTLS *__restrict tls)
+ATTR_NO_OPT void do_draw_face_sets_brush_task_cb_ex(void *__restrict userdata,
+const int n,
+const TaskParallelTLS 
*__restrict tls)
 {
   SculptFaceSetDrawData *data = (SculptFaceSetDrawData *)userdata;
   SculptSession *ss = data->ob->sculpt;
@@ -340,7 +340,7 @@ void do_draw_face_sets_brush_task_cb_ex(void *__restrict 
userdata,
   /*check if we need to sample the current face set*/
 
   bool set_active_faceset = ss->cache->automasking &&
-(brush->automasking_flags & 
BRUSH_AUTOMASKING_FACE_SETS);
+(ss->cache->automasking->settings.flags & 
BRUSH_AUTOMASKING_FACE_SETS);
   set_active_faceset = set_active_faceset && ss->cache->invert;
   set_active_faceset = set_active_faceset && 
ss->cache->automasking->settings.initial_face_set ==
  
ss->cache->automasking->settings.current_face_set;
@@ -661,7 +661,7 @@ static void do_relax_face_sets_brush_task_cb_ex(void 
*__restrict userdata,
   BKE_pbvh_vertex_iter_end;
 }
 
-void SCULPT_do_draw_face_sets_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, 
int totnode)
+ATTR_NO_OPT void SCULPT_do_draw

[Bf-blender-cvs] [42948e2389d] sculpt-dev: sculpt-dev: Fix draw bug

2022-10-06 Thread Joseph Eagar
Commit: 42948e2389dfdbc575496ab109367fd6c8b06721
Author: Joseph Eagar
Date:   Thu Oct 6 01:47:05 2022 -0700
Branches: sculpt-dev
https://developer.blender.org/rB42948e2389dfdbc575496ab109367fd6c8b06721

sculpt-dev: Fix draw bug

===

M   source/blender/blenkernel/BKE_paint.h
M   source/blender/blenkernel/BKE_pbvh.h
M   source/blender/blenkernel/intern/paint.cc
M   source/blender/blenkernel/intern/pbvh_bmesh.c
M   source/blender/blenkernel/intern/pbvh_intern.h
M   source/blender/draw/intern/draw_pbvh.cc

===

diff --git a/source/blender/blenkernel/BKE_paint.h 
b/source/blender/blenkernel/BKE_paint.h
index 286b1f17b34..1628ab6b0d3 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -820,6 +820,9 @@ typedef struct SculptSession {
   /* BMesh for dynamic topology sculpting */
   struct BMesh *bm;
 
+  /* TODO: get rid of these cd_ members and use
+   * .attrs.XXX.bmesh_cd_offset directly.
+   */
   int cd_sculpt_vert;
   int cd_vert_node_offset;
   int cd_face_node_offset;
@@ -827,6 +830,7 @@ typedef struct SculptSession {
   int cd_vert_mask_offset;
   int cd_faceset_offset;
   int cd_face_areas;
+  int cd_hide_poly;
 
   int totuv;
 
diff --git a/source/blender/blenkernel/BKE_pbvh.h 
b/source/blender/blenkernel/BKE_pbvh.h
index 8b8a3ac73a1..6c03c254f17 100644
--- a/source/blender/blenkernel/BKE_pbvh.h
+++ b/source/blender/blenkernel/BKE_pbvh.h
@@ -432,7 +432,8 @@ void BKE_pbvh_update_offsets(PBVH *pbvh,
  const int cd_vert_node_offset,
  const int cd_face_node_offset,
  const int cd_sculpt_vert,
- const int cd_face_areas);
+ const int cd_face_areas,
+ const int cd_hide_poly);
 
 void BKE_pbvh_update_bmesh_offsets(PBVH *pbvh, int cd_vert_node_offset, int 
cd_face_node_offset);
 
diff --git a/source/blender/blenkernel/intern/paint.cc 
b/source/blender/blenkernel/intern/paint.cc
index 0583068108f..c807d600280 100644
--- a/source/blender/blenkernel/intern/paint.cc
+++ b/source/blender/blenkernel/intern/paint.cc
@@ -3532,12 +3532,14 @@ static void 
sculptsession_bmesh_attr_update_internal(Object *ob)
   if (ss->pbvh) {
 int cd_sculpt_vert = CustomData_get_offset(&ss->bm->vdata, 
CD_DYNTOPO_VERT);
 int cd_face_area = ss->attrs.face_areas ? 
ss->attrs.face_areas->bmesh_cd_offset : -1;
+int cd_hide_poly = ss->attrs.hide_poly ? 
ss->attrs.hide_poly->bmesh_cd_offset : -1;
 
 BKE_pbvh_update_offsets(ss->pbvh,
-
ob->sculpt->attrs.dyntopo_node_id_vertex->bmesh_cd_offset,
-
ob->sculpt->attrs.dyntopo_node_id_face->bmesh_cd_offset,
+ss->attrs.dyntopo_node_id_vertex->bmesh_cd_offset,
+ss->attrs.dyntopo_node_id_face->bmesh_cd_offset,
 cd_sculpt_vert,
-cd_face_area);
+cd_face_area,
+cd_hide_poly);
   }
 }
 
@@ -3580,6 +3582,7 @@ static void sculptsession_bmesh_add_layers(Object *ob)
   ss->cd_face_node_offset = ss->attrs.dyntopo_node_id_face->bmesh_cd_offset;
   ss->cd_face_areas = ss->attrs.face_areas->bmesh_cd_offset;
   ss->cd_sculpt_vert = ss->attrs.sculpt_vert->bmesh_cd_offset;
+  ss->cd_hide_poly = ss->attrs.hide_poly ? 
ss->attrs.hide_poly->bmesh_cd_offset : -1;
 }
 
 void BKE_sculpt_attributes_destroy_temporary_stroke(Object *ob)
@@ -3622,13 +3625,15 @@ static void update_bmesh_offsets(Mesh *me, 
SculptSession *ss)
   ss->cd_faceset_offset = CustomData_get_offset_named(
   &ss->bm->pdata, CD_PROP_INT32, ".sculpt_face_set");
   ss->cd_face_areas = ss->attrs.face_areas ? 
ss->attrs.face_areas->bmesh_cd_offset : -1;
+  ss->cd_hide_poly = ss->attrs.hide_poly ? 
ss->attrs.hide_poly->bmesh_cd_offset : -1;
 
   if (ss->pbvh) {
 BKE_pbvh_update_offsets(ss->pbvh,
 ss->cd_vert_node_offset,
 ss->cd_face_node_offset,
 ss->cd_sculpt_vert,
-ss->cd_face_areas);
+ss->cd_face_areas,
+ss->cd_hide_poly);
   }
 }
 
diff --git a/source/blender/blenkernel/intern/pbvh_bmesh.c 
b/source/blender/blenkernel/intern/pbvh_bmesh.c
index d0e45115438..9ce20bec6ff 100644
--- a/source/blender/blenkernel/intern/pbvh_bmesh.c
+++ b/source/blender/blenkernel/intern/pbvh_bmesh.c
@@ -252,6 +252,8 @@ static void pbvh_bmesh_node_finalize(PBVH *pbvh,
   BB_reset(&n->orig_vb);
   BMFace *f;
 
+  int cd_hide_poly = pbvh->cd_hide_poly;
+
   TGSET_ITER (f, n->bm_faces) {
 /* Update ownership of faces */
 BM_ELEM_CD_SET_INT(f, cd_face_node_offset, node_index);
@@ -279,7 +281,7 @@ static void

[Bf-blender-cvs] [65c248af724] cycles_path_guiding: Cycles: Explicitly reset all guiding related state variables at path initialization

2022-10-06 Thread Sebastian Herholz
Commit: 65c248af724ee11b1e68d90486930d1c309e3597
Author: Sebastian Herholz
Date:   Thu Oct 6 10:42:55 2022 +0200
Branches: cycles_path_guiding
https://developer.blender.org/rB65c248af724ee11b1e68d90486930d1c309e3597

Cycles: Explicitly reset all guiding related state variables at path 
initialization

===

M   intern/cycles/kernel/integrator/path_state.h

===

diff --git a/intern/cycles/kernel/integrator/path_state.h 
b/intern/cycles/kernel/integrator/path_state.h
index dbc6fc5a883..7197f0f2f3a 100644
--- a/intern/cycles/kernel/integrator/path_state.h
+++ b/intern/cycles/kernel/integrator/path_state.h
@@ -59,6 +59,13 @@ ccl_device_inline void 
path_state_init_integrator(KernelGlobals kg,
 #ifdef __PATH_GUIDING__
   INTEGRATOR_STATE_WRITE(state, path, unguided_throughput) = 1.0f;
   INTEGRATOR_STATE_WRITE(state, guiding, path_segment) = nullptr;
+  INTEGRATOR_STATE_WRITE(state, guiding, use_surface_guiding) = false;
+  INTEGRATOR_STATE_WRITE(state, guiding, sample_surface_guiding_rand) = 0.5f;
+  INTEGRATOR_STATE_WRITE(state, guiding, surface_guiding_sampling_prob) = 0.0f;
+  INTEGRATOR_STATE_WRITE(state, guiding, bssrdf_sampling_prob) = 0.0f;
+  INTEGRATOR_STATE_WRITE(state, guiding, use_volume_guiding) = false;
+  INTEGRATOR_STATE_WRITE(state, guiding, sample_volume_guiding_rand) = 0.5f;
+  INTEGRATOR_STATE_WRITE(state, guiding, volume_guiding_sampling_prob) = 0.0f;
 #endif
 
 #ifdef __MNEE__

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [896a333867e] cycles_path_guiding: Cycles: Do not use path guiding in (almost) delta volumes

2022-10-06 Thread Sebastian Herholz
Commit: 896a333867e04233a1aa7f16f42e2b8fed927608
Author: Sebastian Herholz
Date:   Thu Oct 6 10:41:05 2022 +0200
Branches: cycles_path_guiding
https://developer.blender.org/rB896a333867e04233a1aa7f16f42e2b8fed927608

Cycles: Do not use path guiding in (almost) delta volumes

===

M   intern/cycles/kernel/integrator/guiding.h

===

diff --git a/intern/cycles/kernel/integrator/guiding.h 
b/intern/cycles/kernel/integrator/guiding.h
index 5904b69b046..634bba2a9b4 100644
--- a/intern/cycles/kernel/integrator/guiding.h
+++ b/intern/cycles/kernel/integrator/guiding.h
@@ -501,6 +501,11 @@ ccl_device_forceinline bool 
guiding_phase_init(KernelGlobals kg,
ccl_private float &rand)
 {
 #if defined(__PATH_GUIDING__) && PATH_GUIDING_LEVEL >= 4
+  /* we do not need to guide almost delta phase functions */
+  if (fabsf(g) >= 0.99f) {
+return false;
+  }
+
   if (kg->opgl_volume_sampling_distribution->Init(
   kg->opgl_guiding_field, guiding_point3f(P), rand, true)) {
 
kg->opgl_volume_sampling_distribution->ApplySingleLobeHenyeyGreensteinProduct(guiding_vec3f(D),

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [5ce446f90cf] cycles_path_guiding: Cycles: enable the use of external Open PGL builds

2022-10-06 Thread Sebastian Herholz
Commit: 5ce446f90cffa0f65538593e65bee12d47cd2773
Author: Sebastian Herholz
Date:   Thu Oct 6 10:37:22 2022 +0200
Branches: cycles_path_guiding
https://developer.blender.org/rB5ce446f90cffa0f65538593e65bee12d47cd2773

Cycles: enable the use of external Open PGL builds

===

M   intern/cycles/cmake/external_libs.cmake

===

diff --git a/intern/cycles/cmake/external_libs.cmake 
b/intern/cycles/cmake/external_libs.cmake
index 9335024f2eb..9524cda54f5 100644
--- a/intern/cycles/cmake/external_libs.cmake
+++ b/intern/cycles/cmake/external_libs.cmake
@@ -274,7 +274,7 @@ endif()
 ###
 
 if(CYCLES_STANDALONE_REPOSITORY AND WITH_CYCLES_PATH_GUIDING)
-  if(EXISTS ${_cycles_lib_dir})
+  if(NOT openpgl_DIR AND EXISTS ${_cycles_lib_dir})
 set(openpgl_DIR ${_cycles_lib_dir}/openpgl/lib/cmake/openpgl)
   endif()

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [f93823e9d4f] cycles_path_guiding: Merge branch 'master' into cycles_path_guiding

2022-10-06 Thread Sebastian Herholz
Commit: f93823e9d4f1cffd85701a90a9484c469672be37
Author: Sebastian Herholz
Date:   Thu Oct 6 10:27:42 2022 +0200
Branches: cycles_path_guiding
https://developer.blender.org/rBf93823e9d4f1cffd85701a90a9484c469672be37

Merge branch 'master' into cycles_path_guiding

# Conflicts:
#   build_files/build_environment/cmake/harvest.cmake
#   intern/cycles/cmake/external_libs.cmake
#   intern/cycles/integrator/path_trace.cpp
#   intern/cycles/integrator/path_trace_work_cpu.h
#   intern/cycles/kernel/integrator/guiding.h
#   intern/cycles/kernel/integrator/state_template.h
#   intern/cycles/kernel/integrator/volume_shader.h

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [8b485e72260] master: I18n: ignore user-installed add-ons when extracting bl_info

2022-10-06 Thread Damien Picard
Commit: 8b485e72260fa1903e6cfe82fdabe9bf45e90886
Author: Damien Picard
Date:   Thu Oct 6 10:28:18 2022 +0200
Branches: master
https://developer.blender.org/rB8b485e72260fa1903e6cfe82fdabe9bf45e90886

I18n: ignore user-installed add-ons when extracting bl_info

Since add-on info was made translatable in D15747, user-installed
add-ons could also get their info extracted. This led to having
different messages depending on the environment of the Blender doing
the I18n messages update.

Reviewed By: mont29

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

===

M   release/scripts/modules/bl_i18n_utils/bl_extract_messages.py

===

diff --git a/release/scripts/modules/bl_i18n_utils/bl_extract_messages.py 
b/release/scripts/modules/bl_i18n_utils/bl_extract_messages.py
index 21ca38bff20..18a41d86322 100644
--- a/release/scripts/modules/bl_i18n_utils/bl_extract_messages.py
+++ b/release/scripts/modules/bl_i18n_utils/bl_extract_messages.py
@@ -978,17 +978,30 @@ def dump_messages(do_messages, do_checks, settings):
 # Get strings from addons' bl_info.
 import addon_utils
 for module in addon_utils.modules():
-if module.bl_info['support'] != 'OFFICIAL':
+# Only process official add-ons, i.e. those marked as 'OFFICIAL' and
+# existing in the system add-ons directory (not user-installed ones).
+if (module.bl_info['support'] != 'OFFICIAL'
+or not bpy.path.is_subdir(module.__file__, 
bpy.utils.system_resource('SCRIPTS'))):
 continue
 dump_addon_bl_info(msgs, reports, module, settings)
 
 # Get strings from addons' categories.
+system_categories = set()
+for module in addon_utils.modules():
+if bpy.path.is_subdir(module.__file__, 
bpy.utils.system_resource('SCRIPTS')):
+system_categories.add(module.bl_info['category'])
 for uid, label, tip in 
bpy.types.WindowManager.addon_filter.keywords['items'](
 bpy.context.window_manager,
 bpy.context,
 ):
-process_msg(msgs, settings.DEFAULT_CONTEXT, label, "Add-ons' 
categories", reports, None, settings)
-if tip:
+if label in system_categories:
+# Only process add-on if it a system one (i.e shipped with 
Blender). Also,
+# we do want to translate official categories, even if they have 
no official add-ons,
+# hence the different test than below.
+process_msg(msgs, settings.DEFAULT_CONTEXT, label, "Add-ons' 
categories", reports, None, settings)
+elif tip:
+# Only special categories get a tip (All and User).
+process_msg(msgs, settings.DEFAULT_CONTEXT, label, "Add-ons' 
categories", reports, None, settings)
 process_msg(msgs, settings.DEFAULT_CONTEXT, tip, "Add-ons' 
categories", reports, None, settings)
 
 # Get strings specific to translations' menu.

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [0598a4b3606] sculpt-dev: sculpt-dev: Fix code being in wrong order

2022-10-06 Thread Joseph Eagar
Commit: 0598a4b3606e394d086ca5d100bbae8371e15a86
Author: Joseph Eagar
Date:   Thu Oct 6 01:21:20 2022 -0700
Branches: sculpt-dev
https://developer.blender.org/rB0598a4b3606e394d086ca5d100bbae8371e15a86

sculpt-dev: Fix code being in wrong order

===

M   source/blender/blenkernel/intern/paint.cc

===

diff --git a/source/blender/blenkernel/intern/paint.cc 
b/source/blender/blenkernel/intern/paint.cc
index 34557276441..0583068108f 100644
--- a/source/blender/blenkernel/intern/paint.cc
+++ b/source/blender/blenkernel/intern/paint.cc
@@ -2896,10 +2896,10 @@ PBVH *BKE_sculpt_object_pbvh_ensure(Depsgraph 
*depsgraph, Object *ob)
   }
 
   BKE_pbvh_set_pmap(pbvh, ob->sculpt->pmap);
-  sculpt_attribute_update_refs(ob);
-
   ob->sculpt->pbvh = pbvh;
 
+  sculpt_attribute_update_refs(ob);
+
   if (pbvh) {
 SCULPT_update_flat_vcol_shading(ob, scene);
   }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [247af8cf5ba] master: UI Translations: Add context to 'New' menu entries for files.

2022-10-06 Thread Bastien Montagne
Commit: 247af8cf5ba4e75a05e6929a4c85569503e92733
Author: Bastien Montagne
Date:   Thu Oct 6 10:16:09 2022 +0200
Branches: master
https://developer.blender.org/rB247af8cf5ba4e75a05e6929a4c85569503e92733

UI Translations: Add context to 'New' menu entries for files.

Aftermath of rBf5d67f3fdf2d and rBa096248d1253, from D16159 (did not
apply direclty).

===

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

===

diff --git a/release/scripts/startup/bl_ui/space_topbar.py 
b/release/scripts/startup/bl_ui/space_topbar.py
index 895e2deb31c..b1ddd2c611d 100644
--- a/release/scripts/startup/bl_ui/space_topbar.py
+++ b/release/scripts/startup/bl_ui/space_topbar.py
@@ -272,7 +272,7 @@ class TOPBAR_MT_file(Menu):
 layout = self.layout
 
 layout.operator_context = 'INVOKE_AREA'
-layout.menu("TOPBAR_MT_file_new", text="New", icon='FILE_NEW')
+layout.menu("TOPBAR_MT_file_new", text="New", 
text_ctxt=i18n_contexts.id_windowmanager, icon='FILE_NEW')
 layout.operator("wm.open_mainfile", text="Open...", icon='FILE_FOLDER')
 layout.menu("TOPBAR_MT_file_open_recent")
 layout.operator("wm.revert_mainfile")
@@ -727,7 +727,7 @@ class TOPBAR_MT_file_context_menu(Menu):
 layout = self.layout
 
 layout.operator_context = 'INVOKE_AREA'
-layout.menu("TOPBAR_MT_file_new", text="New", icon='FILE_NEW')
+layout.menu("TOPBAR_MT_file_new", text="New", 
text_ctxt=i18n_contexts.id_windowmanager, icon='FILE_NEW')
 layout.operator("wm.open_mainfile", text="Open...", icon='FILE_FOLDER')
 
 layout.separator()

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [059fb4098f5] sculpt-dev: sculpt-dev: Various fixes

2022-10-06 Thread Joseph Eagar
Commit: 059fb4098f54d381bb2bc7a7f2c9054a78492663
Author: Joseph Eagar
Date:   Thu Oct 6 01:08:36 2022 -0700
Branches: sculpt-dev
https://developer.blender.org/rB059fb4098f54d381bb2bc7a7f2c9054a78492663

sculpt-dev: Various fixes

* Fix memory corruption in sculpt attribute code.
* Fix a few compile errors for particularly pedantic compilers.
* Consolidate a bit of ASAN code in customdata.cc.

===

M   source/blender/blenkernel/intern/customdata.cc
M   source/blender/blenkernel/intern/mesh_mapping.cc
M   source/blender/blenkernel/intern/paint.cc
M   source/blender/blenkernel/intern/pbvh.c
M   source/blender/editors/sculpt_paint/sculpt_automasking.cc

===

diff --git a/source/blender/blenkernel/intern/customdata.cc 
b/source/blender/blenkernel/intern/customdata.cc
index ff1a886543f..ac0a5bffb02 100644
--- a/source/blender/blenkernel/intern/customdata.cc
+++ b/source/blender/blenkernel/intern/customdata.cc
@@ -70,6 +70,9 @@ using blender::Vector;
 #define CUSTOMDATA_GROW 5
 
 #define BM_ASAN_PAD 32
+#if defined(__SANITIZE_ADDRESS__) || __has_feature(address_sanitizer)
+#  define CD_HAVE_ASAN
+#endif
 
 /* ensure typemap size is ok */
 BLI_STATIC_ASSERT(ARRAY_SIZE(((CustomData *)nullptr)->typemap) == CD_NUMTYPES, 
"size mismatch");
@@ -2835,11 +2838,13 @@ static void customData_update_offsets(CustomData *data)
 
   // do large structs first
   for (int j = 0; j < data->totlayer; j++) {
-typeInfo = layerType_getInfo(data->layers[j].type);
+CustomDataLayer *layer = data->layers + j;
+
+typeInfo = layerType_getInfo(layer->type);
 int size = (int)typeInfo->size;
 
 /* Float vectors get 4-byte alignment. */
-if (ELEM(data->layers[j].type, CD_PROP_COLOR, CD_PROP_FLOAT2, 
CD_PROP_FLOAT3)) {
+if (ELEM(layer->type, CD_PROP_COLOR, CD_PROP_FLOAT2, CD_PROP_FLOAT3)) {
   alignment = max_ii(alignment, 4);
 }
 else if (size > 4) {
@@ -2864,14 +2869,14 @@ static void customData_update_offsets(CustomData *data)
 size += 8 - (size & 7);
   }
 
-#if (defined(__SANITIZE_ADDRESS__) || __has_feature(address_sanitizer))
+#ifdef CD_HAVE_ASAN
   offset += BM_ASAN_PAD;
 #endif
 
-  data->layers[j].offset = offset;
+  layer->offset = offset;
   offset += size;
 
-#if (defined(__SANITIZE_ADDRESS__) || __has_feature(address_sanitizer))
+#ifdef CD_HAVE_ASAN
   offset += BM_ASAN_PAD;
 #endif
 }
@@ -2879,18 +2884,20 @@ static void customData_update_offsets(CustomData *data)
 
   for (int i = 0; i < ARRAY_SIZE(aligns) + 1; i++) {
 for (int j = 0; j < data->totlayer; j++) {
+  CustomDataLayer *layer = data->layers + j;
+
   if (BLI_BITMAP_TEST(donemap, j)) {
 continue;
   }
 
-  typeInfo = layerType_getInfo(data->layers[j].type);
+  typeInfo = layerType_getInfo(layer->type);
   int size = (int)typeInfo->size;
 
   if (i < ARRAY_SIZE(aligns) && (size % aligns[i]) != 0) {
 continue;
   }
 
-#if (defined(__SANITIZE_ADDRESS__) || __has_feature(address_sanitizer))
+#ifdef CD_HAVE_ASAN
   offset += BM_ASAN_PAD;
 #endif
 
@@ -2901,10 +2908,10 @@ static void customData_update_offsets(CustomData *data)
 offset += align2;
   }
 
-  data->layers[j].offset = offset;
+  layer->offset = offset;
   offset += size;
 
-#if (defined(__SANITIZE_ADDRESS__) || __has_feature(address_sanitizer))
+#ifdef CD_HAVE_ASAN
   offset += BM_ASAN_PAD;
 #endif
 }
@@ -2921,7 +2928,7 @@ static void customData_update_offsets(CustomData *data)
 
 void CustomData_bmesh_asan_poison(const CustomData *data, void *block)
 {
-#if (defined(__SANITIZE_ADDRESS__) || __has_feature(address_sanitizer))
+#ifdef CD_HAVE_ASAN
   if (!block) {
 return;
   }
diff --git a/source/blender/blenkernel/intern/mesh_mapping.cc 
b/source/blender/blenkernel/intern/mesh_mapping.cc
index c308961bc98..8b704330da4 100644
--- a/source/blender/blenkernel/intern/mesh_mapping.cc
+++ b/source/blender/blenkernel/intern/mesh_mapping.cc
@@ -227,6 +227,9 @@ static void calc_cloud_normal(DiskCycleSortData *varr,
   }
 
   float dir_a[3];
+  const float *co_a_opposite = NULL;
+  const float *co_b_opposite = NULL;
+
   sub_v3_v3v3(dir_a, co_a, center);
   normalize_v3(dir_a);
 
@@ -257,9 +260,6 @@ static void calc_cloud_normal(DiskCycleSortData *varr,
 
   normalize_v3(dir_b);
 
-  const float *co_a_opposite = NULL;
-  const float *co_b_opposite = NULL;
-
   {
 float dot_a_min = FLT_MAX;
 float dot_b_min = FLT_MAX;
diff --git a/source/blender/blenkernel/intern/paint.cc 
b/source/blender/blenkernel/intern/paint.cc
index 4fd53a341ef..34557276441 100644
--- a/source/blender/blenkernel/intern/paint.cc
+++ b/source/blender/blenkernel/intern/paint.cc
@@ -3202,14 +3202,14 @@ static int sculpt_attr_elem_count_get(Object *ob, 
eAttrDomain domain)
   }
 }
 
-static bool sculpt_attribute_create(SculptSession *ss,
-