[Bf-blender-cvs] [d8094f9212c] master: GHOST/Wayland: partial support for updating the UI scale

2022-07-14 Thread Campbell Barton
Commit: d8094f9212c1703e6230825780c06beb630f6d19
Author: Campbell Barton
Date:   Fri Jul 15 15:42:24 2022 +1000
Branches: master
https://developer.blender.org/rBd8094f9212c1703e6230825780c06beb630f6d19

GHOST/Wayland: partial support for updating the UI scale

Partial support for changing the UI scale while Blender is open.

The scale is set but issues with the window size not updating remain.

===

M   intern/ghost/intern/GHOST_SystemWayland.cpp

===

diff --git a/intern/ghost/intern/GHOST_SystemWayland.cpp 
b/intern/ghost/intern/GHOST_SystemWayland.cpp
index 4124cd059b3..d7520f1243f 100644
--- a/intern/ghost/intern/GHOST_SystemWayland.cpp
+++ b/intern/ghost/intern/GHOST_SystemWayland.cpp
@@ -2597,7 +2597,17 @@ static void output_handle_done(void *data, struct 
wl_output * /*wl_output*/)
 
 static void output_handle_scale(void *data, struct wl_output * /*wl_output*/, 
const int32_t factor)
 {
+  CLOG_INFO(LOG, 2, "scale");
   static_cast(data)->scale = factor;
+
+  if (window_manager) {
+for (GHOST_IWindow *iwin : window_manager->getWindows()) {
+  GHOST_WindowWayland *win = static_cast(iwin);
+  win->outputs_changed_update_scale();
+  /* TODO(@campbellbarton): support refreshing the UI when the DPI changes.
+   * There are glitches when resizing the monitor which would be nice to 
solve. */
+}
+  }
 }
 
 static const struct wl_output_listener output_listener = {

___
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] [60f260eb6a2] master: GHOST/Wayland: fix error setting the cursor scale

2022-07-14 Thread Campbell Barton
Commit: 60f260eb6a21a1bf7ef92ae2a09eb107bbcb0e4a
Author: Campbell Barton
Date:   Fri Jul 15 15:36:21 2022 +1000
Branches: master
https://developer.blender.org/rB60f260eb6a21a1bf7ef92ae2a09eb107bbcb0e4a

GHOST/Wayland: fix error setting the cursor scale

Calculate a scale that's compatible with the cursor size.
Needed so the cursor is always a multiple of scale.

===

M   intern/ghost/intern/GHOST_SystemWayland.cpp

===

diff --git a/intern/ghost/intern/GHOST_SystemWayland.cpp 
b/intern/ghost/intern/GHOST_SystemWayland.cpp
index 099792a4d06..4124cd059b3 100644
--- a/intern/ghost/intern/GHOST_SystemWayland.cpp
+++ b/intern/ghost/intern/GHOST_SystemWayland.cpp
@@ -3275,6 +3275,23 @@ static void cursor_buffer_hide(const input_t *input)
   }
 }
 
+/**
+ * Needed to ensure the cursor size is always a multiple of scale.
+ */
+static int cursor_buffer_compatible_scale_from_image(const struct 
wl_cursor_image *wl_image,
+ int scale)
+{
+  const int32_t image_size_x = int32_t(wl_image->width);
+  const int32_t image_size_y = int32_t(wl_image->height);
+  while (scale > 1) {
+if ((image_size_x % scale) == 0 && (image_size_y % scale) == 0) {
+  break;
+}
+scale -= 1;
+  }
+  return scale;
+}
+
 static void cursor_buffer_set_surface_impl(const input_t *input,
wl_buffer *buffer,
struct wl_surface *wl_surface,
@@ -3301,7 +3318,8 @@ static void cursor_buffer_set(const input_t *input, 
wl_buffer *buffer)
   /* This is a requirement of WAYLAND, when this isn't the case,
* it causes Blender's window to close intermittently. */
   if (input->wl_pointer) {
-const int scale = c->is_custom ? c->custom_scale : 
input->pointer.theme_scale;
+const int scale = cursor_buffer_compatible_scale_from_image(
+wl_image, c->is_custom ? c->custom_scale : input->pointer.theme_scale);
 const int32_t hotspot_x = int32_t(wl_image->hotspot_x) / scale;
 const int32_t hotspot_y = int32_t(wl_image->hotspot_y) / scale;
 cursor_buffer_set_surface_impl(input, buffer, c->wl_surface, scale);
@@ -3314,7 +3332,8 @@ static void cursor_buffer_set(const input_t *input, 
wl_buffer *buffer)
 
   /* Set the cursor for all tablet tools as well. */
   if (!input->tablet_tools.empty()) {
-const int scale = c->is_custom ? c->custom_scale : 
input->tablet.theme_scale;
+const int scale = cursor_buffer_compatible_scale_from_image(
+wl_image, c->is_custom ? c->custom_scale : input->tablet.theme_scale);
 const int32_t hotspot_x = int32_t(wl_image->hotspot_x) / scale;
 const int32_t hotspot_y = int32_t(wl_image->hotspot_y) / scale;
 for (struct zwp_tablet_tool_v2 *zwp_tablet_tool_v2 : input->tablet_tools) {

___
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] [d14d5705807] master: blend_render_info: add check for negative BHead length (corrupt file)

2022-07-14 Thread Campbell Barton
Commit: d14d5705807c8216f3cfb1de3af6f448a1401599
Author: Campbell Barton
Date:   Fri Jul 15 14:52:32 2022 +1000
Branches: master
https://developer.blender.org/rBd14d5705807c8216f3cfb1de3af6f448a1401599

blend_render_info: add check for negative BHead length (corrupt file)

Without this check, corrupt files would raise a Python exception,
now early exit with a useful error.

===

M   release/scripts/modules/blend_render_info.py

===

diff --git a/release/scripts/modules/blend_render_info.py 
b/release/scripts/modules/blend_render_info.py
index 37c5f6dd3ba..6b45a6f7e72 100755
--- a/release/scripts/modules/blend_render_info.py
+++ b/release/scripts/modules/blend_render_info.py
@@ -93,6 +93,11 @@ def _read_blend_rend_chunk_from_file(blendfile, filepath):
 break
 
 sizeof_data_left = struct.unpack('>i' if is_big_endian else 'https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [c8e8f107bf8] master: Fix T99711: Eternal loop reading blend file thumbnail

2022-07-14 Thread Campbell Barton
Commit: c8e8f107bf82fb56f49101e1098f4c697b16cfeb
Author: Campbell Barton
Date:   Fri Jul 15 14:47:18 2022 +1000
Branches: master
https://developer.blender.org/rBc8e8f107bf82fb56f49101e1098f4c697b16cfeb

Fix T99711: Eternal loop reading blend file thumbnail

Account for negative BHead length (already handled by blend file loading).

===

M   source/blender/blendthumb/src/blendthumb_extract.cc

===

diff --git a/source/blender/blendthumb/src/blendthumb_extract.cc 
b/source/blender/blendthumb/src/blendthumb_extract.cc
index 369da559fc8..163197c8b67 100644
--- a/source/blender/blendthumb/src/blendthumb_extract.cc
+++ b/source/blender/blendthumb/src/blendthumb_extract.cc
@@ -121,6 +121,9 @@ static eThumbStatus 
blendthumb_extract_from_file_impl(FileReader *file,
   while (file_read(file, bhead_data, bhead_size)) {
 /* Parse type and size from `BHead`. */
 const int32_t block_size = bytes_to_native_i32(_data[4], 
endian_switch);
+if (UNLIKELY(block_size < 0)) {
+  return BT_INVALID_THUMB;
+}
 
 /* We're looking for the thumbnail, so skip any other block. */
 switch (*((int32_t *)bhead_data)) {

___
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] [675f6ef089c] master: Cleanup: Use const pointers for ImageSaveOptions and ImageFormatData

2022-07-14 Thread Jesse Yurkovich
Commit: 675f6ef089ceeed2f03284e7e81e6af7130e46d7
Author: Jesse Yurkovich
Date:   Thu Jul 14 21:27:58 2022 -0700
Branches: master
https://developer.blender.org/rB675f6ef089ceeed2f03284e7e81e6af7130e46d7

Cleanup: Use const pointers for ImageSaveOptions and ImageFormatData

Use const pointers to ImageSaveOptions and ImageFormatData for API
parameters where appropriate.

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

===

M   source/blender/blenkernel/BKE_image.h
M   source/blender/blenkernel/BKE_image_save.h
M   source/blender/blenkernel/BKE_writeffmpeg.h
M   source/blender/blenkernel/intern/image.cc
M   source/blender/blenkernel/intern/image_save.cc
M   source/blender/blenkernel/intern/writeffmpeg.c
M   source/blender/compositor/operations/COM_OutputFileMultiViewOperation.cc
M   source/blender/compositor/operations/COM_OutputFileMultiViewOperation.h
M   source/blender/compositor/operations/COM_OutputFileOperation.cc
M   source/blender/compositor/operations/COM_OutputFileOperation.h
M   source/blender/editors/object/object_bake_api.c
M   source/blender/editors/space_image/image_ops.c
M   source/blender/nodes/NOD_composite.h
M   source/blender/nodes/composite/nodes/node_composite_output_file.cc

===

diff --git a/source/blender/blenkernel/BKE_image.h 
b/source/blender/blenkernel/BKE_image.h
index 6ec1285af0c..4e622a5708f 100644
--- a/source/blender/blenkernel/BKE_image.h
+++ b/source/blender/blenkernel/BKE_image.h
@@ -97,7 +97,7 @@ int BKE_imbuf_write(struct ImBuf *ibuf, const char *name, 
const struct ImageForm
  */
 int BKE_imbuf_write_as(struct ImBuf *ibuf,
const char *name,
-   struct ImageFormatData *imf,
+   const struct ImageFormatData *imf,
bool save_copy);
 
 /**
diff --git a/source/blender/blenkernel/BKE_image_save.h 
b/source/blender/blenkernel/BKE_image_save.h
index 673a7dffb82..e17136174eb 100644
--- a/source/blender/blenkernel/BKE_image_save.h
+++ b/source/blender/blenkernel/BKE_image_save.h
@@ -48,14 +48,14 @@ bool BKE_image_save_options_init(ImageSaveOptions *opts,
  struct ImageUser *iuser,
  const bool guess_path,
  const bool save_as_render);
-void BKE_image_save_options_update(struct ImageSaveOptions *opts, struct Image 
*ima);
+void BKE_image_save_options_update(struct ImageSaveOptions *opts, const struct 
Image *ima);
 void BKE_image_save_options_free(struct ImageSaveOptions *opts);
 
 bool BKE_image_save(struct ReportList *reports,
 struct Main *bmain,
 struct Image *ima,
 struct ImageUser *iuser,
-struct ImageSaveOptions *opts);
+const struct ImageSaveOptions *opts);
 
 /* Render saving. */
 
diff --git a/source/blender/blenkernel/BKE_writeffmpeg.h 
b/source/blender/blenkernel/BKE_writeffmpeg.h
index 3f92d6fa117..736f7548bb4 100644
--- a/source/blender/blenkernel/BKE_writeffmpeg.h
+++ b/source/blender/blenkernel/BKE_writeffmpeg.h
@@ -68,7 +68,7 @@ void BKE_ffmpeg_filepath_get(char *string,
  const char *suffix);
 
 void BKE_ffmpeg_preset_set(struct RenderData *rd, int preset);
-void BKE_ffmpeg_image_type_verify(struct RenderData *rd, struct 
ImageFormatData *imf);
+void BKE_ffmpeg_image_type_verify(struct RenderData *rd, const struct 
ImageFormatData *imf);
 bool BKE_ffmpeg_alpha_channel_is_supported(const struct RenderData *rd);
 
 void *BKE_ffmpeg_context_create(void);
diff --git a/source/blender/blenkernel/intern/image.cc 
b/source/blender/blenkernel/intern/image.cc
index 92e98935e83..6ec1c52c61a 100644
--- a/source/blender/blenkernel/intern/image.cc
+++ b/source/blender/blenkernel/intern/image.cc
@@ -2475,7 +2475,10 @@ int BKE_imbuf_write(ImBuf *ibuf, const char *name, const 
ImageFormatData *imf)
   return ok;
 }
 
-int BKE_imbuf_write_as(ImBuf *ibuf, const char *name, ImageFormatData *imf, 
const bool save_copy)
+int BKE_imbuf_write_as(ImBuf *ibuf,
+   const char *name,
+   const ImageFormatData *imf,
+   const bool save_copy)
 {
   ImBuf ibuf_back = *ibuf;
   int ok;
diff --git a/source/blender/blenkernel/intern/image_save.cc 
b/source/blender/blenkernel/intern/image_save.cc
index 3f6f81845e2..cd86d3f7087 100644
--- a/source/blender/blenkernel/intern/image_save.cc
+++ b/source/blender/blenkernel/intern/image_save.cc
@@ -204,7 +204,7 @@ bool BKE_image_save_options_init(ImageSaveOptions *opts,
   return (ibuf != nullptr);
 }
 
-void BKE_image_save_options_update(ImageSaveOptions *opts, Image *image)
+void BKE_image_save_options_update(ImageSaveOptions *opts, const Image *image)
 {
   /* Auto update color space when 

[Bf-blender-cvs] [178868cf425] master: Fix T79304: improve uv island calculation when in edge selection mode

2022-07-14 Thread Chris Blackbourn
Commit: 178868cf42594bf7eedfa4db93ba8b7f3bf017ce
Author: Chris Blackbourn
Date:   Thu Jul 14 12:40:43 2022 +1200
Branches: master
https://developer.blender.org/rB178868cf42594bf7eedfa4db93ba8b7f3bf017ce

Fix T79304: improve uv island calculation when in edge selection mode

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

===

M   source/blender/editors/mesh/editmesh_utils.c

===

diff --git a/source/blender/editors/mesh/editmesh_utils.c 
b/source/blender/editors/mesh/editmesh_utils.c
index 60a666ee755..ac5530c8ea9 100644
--- a/source/blender/editors/mesh/editmesh_utils.c
+++ b/source/blender/editors/mesh/editmesh_utils.c
@@ -595,6 +595,132 @@ UvMapVert *BM_uv_vert_map_at_index(UvVertMap *vmap, uint 
v)
 
 #define INVALID_ISLAND ((unsigned int)-1)
 
+static void bm_uv_assign_island(UvElementMap *element_map,
+UvElement *element,
+int nisland,
+uint *map,
+UvElement *islandbuf,
+int islandbufsize)
+{
+  element->island = nisland;
+  map[element - element_map->buf] = islandbufsize;
+
+  /* Copy *element to islandbuf[islandbufsize]. */
+  islandbuf[islandbufsize].l = element->l;
+  islandbuf[islandbufsize].separate = element->separate;
+  islandbuf[islandbufsize].loop_of_poly_index = element->loop_of_poly_index;
+  islandbuf[islandbufsize].island = element->island;
+  islandbuf[islandbufsize].flag = element->flag;
+}
+
+static int bm_uv_edge_select_build_islands(UvElementMap *element_map,
+   const Scene *scene,
+   UvElement *islandbuf,
+   uint *map,
+   bool uv_selected,
+   int cd_loop_uv_offset)
+{
+  int totuv = element_map->totalUVs;
+
+  /* For each UvElement, locate the "separate" UvElement that precedes it in 
the linked list. */
+  UvElement **head_table = MEM_mallocN(sizeof(*head_table) * totuv, 
"uv_island_head_table");
+  for (int i = 0; i < totuv; i++) {
+UvElement *head = element_map->buf + i;
+if (head->separate) {
+  UvElement *element = head;
+  while (element) {
+head_table[element - element_map->buf] = head;
+element = element->next;
+if (element && element->separate) {
+  break;
+}
+  }
+}
+  }
+
+  /* Depth first search the graph, building islands as we go. */
+  int nislands = 0;
+  int islandbufsize = 0;
+  int stack_upper_bound = totuv;
+  UvElement **stack_uv = MEM_mallocN(sizeof(*stack_uv) * stack_upper_bound,
+ "uv_island_element_stack");
+  int stacksize_uv = 0;
+  for (int i = 0; i < totuv; i++) {
+UvElement *element = element_map->buf + i;
+if (element->island != INVALID_ISLAND) {
+  /* Unique UV (element and all it's children) are already part of an 
island. */
+  continue;
+}
+
+/* Create a new island, i.e. nislands++. */
+
+BLI_assert(element->separate); /* Ensure we're the head of this unique UV. 
*/
+
+/* Seed the graph search. */
+stack_uv[stacksize_uv++] = element;
+while (element) {
+  bm_uv_assign_island(element_map, element, nislands, map, islandbuf, 
islandbufsize++);
+  element = element->next;
+  if (element && element->separate) {
+break;
+  }
+}
+
+/* Traverse the graph. */
+while (stacksize_uv) {
+  BLI_assert(stacksize_uv < stack_upper_bound);
+  element = stack_uv[--stacksize_uv];
+  while (element) {
+
+/* Scan forwards around the BMFace that contains element->l. */
+if (!uv_selected || uvedit_edge_select_test(scene, element->l, 
cd_loop_uv_offset)) {
+  UvElement *next = BM_uv_element_get(element_map, 
element->l->next->f, element->l->next);
+  if (next->island == INVALID_ISLAND) {
+UvElement *tail = head_table[next - element_map->buf];
+stack_uv[stacksize_uv++] = tail;
+while (tail) {
+  bm_uv_assign_island(element_map, tail, nislands, map, islandbuf, 
islandbufsize++);
+  tail = tail->next;
+  if (tail && tail->separate) {
+break;
+  }
+}
+  }
+}
+
+/* Scan backwards around the BMFace that contains element->l. */
+if (!uv_selected || uvedit_edge_select_test(scene, element->l->prev, 
cd_loop_uv_offset)) {
+  UvElement *prev = BM_uv_element_get(element_map, 
element->l->prev->f, element->l->prev);
+  if (prev->island == INVALID_ISLAND) {
+UvElement *tail = head_table[prev - element_map->buf];
+stack_uv[stacksize_uv++] = tail;
+while (tail) {
+ 

[Bf-blender-cvs] [0e9367fc29b] master: Cleanup: separate clipUVTransform into two different functions

2022-07-14 Thread Chris Blackbourn
Commit: 0e9367fc29bc42c80e10b7097facec2b029a7362
Author: Chris Blackbourn
Date:   Fri Jul 15 10:04:50 2022 +1200
Branches: master
https://developer.blender.org/rB0e9367fc29bc42c80e10b7097facec2b029a7362

Cleanup: separate clipUVTransform into two different functions

No functional changes.

Prep for D15420 / T98061.

===

M   source/blender/editors/transform/transform_convert.c
M   source/blender/editors/transform/transform_convert.h
M   source/blender/editors/transform/transform_mode_resize.c
M   source/blender/editors/transform/transform_mode_translate.c

===

diff --git a/source/blender/editors/transform/transform_convert.c 
b/source/blender/editors/transform/transform_convert.c
index a23689166c4..bab700560fe 100644
--- a/source/blender/editors/transform/transform_convert.c
+++ b/source/blender/editors/transform/transform_convert.c
@@ -479,132 +479,6 @@ TransDataCurveHandleFlags 
*initTransDataCurveHandles(TransData *td, struct BezTr
 /** \name UV Coordinates
  * \{ */
 
-/**
- * Find the correction for the scaling factor when "Constrain to Bounds" is 
active.
- * \param numerator: How far the UV boundary (unit square) is from the origin 
of the scale.
- * \param denominator: How far the AABB is from the origin of the scale.
- * \param scale: Scale parameter to update.
- */
-static void constrain_scale_to_boundary(const float numerator,
-const float denominator,
-float *scale)
-{
-  if (denominator == 0.0f) {
-/* The origin of the scale is on the edge of the boundary. */
-if (numerator < 0.0f) {
-  /* Negative scale will wrap around and put us outside the boundary. */
-  *scale = 0.0f; /* Hold at the boundary instead. */
-}
-return; /* Nothing else we can do without more info. */
-  }
-
-  const float correction = numerator / denominator;
-  if (correction < 0.0f || !isfinite(correction)) {
-/* TODO: Correction is negative or invalid, but we lack context to fix 
`*scale`. */
-return;
-  }
-
-  if (denominator < 0.0f) {
-/* Scale origin is outside boundary, only make scale bigger. */
-if (*scale < correction) {
-  *scale = correction;
-}
-return;
-  }
-
-  /* Scale origin is inside boundary, the "regular" case, limit maximum scale. 
*/
-  if (*scale > correction) {
-*scale = correction;
-  }
-}
-
-bool clipUVTransform(TransInfo *t, float vec[2], const bool resize)
-{
-  bool clipx = true, clipy = true;
-  float min[2], max[2];
-
-  /* Check if the current image in UV editor is a tiled image or not. */
-  const SpaceImage *sima = t->area->spacedata.first;
-  const Image *image = sima->image;
-  const bool is_tiled_image = image && (image->source == IMA_SRC_TILED);
-  /* Stores the coordinates of the closest UDIM tile.
-   * Also acts as an offset to the tile from the origin of UV space. */
-  float base_offset[2] = {0.0f, 0.0f};
-
-  /* If tiled image then constrain to correct/closest UDIM tile, else 0-1 UV 
space. */
-  if (is_tiled_image) {
-int nearest_tile_index = BKE_image_find_nearest_tile(image, 
t->center_global);
-if (nearest_tile_index != -1) {
-  nearest_tile_index -= 1001;
-  /* Getting coordinates of nearest tile from the tile index. */
-  base_offset[0] = nearest_tile_index % 10;
-  base_offset[1] = nearest_tile_index / 10;
-}
-  }
-
-  min[0] = min[1] = FLT_MAX;
-  max[0] = max[1] = FLT_MIN;
-
-  FOREACH_TRANS_DATA_CONTAINER (t, tc) {
-
-TransData *td;
-int a;
-
-for (a = 0, td = tc->data; a < tc->data_len; a++, td++) {
-  minmax_v2v2_v2(min, max, td->loc);
-}
-  }
-
-  if (resize) {
-/* Assume no change is required. */
-float scalex = 1.0f;
-float scaley = 1.0f;
-
-/* Update U against the left border. */
-constrain_scale_to_boundary(
-t->center_global[0] - base_offset[0], t->center_global[0] - min[0], 
);
-/* Now the right border, negated, because `-1.0 / -1.0 = 1.0` */
-constrain_scale_to_boundary(base_offset[0] + t->aspect[0] - 
t->center_global[0],
-max[0] - t->center_global[0],
-);
-
-/* Do the same for the V co-ordinate, which is called `y`. */
-constrain_scale_to_boundary(
-t->center_global[1] - base_offset[1], t->center_global[1] - min[1], 
);
-constrain_scale_to_boundary(base_offset[1] + t->aspect[1] - 
t->center_global[1],
-max[1] - t->center_global[1],
-);
-
-clipx = (scalex != 1.0f);
-clipy = (scaley != 1.0f);
-vec[0] *= scalex;
-vec[1] *= scaley;
-  }
-  else {
-if (min[0] < base_offset[0]) {
-  vec[0] += base_offset[0] - min[0];
-}
-else if (max[0] > base_offset[0] + t->aspect[0]) {
-  vec[0] -= max[0] - base_offset[0] - t->aspect[0];
-   

[Bf-blender-cvs] [b1329d7eaa5] master: Fix T99705: fix integer overflow in thumbnail extractor

2022-07-14 Thread Ray Molenkamp
Commit: b1329d7eaa52a11c73b75d19d20bd8f6d11ac535
Author: Ray Molenkamp
Date:   Thu Jul 14 12:18:35 2022 -0600
Branches: master
https://developer.blender.org/rBb1329d7eaa52a11c73b75d19d20bd8f6d11ac535

Fix T99705: fix integer overflow in thumbnail extractor

It was smart enough to check if the buffer had the right
size but neglected to cast to a 64 bit value so it
overflowed.

Differential Revision: https://developer.blender.org/D15457
Reviewed By: brecht

===

M   source/blender/blendthumb/src/blendthumb_extract.cc

===

diff --git a/source/blender/blendthumb/src/blendthumb_extract.cc 
b/source/blender/blendthumb/src/blendthumb_extract.cc
index de1f50dfdce..369da559fc8 100644
--- a/source/blender/blendthumb/src/blendthumb_extract.cc
+++ b/source/blender/blendthumb/src/blendthumb_extract.cc
@@ -134,7 +134,8 @@ static eThumbStatus 
blendthumb_extract_from_file_impl(FileReader *file,
 
 /* Verify that image dimensions and data size make sense. */
 size_t data_size = block_size - 8;
-const size_t expected_size = thumb->width * thumb->height * 4;
+const uint64_t expected_size = static_cast(thumb->width) *
+   static_cast(thumb->height) * 
4;
 if (thumb->width < 0 || thumb->height < 0 || data_size != 
expected_size) {
   return BT_INVALID_THUMB;
 }

___
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] [9fedcde750b] master: Modifiers: fix mesh to volume modifier on non-volume objects

2022-07-14 Thread Jacques Lucke
Commit: 9fedcde750bb1f6fbbdc00f8086b12f1fd523231
Author: Jacques Lucke
Date:   Thu Jul 14 20:05:14 2022 +0200
Branches: master
https://developer.blender.org/rB9fedcde750bb1f6fbbdc00f8086b12f1fd523231

Modifiers: fix mesh to volume modifier on non-volume objects

===

M   source/blender/modifiers/intern/MOD_mesh_to_volume.cc

===

diff --git a/source/blender/modifiers/intern/MOD_mesh_to_volume.cc 
b/source/blender/modifiers/intern/MOD_mesh_to_volume.cc
index 01c1875a760..39bd013609b 100644
--- a/source/blender/modifiers/intern/MOD_mesh_to_volume.cc
+++ b/source/blender/modifiers/intern/MOD_mesh_to_volume.cc
@@ -7,6 +7,7 @@
 #include 
 
 #include "BKE_geometry_set.hh"
+#include "BKE_lib_id.h"
 #include "BKE_lib_query.h"
 #include "BKE_mesh_runtime.h"
 #include "BKE_mesh_wrapper.h"
@@ -161,7 +162,13 @@ static Volume *mesh_to_volume(ModifierData *md,

mesh_to_own_object_space_transform);
 
   /* Create a new volume. */
-  Volume *volume = BKE_volume_new_for_eval(input_volume);
+  Volume *volume;
+  if (input_volume == nullptr) {
+volume = static_cast(BKE_id_new_nomain(ID_VO, "Volume"));
+  }
+  else {
+volume = BKE_volume_new_for_eval(input_volume);
+  }
 
   /* Convert mesh to grid and add to volume. */
   geometry::volume_grid_add_from_mesh(volume,

___
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] [bdd0ac5bceb] master: Fix `on_drag_start` handler not getting ID when dragging from Outliner

2022-07-14 Thread Julian Eisel
Commit: bdd0ac5bcebd6deb3d590ada9a3f25c6ddd58ea4
Author: Julian Eisel
Date:   Thu Jul 14 19:21:56 2022 +0200
Branches: master
https://developer.blender.org/rBbdd0ac5bcebd6deb3d590ada9a3f25c6ddd58ea4

Fix `on_drag_start` handler not getting ID when dragging from Outliner

We would first invoke the dragging, and then set the drag data (like the
ID or the dragged modifier), so the `wmDropBox.on_drag_start()` handler
wouldn't be able to access this. This broke dragging some IDs from the
Outliner, noticed in D15333.

It's now possible to first create/request drag data, extend it, and then
invoke the actual dragging. The normal function to start dragging
returns `void` now instead of `wmDrag *`, so the drag data can't easily
be modified after starting anymore.

===

M   source/blender/editors/interface/interface_drag.cc
M   source/blender/editors/space_outliner/outliner_dragdrop.cc
M   source/blender/windowmanager/WM_api.h
M   source/blender/windowmanager/intern/wm_dragdrop.c

===

diff --git a/source/blender/editors/interface/interface_drag.cc 
b/source/blender/editors/interface/interface_drag.cc
index 4c68870b2c7..1db3db32411 100644
--- a/source/blender/editors/interface/interface_drag.cc
+++ b/source/blender/editors/interface/interface_drag.cc
@@ -122,7 +122,7 @@ bool ui_but_drag_is_draggable(const uiBut *but)
 
 void ui_but_drag_start(bContext *C, uiBut *but)
 {
-  wmDrag *drag = WM_event_start_drag(C,
+  wmDrag *drag = WM_drag_data_create(C,
  but->icon,
  but->dragtype,
  but->dragpoin,
@@ -136,6 +136,8 @@ void ui_but_drag_start(bContext *C, uiBut *but)
 WM_event_drag_image(drag, but->imb, but->imb_scale);
   }
 
+  WM_event_start_prepared_drag(C, drag);
+
   /* Special feature for assets: We add another drag item that supports 
multiple assets. It
* gets the assets from context. */
   if (ELEM(but->dragtype, WM_DRAG_ASSET, WM_DRAG_ID)) {
diff --git a/source/blender/editors/space_outliner/outliner_dragdrop.cc 
b/source/blender/editors/space_outliner/outliner_dragdrop.cc
index c72080be811..7435fa50a93 100644
--- a/source/blender/editors/space_outliner/outliner_dragdrop.cc
+++ b/source/blender/editors/space_outliner/outliner_dragdrop.cc
@@ -1455,7 +1455,7 @@ static int outliner_item_drag_drop_invoke(bContext *C,
TSE_GPENCIL_EFFECT_BASE);
 
   const int wm_drag_type = use_datastack_drag ? WM_DRAG_DATASTACK : WM_DRAG_ID;
-  wmDrag *drag = WM_event_start_drag(C, data.icon, wm_drag_type, nullptr, 0.0, 
WM_DRAG_NOP);
+  wmDrag *drag = WM_drag_data_create(C, data.icon, wm_drag_type, nullptr, 0.0, 
WM_DRAG_NOP);
 
   if (use_datastack_drag) {
 TreeElement *te_bone = nullptr;
@@ -1545,6 +1545,8 @@ static int outliner_item_drag_drop_invoke(bContext *C,
 WM_drag_add_local_ID(drag, data.drag_id, data.drag_parent);
   }
 
+  WM_event_start_prepared_drag(C, drag);
+
   ED_outliner_select_sync_from_outliner(C, space_outliner);
 
   return (OPERATOR_FINISHED | OPERATOR_PASS_THROUGH);
diff --git a/source/blender/windowmanager/WM_api.h 
b/source/blender/windowmanager/WM_api.h
index f337dd9d89a..44c5b86857d 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -1214,10 +1214,24 @@ int WM_operator_flag_only_pass_through_on_press(int 
retval, const struct wmEvent
 /* Drag and drop. */
 
 /**
- * Note that the pointer should be valid allocated and not on stack.
+ * Start dragging immediately with the given data.
+ * Note that \a poin should be valid allocated and not on stack.
  */
-struct wmDrag *WM_event_start_drag(
+void WM_event_start_drag(
 struct bContext *C, int icon, int type, void *poin, double value, unsigned 
int flags);
+/**
+ * Create and fill the dragging data, but don't start dragging just yet (unlike
+ * #WM_event_start_drag()). Must be followed up by 
#WM_event_start_prepared_drag(), otherwise the
+ * returned pointer will leak memory.
+ *
+ * Note that \a poin should be valid allocated and not on stack.
+ */
+wmDrag *WM_drag_data_create(
+struct bContext *C, int icon, int type, void *poin, double value, unsigned 
int flags);
+/**
+ * Invoke dragging using the given \a drag data.
+ */
+void WM_event_start_prepared_drag(struct bContext *C, wmDrag *drag);
 void WM_event_drag_image(struct wmDrag *, struct ImBuf *, float scale);
 void WM_drag_free(struct wmDrag *drag);
 void WM_drag_data_free(int dragtype, void *poin);
diff --git a/source/blender/windowmanager/intern/wm_dragdrop.c 
b/source/blender/windowmanager/intern/wm_dragdrop.c
index 546ba795892..36bd69a9b25 100644
--- a/source/blender/windowmanager/intern/wm_dragdrop.c
+++ b/source/blender/windowmanager/intern/wm_dragdrop.c
@@ -175,16 +175,14 @@ static void wm_dropbox_invoke(bContext *C, wmDrag *drag)
   }

[Bf-blender-cvs] [c5e2417d534] arcpatch-D14645: Cycles: refactor to move part of KernelData definition to template header

2022-07-14 Thread Brecht Van Lommel
Commit: c5e2417d534dce518514aa9e26a9341019031709
Author: Brecht Van Lommel
Date:   Tue Jul 12 17:26:29 2022 +0200
Branches: arcpatch-D14645
https://developer.blender.org/rBc5e2417d534dce518514aa9e26a9341019031709

Cycles: refactor to move part of KernelData definition to template header

To be used  for specialization on Metal in a following commit, turning these
members into compile time constants.

===

M   intern/cycles/device/cpu/device_impl.cpp
M   intern/cycles/device/optix/device_impl.cpp
M   intern/cycles/kernel/CMakeLists.txt
M   intern/cycles/kernel/bvh/bvh.h
M   intern/cycles/kernel/bvh/embree.h
M   intern/cycles/kernel/camera/camera.h
A   intern/cycles/kernel/data_template.h
M   intern/cycles/kernel/types.h
M   intern/cycles/scene/film.cpp
M   intern/cycles/scene/geometry.cpp

===

diff --git a/intern/cycles/device/cpu/device_impl.cpp 
b/intern/cycles/device/cpu/device_impl.cpp
index d4f0532aa5e..1e4b9baa0c0 100644
--- a/intern/cycles/device/cpu/device_impl.cpp
+++ b/intern/cycles/device/cpu/device_impl.cpp
@@ -197,7 +197,7 @@ void CPUDevice::const_copy_to(const char *name, void *host, 
size_t size)
 
 // Update scene handle (since it is different for each device on multi 
devices)
 KernelData *const data = (KernelData *)host;
-data->bvh.scene = embree_scene;
+data->device_bvh = embree_scene;
   }
 #endif
   kernel_const_copy(_globals, name, host, size);
diff --git a/intern/cycles/device/optix/device_impl.cpp 
b/intern/cycles/device/optix/device_impl.cpp
index e7dcc29a2da..11c0d1bf8a0 100644
--- a/intern/cycles/device/optix/device_impl.cpp
+++ b/intern/cycles/device/optix/device_impl.cpp
@@ -2047,7 +2047,7 @@ void OptiXDevice::const_copy_to(const char *name, void 
*host, size_t size)
 
 /* Update traversable handle (since it is different for each device on 
multi devices). */
 KernelData *const data = (KernelData *)host;
-*(OptixTraversableHandle *)>bvh.scene = tlas_handle;
+*(OptixTraversableHandle *)>device_bvh = tlas_handle;
 
 update_launch_params(offsetof(KernelParamsOptiX, data), host, size);
 return;
diff --git a/intern/cycles/kernel/CMakeLists.txt 
b/intern/cycles/kernel/CMakeLists.txt
index a07d7852211..2b6c5ca1064 100644
--- a/intern/cycles/kernel/CMakeLists.txt
+++ b/intern/cycles/kernel/CMakeLists.txt
@@ -268,6 +268,7 @@ set(SRC_KERNEL_UTIL_HEADERS
 
 set(SRC_KERNEL_TYPES_HEADERS
   data_arrays.h
+  data_template.h
   tables.h
   types.h
 )
diff --git a/intern/cycles/kernel/bvh/bvh.h b/intern/cycles/kernel/bvh/bvh.h
index a1d0e307170..f375529a6f6 100644
--- a/intern/cycles/kernel/bvh/bvh.h
+++ b/intern/cycles/kernel/bvh/bvh.h
@@ -172,7 +172,7 @@ ccl_device_intersect bool scene_intersect(KernelGlobals kg,
 ray_flags |= OPTIX_RAY_FLAG_TERMINATE_ON_FIRST_HIT;
   }
 
-  optixTrace(scene_intersect_valid(ray) ? kernel_data.bvh.scene : 0,
+  optixTrace(scene_intersect_valid(ray) ? kernel_data.device_bvh : 0,
  ray->P,
  ray->D,
  0.0f,
@@ -295,14 +295,14 @@ ccl_device_intersect bool scene_intersect(KernelGlobals 
kg,
   }
 
 #  ifdef __EMBREE__
-  if (kernel_data.bvh.scene) {
+  if (kernel_data.device_bvh) {
 isect->t = ray->t;
 CCLIntersectContext ctx(kg, CCLIntersectContext::RAY_REGULAR);
 IntersectContext rtc_ctx();
 RTCRayHit ray_hit;
 ctx.ray = ray;
 kernel_embree_setup_rayhit(*ray, ray_hit, visibility);
-rtcIntersect1(kernel_data.bvh.scene, _ctx.context, _hit);
+rtcIntersect1(kernel_data.device_bvh, _ctx.context, _hit);
 if (ray_hit.hit.geomID != RTC_INVALID_GEOMETRY_ID &&
 ray_hit.hit.primID != RTC_INVALID_GEOMETRY_ID) {
   kernel_embree_convert_hit(kg, _hit.ray, _hit.hit, isect);
@@ -357,7 +357,7 @@ ccl_device_intersect bool 
scene_intersect_local(KernelGlobals kg,
   if (local_isect) {
 local_isect->num_hits = 0; /* Initialize hit count to zero. */
   }
-  optixTrace(scene_intersect_valid(ray) ? kernel_data.bvh.scene : 0,
+  optixTrace(scene_intersect_valid(ray) ? kernel_data.device_bvh : 0,
  ray->P,
  ray->D,
  0.0f,
@@ -451,7 +451,7 @@ ccl_device_intersect bool 
scene_intersect_local(KernelGlobals kg,
   }
 
 #ifdef __EMBREE__
-  if (kernel_data.bvh.scene) {
+  if (kernel_data.device_bvh) {
 const bool has_bvh = !(kernel_data_fetch(object_flag, local_object) &
SD_OBJECT_TRANSFORM_APPLIED);
 CCLIntersectContext ctx(
@@ -470,7 +470,7 @@ ccl_device_intersect bool 
scene_intersect_local(KernelGlobals kg,
 
 /* If this object has its own BVH, use it. */
 if (has_bvh) {
-  RTCGeometry geom = rtcGetGeometry(kernel_data.bvh.scene, local_object * 
2);
+  RTCGeometry geom = rtcGetGeometry(kernel_data.device_bvh, local_object * 
2);
   if (geom) {
 float3 P = ray->P;
 float3 dir = 

[Bf-blender-cvs] [fd19555be3d] arcpatch-D14645: Cycles: refactor to move part of KernelData definition to template header

2022-07-14 Thread Michael Jones
Commit: fd19555be3d78575375aa990de60f1ad375e1f06
Author: Michael Jones
Date:   Thu Jul 14 17:40:21 2022 +0100
Branches: arcpatch-D14645
https://developer.blender.org/rBfd19555be3d78575375aa990de60f1ad375e1f06

Cycles: refactor to move part of KernelData definition to template header

To be used  for specialization on Metal in a following commit, turning these
members into compile time constants.

Cycles: keep track of SVM nodes used in kernels

To be used for specialization in Metal, to automatically leave out unused nodes
from the kernel.

Cycles: Apple Silicon optimizations (~20% uplift on M1 Max)

M1 Max samples/min over 30 seconds (macOS 13.0):
```
PSO_GENERIC  PSO_SPECIALIZED_INTERSECT  
PSO_SPECIALIZED_SHADE
barbershop_interior   83.4  89.5   93.7
bmw27   1486.11671.0 1825.8
classroom175.2 196.8  206.3
fishy_cat674.2 704.3  719.3
junkshop 205.4 212.0  257.7
koro 310.1 336.1  342.8
monster  376.7 418.6  424.1
pabellon 273.5 325.4  339.8
sponza   830.6 929.6 1142.4
victor86.7  96.4   96.3
wdas_cloud   111.8 112.7  183.1
```

Next steps:

[ ] ~~Include SHADER_EVAL kernels in the "must cache" list~~ //(limited benefit 
to specializing one off shade steps)//
[ ] Adapt / merge with dynamic kernel compilation caching patch (D14754)
[x] Separate specialization of intersection (fast building) and shading (slow 
building) kernels
[x] Rate-limiting and invalidation of kernel compilation requests
[ ] UI for enabling / disabling background compilation

---

With this patch, the Metal backend compiles & caches a second set of kernels 
which are optimized for scene content, enabled for Apple Silicon.

The optimized kernels result in faster render times, but are slower to compile. 
They are compiled in the background and swapped in when ready. The 
optimizations are:

- ~~Aggressive inlining. This is not scene-specific, but hasn't been enabled 
for the generic kernels because it inflates compile time quite a lot. It 
results in better register usage, reducing the spill that we're seeing in some 
kernels. Possible adjustments: 1) take the compile hit for generic kernels 
since they're only compiled once (and it helps in general), or 2) add a 
_second_ set of generic_kernels with aggressive inlining enabled.~~ //(enabled 
by D14923)//
  - ~8% uplift in isolation for 3 benchmarking scenes

- Substitution of KernelData constants. Select members of KernelData struct are 
replaced with macros that are #defined at the top of source. Only constants 
pertaining to the rendering algorithm is specialized, rather than constants 
which might affect artistic look.
  - ~13% uplift in isolation for 3 benchmarking scenes

- Removal of unused SVM nodes in `svm_eval_nodes`. In combination with the 
other optimizations, this results in a further drop in register usage by 
eliminating dead code that can't be identified by static analysis.

Code contributed by Jason Fielder, Morteza Mostajabodaveh and Michael Jones

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

===

M   intern/cycles/device/device.h
M   intern/cycles/device/metal/device_impl.h
M   intern/cycles/device/metal/device_impl.mm
M   intern/cycles/device/metal/kernel.h
M   intern/cycles/device/metal/kernel.mm
M   intern/cycles/kernel/CMakeLists.txt
A   intern/cycles/kernel/device/metal/function_constants.h
M   intern/cycles/kernel/device/metal/kernel.metal
M   intern/cycles/kernel/svm/svm.h
M   intern/cycles/kernel/types.h
M   intern/cycles/scene/scene.cpp
M   intern/cycles/util/string.cpp
M   intern/cycles/util/string.h

===

diff --git a/intern/cycles/device/device.h b/intern/cycles/device/device.h
index 927caae600c..1681acb9836 100644
--- a/intern/cycles/device/device.h
+++ b/intern/cycles/device/device.h
@@ -29,6 +29,7 @@ class DeviceQueue;
 class Progress;
 class CPUKernels;
 class CPUKernelThreadGlobals;
+class Scene;
 
 /* Device Types */
 
@@ -184,6 +185,11 @@ class Device {
 return 0;
   }
 
+  /* Called after kernel texture setup, and prior to integrator state setup. */
+  virtual void optimize_for_scene(Scene *scene)
+  {
+  }
+
   virtual bool is_resident(device_ptr /*key*/, Device *sub_device)
   {
 /* Memory is always resident if this is not a multi device, regardless of 
whether the pointer
diff --git a/intern/cycles/device/metal/device_impl.h 

[Bf-blender-cvs] [0b53b43f19f] arcpatch-D14645: Cycles: keep track of SVM nodes used in kernels

2022-07-14 Thread Brecht Van Lommel
Commit: 0b53b43f19f66f8a841157b713273ff223d2a5a9
Author: Brecht Van Lommel
Date:   Tue Jul 12 17:22:36 2022 +0200
Branches: arcpatch-D14645
https://developer.blender.org/rB0b53b43f19f66f8a841157b713273ff223d2a5a9

Cycles: keep track of SVM nodes used in kernels

To be used for specialization in Metal, to automatically leave out unused nodes
from the kernel.

===

M   intern/cycles/kernel/CMakeLists.txt
M   intern/cycles/kernel/data_template.h
A   intern/cycles/kernel/svm/node_types_template.h
M   intern/cycles/kernel/svm/svm.h
M   intern/cycles/kernel/svm/types.h
M   intern/cycles/scene/shader_nodes.cpp
M   intern/cycles/scene/svm.cpp
M   intern/cycles/scene/svm.h

===

diff --git a/intern/cycles/kernel/CMakeLists.txt 
b/intern/cycles/kernel/CMakeLists.txt
index 2b6c5ca1064..972febc44e8 100644
--- a/intern/cycles/kernel/CMakeLists.txt
+++ b/intern/cycles/kernel/CMakeLists.txt
@@ -140,6 +140,7 @@ set(SRC_KERNEL_SVM_HEADERS
   svm/math_util.h
   svm/mix.h
   svm/musgrave.h
+  svm/node_types_template.h
   svm/noise.h
   svm/noisetex.h
   svm/normal.h
diff --git a/intern/cycles/kernel/data_template.h 
b/intern/cycles/kernel/data_template.h
index 22f945f1335..b06ac62a5d8 100644
--- a/intern/cycles/kernel/data_template.h
+++ b/intern/cycles/kernel/data_template.h
@@ -194,6 +194,13 @@ KERNEL_STRUCT_MEMBER(integrator, int, 
direct_light_sampling_type)
 KERNEL_STRUCT_MEMBER(integrator, int, pad1)
 KERNEL_STRUCT_END(KernelIntegrator)
 
+/* SVM. For shader specialization. */
+
+KERNEL_STRUCT_BEGIN(KernelSVMUsage, svm_usage)
+#define SHADER_NODE_TYPE(type) KERNEL_STRUCT_MEMBER(svm_usage, int, type)
+#include "kernel/svm/node_types_template.h"
+KERNEL_STRUCT_END(KernelSVMUsage)
+
 #undef KERNEL_STRUCT_BEGIN
 #undef KERNEL_STRUCT_MEMBER
 #undef KERNEL_STRUCT_END
diff --git a/intern/cycles/kernel/svm/node_types_template.h 
b/intern/cycles/kernel/svm/node_types_template.h
new file mode 100644
index 000..39d279be4cb
--- /dev/null
+++ b/intern/cycles/kernel/svm/node_types_template.h
@@ -0,0 +1,110 @@
+/* SPDX-License-Identifier: Apache-2.0
+ * Copyright 2011-2022 Blender Foundation */
+
+#ifndef SHADER_NODE_TYPE
+#  define SHADER_NODE_TYPE(name)
+#endif
+
+/* NOTE: for best OpenCL performance, item definition in the enum must
+ * match the switch case order in `svm.h`. */
+
+SHADER_NODE_TYPE(NODE_END)
+SHADER_NODE_TYPE(NODE_SHADER_JUMP)
+SHADER_NODE_TYPE(NODE_CLOSURE_BSDF)
+SHADER_NODE_TYPE(NODE_CLOSURE_EMISSION)
+SHADER_NODE_TYPE(NODE_CLOSURE_BACKGROUND)
+SHADER_NODE_TYPE(NODE_CLOSURE_SET_WEIGHT)
+SHADER_NODE_TYPE(NODE_CLOSURE_WEIGHT)
+SHADER_NODE_TYPE(NODE_EMISSION_WEIGHT)
+SHADER_NODE_TYPE(NODE_MIX_CLOSURE)
+SHADER_NODE_TYPE(NODE_JUMP_IF_ZERO)
+SHADER_NODE_TYPE(NODE_JUMP_IF_ONE)
+SHADER_NODE_TYPE(NODE_GEOMETRY)
+SHADER_NODE_TYPE(NODE_CONVERT)
+SHADER_NODE_TYPE(NODE_TEX_COORD)
+SHADER_NODE_TYPE(NODE_VALUE_F)
+SHADER_NODE_TYPE(NODE_VALUE_V)
+SHADER_NODE_TYPE(NODE_ATTR)
+SHADER_NODE_TYPE(NODE_VERTEX_COLOR)
+SHADER_NODE_TYPE(NODE_GEOMETRY_BUMP_DX)
+SHADER_NODE_TYPE(NODE_GEOMETRY_BUMP_DY)
+SHADER_NODE_TYPE(NODE_SET_DISPLACEMENT)
+SHADER_NODE_TYPE(NODE_DISPLACEMENT)
+SHADER_NODE_TYPE(NODE_VECTOR_DISPLACEMENT)
+SHADER_NODE_TYPE(NODE_TEX_IMAGE)
+SHADER_NODE_TYPE(NODE_TEX_IMAGE_BOX)
+SHADER_NODE_TYPE(NODE_TEX_NOISE)
+SHADER_NODE_TYPE(NODE_SET_BUMP)
+SHADER_NODE_TYPE(NODE_ATTR_BUMP_DX)
+SHADER_NODE_TYPE(NODE_ATTR_BUMP_DY)
+SHADER_NODE_TYPE(NODE_VERTEX_COLOR_BUMP_DX)
+SHADER_NODE_TYPE(NODE_VERTEX_COLOR_BUMP_DY)
+SHADER_NODE_TYPE(NODE_TEX_COORD_BUMP_DX)
+SHADER_NODE_TYPE(NODE_TEX_COORD_BUMP_DY)
+SHADER_NODE_TYPE(NODE_CLOSURE_SET_NORMAL)
+SHADER_NODE_TYPE(NODE_ENTER_BUMP_EVAL)
+SHADER_NODE_TYPE(NODE_LEAVE_BUMP_EVAL)
+SHADER_NODE_TYPE(NODE_HSV)
+SHADER_NODE_TYPE(NODE_CLOSURE_HOLDOUT)
+SHADER_NODE_TYPE(NODE_FRESNEL)
+SHADER_NODE_TYPE(NODE_LAYER_WEIGHT)
+SHADER_NODE_TYPE(NODE_CLOSURE_VOLUME)
+SHADER_NODE_TYPE(NODE_PRINCIPLED_VOLUME)
+SHADER_NODE_TYPE(NODE_MATH)
+SHADER_NODE_TYPE(NODE_VECTOR_MATH)
+SHADER_NODE_TYPE(NODE_RGB_RAMP)
+SHADER_NODE_TYPE(NODE_GAMMA)
+SHADER_NODE_TYPE(NODE_BRIGHTCONTRAST)
+SHADER_NODE_TYPE(NODE_LIGHT_PATH)
+SHADER_NODE_TYPE(NODE_OBJECT_INFO)
+SHADER_NODE_TYPE(NODE_PARTICLE_INFO)
+SHADER_NODE_TYPE(NODE_HAIR_INFO)
+SHADER_NODE_TYPE(NODE_POINT_INFO)
+SHADER_NODE_TYPE(NODE_TEXTURE_MAPPING)
+SHADER_NODE_TYPE(NODE_MAPPING)
+SHADER_NODE_TYPE(NODE_MIN_MAX)
+SHADER_NODE_TYPE(NODE_CAMERA)
+SHADER_NODE_TYPE(NODE_TEX_ENVIRONMENT)
+SHADER_NODE_TYPE(NODE_TEX_SKY)
+SHADER_NODE_TYPE(NODE_TEX_GRADIENT)
+SHADER_NODE_TYPE(NODE_TEX_VORONOI)
+SHADER_NODE_TYPE(NODE_TEX_MUSGRAVE)
+SHADER_NODE_TYPE(NODE_TEX_WAVE)
+SHADER_NODE_TYPE(NODE_TEX_MAGIC)
+SHADER_NODE_TYPE(NODE_TEX_CHECKER)
+SHADER_NODE_TYPE(NODE_TEX_BRICK)
+SHADER_NODE_TYPE(NODE_TEX_WHITE_NOISE)
+SHADER_NODE_TYPE(NODE_NORMAL)
+SHADER_NODE_TYPE(NODE_LIGHT_FALLOFF)
+SHADER_NODE_TYPE(NODE_IES)

[Bf-blender-cvs] [1ef686bd26c] master: UI: Tweak layout of File Browser Preferences

2022-07-14 Thread Julian Eisel
Commit: 1ef686bd26cc3c89849f41770ce76d7b94f169db
Author: Julian Eisel
Date:   Thu Jul 14 19:07:13 2022 +0200
Branches: master
https://developer.blender.org/rB1ef686bd26cc3c89849f41770ce76d7b94f169db

UI: Tweak layout of File Browser Preferences

* Don't nest "Show Recent Locations" and "Show System Locations" under a
  "Defaults" heading. They are not just a default setting but completely
  hide panels from the UI.
* Use own "Show Locations" heading instead, and remove redundant words
  from labels.
* Move the options to the top of the panel, they are more general since
  they can't be toggled in a File Browser session, and thus have bigger
  impact.

We may want to remove these options in a future major release, I don't
think they are useful.

Agreed on with Pablo Vazquez.

===

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

===

diff --git a/release/scripts/startup/bl_ui/space_userpref.py 
b/release/scripts/startup/bl_ui/space_userpref.py
index cccbb63d27c..7a651e8c3c8 100644
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@ -1485,11 +1485,13 @@ class USERPREF_PT_saveload_file_browser(SaveLoadPanel, 
CenterAlignMixIn, Panel):
 prefs = context.preferences
 paths = prefs.filepaths
 
+col = layout.column(heading="Show Locations")
+col.prop(paths, "show_recent_locations", text="Recent")
+col.prop(paths, "show_system_bookmarks", text="System")
+
 col = layout.column(heading="Defaults")
 col.prop(paths, "use_filter_files")
 col.prop(paths, "show_hidden_files_datablocks")
-col.prop(paths, "show_recent_locations")
-col.prop(paths, "show_system_bookmarks")
 
 
 # -

___
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] [b6de6da59af] master: I18n: Fix regex for messages from `BKE_modifier_set_error`.

2022-07-14 Thread Bastien Montagne
Commit: b6de6da59afbf84b21df661d096f324360c763d7
Author: Bastien Montagne
Date:   Thu Jul 14 18:46:52 2022 +0200
Branches: master
https://developer.blender.org/rBb6de6da59afbf84b21df661d096f324360c763d7

I18n: Fix regex for messages from `BKE_modifier_set_error`.

Signature of this function changed at some point, regex to extract
messages from it was no longer working.

Reported/detected as part of D15418.

===

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

===

diff --git a/release/scripts/modules/bl_i18n_utils/settings.py 
b/release/scripts/modules/bl_i18n_utils/settings.py
index 7aeef80b0bd..9b38c512d31 100644
--- a/release/scripts/modules/bl_i18n_utils/settings.py
+++ b/release/scripts/modules/bl_i18n_utils/settings.py
@@ -248,7 +248,7 @@ PYGETTEXT_KEYWORDS = (() +
 tuple(("{}\\((?:[^\"',]+,){{3}}\\s*" + _msg_re + r"\s*\)").format(it)
   for it in ("BMO_error_raise",)) +
 
-tuple(("{}\\((?:[^\"',]+,)\\s*" + _msg_re + r"\s*(?:\)|,)").format(it)
+tuple(("{}\\((?:[^\"',]+,){{2}}\\s*" + _msg_re + r"\s*(?:\)|,)").format(it)
   for it in ("BKE_modifier_set_error",)) +
 
 # bUnitDef unit names.

___
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] [3b15467e97a] master: Fix T99702: Gpencil Flip strokes did not support multiframe edit

2022-07-14 Thread Antonio Vazquez
Commit: 3b15467e97abf473d4d25c7382999115d3169a57
Author: Antonio Vazquez
Date:   Thu Jul 14 16:33:21 2022 +0200
Branches: master
https://developer.blender.org/rB3b15467e97abf473d4d25c7382999115d3169a57

Fix T99702: Gpencil Flip strokes did not support multiframe edit

This was a missing feature and this commit solves this.

===

M   source/blender/editors/gpencil/gpencil_edit.c

===

diff --git a/source/blender/editors/gpencil/gpencil_edit.c 
b/source/blender/editors/gpencil/gpencil_edit.c
index 06f3c169fa9..71cf9b1fafd 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -3709,35 +3709,44 @@ static int gpencil_stroke_flip_exec(bContext *C, 
wmOperator *op)
 return OPERATOR_CANCELLED;
   }
 
+  const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd);
   const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd);
+
   bool changed = false;
-  /* read all selected strokes */
+  /* Read all selected strokes. */
   CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) {
-bGPDframe *gpf = gpl->actframe;
-if (gpf == NULL) {
-  continue;
-}
+bGPDframe *init_gpf = (is_multiedit) ? gpl->frames.first : gpl->actframe;
 
-LISTBASE_FOREACH (bGPDstroke *, gps, >strokes) {
-  if (gps->flag & GP_STROKE_SELECT) {
-/* skip strokes that are invalid for current view */
-if (ED_gpencil_stroke_can_use(C, gps) == false) {
-  continue;
-}
-/* check if the color is editable */
-if (ED_gpencil_stroke_material_editable(ob, gpl, gps) == false) {
+for (bGPDframe *gpf = init_gpf; gpf; gpf = gpf->next) {
+  if ((gpf == gpl->actframe) || ((gpf->flag & GP_FRAME_SELECT) && 
(is_multiedit))) {
+if (gpf == NULL) {
   continue;
 }
+LISTBASE_FOREACH (bGPDstroke *, gps, >strokes) {
+  if (gps->flag & GP_STROKE_SELECT) {
+/* skip strokes that are invalid for current view */
+if (ED_gpencil_stroke_can_use(C, gps) == false) {
+  continue;
+}
+/* check if the color is editable */
+if (ED_gpencil_stroke_material_editable(ob, gpl, gps) == false) {
+  continue;
+}
 
-if (is_curve_edit) {
-  BKE_report(op->reports, RPT_ERROR, "Not implemented!");
-}
-else {
-  /* Flip stroke. */
-  BKE_gpencil_stroke_flip(gps);
+if (is_curve_edit) {
+  BKE_report(op->reports, RPT_ERROR, "Not implemented!");
+}
+else {
+  /* Flip stroke. */
+  BKE_gpencil_stroke_flip(gps);
+  changed = true;
+}
+  }
 }
-
-changed = true;
+  }
+  /* If not multi-edit, exit loop. */
+  if (!is_multiedit) {
+break;
   }
 }
   }

___
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] [28c3739a9bc] master: Cleanup: replace state flow macros in the kernel with functions

2022-07-14 Thread Brecht Van Lommel
Commit: 28c3739a9bc055b3a3e5ba2f5cfc219f70d64dfa
Author: Brecht Van Lommel
Date:   Wed Jul 13 14:22:42 2022 +0200
Branches: master
https://developer.blender.org/rB28c3739a9bc055b3a3e5ba2f5cfc219f70d64dfa

Cleanup: replace state flow macros in the kernel with functions

===

M   intern/cycles/kernel/integrator/init_from_bake.h
M   intern/cycles/kernel/integrator/init_from_camera.h
M   intern/cycles/kernel/integrator/intersect_closest.h
M   intern/cycles/kernel/integrator/intersect_shadow.h
M   intern/cycles/kernel/integrator/intersect_subsurface.h
M   intern/cycles/kernel/integrator/intersect_volume_stack.h
M   intern/cycles/kernel/integrator/shade_background.h
M   intern/cycles/kernel/integrator/shade_light.h
M   intern/cycles/kernel/integrator/shade_shadow.h
M   intern/cycles/kernel/integrator/shade_surface.h
M   intern/cycles/kernel/integrator/shade_volume.h
M   intern/cycles/kernel/integrator/shadow_catcher.h
M   intern/cycles/kernel/integrator/state_flow.h
M   intern/cycles/kernel/integrator/subsurface.h

===

diff --git a/intern/cycles/kernel/integrator/init_from_bake.h 
b/intern/cycles/kernel/integrator/init_from_bake.h
index c63684d58e6..4d75dcea190 100644
--- a/intern/cycles/kernel/integrator/init_from_bake.h
+++ b/intern/cycles/kernel/integrator/init_from_bake.h
@@ -181,7 +181,7 @@ ccl_device bool integrator_init_from_bake(KernelGlobals kg,
 integrator_state_write_ray(kg, state, );
 
 /* Setup next kernel to execute. */
-INTEGRATOR_PATH_INIT(DEVICE_KERNEL_INTEGRATOR_SHADE_BACKGROUND);
+integrator_path_init(kg, state, DEVICE_KERNEL_INTEGRATOR_SHADE_BACKGROUND);
   }
   else {
 /* Surface baking. */
@@ -247,13 +247,13 @@ ccl_device bool integrator_init_from_bake(KernelGlobals 
kg,
 const bool use_raytrace_kernel = (shader_flags & SD_HAS_RAYTRACE);
 
 if (use_caustics) {
-  INTEGRATOR_PATH_INIT_SORTED(DEVICE_KERNEL_INTEGRATOR_SHADE_SURFACE_MNEE, 
shader_index);
+  integrator_path_init_sorted(kg, state, 
DEVICE_KERNEL_INTEGRATOR_SHADE_SURFACE_MNEE, shader_index);
 }
 else if (use_raytrace_kernel) {
-  
INTEGRATOR_PATH_INIT_SORTED(DEVICE_KERNEL_INTEGRATOR_SHADE_SURFACE_RAYTRACE, 
shader_index);
+  integrator_path_init_sorted(kg, state, 
DEVICE_KERNEL_INTEGRATOR_SHADE_SURFACE_RAYTRACE, shader_index);
 }
 else {
-  INTEGRATOR_PATH_INIT_SORTED(DEVICE_KERNEL_INTEGRATOR_SHADE_SURFACE, 
shader_index);
+  integrator_path_init_sorted(kg, state, 
DEVICE_KERNEL_INTEGRATOR_SHADE_SURFACE, shader_index);
 }
   }
 
diff --git a/intern/cycles/kernel/integrator/init_from_camera.h 
b/intern/cycles/kernel/integrator/init_from_camera.h
index 9fe27cdda9a..73db13be697 100644
--- a/intern/cycles/kernel/integrator/init_from_camera.h
+++ b/intern/cycles/kernel/integrator/init_from_camera.h
@@ -100,10 +100,10 @@ ccl_device bool integrator_init_from_camera(KernelGlobals 
kg,
   /* Continue with intersect_closest kernel, optionally initializing volume
* stack before that if the camera may be inside a volume. */
   if (kernel_data.cam.is_inside_volume) {
-INTEGRATOR_PATH_INIT(DEVICE_KERNEL_INTEGRATOR_INTERSECT_VOLUME_STACK);
+integrator_path_init(kg, state, 
DEVICE_KERNEL_INTEGRATOR_INTERSECT_VOLUME_STACK);
   }
   else {
-INTEGRATOR_PATH_INIT(DEVICE_KERNEL_INTEGRATOR_INTERSECT_CLOSEST);
+integrator_path_init(kg, state, 
DEVICE_KERNEL_INTEGRATOR_INTERSECT_CLOSEST);
   }
 
   return true;
diff --git a/intern/cycles/kernel/integrator/intersect_closest.h 
b/intern/cycles/kernel/integrator/intersect_closest.h
index 621aa05f46b..923dab9591a 100644
--- a/intern/cycles/kernel/integrator/intersect_closest.h
+++ b/intern/cycles/kernel/integrator/intersect_closest.h
@@ -109,14 +109,14 @@ ccl_device_forceinline void 
integrator_split_shadow_catcher(
 /* If using background pass, schedule background shading kernel so that we 
have a background
  * to alpha-over on. The background kernel will then continue the path 
afterwards. */
 INTEGRATOR_STATE_WRITE(state, path, flag) |= 
PATH_RAY_SHADOW_CATCHER_BACKGROUND;
-INTEGRATOR_PATH_INIT(DEVICE_KERNEL_INTEGRATOR_SHADE_BACKGROUND);
+integrator_path_init(kg, state, DEVICE_KERNEL_INTEGRATOR_SHADE_BACKGROUND);
 return;
   }
 
   if (!integrator_state_volume_stack_is_empty(kg, state)) {
 /* Volume stack is not empty. Re-init the volume stack to exclude any 
non-shadow catcher
  * objects from it, and then continue shading volume and shadow catcher 
surface after. */
-INTEGRATOR_PATH_INIT(DEVICE_KERNEL_INTEGRATOR_INTERSECT_VOLUME_STACK);
+integrator_path_init(kg, state, 
DEVICE_KERNEL_INTEGRATOR_INTERSECT_VOLUME_STACK);
 return;
   }
 
@@ -128,18 +128,19 @@ ccl_device_forceinline void 
integrator_split_shadow_catcher(
   const bool use_raytrace_kernel = (flags & SD_HAS_RAYTRACE);
 
   if 

[Bf-blender-cvs] [1b5db02a020] master: Fix Cycles MNEE wrong results with area light spread

2022-07-14 Thread Olivier Maury
Commit: 1b5db02a0207621a0325c0d2ee6f748b2520d2fe
Author: Olivier Maury
Date:   Thu Jul 14 15:59:26 2022 +0200
Branches: master
https://developer.blender.org/rB1b5db02a0207621a0325c0d2ee6f748b2520d2fe

Fix Cycles MNEE wrong results with area light spread

When the solve is successful, the light sample needs to be updated since the
effective shading point is now on the last refractive interface. Spread was
not taken into account, creating false caustics.

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

===

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

===

diff --git a/intern/cycles/kernel/integrator/mnee.h 
b/intern/cycles/kernel/integrator/mnee.h
index 67505b9b612..70b009d3b48 100644
--- a/intern/cycles/kernel/integrator/mnee.h
+++ b/intern/cycles/kernel/integrator/mnee.h
@@ -137,8 +137,14 @@ ccl_device_forceinline void 
mnee_update_light_sample(KernelGlobals kg,
 }
   }
   else if (ls->type == LIGHT_AREA) {
+float invarea = fabsf(klight->area.invarea);
 ls->D = normalize_len(ls->P - P, >t);
-ls->pdf = fabsf(klight->area.invarea);
+ls->pdf = invarea;
+if (klight->area.tan_spread > 0.f) {
+  ls->eval_fac = 0.25f * invarea;
+  ls->eval_fac *= light_spread_attenuation(
+  ls->D, ls->Ng, klight->area.tan_spread, 
klight->area.normalize_spread);
+}
   }
 
   ls->pdf *= kernel_data.integrator.pdf_lights;

___
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] [5539fb31213] master: Cycles: add presets to the Performance panel

2022-07-14 Thread Brecht Van Lommel
Commit: 5539fb3121313f91b6e46d982ef62ff97763d2c2
Author: Brecht Van Lommel
Date:   Wed Jul 13 15:23:50 2022 +0200
Branches: master
https://developer.blender.org/rB5539fb3121313f91b6e46d982ef62ff97763d2c2

Cycles: add presets to the Performance panel

With choices Default, Lower Memory and Faster Render. For convenience, and
to help communicate what the various settings do.

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

===

M   intern/cycles/blender/addon/presets.py
M   intern/cycles/blender/addon/ui.py
A   release/scripts/presets/cycles/performance/Default.py
A   release/scripts/presets/cycles/performance/Faster_Render.py
A   release/scripts/presets/cycles/performance/Lower_Memory.py

===

diff --git a/intern/cycles/blender/addon/presets.py 
b/intern/cycles/blender/addon/presets.py
index cc6d574da99..e1f08c07eaf 100644
--- a/intern/cycles/blender/addon/presets.py
+++ b/intern/cycles/blender/addon/presets.py
@@ -84,10 +84,36 @@ class AddPresetViewportSampling(AddPresetBase, Operator):
 preset_subdir = "cycles/viewport_sampling"
 
 
+class AddPresetPerformance(AddPresetBase, Operator):
+'''Add an Performance Preset'''
+bl_idname = "render.cycles_performance_preset_add"
+bl_label = "Add Performance Preset"
+preset_menu = "CYCLES_PT_performance_presets"
+
+preset_defines = [
+"render = bpy.context.scene.render"
+"cycles = bpy.context.scene.cycles"
+]
+
+preset_values = [
+"render.threads_mode",
+"render.use_persistent_data",
+"cycles.debug_use_spatial_splits",
+"cycles.debug_use_compact_bvh",
+"cycles.debug_use_hair_bvh",
+"cycles.debug_bvh_time_steps",
+"cycles.use_auto_tile",
+"cycles.tile_size",
+]
+
+preset_subdir = "cycles/performance"
+
+
 classes = (
 AddPresetIntegrator,
 AddPresetSampling,
 AddPresetViewportSampling,
+AddPresetPerformance,
 )
 
 
diff --git a/intern/cycles/blender/addon/ui.py 
b/intern/cycles/blender/addon/ui.py
index 09aecb5cb81..3c898d4be73 100644
--- a/intern/cycles/blender/addon/ui.py
+++ b/intern/cycles/blender/addon/ui.py
@@ -43,6 +43,12 @@ class CYCLES_PT_integrator_presets(CyclesPresetPanel):
 preset_add_operator = "render.cycles_integrator_preset_add"
 
 
+class CYCLES_PT_performance_presets(CyclesPresetPanel):
+bl_label = "Performance Presets"
+preset_subdir = "cycles/performance"
+preset_add_operator = "render.cycles_performance_preset_add"
+
+
 class CyclesButtonsPanel:
 bl_space_type = "PROPERTIES"
 bl_region_type = "WINDOW"
@@ -624,6 +630,9 @@ class CYCLES_RENDER_PT_performance(CyclesButtonsPanel, 
Panel):
 bl_label = "Performance"
 bl_options = {'DEFAULT_CLOSED'}
 
+def draw_header_preset(self, context):
+CYCLES_PT_performance_presets.draw_panel_header(self.layout)
+
 def draw(self, context):
 pass
 
@@ -2269,6 +2278,7 @@ classes = (
 CYCLES_PT_sampling_presets,
 CYCLES_PT_viewport_sampling_presets,
 CYCLES_PT_integrator_presets,
+CYCLES_PT_performance_presets,
 CYCLES_RENDER_PT_sampling,
 CYCLES_RENDER_PT_sampling_viewport,
 CYCLES_RENDER_PT_sampling_viewport_denoise,
diff --git a/release/scripts/presets/cycles/performance/Default.py 
b/release/scripts/presets/cycles/performance/Default.py
new file mode 100644
index 000..5c25f23eca0
--- /dev/null
+++ b/release/scripts/presets/cycles/performance/Default.py
@@ -0,0 +1,12 @@
+import bpy
+render = bpy.context.scene.render
+cycles = bpy.context.scene.cycles
+
+render.threads_mode = 'AUTO'
+render.use_persistent_data = False
+cycles.debug_use_spatial_splits = False
+cycles.debug_use_compact_bvh = False
+cycles.debug_use_hair_bvh = True
+cycles.debug_bvh_time_steps = 0
+cycles.use_auto_tile = True
+cycles.tile_size = 2048
diff --git a/release/scripts/presets/cycles/performance/Faster_Render.py 
b/release/scripts/presets/cycles/performance/Faster_Render.py
new file mode 100644
index 000..7f1e3c68f1f
--- /dev/null
+++ b/release/scripts/presets/cycles/performance/Faster_Render.py
@@ -0,0 +1,12 @@
+import bpy
+render = bpy.context.scene.render
+cycles = bpy.context.scene.cycles
+
+render.threads_mode = 'AUTO'
+render.use_persistent_data = True
+cycles.debug_use_spatial_splits = True
+cycles.debug_use_compact_bvh = False
+cycles.debug_use_hair_bvh = True
+cycles.debug_bvh_time_steps = 2
+cycles.use_auto_tile = True
+cycles.tile_size = 2048
diff --git a/release/scripts/presets/cycles/performance/Lower_Memory.py 
b/release/scripts/presets/cycles/performance/Lower_Memory.py
new file mode 100644
index 000..d1a45f1888d
--- /dev/null
+++ b/release/scripts/presets/cycles/performance/Lower_Memory.py
@@ -0,0 +1,12 @@
+import bpy
+render = bpy.context.scene.render
+cycles = bpy.context.scene.cycles
+
+render.threads_mode = 'AUTO'

[Bf-blender-cvs] [02ce29c6ee8] master: Improve Tool tip for Add-on search

2022-07-14 Thread Gaia Clary
Commit: 02ce29c6ee82a22d1fce126188b8b9db1a221d4b
Author: Gaia Clary
Date:   Sun Jul 10 10:35:05 2022 +0200
Branches: master
https://developer.blender.org/rB02ce29c6ee82a22d1fce126188b8b9db1a221d4b

Improve Tool tip for Add-on search

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

===

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

===

diff --git a/release/scripts/startup/bl_ui/__init__.py 
b/release/scripts/startup/bl_ui/__init__.py
index c61dde87d7c..c4e3df469b7 100644
--- a/release/scripts/startup/bl_ui/__init__.py
+++ b/release/scripts/startup/bl_ui/__init__.py
@@ -128,8 +128,8 @@ def register():
 return items
 
 WindowManager.addon_search = StringProperty(
-name="Search",
-description="Search within the selected filter",
+name="Filter",
+description="Filter by add-on name, author & category",
 options={'TEXTEDIT_UPDATE'},
 )
 WindowManager.addon_filter = EnumProperty(

___
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] [4b1d315017e] master: Cycles: Improve cache usage on Apple GPUs by chunking active indices

2022-07-14 Thread Michael Jones
Commit: 4b1d315017ef103f3034160d349b3c3c21a4cd6a
Author: Michael Jones
Date:   Wed Jul 13 20:56:57 2022 +0100
Branches: master
https://developer.blender.org/rB4b1d315017ef103f3034160d349b3c3c21a4cd6a

Cycles: Improve cache usage on Apple GPUs by chunking active indices

This patch partitions the active indices into chunks prior to sorting by 
material in order to tradeoff some material coherence for better locality. On 
Apple Silicon GPUs (particularly higher end M1-family GPUs), we observe overall 
render time speedups of up to 15%. The partitioning is implemented by repeating 
the range of `shader_sort_key` for each partition, and encoding a "locator" key 
which distributes the indices into sorted chunks.

Reviewed By: brecht

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

===

M   intern/cycles/device/metal/device_impl.mm
M   intern/cycles/device/metal/queue.h
M   intern/cycles/device/metal/queue.mm
M   intern/cycles/device/metal/util.h
M   intern/cycles/device/metal/util.mm
M   intern/cycles/device/queue.h
M   intern/cycles/integrator/path_trace.cpp
M   intern/cycles/integrator/path_trace_work_gpu.cpp
M   intern/cycles/integrator/path_trace_work_gpu.h
M   intern/cycles/kernel/integrator/state.h
M   intern/cycles/kernel/integrator/state_flow.h

===

diff --git a/intern/cycles/device/metal/device_impl.mm 
b/intern/cycles/device/metal/device_impl.mm
index 87c83242240..ba9317e3204 100644
--- a/intern/cycles/device/metal/device_impl.mm
+++ b/intern/cycles/device/metal/device_impl.mm
@@ -217,6 +217,10 @@ string MetalDevice::get_source(const uint kernel_features)
 build_options += " -D__KERNEL_FEATURES__=" + to_string(kernel_features);
   }
 
+  if (MetalInfo::optimal_sort_partition_elements(mtlDevice) > 0) {
+build_options += " -D__KERNEL_SORT_PARTITIONING__ ";
+  }
+
   if (use_metalrt) {
 build_options += "-D__METALRT__ ";
 if (motion_blur) {
@@ -652,7 +656,7 @@ void MetalDevice::const_copy_to(const char *name, void 
*host, size_t size)
   /* Update data storage pointers in launch parameters. */
   if (strcmp(name, "integrator_state") == 0) {
 /* IntegratorStateGPU is contiguous pointers */
-const size_t pointer_block_size = sizeof(IntegratorStateGPU);
+const size_t pointer_block_size = offsetof(IntegratorStateGPU, 
sort_partition_divisor);
 update_launch_pointers(
 offsetof(KernelParamsMetal, integrator_state), host, size, 
pointer_block_size);
   }
diff --git a/intern/cycles/device/metal/queue.h 
b/intern/cycles/device/metal/queue.h
index b0bd487c86d..836289172f7 100644
--- a/intern/cycles/device/metal/queue.h
+++ b/intern/cycles/device/metal/queue.h
@@ -24,6 +24,7 @@ class MetalDeviceQueue : public DeviceQueue {
 
   virtual int num_concurrent_states(const size_t) const override;
   virtual int num_concurrent_busy_states() const override;
+  virtual int num_sort_partitions(const size_t) const override;
 
   virtual void init_execution() override;
 
diff --git a/intern/cycles/device/metal/queue.mm 
b/intern/cycles/device/metal/queue.mm
index 03e60b6bb6e..6a9cc552098 100644
--- a/intern/cycles/device/metal/queue.mm
+++ b/intern/cycles/device/metal/queue.mm
@@ -293,6 +293,23 @@ int MetalDeviceQueue::num_concurrent_busy_states() const
   return result;
 }
 
+int MetalDeviceQueue::num_sort_partitions(const size_t state_size) const
+{
+  /* Sort partitioning becomes less effective when more shaders are in the 
wavefront. In lieu of a
+   * more sophisticated heuristic we simply disable sort partitioning if the 
shader count is high.
+   */
+  if (metal_device_->launch_params.data.max_shaders >= 300) {
+return 1;
+  }
+
+  const int optimal_partition_elements = 
MetalInfo::optimal_sort_partition_elements(
+  metal_device_->mtlDevice);
+  if (optimal_partition_elements) {
+return num_concurrent_states(state_size) / optimal_partition_elements;
+  }
+  return 1;
+}
+
 void MetalDeviceQueue::init_execution()
 {
   /* Synchronize all textures and memory copies before executing task. */
@@ -359,7 +376,7 @@ bool MetalDeviceQueue::enqueue(DeviceKernel kernel,
   /* Prepare any non-pointer (i.e. plain-old-data) KernelParamsMetal data */
   /* The plain-old-data is contiguous, continuing to the end of 
KernelParamsMetal */
   size_t plain_old_launch_data_offset = offsetof(KernelParamsMetal, 
integrator_state) +
-sizeof(IntegratorStateGPU);
+offsetof(IntegratorStateGPU, 
sort_partition_divisor);
   size_t plain_old_launch_data_size = sizeof(KernelParamsMetal) - 
plain_old_launch_data_offset;
   memcpy(init_arg_buffer + globals_offsets + plain_old_launch_data_offset,
  (uint8_t *)_device_->launch_params + 
plain_old_launch_data_offset,
@@ -416,7 +433,7 @@ bool MetalDeviceQueue::enqueue(DeviceKernel 

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

2022-07-14 Thread Campbell Barton
Commit: 2d04012e57a75254ccfe97ed2df747e03dcd4da5
Author: Campbell Barton
Date:   Thu Jul 14 22:02:52 2022 +1000
Branches: master
https://developer.blender.org/rB2d04012e57a75254ccfe97ed2df747e03dcd4da5

Cleanup: spelling in comments

Also remove duplicate comments in bmesh_log.h, caused by automated
comment relocation in [0].

[0]: c4e041da23b9c45273fcd4874308c536b6a315d1

===

M   intern/cycles/scene/scene.h
M   source/blender/blenkernel/intern/brush.cc
M   source/blender/blenkernel/intern/mesh_merge_customdata.cc
M   source/blender/bmesh/intern/bmesh_log.c
M   source/blender/bmesh/intern/bmesh_log.h
M   source/blender/gpu/metal/mtl_texture.hh

===

diff --git a/intern/cycles/scene/scene.h b/intern/cycles/scene/scene.h
index d04c6a27f11..d1004bb7b66 100644
--- a/intern/cycles/scene/scene.h
+++ b/intern/cycles/scene/scene.h
@@ -82,7 +82,7 @@ class DeviceScene {
 
   device_vector patches;
 
-  /* pointcloud */
+  /* point-cloud */
   device_vector points;
   device_vector points_shader;
 
@@ -124,7 +124,7 @@ class DeviceScene {
   /* integrator */
   device_vector sample_pattern_lut;
 
-  /* ies lights */
+  /* IES lights */
   device_vector ies_lights;
 
   KernelData data;
diff --git a/source/blender/blenkernel/intern/brush.cc 
b/source/blender/blenkernel/intern/brush.cc
index 1c2408bab8a..99733c8edb3 100644
--- a/source/blender/blenkernel/intern/brush.cc
+++ b/source/blender/blenkernel/intern/brush.cc
@@ -587,15 +587,15 @@ bool BKE_brush_delete(Main *bmain, Brush *brush)
   return true;
 }
 
-/* grease pencil cumapping->preset */
-typedef enum eGPCurveMappingPreset {
+/** Local grease pencil curve mapping preset. */
+using eGPCurveMappingPreset = enum eGPCurveMappingPreset {
   GPCURVE_PRESET_PENCIL = 0,
   GPCURVE_PRESET_INK = 1,
   GPCURVE_PRESET_INKNOISE = 2,
   GPCURVE_PRESET_MARKER = 3,
   GPCURVE_PRESET_CHISEL_SENSIVITY = 4,
   GPCURVE_PRESET_CHISEL_STRENGTH = 5,
-} eGPCurveMappingPreset;
+};
 
 static void brush_gpencil_curvemap_reset(CurveMap *cuma, int tot, int preset)
 {
diff --git a/source/blender/blenkernel/intern/mesh_merge_customdata.cc 
b/source/blender/blenkernel/intern/mesh_merge_customdata.cc
index adaf378ed27..7bc429954b0 100644
--- a/source/blender/blenkernel/intern/mesh_merge_customdata.cc
+++ b/source/blender/blenkernel/intern/mesh_merge_customdata.cc
@@ -33,11 +33,11 @@ static int compare_v2_classify(const float uv_a[2], const 
float uv_b[2])
   if (uv_a[0] == uv_b[0] && uv_a[1] == uv_b[1]) {
 return CMP_EQUAL;
   }
-  /* Note that the ULP value is the primary value used to compare relative 
values
-   * as the absolute value doesn't account for float precision at difference 
scales.
+  /* NOTE(@campbellbarton): that the ULP value is the primary value used to 
compare relative
+   * values as the absolute value doesn't account for float precision at 
difference scales.
* - For subdivision-surface ULP of 3 is sufficient,
*   although this value is extremely small.
-   * - For bevel the URL of 12 is sufficient to merge UV's that appear to be 
connected
+   * - For bevel the ULP of 12 is sufficient to merge UV's that appear to be 
connected
*   with bevel on Suzanne beveled 15% with 6 segments.
*
* These values could be tweaked but should be kept on the small side to 
prevent
diff --git a/source/blender/bmesh/intern/bmesh_log.c 
b/source/blender/bmesh/intern/bmesh_log.c
index a81ae934629..64e6c63e9f0 100644
--- a/source/blender/bmesh/intern/bmesh_log.c
+++ b/source/blender/bmesh/intern/bmesh_log.c
@@ -34,42 +34,41 @@
 struct BMLogEntry {
   struct BMLogEntry *next, *prev;
 
-  /* The following GHashes map from an element ID to one of the log
-   * types above */
+  /* The following #GHash members map from an element ID to one of the log 
types above. */
 
-  /* Elements that were in the previous entry, but have been
-   * deleted */
+  /** Elements that were in the previous entry, but have been deleted. */
   GHash *deleted_verts;
   GHash *deleted_faces;
-  /* Elements that were not in the previous entry, but are in the
-   * result of this entry */
+  /** Elements that were not in the previous entry, but are in the result of 
this entry. */
   GHash *added_verts;
   GHash *added_faces;
 
-  /* Vertices whose coordinates, mask value, or hflag have changed */
+  /** Vertices whose coordinates, mask value, or hflag have changed. */
   GHash *modified_verts;
   GHash *modified_faces;
 
   BLI_mempool *pool_verts;
   BLI_mempool *pool_faces;
 
-  /* This is only needed for dropping BMLogEntries while still in
+  /**
+   * This is only needed for dropping BMLogEntries while still in
* dynamic-topology mode, as that should release vert/face IDs
-   * back to the BMLog but no BMLog pointer is available at that
-   * time.
+   * back to the BMLog but no BMLog pointer is available at that time.
*
* This 

[Bf-blender-cvs] [47d4ce498e3] master: Cleanup: minor changes to camera frame fitting

2022-07-14 Thread Campbell Barton
Commit: 47d4ce498e3f5a11a0210b1efd57053f0b1c85bd
Author: Campbell Barton
Date:   Thu Jul 14 22:05:31 2022 +1000
Branches: master
https://developer.blender.org/rB47d4ce498e3f5a11a0210b1efd57053f0b1c85bd

Cleanup: minor changes to camera frame fitting

Use const vars & make order of min/max checks consistent.

===

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

===

diff --git a/source/blender/blenkernel/intern/camera.c 
b/source/blender/blenkernel/intern/camera.c
index 48a48d6e2b4..7cfac0cb75a 100644
--- a/source/blender/blenkernel/intern/camera.c
+++ b/source/blender/blenkernel/intern/camera.c
@@ -704,7 +704,7 @@ static bool camera_frame_fit_calc_from_data(CameraParams 
*params,
 }
 
 if ((!isect_plane_plane_v3(
-plane_tx[Y_MAX], plane_tx[Y_MIN], plane_isect_1, 
plane_isect_1_no)) ||
+plane_tx[Y_MIN], plane_tx[Y_MAX], plane_isect_1, 
plane_isect_1_no)) ||
 (!isect_plane_plane_v3(
 plane_tx[Z_MIN], plane_tx[Z_MAX], plane_isect_2, 
plane_isect_2_no))) {
   return false;
@@ -713,28 +713,27 @@ static bool camera_frame_fit_calc_from_data(CameraParams 
*params,
 add_v3_v3v3(plane_isect_1_other, plane_isect_1, plane_isect_1_no);
 add_v3_v3v3(plane_isect_2_other, plane_isect_2, plane_isect_2_no);
 
-if (isect_line_line_v3(plane_isect_1,
-   plane_isect_1_other,
-   plane_isect_2,
-   plane_isect_2_other,
-   plane_isect_pt_1,
-   plane_isect_pt_2) == 0) {
+if (!isect_line_line_v3(plane_isect_1,
+plane_isect_1_other,
+plane_isect_2,
+plane_isect_2_other,
+plane_isect_pt_1,
+plane_isect_pt_2)) {
   return false;
 }
 
 float cam_plane_no[3];
 float plane_isect_delta[3];
-float plane_isect_delta_len;
 
-float shift_fac = BKE_camera_sensor_size(
-  params->sensor_fit, params->sensor_x, 
params->sensor_y) /
-  params->lens;
+const float shift_fac = BKE_camera_sensor_size(
+params->sensor_fit, params->sensor_x, 
params->sensor_y) /
+params->lens;
 
 /* we want (0, 0, -1) transformed by camera_rotmat, this is a quicker 
shortcut. */
 negate_v3_v3(cam_plane_no, data->camera_rotmat[2]);
 
 sub_v3_v3v3(plane_isect_delta, plane_isect_pt_2, plane_isect_pt_1);
-plane_isect_delta_len = len_v3(plane_isect_delta);
+const float plane_isect_delta_len = len_v3(plane_isect_delta);
 
 if (dot_v3v3(plane_isect_delta, cam_plane_no) > 0.0f) {
   copy_v3_v3(r_co, plane_isect_pt_1);

___
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] [9dfabc1de33] master: Cleanup: remove redundant `event->val` check for 3D text insertion

2022-07-14 Thread Campbell Barton
Commit: 9dfabc1de33f555d3e2856974952fc5c646b3b85
Author: Campbell Barton
Date:   Thu Jul 14 22:01:43 2022 +1000
Branches: master
https://developer.blender.org/rB9dfabc1de33f555d3e2856974952fc5c646b3b85

Cleanup: remove redundant `event->val` check for 3D text insertion

===

M   source/blender/editors/curve/editfont.c

===

diff --git a/source/blender/editors/curve/editfont.c 
b/source/blender/editors/curve/editfont.c
index 623f41dcd20..ceed12dcff1 100644
--- a/source/blender/editors/curve/editfont.c
+++ b/source/blender/editors/curve/editfont.c
@@ -1642,7 +1642,6 @@ static int insert_text_invoke(bContext *C, wmOperator 
*op, const wmEvent *event)
   const bool alt = event->modifier & KM_ALT;
   const bool shift = event->modifier & KM_SHIFT;
   const bool ctrl = event->modifier & KM_CTRL;
-  int event_type = event->type, event_val = event->val;
   char32_t insert_char_override = 0;
   char32_t inserted_text[2] = {0};
 
@@ -1657,7 +1656,7 @@ static int insert_text_invoke(bContext *C, wmOperator 
*op, const wmEvent *event)
 return OPERATOR_FINISHED;
   }
 
-  if (event_type == EVT_BACKSPACEKEY) {
+  if (event->type == EVT_BACKSPACEKEY) {
 if (alt && ef->len != 0 && ef->pos > 0) {
   accentcode = true;
 }
@@ -1665,14 +1664,14 @@ static int insert_text_invoke(bContext *C, wmOperator 
*op, const wmEvent *event)
   }
 
   /* Tab typically exit edit-mode, but we allow it to be typed using modifier 
keys. */
-  if (event_type == EVT_TABKEY) {
+  if (event->type == EVT_TABKEY) {
 if ((alt || ctrl || shift) == 0) {
   return OPERATOR_PASS_THROUGH;
 }
 insert_char_override = '\t';
   }
 
-  if (event_val && (insert_char_override || event->utf8_buf[0])) {
+  if (insert_char_override || event->utf8_buf[0]) {
 if (insert_char_override) {
   /* Handle case like TAB ('\t'). */
   inserted_text[0] = insert_char_override;
@@ -1714,11 +1713,6 @@ static int insert_text_invoke(bContext *C, wmOperator 
*op, const wmEvent *event)
 RNA_string_set(op->ptr, "text", inserted_utf8);
   }
 
-  /* reset property? */
-  if (event_val == 0) {
-accentcode = false;
-  }
-
   return OPERATOR_FINISHED;
 }

___
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] [93f74299f07] master: Cleanup: clang-tidy changes to GHOST_SystemX11

2022-07-14 Thread Campbell Barton
Commit: 93f74299f07585d5c922aa048055141e7a487e07
Author: Campbell Barton
Date:   Thu Jul 14 21:55:46 2022 +1000
Branches: master
https://developer.blender.org/rB93f74299f07585d5c922aa048055141e7a487e07

Cleanup: clang-tidy changes to GHOST_SystemX11

Also remove redundant check.

===

M   intern/ghost/intern/GHOST_SystemX11.cpp

===

diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp 
b/intern/ghost/intern/GHOST_SystemX11.cpp
index 70a9687672c..00cc5f3af8f 100644
--- a/intern/ghost/intern/GHOST_SystemX11.cpp
+++ b/intern/ghost/intern/GHOST_SystemX11.cpp
@@ -1159,7 +1159,7 @@ void GHOST_SystemX11::processEvent(XEvent *xe)
 #if defined(WITH_X11_XINPUT) && defined(X_HAVE_UTF8_STRING)
 /* Setting unicode on key-up events gives #XLookupNone status. */
 xic = window->getX11_XIC();
-if (xic && xke->type == KeyPress) {
+if (xic) {
   Status status;
 
   /* Use utf8 because its not locale repentant, from XORG docs. */
@@ -1213,20 +1213,21 @@ void GHOST_SystemX11::processEvent(XEvent *xe)
   if (xke->type == KeyPress && xic) {
 unsigned char c;
 int i = 0;
-while (1) {
-  /* search character boundary */
-  if ((unsigned char)utf8_buf[i++] > 0x7f) {
+while (true) {
+  /* Search character boundary. */
+  if ((uchar)utf8_buf[i++] > 0x7f) {
 for (; i < len; ++i) {
   c = utf8_buf[i];
-  if (c < 0x80 || c > 0xbf)
+  if (c < 0x80 || c > 0xbf) {
 break;
+  }
 }
   }
 
-  if (i >= len)
+  if (i >= len) {
 break;
-
-  /* enqueue previous character */
+  }
+  /* Enqueue previous character. */
   pushEvent(g_event);
 
   g_event = new GHOST_EventKey(
@@ -1234,8 +1235,9 @@ void GHOST_SystemX11::processEvent(XEvent *xe)
 }
   }
 
-  if (utf8_buf != utf8_array)
+  if (utf8_buf != utf8_array) {
 free(utf8_buf);
+  }
 #endif
 
   break;

___
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] [cdd8b96e3b4] master: GHOST: remove redundant ascii argument to GHOST_EventKey

2022-07-14 Thread Campbell Barton
Commit: cdd8b96e3b476df38847121102c6a267b5522a85
Author: Campbell Barton
Date:   Thu Jul 14 21:39:31 2022 +1000
Branches: master
https://developer.blender.org/rBcdd8b96e3b476df38847121102c6a267b5522a85

GHOST: remove redundant ascii argument to GHOST_EventKey

Now only the utf8 buffer is used there is no reason to pass both.

===

M   intern/ghost/intern/GHOST_EventKey.h
M   intern/ghost/intern/GHOST_SystemCocoa.mm
M   intern/ghost/intern/GHOST_SystemSDL.cpp
M   intern/ghost/intern/GHOST_SystemWayland.cpp
M   intern/ghost/intern/GHOST_SystemWin32.cpp
M   intern/ghost/intern/GHOST_SystemX11.cpp

===

diff --git a/intern/ghost/intern/GHOST_EventKey.h 
b/intern/ghost/intern/GHOST_EventKey.h
index d3cfbbeddd7..f85a674be9f 100644
--- a/intern/ghost/intern/GHOST_EventKey.h
+++ b/intern/ghost/intern/GHOST_EventKey.h
@@ -22,6 +22,7 @@ class GHOST_EventKey : public GHOST_Event {
* \param msec: The time this event was generated.
* \param type: The type of key event.
* \param key: The key code of the key.
+   * \param is_repeat: Enabled for key repeat events (only for press events).
*/
   GHOST_EventKey(
   uint64_t msec, GHOST_TEventType type, GHOST_IWindow *window, GHOST_TKey 
key, bool is_repeat)
@@ -38,15 +39,15 @@ class GHOST_EventKey : public GHOST_Event {
* \param msec: The time this event was generated.
* \param type: The type of key event.
* \param key: The key code of the key.
-   * \param ascii: The ascii code for the key event.
+   * \param is_repeat: Enabled for key repeat events (only for press events).
+   * \param utf8_buf: The text associated with this key event (only for press 
events).
*/
   GHOST_EventKey(uint64_t msec,
  GHOST_TEventType type,
  GHOST_IWindow *window,
  GHOST_TKey key,
- char ascii,
- const char utf8_buf[6],
- bool is_repeat)
+ bool is_repeat,
+ const char utf8_buf[6])
   : GHOST_Event(msec, type, window)
   {
 m_keyEventData.key = key;
@@ -56,11 +57,6 @@ class GHOST_EventKey : public GHOST_Event {
 else {
   m_keyEventData.utf8_buf[0] = '\0';
 }
-/* TODO(@campbellbarton): phase out `ascii` and always use `utf8_buf`, 
this needs to be done
- * on all platforms though, so for now write the ascii into the utf8_buf. 
*/
-if (m_keyEventData.utf8_buf[0] == '\0' && ascii) {
-  m_keyEventData.utf8_buf[0] = ascii;
-}
 m_keyEventData.is_repeat = is_repeat;
 m_data = _keyEventData;
   }
diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm 
b/intern/ghost/intern/GHOST_SystemCocoa.mm
index 0a905f5093e..c247ef3daa0 100644
--- a/intern/ghost/intern/GHOST_SystemCocoa.mm
+++ b/intern/ghost/intern/GHOST_SystemCocoa.mm
@@ -1779,7 +1779,6 @@ GHOST_TSuccess GHOST_SystemCocoa::handleKeyEvent(void 
*eventPtr)
   NSString *characters;
   NSData *convertedCharacters;
   GHOST_TKey keyCode;
-  unsigned char ascii;
   NSString *charsIgnoringModifiers;
 
   window = m_windowManager->getWindowAssociatedWithOSWindow((void *)[event 
window]);
@@ -1789,7 +1788,6 @@ GHOST_TSuccess GHOST_SystemCocoa::handleKeyEvent(void 
*eventPtr)
   }
 
   char utf8_buf[6] = {'\0'};
-  ascii = 0;
 
   switch ([event type]) {
 
@@ -1809,7 +1807,6 @@ GHOST_TSuccess GHOST_SystemCocoa::handleKeyEvent(void 
*eventPtr)
   
kUCKeyActionUp);
   }
 
-  /* handling both unicode or ascii */
   characters = [event characters];
   if ([characters length] > 0) {
 convertedCharacters = [characters 
dataUsingEncoding:NSUTF8StringEncoding];
@@ -1835,41 +1832,31 @@ GHOST_TSuccess GHOST_SystemCocoa::handleKeyEvent(void 
*eventPtr)
   if ((keyCode == GHOST_kKeyQ) && (m_modifierMask & 
NSEventModifierFlagCommand))
 break;  // Cmd-Q is directly handled by Cocoa
 
-  /* ascii is a subset of unicode */
-  if (utf8_buf[0] && !utf8_buf[1]) {
-ascii = utf8_buf[0];
-  }
-
   if ([event type] == NSEventTypeKeyDown) {
 pushEvent(new GHOST_EventKey([event timestamp] * 1000,
  GHOST_kEventKeyDown,
  window,
  keyCode,
- ascii,
- utf8_buf,
- [event isARepeat]));
+ [event isARepeat],
+ utf8_buf));
 #if 0
-printf("Key down rawCode=0x%x charsIgnoringModifiers=%c keyCode=%u 
ascii=%i %c utf8=%s\n",
+printf("Key down rawCode=0x%x charsIgnoringModifiers=%c keyCode=%u 
utf8=%s\n",
[event keyCode],
[charsIgnoringModifiers length] > 0 ? 

[Bf-blender-cvs] [eb3e56a36e1] master: Fix: Wrong output types for some compositor nodes

2022-07-14 Thread Omar Emara
Commit: eb3e56a36e18fd4d560a31c2b60ceb235fd0da09
Author: Omar Emara
Date:   Thu Jul 14 13:52:44 2022 +0200
Branches: master
https://developer.blender.org/rBeb3e56a36e18fd4d560a31c2b60ceb235fd0da09

Fix: Wrong output types for some compositor nodes

The Difference Matte and RGB To BW nodes have a wrong output type. They
should be floats but are of type color.

This is a regression that was introduced during the migration to the
socket builder API in D13266.

Reviewed By: Blendify, fclem

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

===

M   source/blender/nodes/composite/nodes/node_composite_diff_matte.cc
M   source/blender/nodes/composite/nodes/node_composite_val_to_rgb.cc

===

diff --git a/source/blender/nodes/composite/nodes/node_composite_diff_matte.cc 
b/source/blender/nodes/composite/nodes/node_composite_diff_matte.cc
index 20dd61a9725..b87bbe439db 100644
--- a/source/blender/nodes/composite/nodes/node_composite_diff_matte.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_diff_matte.cc
@@ -19,7 +19,7 @@ static void 
cmp_node_diff_matte_declare(NodeDeclarationBuilder )
   b.add_input(N_("Image 1")).default_value({1.0f, 1.0f, 1.0f, 
1.0f});
   b.add_input(N_("Image 2")).default_value({1.0f, 1.0f, 1.0f, 
1.0f});
   b.add_output(N_("Image"));
-  b.add_output(N_("Matte"));
+  b.add_output(N_("Matte"));
 }
 
 static void node_composit_init_diff_matte(bNodeTree *UNUSED(ntree), bNode 
*node)
diff --git a/source/blender/nodes/composite/nodes/node_composite_val_to_rgb.cc 
b/source/blender/nodes/composite/nodes/node_composite_val_to_rgb.cc
index 0dfdeda24e6..df669d5beda 100644
--- a/source/blender/nodes/composite/nodes/node_composite_val_to_rgb.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_val_to_rgb.cc
@@ -49,7 +49,7 @@ namespace blender::nodes::node_composite_val_to_rgb_cc {
 static void cmp_node_rgbtobw_declare(NodeDeclarationBuilder )
 {
   b.add_input(N_("Image")).default_value({0.8f, 0.8f, 0.8f, 
1.0f});
-  b.add_output(N_("Val"));
+  b.add_output(N_("Val"));
 }
 
 }  // namespace blender::nodes::node_composite_val_to_rgb_cc

___
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] [9d35fc5a134] temp-ghost-remove-ascii-arg: Remove ASCII arguemnt from ghost (temp branch for testing)

2022-07-14 Thread Campbell Barton
Commit: 9d35fc5a134c5332754ac978e75941f71db37397
Author: Campbell Barton
Date:   Thu Jul 14 21:39:31 2022 +1000
Branches: temp-ghost-remove-ascii-arg
https://developer.blender.org/rB9d35fc5a134c5332754ac978e75941f71db37397

Remove ASCII arguemnt from ghost (temp branch for testing)

===

M   intern/ghost/intern/GHOST_EventKey.h
M   intern/ghost/intern/GHOST_SystemCocoa.mm
M   intern/ghost/intern/GHOST_SystemSDL.cpp
M   intern/ghost/intern/GHOST_SystemWayland.cpp
M   intern/ghost/intern/GHOST_SystemWin32.cpp
M   intern/ghost/intern/GHOST_SystemX11.cpp

===

diff --git a/intern/ghost/intern/GHOST_EventKey.h 
b/intern/ghost/intern/GHOST_EventKey.h
index d3cfbbeddd7..a110e61778c 100644
--- a/intern/ghost/intern/GHOST_EventKey.h
+++ b/intern/ghost/intern/GHOST_EventKey.h
@@ -38,15 +38,14 @@ class GHOST_EventKey : public GHOST_Event {
* \param msec: The time this event was generated.
* \param type: The type of key event.
* \param key: The key code of the key.
-   * \param ascii: The ascii code for the key event.
+   * \param utf8_buf: The text associated with this key event (only for press 
events).
*/
   GHOST_EventKey(uint64_t msec,
  GHOST_TEventType type,
  GHOST_IWindow *window,
  GHOST_TKey key,
- char ascii,
- const char utf8_buf[6],
- bool is_repeat)
+ bool is_repeat,
+ const char utf8_buf[6])
   : GHOST_Event(msec, type, window)
   {
 m_keyEventData.key = key;
@@ -56,11 +55,6 @@ class GHOST_EventKey : public GHOST_Event {
 else {
   m_keyEventData.utf8_buf[0] = '\0';
 }
-/* TODO(@campbellbarton): phase out `ascii` and always use `utf8_buf`, 
this needs to be done
- * on all platforms though, so for now write the ascii into the utf8_buf. 
*/
-if (m_keyEventData.utf8_buf[0] == '\0' && ascii) {
-  m_keyEventData.utf8_buf[0] = ascii;
-}
 m_keyEventData.is_repeat = is_repeat;
 m_data = _keyEventData;
   }
diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm 
b/intern/ghost/intern/GHOST_SystemCocoa.mm
index 0a905f5093e..a15d60fb2cf 100644
--- a/intern/ghost/intern/GHOST_SystemCocoa.mm
+++ b/intern/ghost/intern/GHOST_SystemCocoa.mm
@@ -1845,31 +1845,26 @@ GHOST_TSuccess GHOST_SystemCocoa::handleKeyEvent(void 
*eventPtr)
  GHOST_kEventKeyDown,
  window,
  keyCode,
- ascii,
- utf8_buf,
- [event isARepeat]));
+ [event isARepeat],
+ utf8_buf));
 #if 0
-printf("Key down rawCode=0x%x charsIgnoringModifiers=%c keyCode=%u 
ascii=%i %c utf8=%s\n",
+printf("Key down rawCode=0x%x charsIgnoringModifiers=%c keyCode=%u 
utf8=%s\n",
[event keyCode],
[charsIgnoringModifiers length] > 0 ? [charsIgnoringModifiers 
characterAtIndex:0] :
  ' ',
keyCode,
-   ascii,
-   ascii,
utf8_buf);
 #endif
   }
   else {
 pushEvent(new GHOST_EventKey(
-[event timestamp] * 1000, GHOST_kEventKeyUp, window, keyCode, 0, 
NULL, false));
+[event timestamp] * 1000, GHOST_kEventKeyUp, window, keyCode, 
false, NULL));
 #if 0
-printf("Key up rawCode=0x%x charsIgnoringModifiers=%c keyCode=%u 
ascii=%i %c utf8=%s\n",
+printf("Key up rawCode=0x%x charsIgnoringModifiers=%c keyCode=%u 
utf8=%s\n",
[event keyCode],
[charsIgnoringModifiers length] > 0 ? [charsIgnoringModifiers 
characterAtIndex:0] :
  ' ',
keyCode,
-   ascii,
-   ascii,
utf8_buf);
 #endif
   }
diff --git a/intern/ghost/intern/GHOST_SystemSDL.cpp 
b/intern/ghost/intern/GHOST_SystemSDL.cpp
index 55a15ae470e..d912b57f049 100644
--- a/intern/ghost/intern/GHOST_SystemSDL.cpp
+++ b/intern/ghost/intern/GHOST_SystemSDL.cpp
@@ -608,8 +608,7 @@ void GHOST_SystemSDL::processEvent(SDL_Event *sdl_event)
 utf8_buf[0] = convert_keyboard_event_to_ascii(sdl_sub_evt);
   }
 
-  g_event = new GHOST_EventKey(
-  getMilliSeconds(), type, window, gkey, '\0', utf8_buf, is_repeat);
+  g_event = new GHOST_EventKey(getMilliSeconds(), type, window, gkey, 
is_repeat, utf8_buf);
   break;
 }
   }
diff --git a/intern/ghost/intern/GHOST_SystemWayland.cpp 
b/intern/ghost/intern/GHOST_SystemWayland.cpp
index 876f77732c2..099792a4d06 100644
--- a/intern/ghost/intern/GHOST_SystemWayland.cpp
+++ 

[Bf-blender-cvs] [db80cf6ad79] master: GHOST/X11: avoid redundant utf8 text lookups for release events

2022-07-14 Thread Campbell Barton
Commit: db80cf6ad79cad93ce5638d6e406e674775fc5dc
Author: Campbell Barton
Date:   Thu Jul 14 21:07:37 2022 +1000
Branches: master
https://developer.blender.org/rBdb80cf6ad79cad93ce5638d6e406e674775fc5dc

GHOST/X11: avoid redundant utf8 text lookups for release events

The text representation of release events is never used,
so only calculate this for press events.

===

M   intern/ghost/intern/GHOST_SystemX11.cpp

===

diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp 
b/intern/ghost/intern/GHOST_SystemX11.cpp
index 6b28c271059..4145856ee16 100644
--- a/intern/ghost/intern/GHOST_SystemX11.cpp
+++ b/intern/ghost/intern/GHOST_SystemX11.cpp
@@ -1017,7 +1017,9 @@ void GHOST_SystemX11::processEvent(XEvent *xe)
 case KeyRelease: {
   XKeyEvent *xke = &(xe->xkey);
   KeySym key_sym;
+  char *utf8_buf = nullptr;
   char ascii;
+
 #if defined(WITH_X11_XINPUT) && defined(X_HAVE_UTF8_STRING)
   /* utf8_array[] is initial buffer used for Xutf8LookupString().
* if the length of the utf8 string exceeds this array, allocate
@@ -1026,12 +1028,10 @@ void GHOST_SystemX11::processEvent(XEvent *xe)
* at the end of this buffer when the constructor of GHOST_EventKey
* reads 6 bytes regardless of the effective data length. */
   char utf8_array[16 * 6 + 5]; /* 16 utf8 characters */
-  char *utf8_buf = utf8_array;
-  int len = 1; /* at least one null character will be stored */
+  int len = 1; /* at least one null character will be 
stored */
 #else
-  char *utf8_buf = nullptr;
+  char utf8_array[sizeof(GHOST_TEventKeyData::utf8_buf)] = {'\0'};
 #endif
-
   GHOST_TEventType type = (xke->type == KeyPress) ? GHOST_kEventKeyDown : 
GHOST_kEventKeyUp;
 
   GHOST_TKey gkey;
@@ -1151,61 +1151,68 @@ void GHOST_SystemX11::processEvent(XEvent *xe)
 #endif
 
 #if defined(WITH_X11_XINPUT) && defined(X_HAVE_UTF8_STRING)
-  /* Setting unicode on key-up events gives #XLookupNone status. */
-  XIC xic = window->getX11_XIC();
-  if (xic && xke->type == KeyPress) {
-Status status;
+  /* Only used for key-press. */
+  XIC xic = nullptr;
+#endif
 
-/* Use utf8 because its not locale repentant, from XORG docs. */
-if (!(len = Xutf8LookupString(
-  xic, xke, utf8_buf, sizeof(utf8_array) - 5, _sym, 
))) {
-  utf8_buf[0] = '\0';
-}
+  if (xke->type == KeyPress) {
+utf8_buf = utf8_array;
+#if defined(WITH_X11_XINPUT) && defined(X_HAVE_UTF8_STRING)
+/* Setting unicode on key-up events gives #XLookupNone status. */
+xic = window->getX11_XIC();
+if (xic && xke->type == KeyPress) {
+  Status status;
+
+  /* Use utf8 because its not locale repentant, from XORG docs. */
+  if (!(len = Xutf8LookupString(
+xic, xke, utf8_buf, sizeof(utf8_array) - 5, _sym, 
))) {
+utf8_buf[0] = '\0';
+  }
 
-if (status == XBufferOverflow) {
-  utf8_buf = (char *)malloc(len + 5);
-  len = Xutf8LookupString(xic, xke, utf8_buf, len, _sym, );
-}
+  if (status == XBufferOverflow) {
+utf8_buf = (char *)malloc(len + 5);
+len = Xutf8LookupString(xic, xke, utf8_buf, len, _sym, 
);
+  }
 
-if (ELEM(status, XLookupChars, XLookupBoth)) {
-  if ((unsigned char)utf8_buf[0] >= 32) { /* not an ascii control 
character */
-/* do nothing for now, this is valid utf8 */
+  if (ELEM(status, XLookupChars, XLookupBoth)) {
+if ((unsigned char)utf8_buf[0] >= 32) { /* not an ascii control 
character */
+  /* do nothing for now, this is valid utf8 */
+}
+else {
+  utf8_buf[0] = '\0';
+}
+  }
+  else if (status == XLookupKeySym) {
+/* this key doesn't have a text representation, it is a command
+ * key of some sort */
   }
   else {
-utf8_buf[0] = '\0';
+printf("Bad keycode lookup. Keysym 0x%x Status: %s\n",
+   (unsigned int)key_sym,
+   (status == XLookupNone   ? "XLookupNone" :
+status == XLookupKeySym ? "XLookupKeySym" :
+  "Unknown status"));
+
+printf("'%.*s' %p %p\n", len, utf8_buf, xic, m_xim);
   }
 }
-else if (status == XLookupKeySym) {
-  /* this key doesn't have a text representation, it is a command
-   * key of some sort */
-}
 else {
-  printf("Bad keycode lookup. Keysym 0x%x Status: %s\n",
- (unsigned int)key_sym,
- (status == XLookupNone   ? "XLookupNone" :
-  status == XLookupKeySym ? "XLookupKeySym" :
-

[Bf-blender-cvs] [64e196422e8] master: GHOST/X11: Quiet warning about key-release events having their utf8 set

2022-07-14 Thread Campbell Barton
Commit: 64e196422e85e5177e3b30d2646fc6e9c34e6628
Author: Campbell Barton
Date:   Thu Jul 14 20:55:02 2022 +1000
Branches: master
https://developer.blender.org/rB64e196422e85e5177e3b30d2646fc6e9c34e6628

GHOST/X11: Quiet warning about key-release events having their utf8 set

Quiet warning from [0], no functional change as the this information
was always ignored.

Key release events shouldn't have associated text, this was cleared
for wmEvent's, so there is no reason to pass it from GHOST.

[0]: d6fef73ef110eb43756b7b87c2cba80abae3b39f

===

M   intern/ghost/intern/GHOST_SystemX11.cpp

===

diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp 
b/intern/ghost/intern/GHOST_SystemX11.cpp
index 5e549b54afd..6b28c271059 100644
--- a/intern/ghost/intern/GHOST_SystemX11.cpp
+++ b/intern/ghost/intern/GHOST_SystemX11.cpp
@@ -1194,6 +1194,11 @@ void GHOST_SystemX11::processEvent(XEvent *xe)
   }
 #endif
 
+  if (type != GHOST_kEventKeyDown) {
+ascii = 0;
+utf8_buf = nullptr;
+  }
+
   g_event = new GHOST_EventKey(
   getMilliSeconds(), type, window, gkey, ascii, utf8_buf, is_repeat);

___
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] [7fa7722350b] master: Cleanup: format, unused argument

2022-07-14 Thread Campbell Barton
Commit: 7fa7722350b471e3ce6b369137c5b41574a4bda2
Author: Campbell Barton
Date:   Thu Jul 14 20:52:47 2022 +1000
Branches: master
https://developer.blender.org/rB7fa7722350b471e3ce6b369137c5b41574a4bda2

Cleanup: format, unused argument

===

M   source/blender/blenkernel/BKE_fcurve.h
M   source/blender/blenkernel/intern/lib_id_test.cc
M   source/blender/editors/screen/screen_user_menu.c
M   source/blender/editors/space_nla/nla_edit.c

===

diff --git a/source/blender/blenkernel/BKE_fcurve.h 
b/source/blender/blenkernel/BKE_fcurve.h
index 3ccbd2ac1da..c5788c07336 100644
--- a/source/blender/blenkernel/BKE_fcurve.h
+++ b/source/blender/blenkernel/BKE_fcurve.h
@@ -488,7 +488,8 @@ void BKE_fcurve_delete_keys_all(struct FCurve *fcu);
  */
 void BKE_fcurve_handles_recalc(struct FCurve *fcu);
 /**
- * Variant of #BKE_fcurve_handles_recalc() that allows calculating based on a 
different select flag.
+ * Variant of #BKE_fcurve_handles_recalc() that allows calculating based on a 
different select
+ * flag.
  *
  * \param handle_sel_flag: The flag (bezt.f1/2/3) value to use to determine 
selection.
  * Usually `SELECT`, but may want to use a different one at times
diff --git a/source/blender/blenkernel/intern/lib_id_test.cc 
b/source/blender/blenkernel/intern/lib_id_test.cc
index 96718b3a65b..1aba78eed8f 100644
--- a/source/blender/blenkernel/intern/lib_id_test.cc
+++ b/source/blender/blenkernel/intern/lib_id_test.cc
@@ -57,7 +57,7 @@ TEST(lib_id_main_sort, local_ids_1)
   test_lib_id_main_sort_check_order({id_a, id_b, id_c});
 }
 
-static void change_lib(Main *bmain, ID *id, Library *lib)
+static void change_lib(Main * /*bmain*/, ID *id, Library *lib)
 {
   id->lib = lib;
 }
diff --git a/source/blender/editors/screen/screen_user_menu.c 
b/source/blender/editors/screen/screen_user_menu.c
index 67ca6a83b2b..9d66debda6f 100644
--- a/source/blender/editors/screen/screen_user_menu.c
+++ b/source/blender/editors/screen/screen_user_menu.c
@@ -214,7 +214,14 @@ static void screen_user_menu_draw(const bContext *C, Menu 
*menu)
 wmOperatorType *ot = WM_operatortype_find(umi_op->op_idname, false);
 if (ot != NULL) {
   IDProperty *prop = umi_op->prop ? IDP_CopyProperty(umi_op->prop) : 
NULL;
-  uiItemFullO_ptr(menu->layout, ot, 
CTX_IFACE_(ot->translation_context, ui_name), ICON_NONE, prop, 
umi_op->opcontext, 0, NULL);
+  uiItemFullO_ptr(menu->layout,
+  ot,
+  CTX_IFACE_(ot->translation_context, ui_name),
+  ICON_NONE,
+  prop,
+  umi_op->opcontext,
+  0,
+  NULL);
   is_empty = false;
 }
 else {
diff --git a/source/blender/editors/space_nla/nla_edit.c 
b/source/blender/editors/space_nla/nla_edit.c
index 42509f17b92..d1a667c6e4e 100644
--- a/source/blender/editors/space_nla/nla_edit.c
+++ b/source/blender/editors/space_nla/nla_edit.c
@@ -2204,8 +2204,13 @@ static int nlaedit_apply_scale_exec(bContext *C, 
wmOperator *UNUSED(op))
 /* setup iterator, and iterate over all the keyframes in the action,
  * applying this scaling */
 ked.data = strip;
-ANIM_animchanneldata_keyframes_loop(
-, ac.ads, strip->act, ALE_ACT, NULL, bezt_apply_nlamapping, 
BKE_fcurve_handles_recalc);
+ANIM_animchanneldata_keyframes_loop(,
+ac.ads,
+strip->act,
+ALE_ACT,
+NULL,
+bezt_apply_nlamapping,
+BKE_fcurve_handles_recalc);
 
 /* clear scale of strip now that it has been applied,
  * and recalculate the extents of the action now that it has been 
scaled

___
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] [6cd30d5ff04] master: IDManagement: add more ID naming tests

2022-07-14 Thread Aras Pranckevicius
Commit: 6cd30d5ff04afd690e396f4aff14b38a6bc9e466
Author: Aras Pranckevicius
Date:   Thu Jul 14 13:41:43 2022 +0300
Branches: master
https://developer.blender.org/rB6cd30d5ff04afd690e396f4aff14b38a6bc9e466

IDManagement: add more ID naming tests

As part of a larger change (https://developer.blender.org/D14162),
adding more test coverage for existing functionality separately.

New tests:
- ids_sorted_by_default
- ids_sorted_by_default_with_libraries
- name_too_long_handling
- create_equivalent_numeric_suffixes
- zero_suffix_is_never_assigned
- remove_after_dup_get_original_name
- name_number_suffix_assignment
- renames_with_duplicates
- names_are_unique_per_id_type

===

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

===

diff --git a/source/blender/blenkernel/intern/lib_id_test.cc 
b/source/blender/blenkernel/intern/lib_id_test.cc
index d6101d71be5..96718b3a65b 100644
--- a/source/blender/blenkernel/intern/lib_id_test.cc
+++ b/source/blender/blenkernel/intern/lib_id_test.cc
@@ -18,19 +18,18 @@
 namespace blender::bke::tests {
 
 struct LibIDMainSortTestContext {
-  Main *bmain;
-};
+  Main *bmain = nullptr;
 
-static void test_lib_id_main_sort_init(LibIDMainSortTestContext *ctx)
-{
-  BKE_idtype_init();
-  ctx->bmain = BKE_main_new();
-}
-
-static void test_lib_id_main_sort_free(LibIDMainSortTestContext *ctx)
-{
-  BKE_main_free(ctx->bmain);
-}
+  LibIDMainSortTestContext()
+  {
+BKE_idtype_init();
+bmain = BKE_main_new();
+  }
+  ~LibIDMainSortTestContext()
+  {
+BKE_main_free(bmain);
+  }
+};
 
 static void test_lib_id_main_sort_check_order(std::initializer_list list)
 {
@@ -47,8 +46,7 @@ static void 
test_lib_id_main_sort_check_order(std::initializer_list list)
 
 TEST(lib_id_main_sort, local_ids_1)
 {
-  LibIDMainSortTestContext ctx = {nullptr};
-  test_lib_id_main_sort_init();
+  LibIDMainSortTestContext ctx;
   EXPECT_TRUE(BLI_listbase_is_empty(>libraries));
 
   ID *id_c = static_cast(BKE_id_new(ctx.bmain, ID_OB, "OB_C"));
@@ -57,14 +55,22 @@ TEST(lib_id_main_sort, local_ids_1)
   EXPECT_TRUE(ctx.bmain->objects.first == id_a);
   EXPECT_TRUE(ctx.bmain->objects.last == id_c);
   test_lib_id_main_sort_check_order({id_a, id_b, id_c});
+}
 
-  test_lib_id_main_sort_free();
+static void change_lib(Main *bmain, ID *id, Library *lib)
+{
+  id->lib = lib;
+}
+
+static void change_name(Main *bmain, ID *id, const char *name)
+{
+  BLI_strncpy(id->name + 2, name, MAX_NAME);
+  BKE_id_new_name_validate(>objects, id, nullptr, true);
 }
 
 TEST(lib_id_main_sort, linked_ids_1)
 {
-  LibIDMainSortTestContext ctx = {nullptr};
-  test_lib_id_main_sort_init();
+  LibIDMainSortTestContext ctx;
   EXPECT_TRUE(BLI_listbase_is_empty(>libraries));
 
   Library *lib_a = static_cast(BKE_id_new(ctx.bmain, ID_LI, 
"LI_A"));
@@ -92,14 +98,11 @@ TEST(lib_id_main_sort, linked_ids_1)
   EXPECT_TRUE(ctx.bmain->objects.first == id_c);
   EXPECT_TRUE(ctx.bmain->objects.last == id_b);
   test_lib_id_main_sort_check_order({id_c, id_a, id_b});
-
-  test_lib_id_main_sort_free();
 }
 
 TEST(lib_id_main_unique_name, local_ids_1)
 {
-  LibIDMainSortTestContext ctx = {nullptr};
-  test_lib_id_main_sort_init();
+  LibIDMainSortTestContext ctx;
   EXPECT_TRUE(BLI_listbase_is_empty(>libraries));
 
   ID *id_c = static_cast(BKE_id_new(ctx.bmain, ID_OB, "OB_C"));
@@ -107,21 +110,18 @@ TEST(lib_id_main_unique_name, local_ids_1)
   ID *id_b = static_cast(BKE_id_new(ctx.bmain, ID_OB, "OB_B"));
   test_lib_id_main_sort_check_order({id_a, id_b, id_c});
 
-  BLI_strncpy(id_c->name, id_a->name, sizeof(id_c->name));
-  BKE_id_new_name_validate(>objects, id_c, nullptr, false);
-  EXPECT_TRUE(strcmp(id_c->name + 2, "OB_A.001") == 0);
-  EXPECT_TRUE(strcmp(id_a->name + 2, "OB_A") == 0);
+  change_name(ctx.bmain, id_c, "OB_A");
+
+  EXPECT_STREQ(id_c->name + 2, "OB_A.001");
+  EXPECT_STREQ(id_a->name + 2, "OB_A");
   EXPECT_TRUE(ctx.bmain->objects.first == id_a);
   EXPECT_TRUE(ctx.bmain->objects.last == id_b);
   test_lib_id_main_sort_check_order({id_a, id_c, id_b});
-
-  test_lib_id_main_sort_free();
 }
 
 TEST(lib_id_main_unique_name, linked_ids_1)
 {
-  LibIDMainSortTestContext ctx = {nullptr};
-  test_lib_id_main_sort_init();
+  LibIDMainSortTestContext ctx;
   EXPECT_TRUE(BLI_listbase_is_empty(>libraries));
 
   Library *lib_a = static_cast(BKE_id_new(ctx.bmain, ID_LI, 
"LI_A"));
@@ -130,29 +130,263 @@ TEST(lib_id_main_unique_name, linked_ids_1)
   ID *id_a = static_cast(BKE_id_new(ctx.bmain, ID_OB, "OB_A"));
   ID *id_b = static_cast(BKE_id_new(ctx.bmain, ID_OB, "OB_B"));
 
-  id_a->lib = lib_a;
+  change_lib(ctx.bmain, id_a, lib_a);
   id_sort_by_name(>objects, id_a, nullptr);
-  id_b->lib = lib_a;
+  change_lib(ctx.bmain, id_b, lib_a);
   id_sort_by_name(>objects, id_b, nullptr);
-  BLI_strncpy(id_b->name, id_a->name, sizeof(id_b->name));
-  BKE_id_new_name_validate(>objects, id_b, nullptr, true);
-  

[Bf-blender-cvs] [cb62095c1c8] master: Correct error with IME from d6fef73ef110eb43756b7b87c2cba80abae3b39f

2022-07-14 Thread Campbell Barton
Commit: cb62095c1c8afc4e2b5f28904e3ac4cbd47503b2
Author: Campbell Barton
Date:   Thu Jul 14 20:07:06 2022 +1000
Branches: master
https://developer.blender.org/rBcb62095c1c8afc4e2b5f28904e3ac4cbd47503b2

Correct error with IME from d6fef73ef110eb43756b7b87c2cba80abae3b39f

===

M   source/blender/editors/interface/interface_handlers.c

===

diff --git a/source/blender/editors/interface/interface_handlers.c 
b/source/blender/editors/interface/interface_handlers.c
index 2ad2cd15c43..2496136883d 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -3172,6 +3172,13 @@ static bool ui_textedit_insert_buf(uiBut *but,
   return changed;
 }
 
+static bool ui_textedit_insert_ascii(uiBut *but, uiHandleButtonData *data, 
const char ascii)
+{
+  BLI_assert(isascii(ascii));
+  const char buf[2] = {ascii, '\0'};
+  return ui_textedit_insert_buf(but, data, buf, sizeof(buf) - 1);
+}
+
 static void ui_textedit_move(uiBut *but,
  uiHandleButtonData *data,
  eStrCursorJumpDirection direction,
@@ -3934,6 +3941,9 @@ static void ui_do_but_textedit(
   else if (event->type == WM_IME_COMPOSITE_END) {
 changed = true;
   }
+#else
+  /* Prevent the function from being unused. */
+  (void)ui_textedit_insert_ascii;
 #endif
 
   if (changed) {

___
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] [96cc6030375] master: Geometry Nodes: update curve type counts after realizing instances

2022-07-14 Thread Jacques Lucke
Commit: 96cc6030375b9173ae6b234a12d3af25bfbc0aa6
Author: Jacques Lucke
Date:   Thu Jul 14 11:49:28 2022 +0200
Branches: master
https://developer.blender.org/rB96cc6030375b9173ae6b234a12d3af25bfbc0aa6

Geometry Nodes: update curve type counts after realizing instances

The type counts have to be updated eagerly. This was missing from
the realize-instances code before, leading to bugs further down
the line.

===

M   source/blender/geometry/intern/realize_instances.cc

===

diff --git a/source/blender/geometry/intern/realize_instances.cc 
b/source/blender/geometry/intern/realize_instances.cc
index 25bf00c5783..66b856ee0c4 100644
--- a/source/blender/geometry/intern/realize_instances.cc
+++ b/source/blender/geometry/intern/realize_instances.cc
@@ -1295,6 +1295,15 @@ static void execute_realize_curve_tasks(const 
RealizeInstancesOptions ,
 }
   });
 
+  /* Type counts have to be updated eagerly. */
+  dst_curves.runtime->type_counts.fill(0);
+  for (const RealizeCurveTask  : tasks) {
+for (const int i : IndexRange(CURVE_TYPES_NUM)) {
+  dst_curves.runtime->type_counts[i] +=
+  task.curve_info->curves->geometry.runtime->type_counts[i];
+}
+  }
+
   /* Tag modified attributes. */
   for (GSpanAttributeWriter _attribute : dst_attribute_writers) {
 dst_attribute.finish();

___
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] [c8a07ef6631] master: BLI: fix finding indices from virtual array

2022-07-14 Thread Jacques Lucke
Commit: c8a07ef66311a31cc45901717845139ae0682f2f
Author: Jacques Lucke
Date:   Thu Jul 14 11:32:01 2022 +0200
Branches: master
https://developer.blender.org/rBc8a07ef66311a31cc45901717845139ae0682f2f

BLI: fix finding indices from virtual array

The sorting of index vectors assumed that all vectors have
at least one element. Now this is checked for more explicitely.

===

M   source/blender/blenlib/intern/index_mask.cc

===

diff --git a/source/blender/blenlib/intern/index_mask.cc 
b/source/blender/blenlib/intern/index_mask.cc
index f3590e4a41c..e9af183d60d 100644
--- a/source/blender/blenlib/intern/index_mask.cc
+++ b/source/blender/blenlib/intern/index_mask.cc
@@ -142,6 +142,7 @@ IndexMask find_indices_based_on_predicate__merge(
   int64_t result_mask_size = 0;
   for (Vector> _sub_masks : sub_masks) {
 for (Vector _mask : local_sub_masks) {
+  BLI_assert(!sub_mask.is_empty());
   all_vectors.append(_mask);
   result_mask_size += sub_mask.size();
 }
@@ -232,7 +233,9 @@ IndexMask find_indices_from_virtual_array(const IndexMask 
indices_to_check,
 }
   }
 });
-sub_masks.local().append(std::move(masked_indices));
+if (!masked_indices.is_empty()) {
+  sub_masks.local().append(std::move(masked_indices));
+}
   });
 
   return detail::find_indices_based_on_predicate__merge(indices_to_check, 
sub_masks, r_indices);

___
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] [bcdce4ffd84] master: Geometry Nodes: fix face corner to edge boolean interpolation

2022-07-14 Thread Jacques Lucke
Commit: bcdce4ffd848d5b47c467bedeb221645ec033f20
Author: Jacques Lucke
Date:   Thu Jul 14 10:47:26 2022 +0200
Branches: master
https://developer.blender.org/rBbcdce4ffd848d5b47c467bedeb221645ec033f20

Geometry Nodes: fix face corner to edge boolean interpolation

This is a follow up for rB44e530e1b107fd0d91f472f9a58642ab59fd5422
which did not fix the function that interpolates boolean attributes.

===

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

===

diff --git a/source/blender/blenkernel/intern/geometry_component_mesh.cc 
b/source/blender/blenkernel/intern/geometry_component_mesh.cc
index 83bf2a5d27b..436868ba375 100644
--- a/source/blender/blenkernel/intern/geometry_component_mesh.cc
+++ b/source/blender/blenkernel/intern/geometry_component_mesh.cc
@@ -327,13 +327,16 @@ void adapt_mesh_domain_corner_to_edge_impl(const Mesh 
,
   for (const int poly_index : IndexRange(mesh.totpoly)) {
 const MPoly  = mesh.mpoly[poly_index];
 
-for (const int loop_index : IndexRange(poly.loopstart, poly.totloop)) {
-  const int loop_index_next = (loop_index == poly.totloop) ? 
poly.loopstart : (loop_index + 1);
-  const MLoop  = mesh.mloop[loop_index];
+for (const int i : IndexRange(poly.totloop)) {
+  const int next_i = (i + 1) % poly.totloop;
+  const int loop_i = poly.loopstart + i;
+  const int next_loop_i = poly.loopstart + next_i;
+  const MLoop  = mesh.mloop[loop_i];
   const int edge_index = loop.e;
+
   loose_edges[edge_index] = false;
 
-  if (!old_values[loop_index] || !old_values[loop_index_next]) {
+  if (!old_values[loop_i] || !old_values[next_loop_i]) {
 r_values[edge_index] = 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] [44e530e1b10] master: Geometry Nodes: fix face corner to edge attribute interpolation

2022-07-14 Thread Jacques Lucke
Commit: 44e530e1b107fd0d91f472f9a58642ab59fd5422
Author: Jacques Lucke
Date:   Thu Jul 14 10:35:46 2022 +0200
Branches: master
https://developer.blender.org/rB44e530e1b107fd0d91f472f9a58642ab59fd5422

Geometry Nodes: fix face corner to edge attribute interpolation

Looks like this was wrong all the time.. Luckily, this conversion
is not very common.

Found when testing D15274.

===

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

===

diff --git a/source/blender/blenkernel/intern/geometry_component_mesh.cc 
b/source/blender/blenkernel/intern/geometry_component_mesh.cc
index cf6681a69be..83bf2a5d27b 100644
--- a/source/blender/blenkernel/intern/geometry_component_mesh.cc
+++ b/source/blender/blenkernel/intern/geometry_component_mesh.cc
@@ -298,12 +298,14 @@ static void adapt_mesh_domain_corner_to_edge_impl(const 
Mesh ,
 const MPoly  = mesh.mpoly[poly_index];
 
 /* For every edge, mix values from the two adjacent corners (the current 
and next corner). */
-for (const int loop_index : IndexRange(poly.loopstart, poly.totloop)) {
-  const int loop_index_next = (loop_index + 1) % poly.totloop;
-  const MLoop  = mesh.mloop[loop_index];
+for (const int i : IndexRange(poly.totloop)) {
+  const int next_i = (i + 1) % poly.totloop;
+  const int loop_i = poly.loopstart + i;
+  const int next_loop_i = poly.loopstart + next_i;
+  const MLoop  = mesh.mloop[loop_i];
   const int edge_index = loop.e;
-  mixer.mix_in(edge_index, old_values[loop_index]);
-  mixer.mix_in(edge_index, old_values[loop_index_next]);
+  mixer.mix_in(edge_index, old_values[loop_i]);
+  mixer.mix_in(edge_index, old_values[next_loop_i]);
 }
   }

___
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] [9d73bbd9668] master: UI: translate tooltips coming from menu descriptions

2022-07-14 Thread Damien Picard
Commit: 9d73bbd9668aaa9fd407780309f5b63b05655fcd
Author: Damien Picard
Date:   Thu Jul 14 10:28:52 2022 +0200
Branches: master
https://developer.blender.org/rB9d73bbd9668aaa9fd407780309f5b63b05655fcd

UI: translate tooltips coming from menu descriptions

Many menus get their labels exported to the .po file, but then are not actually 
translated in the UI.

Before:
{F13283752}

After:
{F13283750}

Reviewed By: mont29

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

===

M   source/blender/editors/interface/interface.cc

===

diff --git a/source/blender/editors/interface/interface.cc 
b/source/blender/editors/interface/interface.cc
index 3f623566807..c0df193de87 100644
--- a/source/blender/editors/interface/interface.cc
+++ b/source/blender/editors/interface/interface.cc
@@ -6623,7 +6623,7 @@ void UI_but_string_info_get(bContext *C, uiBut *but, ...)
   MenuType *mt = UI_but_menutype_get(but);
   if (mt) {
 if (type == BUT_GET_RNA_LABEL) {
-  tmp = BLI_strdup(mt->label);
+  tmp = BLI_strdup(CTX_TIP_(mt->translation_context, mt->label));
 }
 else {
   /* Not all menus are from Python. */
@@ -6653,7 +6653,7 @@ void UI_but_string_info_get(bContext *C, uiBut *but, ...)
   PanelType *pt = UI_but_paneltype_get(but);
   if (pt) {
 if (type == BUT_GET_RNA_LABEL) {
-  tmp = BLI_strdup(pt->label);
+  tmp = BLI_strdup(CTX_TIP_(pt->translation_context, pt->label));
 }
 else {
   /* Not all panels are from Python. */

___
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] [8e3879ab527] master: Cleanup: Rename & refactor several F-curve functions

2022-07-14 Thread Colin Basnett
Commit: 8e3879ab5276cf24ebd59a7bf0df69232fd5e4e6
Author: Colin Basnett
Date:   Thu Jul 14 10:22:30 2022 +0200
Branches: master
https://developer.blender.org/rB8e3879ab5276cf24ebd59a7bf0df69232fd5e4e6

Cleanup: Rename & refactor several F-curve functions

Rename and refactor several F-curve key manipulation functions, and move
them from `editors` to `blenkernel`.

The functions formerly known as `delete_fcurve_key`,
`delete_fcurve_keys`, and `clear_fcurve_keys` have been moved from
`ED_keyframes_edit.h` to `BKE_fcurve.h` and have been renamed according
to hierarchical naming rules.

Below is a table of the naming changes.

| From | To |
| -- | -- |
| `delete_fcurve_key(fcu, index, do_recalc)` | `BKE_fcurve_delete_key(fcu, 
index)` |
| `delete_fcurve_keys(fcu)` | `BKE_fcurve_delete_keys_selected(fcu)` |
| `clear_fcurve_keys(fcu)` | `BKE_fcurve_delete_keys_all(fcu)` |
| `calchandles_fcurve()` | `BKE_fcurve_handles_recalc()` |
| `calchandles_fcurve_ex()`| `BKE_fcurve_handles_recalc_ex()` |

The function formerly known as `delete_fcurve_key` no longer takes a
`do_fast` parameter, which determined whether or not to call
`calchandles_fcurve`. Now, the responsibility is on the caller to run
the new `BKE_fcurve_handles_recalc` function if they have want to
recalculate the handles.

In addition, there is now a new static private function called
`fcurve_bezt_free` which sets the key count to zero and frees the key
array. This function is now used in couple of instances of functionally
equivalent code. Note that `BKE_fcurve_delete_keys_all` is just a
wrapper around `fcurve_bezt_free`.

This change was initially spurred by the fact that `delete_fcurve_keys`
was improperly named; this was a good opportunity to fix the location
and naming of a few of these functions.

Reviewed By: sybren

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

===

M   source/blender/blenkernel/BKE_fcurve.h
M   source/blender/blenkernel/intern/action_mirror.c
M   source/blender/blenkernel/intern/fcurve.c
M   source/blender/blenkernel/intern/fmodifier.c
M   source/blender/editors/animation/anim_deps.c
M   source/blender/editors/animation/drivers.c
M   source/blender/editors/animation/fmodifier_ui.c
M   source/blender/editors/animation/keyframes_edit.c
M   source/blender/editors/animation/keyframes_general.c
M   source/blender/editors/animation/keyframing.c
M   source/blender/editors/armature/pose_lib.c
M   source/blender/editors/gpencil/gpencil_convert.c
M   source/blender/editors/include/ED_keyframes_edit.h
M   source/blender/editors/space_action/action_edit.c
M   source/blender/editors/space_graph/graph_buttons.c
M   source/blender/editors/space_graph/graph_edit.c
M   source/blender/editors/space_nla/nla_edit.c
M   source/blender/editors/transform/transform_convert.c
M   source/blender/editors/transform/transform_convert_graph.c
M   source/blender/io/collada/AnimationImporter.cpp
M   source/blender/io/collada/BCAnimationCurve.cpp
M   source/blender/makesrna/intern/rna_fcurve.c
M   source/blender/python/intern/bpy_rna_anim.c

===

diff --git a/source/blender/blenkernel/BKE_fcurve.h 
b/source/blender/blenkernel/BKE_fcurve.h
index 10d9ce3364d..3ccbd2ac1da 100644
--- a/source/blender/blenkernel/BKE_fcurve.h
+++ b/source/blender/blenkernel/BKE_fcurve.h
@@ -463,23 +463,38 @@ bool BKE_fcurve_bezt_subdivide_handles(struct BezTriple 
*bezt,
struct BezTriple *next,
float *r_pdelta);
 
+/**
+ * Delete a keyframe from an F-curve at a specific index.
+ */
+void BKE_fcurve_delete_key(struct FCurve *fcu, int index);
+
+/**
+ * Delete selected keyframes from an F-curve.
+ */
+bool BKE_fcurve_delete_keys_selected(struct FCurve *fcu);
+
+/**
+ * Delete all keyframes from an F-curve.
+ */
+void BKE_fcurve_delete_keys_all(struct FCurve *fcu);
+
 /*  Curve Sanity  */
 
 /**
  * This function recalculates the handles of an F-Curve. Acts based on 
selection with `SELECT`
- * flag. To use a different flag, use #calchandles_fcurve_ex().
+ * flag. To use a different flag, use #BKE_fcurve_handles_recalc_ex().
  *
  * If the BezTriples have been rearranged, sort them first before using this.
  */
-void calchandles_fcurve(struct FCurve *fcu);
+void BKE_fcurve_handles_recalc(struct FCurve *fcu);
 /**
- * Variant of #calchandles_fcurve() that allows calculating based on a 
different select flag.
+ * Variant of #BKE_fcurve_handles_recalc() that allows calculating based on a 
different select flag.
  *
  * \param handle_sel_flag: The flag (bezt.f1/2/3) value to use to determine 
selection.
  * Usually `SELECT`, but may want to use a different one at times
  * (if caller does not operate on selection).
  */
-void calchandles_fcurve_ex(struct FCurve *fcu, 

[Bf-blender-cvs] [77df9d788a2] master: Fix T99239: weird behavior in Field on Domain node

2022-07-14 Thread Iliay Katueshenock
Commit: 77df9d788a2bb9d7173f10edf3631dc26ccce8ed
Author: Iliay Katueshenock
Date:   Thu Jul 14 10:04:35 2022 +0200
Branches: master
https://developer.blender.org/rB77df9d788a2bb9d7173f10edf3631dc26ccce8ed

Fix T99239: weird behavior in Field on Domain node

===

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

===

diff --git a/source/blender/nodes/geometry/nodes/node_geo_field_on_domain.cc 
b/source/blender/nodes/geometry/nodes/node_geo_field_on_domain.cc
index 5939ed5334d..59e243db4a2 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_field_on_domain.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_field_on_domain.cc
@@ -85,12 +85,13 @@ class FieldOnDomain final : public GeometryFieldInput {
  IndexMask /* mask */) const final
   {
 const GeometryComponentFieldContext context{component, src_domain_};
-FieldEvaluator value_evaluator{context, 
component.attribute_domain_size(src_domain_)};
-value_evaluator.add(src_field_);
+const int64_t src_domain_size = 
component.attribute_domain_size(src_domain_);
+GArray values(src_field_.cpp_type(), src_domain_size);
+FieldEvaluator value_evaluator{context, src_domain_size};
+value_evaluator.add_with_destination(src_field_, values.as_mutable_span());
 value_evaluator.evaluate();
-const GVArray  = value_evaluator.get_evaluated(0);
-
-return component.attributes()->adapt_domain(values, src_domain_, domain);
+return component.attributes()->adapt_domain(
+GVArray::ForGArray(std::move(values)), src_domain_, domain);
   }
 };

___
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] [1571ee66b51] master: I18N: Allow translating newly added GP data names, and a missing Surface one.

2022-07-14 Thread Damien Picard
Commit: 1571ee66b51d5a8cd700228d01577608e62c0be9
Author: Damien Picard
Date:   Thu Jul 14 09:40:55 2022 +0200
Branches: master
https://developer.blender.org/rB1571ee66b51d5a8cd700228d01577608e62c0be9

I18N: Allow translating newly added GP data names, and a missing Surface one.

===

M   source/blender/editors/curve/editcurve_add.c
M   source/blender/editors/object/object_add.cc

===

diff --git a/source/blender/editors/curve/editcurve_add.c 
b/source/blender/editors/curve/editcurve_add.c
index ba5a7409ba7..ee6376ca95f 100644
--- a/source/blender/editors/curve/editcurve_add.c
+++ b/source/blender/editors/curve/editcurve_add.c
@@ -87,6 +87,8 @@ static const char *get_surf_defname(int type)
   return CTX_DATA_(BLT_I18NCONTEXT_ID_CURVE_LEGACY, "SurfCircle");
 case CU_PRIM_PATCH:
   return CTX_DATA_(BLT_I18NCONTEXT_ID_CURVE_LEGACY, "SurfPatch");
+case CU_PRIM_TUBE:
+  return CTX_DATA_(BLT_I18NCONTEXT_ID_CURVE_LEGACY, "SurfCylinder");
 case CU_PRIM_SPHERE:
   return CTX_DATA_(BLT_I18NCONTEXT_ID_CURVE_LEGACY, "SurfSphere");
 case CU_PRIM_DONUT:
diff --git a/source/blender/editors/object/object_add.cc 
b/source/blender/editors/object/object_add.cc
index 671a32ce438..35d23edfbf0 100644
--- a/source/blender/editors/object/object_add.cc
+++ b/source/blender/editors/object/object_add.cc
@@ -1335,21 +1335,21 @@ static int object_gpencil_add_exec(bContext *C, 
wmOperator *op)
 const char *ob_name = nullptr;
 switch (type) {
   case GP_EMPTY: {
-ob_name = "GPencil";
+ob_name = CTX_DATA_(BLT_I18NCONTEXT_ID_GPENCIL, "GPencil");
 break;
   }
   case GP_MONKEY: {
-ob_name = "Suzanne";
+ob_name = CTX_DATA_(BLT_I18NCONTEXT_ID_GPENCIL, "Suzanne");
 break;
   }
   case GP_STROKE: {
-ob_name = "Stroke";
+ob_name = CTX_DATA_(BLT_I18NCONTEXT_ID_GPENCIL, "Stroke");
 break;
   }
   case GP_LRT_OBJECT:
   case GP_LRT_SCENE:
   case GP_LRT_COLLECTION: {
-ob_name = "LineArt";
+ob_name = CTX_DATA_(BLT_I18NCONTEXT_ID_GPENCIL, "LineArt");
 break;
   }
   default: {

___
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] [f48fadc953f] master: UI: translate quick favorites menu operator names

2022-07-14 Thread Damien Picard
Commit: f48fadc953f68ba24084bb277ff2ca05ddaa289d
Author: Damien Picard
Date:   Thu Jul 14 09:42:48 2022 +0200
Branches: master
https://developer.blender.org/rBf48fadc953f68ba24084bb277ff2ca05ddaa289d

UI: translate quick favorites menu operator names

Some operator titles were not translated in the quick favorites menu.

Before:
{F13283724}

After:
{F13283725}

Reviewed By: mont29

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

===

M   source/blender/editors/screen/screen_user_menu.c

===

diff --git a/source/blender/editors/screen/screen_user_menu.c 
b/source/blender/editors/screen/screen_user_menu.c
index 1156452310c..67ca6a83b2b 100644
--- a/source/blender/editors/screen/screen_user_menu.c
+++ b/source/blender/editors/screen/screen_user_menu.c
@@ -214,7 +214,7 @@ static void screen_user_menu_draw(const bContext *C, Menu 
*menu)
 wmOperatorType *ot = WM_operatortype_find(umi_op->op_idname, false);
 if (ot != NULL) {
   IDProperty *prop = umi_op->prop ? IDP_CopyProperty(umi_op->prop) : 
NULL;
-  uiItemFullO_ptr(menu->layout, ot, ui_name, ICON_NONE, prop, 
umi_op->opcontext, 0, NULL);
+  uiItemFullO_ptr(menu->layout, ot, 
CTX_IFACE_(ot->translation_context, ui_name), ICON_NONE, prop, 
umi_op->opcontext, 0, NULL);
   is_empty = false;
 }
 else {

___
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] [3935bf255e3] master: Fix T99677: crash when convex hull node is used on empty mesh

2022-07-14 Thread Jacques Lucke
Commit: 3935bf255e3313534bc16090aac8118939a1b333
Author: Jacques Lucke
Date:   Thu Jul 14 09:57:08 2022 +0200
Branches: master
https://developer.blender.org/rB3935bf255e3313534bc16090aac8118939a1b333

Fix T99677: crash when convex hull node is used on empty mesh

Fundamental issue is that the attribute api returns none, because
the custom data api returns null for a layer when the size of 0.
This should be improved separately.

===

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

===

diff --git a/source/blender/nodes/geometry/nodes/node_geo_convex_hull.cc 
b/source/blender/nodes/geometry/nodes/node_geo_convex_hull.cc
index 489b618b8be..3394a7cad62 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_convex_hull.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_convex_hull.cc
@@ -183,8 +183,10 @@ static Mesh *compute_hull(const GeometrySet _set)
 const MeshComponent *component = 
geometry_set.get_component_for_read();
 const VArray varray = 
component->attributes()->lookup("position",
   
ATTR_DOMAIN_POINT);
-varray.materialize(positions.as_mutable_span().slice(offset, 
varray.size()));
-offset += varray.size();
+if (varray) {
+  varray.materialize(positions.as_mutable_span().slice(offset, 
varray.size()));
+  offset += varray.size();
+}
   }
 
   if (geometry_set.has_pointcloud()) {
@@ -192,8 +194,10 @@ static Mesh *compute_hull(const GeometrySet _set)
 geometry_set.get_component_for_read();
 const VArray varray = 
component->attributes()->lookup("position",
   
ATTR_DOMAIN_POINT);
-varray.materialize(positions.as_mutable_span().slice(offset, 
varray.size()));
-offset += varray.size();
+if (varray) {
+  varray.materialize(positions.as_mutable_span().slice(offset, 
varray.size()));
+  offset += varray.size();
+}
   }
 
   if (geometry_set.has_curves()) {

___
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] [411bcf1fe73] master: Cleanup: simplify 3D text insert, remove checks for ascii escape codes

2022-07-14 Thread Campbell Barton
Commit: 411bcf1fe7345f2e513b49249c34d3601631a5d7
Author: Campbell Barton
Date:   Thu Jul 14 16:26:24 2022 +1000
Branches: master
https://developer.blender.org/rB411bcf1fe7345f2e513b49249c34d3601631a5d7

Cleanup: simplify 3D text insert, remove checks for ascii escape codes

3D text included checks for escape codes such as \n\r\b which have not
been included in wmEvent.ascii since [0] (2009).

Remove these and use more straightforward logic for overriding the
events text input.

[0] 66437a62a73966de8ccb673473ba69d6c1ed66a3

===

M   source/blender/editors/curve/editfont.c

===

diff --git a/source/blender/editors/curve/editfont.c 
b/source/blender/editors/curve/editfont.c
index 33e3837c9d4..623f41dcd20 100644
--- a/source/blender/editors/curve/editfont.c
+++ b/source/blender/editors/curve/editfont.c
@@ -59,7 +59,7 @@ static int kill_selection(Object *obedit, int ins);
 /** \name Internal Utilities
  * \{ */
 
-static char32_t findaccent(char32_t char1, uint code)
+static char32_t findaccent(char32_t char1, const char code)
 {
   char32_t new = 0;
 
@@ -1638,12 +1638,12 @@ static int insert_text_invoke(bContext *C, wmOperator 
*op, const wmEvent *event)
   Object *obedit = CTX_data_edit_object(C);
   Curve *cu = obedit->data;
   EditFont *ef = cu->editfont;
-  static int accentcode = 0;
-  uintptr_t ascii = WM_event_utf8_to_ascii(event);
+  static bool accentcode = false;
   const bool alt = event->modifier & KM_ALT;
   const bool shift = event->modifier & KM_SHIFT;
   const bool ctrl = event->modifier & KM_CTRL;
   int event_type = event->type, event_val = event->val;
+  char32_t insert_char_override = 0;
   char32_t inserted_text[2] = {0};
 
   if (RNA_struct_property_is_set(op->ptr, "text")) {
@@ -1652,48 +1652,47 @@ static int insert_text_invoke(bContext *C, wmOperator 
*op, const wmEvent *event)
 
   if (RNA_struct_property_is_set(op->ptr, "accent")) {
 if (ef->len != 0 && ef->pos > 0) {
-  accentcode = 1;
+  accentcode = true;
 }
 return OPERATOR_FINISHED;
   }
 
-  /* tab should exit editmode, but we allow it to be typed using modifier keys 
*/
-  if (event_type == EVT_TABKEY) {
-if ((alt || ctrl || shift) == 0) {
-  return OPERATOR_PASS_THROUGH;
-}
-
-ascii = 9;
-  }
-
   if (event_type == EVT_BACKSPACEKEY) {
 if (alt && ef->len != 0 && ef->pos > 0) {
-  accentcode = 1;
+  accentcode = true;
 }
 return OPERATOR_PASS_THROUGH;
   }
 
-  if (event_val && (ascii || event->utf8_buf[0])) {
-/* handle case like TAB (== 9) */
-if ((ascii > 31 && ascii < 254 && ascii != 127) || (ELEM(ascii, 13, 10)) 
|| (ascii == 8) ||
-(event->utf8_buf[0])) {
+  /* Tab typically exit edit-mode, but we allow it to be typed using modifier 
keys. */
+  if (event_type == EVT_TABKEY) {
+if ((alt || ctrl || shift) == 0) {
+  return OPERATOR_PASS_THROUGH;
+}
+insert_char_override = '\t';
+  }
 
+  if (event_val && (insert_char_override || event->utf8_buf[0])) {
+if (insert_char_override) {
+  /* Handle case like TAB ('\t'). */
+  inserted_text[0] = insert_char_override;
+  insert_into_textbuf(obedit, insert_char_override);
+  text_update_edited(C, obedit, FO_EDIT);
+}
+else {
+  BLI_assert(event->utf8_buf[0]);
   if (accentcode) {
 if (ef->pos > 0) {
-  inserted_text[0] = findaccent(ef->textbuf[ef->pos - 1], ascii);
+  inserted_text[0] = findaccent(ef->textbuf[ef->pos - 1],
+
BLI_str_utf8_as_unicode(event->utf8_buf));
   ef->textbuf[ef->pos - 1] = inserted_text[0];
 }
-accentcode = 0;
+accentcode = false;
   }
   else if (event->utf8_buf[0]) {
 inserted_text[0] = BLI_str_utf8_as_unicode(event->utf8_buf);
-ascii = inserted_text[0];
-insert_into_textbuf(obedit, ascii);
-accentcode = 0;
-  }
-  else if (ascii) {
-insert_into_textbuf(obedit, ascii);
-accentcode = 0;
+insert_into_textbuf(obedit, inserted_text[0]);
+accentcode = false;
   }
   else {
 BLI_assert(0);
@@ -1702,11 +1701,6 @@ static int insert_text_invoke(bContext *C, wmOperator 
*op, const wmEvent *event)
   kill_selection(obedit, 1);
   text_update_edited(C, obedit, FO_EDIT);
 }
-else {
-  inserted_text[0] = ascii;
-  insert_into_textbuf(obedit, ascii);
-  text_update_edited(C, obedit, FO_EDIT);
-}
   }
   else {
 return OPERATOR_PASS_THROUGH;
@@ -1722,7 +1716,7 @@ static int insert_text_invoke(bContext *C, wmOperator 
*op, const wmEvent *event)
 
   /* reset property? */
   if (event_val == 0) {
-accentcode = 0;
+accentcode = false;
   }
 
   return OPERATOR_FINISHED;

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

[Bf-blender-cvs] [b35e33317dd] master: Cleanup: update & correct comments for event handling

2022-07-14 Thread Campbell Barton
Commit: b35e33317dd3c1b0b4ceb3aa0b55f805661fdb05
Author: Campbell Barton
Date:   Thu Jul 14 16:10:13 2022 +1000
Branches: master
https://developer.blender.org/rBb35e33317dd3c1b0b4ceb3aa0b55f805661fdb05

Cleanup: update & correct comments for event handling

- Remove references to `ISTEXTINPUT` as any keyboard event with it's
  utf8_buf set can be handled as text input.

- Update references to the key repeat flag.

===

M   intern/ghost/GHOST_Types.h
M   source/blender/editors/interface/interface_region_menu_pie.cc
M   source/blender/makesdna/DNA_windowmanager_types.h
M   source/blender/windowmanager/intern/wm_event_system.cc
M   source/blender/windowmanager/wm_event_types.h

===

diff --git a/intern/ghost/GHOST_Types.h b/intern/ghost/GHOST_Types.h
index fa74bfde866..495fb739978 100644
--- a/intern/ghost/GHOST_Types.h
+++ b/intern/ghost/GHOST_Types.h
@@ -550,7 +550,12 @@ typedef struct {
   /** The unicode character. if the length is 6, not NULL terminated if all 6 
are set. */
   char utf8_buf[6];
 
-  /** Generated by auto-repeat. */
+  /**
+   * Enabled when the key is held (auto-repeat).
+   * In this case press events are sent without a corresponding release/up 
event.
+   *
+   * All back-ends must set this variable for correct behavior regarding 
repeatable keys.
+   */
   char is_repeat;
 } GHOST_TEventKeyData;
 
diff --git a/source/blender/editors/interface/interface_region_menu_pie.cc 
b/source/blender/editors/interface/interface_region_menu_pie.cc
index b11564f09c5..09902dd6c35 100644
--- a/source/blender/editors/interface/interface_region_menu_pie.cc
+++ b/source/blender/editors/interface/interface_region_menu_pie.cc
@@ -371,7 +371,7 @@ void ui_pie_menu_level_create(uiBlock *block,
   EnumPropertyItem *remaining = static_cast(
   MEM_mallocN(array_size + sizeof(EnumPropertyItem), 
"pie_level_item_array"));
   memcpy(remaining, items + totitem_parent, array_size);
-  /* A nullptr terminating sentinel element is required. */
+  /* A null terminating sentinel element is required. */
   memset([totitem_remain], 0, sizeof(EnumPropertyItem));
 
   /* yuk, static... issue is we can't reliably free this without doing 
dangerous changes */
diff --git a/source/blender/makesdna/DNA_windowmanager_types.h 
b/source/blender/makesdna/DNA_windowmanager_types.h
index a3d9b5fc7b6..116ea4821cb 100644
--- a/source/blender/makesdna/DNA_windowmanager_types.h
+++ b/source/blender/makesdna/DNA_windowmanager_types.h
@@ -407,13 +407,13 @@ enum {
   KMI_USER_MODIFIED = (1 << 2),
   KMI_UPDATE = (1 << 3),
   /**
-   * When set, ignore events with #wmEvent.is_repeat enabled.
+   * When set, ignore events with `wmEvent.flag & WM_EVENT_IS_REPEAT` enabled.
*
* \note this flag isn't cleared when editing/loading the key-map items,
* so it may be set in cases which don't make sense (modifier-keys or 
mouse-motion for example).
*
* Knowing if an event may repeat is something set at the operating-systems 
event handling level
-   * so rely on #wmEvent.is_repeat being false non keyboard events instead of 
checking if this
+   * so rely on #WM_EVENT_IS_REPEAT being false non keyboard events instead of 
checking if this
* flag makes sense.
*
* Only used when: `ISKEYBOARD(kmi->type) || (kmi->type == KM_TEXTINPUT)`
diff --git a/source/blender/windowmanager/intern/wm_event_system.cc 
b/source/blender/windowmanager/intern/wm_event_system.cc
index a371fa7e185..757c3aae00c 100644
--- a/source/blender/windowmanager/intern/wm_event_system.cc
+++ b/source/blender/windowmanager/intern/wm_event_system.cc
@@ -2086,8 +2086,6 @@ static bool wm_eventmatch(const wmEvent *winevent, const 
wmKeyMapItem *kmi)
   /* The matching rules. */
   if (kmitype == KM_TEXTINPUT) {
 if (winevent->val == KM_PRESS) { /* Prevent double clicks. */
-  /* Not using #ISTEXTINPUT anymore because (at least on Windows) some key 
codes above 255
-   * could have printable ascii keys, See T30479. */
   if (ISKEYBOARD(winevent->type) && winevent->utf8_buf[0]) {
 return true;
   }
@@ -5328,7 +5326,7 @@ void wm_event_add_ghostevent(wmWindowManager *wm, 
wmWindow *win, int type, void
 break;
   }
 
-  /* Might be not nullptr terminated. */
+  /* Might be not null terminated. */
   memcpy(event.utf8_buf, kd->utf8_buf, sizeof(event.utf8_buf));
   if (kd->is_repeat) {
 event.flag |= WM_EVENT_IS_REPEAT;
diff --git a/source/blender/windowmanager/wm_event_types.h 
b/source/blender/windowmanager/wm_event_types.h
index 2d3624704d0..edac3ada73b 100644
--- a/source/blender/windowmanager/wm_event_types.h
+++ b/source/blender/windowmanager/wm_event_types.h
@@ -358,12 +358,6 @@ enum {
 /** Test whether the event is timer event. */
 #define ISTIMER(event_type) ((event_type) >= TIMER && (event_type) <= TIMERF)
 
-/* for event checks */
-/* only used 

[Bf-blender-cvs] [d6fef73ef11] master: WM: Remove ASCII members from wmEvent & GHOST_TEventKeyData

2022-07-14 Thread Campbell Barton
Commit: d6fef73ef110eb43756b7b87c2cba80abae3b39f
Author: Campbell Barton
Date:   Thu Jul 14 13:54:26 2022 +1000
Branches: master
https://developer.blender.org/rBd6fef73ef110eb43756b7b87c2cba80abae3b39f

WM: Remove ASCII members from wmEvent & GHOST_TEventKeyData

The `ascii` member was only kept for historic reason as some platforms
didn't support utf8 when it was first introduced.

Remove the `ascii` struct members since many checks used this as a
fall-back for utf8_buf not being set which isn't needed.
There are a few cases where it's convenient to access the ASCII value
of an event (or nil) so a function has been added to do that.

*Details*

- WM_event_utf8_to_ascii() has been added for the few cases an events
  ASCII value needs to be accessed, this just avoids having to do
  multi-byte character checks in-line.

- RNA Event.ascii remains, using utf8_buf[0] for single byte characters.

- GHOST_TEventKeyData.ascii has been removed.

- To avoid regressions non-ASCII Latin1 characters from GHOST are
  converted into multi-byte UTF8, when building X11 without
  XInput & X_HAVE_UTF8_STRING it seems like could still occur.

===

M   intern/ghost/GHOST_Types.h
M   intern/ghost/intern/GHOST_EventKey.h
M   intern/ghost/test/multitest/EventToBuf.c
M   source/blender/editors/armature/pose_lib.c
M   source/blender/editors/curve/editfont.c
M   source/blender/editors/interface/interface_handlers.c
M   source/blender/editors/space_console/console_ops.c
M   source/blender/editors/space_text/text_ops.c
M   source/blender/editors/util/numinput.c
M   source/blender/makesrna/intern/rna_wm.c
M   source/blender/makesrna/intern/rna_wm_api.c
M   source/blender/windowmanager/WM_api.h
M   source/blender/windowmanager/WM_types.h
M   source/blender/windowmanager/intern/wm_event_query.c
M   source/blender/windowmanager/intern/wm_event_system.cc
M   source/blender/windowmanager/intern/wm_window.c

===

diff --git a/intern/ghost/GHOST_Types.h b/intern/ghost/GHOST_Types.h
index 2fc84349eb9..fa74bfde866 100644
--- a/intern/ghost/GHOST_Types.h
+++ b/intern/ghost/GHOST_Types.h
@@ -547,17 +547,6 @@ typedef struct {
   /** The key code. */
   GHOST_TKey key;
 
-  /* ascii / utf8: both should always be set when possible,
-   * - ascii may be '\0' however if the user presses a non ascii key
-   * - unicode may not be set if the system has no unicode support
-   *
-   * These values are intended to be used as follows.
-   * For text input use unicode when available, fallback to ascii.
-   * For areas where unicode is not needed, number input for example, always
-   * use ascii, unicode is ignored - campbell.
-   */
-  /** The ascii code for the key event ('\0' if none). */
-  char ascii;
   /** The unicode character. if the length is 6, not NULL terminated if all 6 
are set. */
   char utf8_buf[6];
 
diff --git a/intern/ghost/intern/GHOST_EventKey.h 
b/intern/ghost/intern/GHOST_EventKey.h
index 1c3156c27d2..d3cfbbeddd7 100644
--- a/intern/ghost/intern/GHOST_EventKey.h
+++ b/intern/ghost/intern/GHOST_EventKey.h
@@ -28,7 +28,6 @@ class GHOST_EventKey : public GHOST_Event {
   : GHOST_Event(msec, type, window)
   {
 m_keyEventData.key = key;
-m_keyEventData.ascii = '\0';
 m_keyEventData.utf8_buf[0] = '\0';
 m_keyEventData.is_repeat = is_repeat;
 m_data = _keyEventData;
@@ -51,11 +50,17 @@ class GHOST_EventKey : public GHOST_Event {
   : GHOST_Event(msec, type, window)
   {
 m_keyEventData.key = key;
-m_keyEventData.ascii = ascii;
-if (utf8_buf)
+if (utf8_buf) {
   memcpy(m_keyEventData.utf8_buf, utf8_buf, 
sizeof(m_keyEventData.utf8_buf));
-else
+}
+else {
   m_keyEventData.utf8_buf[0] = '\0';
+}
+/* TODO(@campbellbarton): phase out `ascii` and always use `utf8_buf`, 
this needs to be done
+ * on all platforms though, so for now write the ascii into the utf8_buf. 
*/
+if (m_keyEventData.utf8_buf[0] == '\0' && ascii) {
+  m_keyEventData.utf8_buf[0] = ascii;
+}
 m_keyEventData.is_repeat = is_repeat;
 m_data = _keyEventData;
   }
diff --git a/intern/ghost/test/multitest/EventToBuf.c 
b/intern/ghost/test/multitest/EventToBuf.c
index baab32328c3..846a867a371 100644
--- a/intern/ghost/test/multitest/EventToBuf.c
+++ b/intern/ghost/test/multitest/EventToBuf.c
@@ -218,8 +218,10 @@ void event_to_buf(GHOST_EventHandle evt, char buf[128])
 case GHOST_kEventKeyUp: {
   GHOST_TEventKeyData *kd = data;
   pos += sprintf(pos, " - key: %s (%d)", keytype_to_string(kd->key), 
kd->key);
-  if (kd->ascii)
-pos += sprintf(pos, " ascii: '%c' (%d)", kd->ascii, kd->ascii);
+  /* TODO: ideally this would print the unicode character. */
+  if (kd->utf8_buf[0]) {
+pos += sprintf(pos, " ascii: '%c' (%d)", kd->utf8_buf[0], 
kd->utf8_buf[0]);
+  

[Bf-blender-cvs] [816a73891b6] master: GHOST/SDL: pass in utf8 buffer for keyboard events

2022-07-14 Thread Campbell Barton
Commit: 816a73891b69e2060c5b99d599e2a99e273db124
Author: Campbell Barton
Date:   Thu Jul 14 13:23:35 2022 +1000
Branches: master
https://developer.blender.org/rB816a73891b69e2060c5b99d599e2a99e273db124

GHOST/SDL: pass in utf8 buffer for keyboard events

While GHOST/SDL doesn't support non-ASCII text input,
use the UTF8 buffer to be consistent with all other back-ends.

Move the conversion from SDL_KeyboardEvent to ASCII into a function.

Also only lookup this value on key press (not release).

===

M   intern/ghost/intern/GHOST_SystemSDL.cpp

===

diff --git a/intern/ghost/intern/GHOST_SystemSDL.cpp 
b/intern/ghost/intern/GHOST_SystemSDL.cpp
index 0ca37adced6..55a15ae470e 100644
--- a/intern/ghost/intern/GHOST_SystemSDL.cpp
+++ b/intern/ghost/intern/GHOST_SystemSDL.cpp
@@ -279,6 +279,141 @@ static GHOST_TKey convertSDLKey(SDL_Scancode key)
 }
 #undef GXMAP
 
+static char convert_keyboard_event_to_ascii(const SDL_KeyboardEvent 
_sub_evt)
+{
+  SDL_Keycode sym = sdl_sub_evt.keysym.sym;
+  if (sym > 127) {
+switch (sym) {
+  case SDLK_KP_DIVIDE:
+sym = '/';
+break;
+  case SDLK_KP_MULTIPLY:
+sym = '*';
+break;
+  case SDLK_KP_MINUS:
+sym = '-';
+break;
+  case SDLK_KP_PLUS:
+sym = '+';
+break;
+  case SDLK_KP_1:
+sym = '1';
+break;
+  case SDLK_KP_2:
+sym = '2';
+break;
+  case SDLK_KP_3:
+sym = '3';
+break;
+  case SDLK_KP_4:
+sym = '4';
+break;
+  case SDLK_KP_5:
+sym = '5';
+break;
+  case SDLK_KP_6:
+sym = '6';
+break;
+  case SDLK_KP_7:
+sym = '7';
+break;
+  case SDLK_KP_8:
+sym = '8';
+break;
+  case SDLK_KP_9:
+sym = '9';
+break;
+  case SDLK_KP_0:
+sym = '0';
+break;
+  case SDLK_KP_PERIOD:
+sym = '.';
+break;
+  default:
+sym = 0;
+break;
+}
+  }
+  else {
+if (sdl_sub_evt.keysym.mod & (KMOD_LSHIFT | KMOD_RSHIFT)) {
+  /* Weak US keyboard assumptions. */
+  if (sym >= 'a' && sym <= ('a' + 32)) {
+sym -= 32;
+  }
+  else {
+switch (sym) {
+  case '`':
+sym = '~';
+break;
+  case '1':
+sym = '!';
+break;
+  case '2':
+sym = '@';
+break;
+  case '3':
+sym = '#';
+break;
+  case '4':
+sym = '$';
+break;
+  case '5':
+sym = '%';
+break;
+  case '6':
+sym = '^';
+break;
+  case '7':
+sym = '&';
+break;
+  case '8':
+sym = '*';
+break;
+  case '9':
+sym = '(';
+break;
+  case '0':
+sym = ')';
+break;
+  case '-':
+sym = '_';
+break;
+  case '=':
+sym = '+';
+break;
+  case '[':
+sym = '{';
+break;
+  case ']':
+sym = '}';
+break;
+  case '\\':
+sym = '|';
+break;
+  case ';':
+sym = ':';
+break;
+  case '\'':
+sym = '"';
+break;
+  case ',':
+sym = '<';
+break;
+  case '.':
+sym = '>';
+break;
+  case '/':
+sym = '?';
+break;
+  default:
+break;
+}
+  }
+}
+  }
+  return (char)sym;
+}
+
 /**
  * Events don't always have valid windows,
  * but GHOST needs a window _always_. fallback to the GL window.
@@ -454,7 +589,6 @@ void GHOST_SystemSDL::processEvent(SDL_Event *sdl_event)
 case SDL_KEYDOWN:
 case SDL_KEYUP: {
   SDL_KeyboardEvent _sub_evt = sdl_event->key;
-  SDL_Keycode sym = sdl_sub_evt.keysym.sym;
   GHOST_TEventType type = (sdl_sub_evt.state == SDL_PRESSED) ? 
GHOST_kEventKeyDown :

GHOST_kEventKeyUp;
   const bool is_repeat = sdl_sub_evt.repeat != 0;
@@ -466,138 +600,16 @@ void GHOST_SystemSDL::processEvent(SDL_Event *sdl_event)
   GHOST_TKey gkey = convertSDLKey(sdl_sub_evt.keysym.scancode);
   /* NOTE: the `sdl_sub_evt.keysym.sym` is truncated,
* for unicode support ghost has to be modified. */
-  // printf("%d\n", sym);
-  if (sym > 127) {
-switch (sym) {
-  case SDLK_KP_DIVIDE:
-sym = '/';
-break;
-  case SDLK_KP_MULTIPLY:
-sym = '*';
-break;
-  case SDLK_KP_MINUS:
-sym = '-';
-break;
-