[Bf-blender-cvs] [3323cd9c9aa] master: GHOST/Wayland: support for cursor warp with hidden/wrapped grab enabled

2022-06-23 Thread Campbell Barton
Commit: 3323cd9c9aa07cfc131b295977cd921fe7c547f0
Author: Campbell Barton
Date:   Fri Jun 24 14:17:38 2022 +1000
Branches: master
https://developer.blender.org/rB3323cd9c9aa07cfc131b295977cd921fe7c547f0

GHOST/Wayland: support for cursor warp with hidden/wrapped grab enabled

As grab already uses it's own virtual coordinates, cursor warping can
be used when grab is enabled.

Currently nothing depends on this however it could be useful in future.

===

M   intern/ghost/intern/GHOST_SystemWayland.cpp

===

diff --git a/intern/ghost/intern/GHOST_SystemWayland.cpp 
b/intern/ghost/intern/GHOST_SystemWayland.cpp
index 78d2773c0c1..8e3ca59cc74 100644
--- a/intern/ghost/intern/GHOST_SystemWayland.cpp
+++ b/intern/ghost/intern/GHOST_SystemWayland.cpp
@@ -620,24 +620,17 @@ static const std::vector mime_send = {
  * an event is received from the compositor.
  * \{ */
 
-static void relative_pointer_handle_relative_motion(
-void *data,
-struct zwp_relative_pointer_v1 * /*zwp_relative_pointer_v1*/,
-const uint32_t /*utime_hi*/,
-const uint32_t /*utime_lo*/,
-const wl_fixed_t dx,
-const wl_fixed_t dy,
-const wl_fixed_t /*dx_unaccel*/,
-const wl_fixed_t /*dy_unaccel*/)
+/**
+ * The caller is responsible for setting the value of `input->xy`.
+ */
+static void relative_pointer_handle_relative_motion_impl(input_t *input,
+ GHOST_WindowWayland 
*win,
+ const wl_fixed_t 
xy[2])
 {
-  input_t *input = static_cast(data);
-  GHOST_WindowWayland *win = window_from_surface(input->focus_pointer);
-  if (!win) {
-return;
-  }
   const wl_fixed_t scale = win->scale();
-  input->xy[0] += dx / scale;
-  input->xy[1] += dy / scale;
+
+  input->xy[0] = xy[0];
+  input->xy[1] = xy[1];
 
 #ifdef USE_GNOME_CONFINE_HACK
   if (input->xy_software_confine) {
@@ -662,6 +655,29 @@ static void relative_pointer_handle_relative_motion(
  GHOST_TABLET_DATA_NONE));
 }
 
+static void relative_pointer_handle_relative_motion(
+void *data,
+struct zwp_relative_pointer_v1 * /*zwp_relative_pointer_v1*/,
+const uint32_t /*utime_hi*/,
+const uint32_t /*utime_lo*/,
+const wl_fixed_t dx,
+const wl_fixed_t dy,
+const wl_fixed_t /*dx_unaccel*/,
+const wl_fixed_t /*dy_unaccel*/)
+{
+  input_t *input = static_cast(data);
+  GHOST_WindowWayland *win = window_from_surface(input->focus_pointer);
+  if (!win) {
+return;
+  }
+  const wl_fixed_t scale = win->scale();
+  const wl_fixed_t xy_next[2] = {
+  input->xy[0] + dx / scale,
+  input->xy[1] + dy / scale,
+  };
+  relative_pointer_handle_relative_motion_impl(input, win, xy_next);
+}
+
 static const zwp_relative_pointer_v1_listener relative_pointer_listener = {
 relative_pointer_handle_relative_motion,
 };
@@ -2479,9 +2495,33 @@ GHOST_TSuccess 
GHOST_SystemWayland::getCursorPosition(int32_t &x, int32_t &y) co
   return GHOST_kSuccess;
 }
 
-GHOST_TSuccess GHOST_SystemWayland::setCursorPosition(const int32_t /*x*/, 
const int32_t /*y*/)
+GHOST_TSuccess GHOST_SystemWayland::setCursorPosition(const int32_t x, const 
int32_t y)
 {
-  return GHOST_kFailure;
+  /* NOTE: WAYLAND doesn't support warping the cursor.
+   * However when grab is enabled, we already simulate a cursor location
+   * so that can be set to a new location. */
+  if (d->inputs.empty()) {
+return GHOST_kFailure;
+  }
+  input_t *input = d->inputs[0];
+  if (!input->relative_pointer) {
+return GHOST_kFailure;
+  }
+
+  GHOST_WindowWayland *win = window_from_surface(input->focus_pointer);
+  if (!win) {
+return GHOST_kFailure;
+  }
+  const wl_fixed_t scale = win->scale();
+  const wl_fixed_t xy_next[2] = {
+  wl_fixed_from_int(x) / scale,
+  wl_fixed_from_int(y) / scale,
+  };
+
+  /* As the cursor was "warped" generate an event at the new location. */
+  relative_pointer_handle_relative_motion_impl(input, win, xy_next);
+
+  return GHOST_kSuccess;
 }
 
 void GHOST_SystemWayland::getMainDisplayDimensions(uint32_t &width, uint32_t 
&height) const

___
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] [4c4e8cc926a] master: Fix T99021: Walk-mode doesn't work in Wayland

2022-06-23 Thread Campbell Barton
Commit: 4c4e8cc926a672ac60692b3fb8c20249f9cae679
Author: Campbell Barton
Date:   Fri Jun 24 13:45:08 2022 +1000
Branches: master
https://developer.blender.org/rB4c4e8cc926a672ac60692b3fb8c20249f9cae679

Fix T99021: Walk-mode doesn't work in Wayland

Walk mode implemented it's own grab which relied on WM_cursor_warp
to work (which isn't implemented for wayland).

Resolve this by using WM_cursor_grab_{enable/disable}.

Besides fixing Wayland this removes the need for workarounds:

- Ensure the event received were after the event generated from warping.
- Alternate logic that reset the "center" when using tablets.
- Checking the cursor location was scaled by native-pixels on macOS.

There is a minor change in behavior: on completion the cursor is left
at the location walk-mode began instead of the center of the region.

===

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

===

diff --git a/source/blender/editors/space_view3d/view3d_navigate_walk.c 
b/source/blender/editors/space_view3d/view3d_navigate_walk.c
index c4eff01375b..471231b5f27 100644
--- a/source/blender/editors/space_view3d/view3d_navigate_walk.c
+++ b/source/blender/editors/space_view3d/view3d_navigate_walk.c
@@ -55,9 +55,6 @@
 
 #define USE_TABLET_SUPPORT
 
-/* ensure the target position is one we can reach, see: T45771 */
-#define USE_PIXELSIZE_NATIVE_SUPPORT
-
 /*  */
 /** \name Modal Key-map
  * \{ */
@@ -226,8 +223,8 @@ typedef struct WalkInfo {
 
   /** Previous 2D mouse values. */
   int prev_mval[2];
-  /** Center mouse values. */
-  int center_mval[2];
+  /** Initial mouse location. */
+  int init_mval[2];
 
   int moffset[2];
 
@@ -271,9 +268,6 @@ typedef struct WalkInfo {
   bool is_reversed;
 
 #ifdef USE_TABLET_SUPPORT
-  /** Check if we had a cursor event before. */
-  bool is_cursor_first;
-
   /** Tablet devices (we can't relocate the cursor). */
   bool is_cursor_absolute;
 #endif
@@ -484,7 +478,7 @@ enum {
 static float base_speed = -1.0f;
 static float userdef_speed = -1.0f;
 
-static bool initWalkInfo(bContext *C, WalkInfo *walk, wmOperator *op)
+static bool initWalkInfo(bContext *C, WalkInfo *walk, wmOperator *op, const 
int mval[2])
 {
   wmWindowManager *wm = CTX_wm_manager(C);
   wmWindow *win = CTX_wm_window(C);
@@ -565,8 +559,6 @@ static bool initWalkInfo(bContext *C, WalkInfo *walk, 
wmOperator *op)
   walk->is_reversed = ((U.walk_navigation.flag & USER_WALK_MOUSE_REVERSE) != 
0);
 
 #ifdef USE_TABLET_SUPPORT
-  walk->is_cursor_first = true;
-
   walk->is_cursor_absolute = false;
 #endif
 
@@ -599,28 +591,10 @@ static bool initWalkInfo(bContext *C, WalkInfo *walk, 
wmOperator *op)
   walk->v3d_camera_control = ED_view3d_cameracontrol_acquire(
   walk->depsgraph, walk->scene, walk->v3d, walk->rv3d);
 
-  /* center the mouse */
-  walk->center_mval[0] = walk->region->winx * 0.5f;
-  walk->center_mval[1] = walk->region->winy * 0.5f;
-
-#ifdef USE_PIXELSIZE_NATIVE_SUPPORT
-  walk->center_mval[0] += walk->region->winrct.xmin;
-  walk->center_mval[1] += walk->region->winrct.ymin;
-
-  WM_cursor_compatible_xy(win, &walk->center_mval[0], &walk->center_mval[1]);
-
-  walk->center_mval[0] -= walk->region->winrct.xmin;
-  walk->center_mval[1] -= walk->region->winrct.ymin;
-#endif
+  copy_v2_v2_int(walk->init_mval, mval);
+  copy_v2_v2_int(walk->prev_mval, mval);
 
-  copy_v2_v2_int(walk->prev_mval, walk->center_mval);
-
-  WM_cursor_warp(win,
- walk->region->winrct.xmin + walk->center_mval[0],
- walk->region->winrct.ymin + walk->center_mval[1]);
-
-  /* remove the mouse cursor temporarily */
-  WM_cursor_modal_set(win, WM_CURSOR_NONE);
+  WM_cursor_grab_enable(win, 0, true, NULL);
 
   return 1;
 }
@@ -669,18 +643,7 @@ static int walkEnd(bContext *C, WalkInfo *walk)
   }
 #endif
 
-  /* restore the cursor */
-  WM_cursor_modal_restore(win);
-
-#ifdef USE_TABLET_SUPPORT
-  if (walk->is_cursor_absolute == false)
-#endif
-  {
-/* center the mouse */
-WM_cursor_warp(win,
-   walk->region->winrct.xmin + walk->center_mval[0],
-   walk->region->winrct.ymin + walk->center_mval[1]);
-  }
+  WM_cursor_grab_enable(win, 0, true, NULL);
 
   if (walk->state == WALK_CONFIRM) {
 MEM_freeN(walk);
@@ -691,7 +654,7 @@ static int walkEnd(bContext *C, WalkInfo *walk)
   return OPERATOR_CANCELLED;
 }
 
-static void walkEvent(bContext *C, WalkInfo *walk, const wmEvent *event)
+static void walkEvent(WalkInfo *walk, const wmEvent *event)
 {
   if (event->type == TIMER && event->customdata == walk->timer) {
 walk->redraw = true;
@@ -699,26 +662,8 @@ static void walkEvent(bContext *C, WalkInfo *walk, const 
wmEvent *event)
   else if (ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) {
 
 #ifdef USE_TABLET_SUPPORT
-if (walk->is_cursor_first) {
-  /* wa

[Bf-blender-cvs] [11f38f59e2b] master: Cleanup: remove unused function WM_cursor_compatible_xy

2022-06-23 Thread Campbell Barton
Commit: 11f38f59e2b2ed45dd26628d39d73019e263a69f
Author: Campbell Barton
Date:   Fri Jun 24 14:00:36 2022 +1000
Branches: master
https://developer.blender.org/rB11f38f59e2b2ed45dd26628d39d73019e263a69f

Cleanup: remove unused function WM_cursor_compatible_xy

===

M   source/blender/windowmanager/WM_api.h
M   source/blender/windowmanager/intern/wm_window.c

===

diff --git a/source/blender/windowmanager/WM_api.h 
b/source/blender/windowmanager/WM_api.h
index 60cded3b869..ab48d6f6c39 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -314,10 +314,6 @@ void WM_paint_cursor_tag_redraw(struct wmWindow *win, 
struct ARegion *region);
  * This function requires access to the GHOST_SystemHandle (g_system).
  */
 void WM_cursor_warp(struct wmWindow *win, int x, int y);
-/**
- * Set x, y to values we can actually position the cursor to.
- */
-void WM_cursor_compatible_xy(wmWindow *win, int *x, int *y);
 
 /* Handlers. */
 
diff --git a/source/blender/windowmanager/intern/wm_window.c 
b/source/blender/windowmanager/intern/wm_window.c
index 91ec45da6d4..49389634462 100644
--- a/source/blender/windowmanager/intern/wm_window.c
+++ b/source/blender/windowmanager/intern/wm_window.c
@@ -2024,15 +2024,6 @@ void WM_cursor_warp(wmWindow *win, int x, int y)
   }
 }
 
-void WM_cursor_compatible_xy(wmWindow *win, int *x, int *y)
-{
-  float f = GHOST_GetNativePixelSize(win->ghostwin);
-  if (f != 1.0f) {
-*x = (int)(*x / f) * f;
-*y = (int)(*y / f) * f;
-  }
-}
-
 /** \} */
 
 /*  */

___
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] [70648683a2a] master: Cleanup: add C++ compatible WL_ARRAY_FOR_EACH macro

2022-06-23 Thread Campbell Barton
Commit: 70648683a2aa97c7d0ebd310d7a2ab564bcd4fed
Author: Campbell Barton
Date:   Fri Jun 24 10:21:45 2022 +1000
Branches: master
https://developer.blender.org/rB70648683a2aa97c7d0ebd310d7a2ab564bcd4fed

Cleanup: add C++ compatible WL_ARRAY_FOR_EACH macro

===

M   .clang-format
A   intern/ghost/intern/GHOST_WaylandUtils.h
M   intern/ghost/intern/GHOST_WindowWayland.cpp

===

diff --git a/.clang-format b/.clang-format
index f7b785adaf2..7b8e0ef8eba 100644
--- a/.clang-format
+++ b/.clang-format
@@ -265,6 +265,7 @@ ForEachMacros:
   - SET_SLOT_PROBING_BEGIN
   - MAP_SLOT_PROBING_BEGIN
   - VECTOR_SET_SLOT_PROBING_BEGIN
+  - WL_ARRAY_FOR_EACH
 
 StatementMacros:
   - PyObject_HEAD
diff --git a/intern/ghost/intern/GHOST_WaylandUtils.h 
b/intern/ghost/intern/GHOST_WaylandUtils.h
new file mode 100644
index 000..0e1e133bc4c
--- /dev/null
+++ b/intern/ghost/intern/GHOST_WaylandUtils.h
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+/** \file
+ * \ingroup GHOST
+ */
+
+#pragma once
+
+#ifdef __cplusplus
+#  undef wl_array_for_each
+/**
+ * This macro causes a warning for C++ code, define our own.
+ * See: https://gitlab.freedesktop.org/wayland/wayland/-/issues/34
+ */
+#  define WL_ARRAY_FOR_EACH(pos, array) \
+for (pos = (decltype(pos))((array)->data); \
+ (const char *)pos < ((const char *)(array)->data + (array)->size); \
+ (pos)++)
+#endif
diff --git a/intern/ghost/intern/GHOST_WindowWayland.cpp 
b/intern/ghost/intern/GHOST_WindowWayland.cpp
index 394ad35082b..afaa2e11aa7 100644
--- a/intern/ghost/intern/GHOST_WindowWayland.cpp
+++ b/intern/ghost/intern/GHOST_WindowWayland.cpp
@@ -6,6 +6,7 @@
 
 #include "GHOST_WindowWayland.h"
 #include "GHOST_SystemWayland.h"
+#include "GHOST_WaylandUtils.h"
 #include "GHOST_WindowManager.h"
 
 #include "GHOST_Event.h"
@@ -134,12 +135,8 @@ static void xdg_toplevel_handle_configure(void *data,
   win->is_fullscreen = false;
   win->is_active = false;
 
-  /* Note that the macro 'wl_array_for_each' would typically be used to 
simplify this logic,
-   * however it's not compatible with C++, so perform casts instead.
-   * If this needs to be done more often we could define our own C++ 
compatible macro. */
-  for (enum xdg_toplevel_state *state = static_cast(states->data);
-   reinterpret_cast(state) < (static_cast(states->data) + states->size);
-   state++) {
+  enum xdg_toplevel_state *state;
+  WL_ARRAY_FOR_EACH (state, states) {
 switch (*state) {
   case XDG_TOPLEVEL_STATE_MAXIMIZED:
 win->is_maximised = true;

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


[Bf-blender-cvs] [b3a713fffa3] master: Cleanup: use const arguments for GHOST/Wayland

2022-06-23 Thread Campbell Barton
Commit: b3a713fffa3928e1692cf5b1354728d0feaf4c77
Author: Campbell Barton
Date:   Fri Jun 24 09:58:27 2022 +1000
Branches: master
https://developer.blender.org/rBb3a713fffa3928e1692cf5b1354728d0feaf4c77

Cleanup: use const arguments for GHOST/Wayland

===

M   intern/ghost/intern/GHOST_SystemWayland.cpp
M   intern/ghost/intern/GHOST_WindowWayland.cpp

===

diff --git a/intern/ghost/intern/GHOST_SystemWayland.cpp 
b/intern/ghost/intern/GHOST_SystemWayland.cpp
index 85860bccbe3..daedae3112b 100644
--- a/intern/ghost/intern/GHOST_SystemWayland.cpp
+++ b/intern/ghost/intern/GHOST_SystemWayland.cpp
@@ -626,12 +626,12 @@ static const std::vector mime_send = {
 static void relative_pointer_handle_relative_motion(
 void *data,
 struct zwp_relative_pointer_v1 * /*zwp_relative_pointer_v1*/,
-uint32_t /*utime_hi*/,
-uint32_t /*utime_lo*/,
-wl_fixed_t dx,
-wl_fixed_t dy,
-wl_fixed_t /*dx_unaccel*/,
-wl_fixed_t /*dy_unaccel*/)
+const uint32_t /*utime_hi*/,
+const uint32_t /*utime_lo*/,
+const wl_fixed_t dx,
+const wl_fixed_t dy,
+const wl_fixed_t /*dx_unaccel*/,
+const wl_fixed_t /*dy_unaccel*/)
 {
   input_t *input = static_cast(data);
   GHOST_WindowWayland *win = window_from_surface(input->focus_pointer);
@@ -741,7 +741,7 @@ static void data_source_handle_target(void * /*data*/,
 static void data_source_handle_send(void *data,
 struct wl_data_source * /*wl_data_source*/,
 const char * /*mime_type*/,
-int32_t fd)
+const int32_t fd)
 {
   input_t *input = static_cast(data);
   std::lock_guard lock{input->data_source_mutex};
@@ -793,7 +793,7 @@ static void data_source_handle_dnd_finished(void * /*data*/,
  */
 static void data_source_handle_action(void * /*data*/,
   struct wl_data_source * 
/*wl_data_source*/,
-  uint32_t /*dnd_action*/)
+  const uint32_t /*dnd_action*/)
 {
   /* pass */
 }
@@ -822,14 +822,14 @@ static void data_offer_handle_offer(void *data,
 
 static void data_offer_handle_source_actions(void *data,
  struct wl_data_offer * 
/*wl_data_offer*/,
- uint32_t source_actions)
+ const uint32_t source_actions)
 {
   static_cast(data)->source_actions = source_actions;
 }
 
 static void data_offer_handle_action(void *data,
  struct wl_data_offer * /*wl_data_offer*/,
- uint32_t dnd_action)
+ const uint32_t dnd_action)
 {
   static_cast(data)->dnd_action = dnd_action;
 }
@@ -857,10 +857,10 @@ static void data_device_handle_data_offer(void * /*data*/,
 
 static void data_device_handle_enter(void *data,
  struct wl_data_device * 
/*wl_data_device*/,
- uint32_t serial,
+ const uint32_t serial,
  struct wl_surface *surface,
- wl_fixed_t x,
- wl_fixed_t y,
+ const wl_fixed_t x,
+ const wl_fixed_t y,
  struct wl_data_offer *id)
 {
   input_t *input = static_cast(data);
@@ -903,9 +903,9 @@ static void data_device_handle_leave(void *data, struct 
wl_data_device * /*wl_da
 
 static void data_device_handle_motion(void *data,
   struct wl_data_device * 
/*wl_data_device*/,
-  uint32_t /*time*/,
-  wl_fixed_t x,
-  wl_fixed_t y)
+  const uint32_t /*time*/,
+  const wl_fixed_t x,
+  const wl_fixed_t y)
 {
   input_t *input = static_cast(data);
   std::lock_guard lock{input->data_offer_dnd_mutex};
@@ -1157,10 +1157,10 @@ struct wl_surface_listener cursor_surface_listener = {
 
 static void pointer_handle_enter(void *data,
  struct wl_pointer * /*wl_pointer*/,
- uint32_t serial,
+ const uint32_t serial,
  struct wl_surface *surface,
- wl_fixed_t surface_x,
- wl_fixed_t surface_y)
+ const wl_fixed_t surface_x,
+ const wl_fixed_t surface_y)
 

[Bf-blender-cvs] [cc09661c4ef] master: Cleanup: remove unused cursor struct members in GHOST/Wayland

2022-06-23 Thread Campbell Barton
Commit: cc09661c4ef586ebb03bc6a833099819bd38485c
Author: Campbell Barton
Date:   Fri Jun 24 09:59:37 2022 +1000
Branches: master
https://developer.blender.org/rBcc09661c4ef586ebb03bc6a833099819bd38485c

Cleanup: remove unused cursor struct members in GHOST/Wayland

===

M   intern/ghost/intern/GHOST_SystemWayland.cpp

===

diff --git a/intern/ghost/intern/GHOST_SystemWayland.cpp 
b/intern/ghost/intern/GHOST_SystemWayland.cpp
index daedae3112b..78d2773c0c1 100644
--- a/intern/ghost/intern/GHOST_SystemWayland.cpp
+++ b/intern/ghost/intern/GHOST_SystemWayland.cpp
@@ -260,10 +260,7 @@ struct display_t {
   struct wl_shm *shm = nullptr;
   std::vector outputs;
   std::vector inputs;
-  struct {
-std::string theme;
-int size = 0;
-  } cursor;
+
   struct wl_data_device_manager *data_device_manager = nullptr;
   struct zwp_tablet_manager_v2 *tablet_manager = nullptr;
   struct zwp_relative_pointer_manager_v1 *relative_pointer_manager = nullptr;

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


[Bf-blender-cvs] [9b5dda3b074] master: GHOST: use GHOST_ASSERT for non-release builds

2022-06-23 Thread Campbell Barton
Commit: 9b5dda3b07496bda28970dfd23e4951a76d0f8ed
Author: Campbell Barton
Date:   Fri Jun 24 08:54:48 2022 +1000
Branches: master
https://developer.blender.org/rB9b5dda3b07496bda28970dfd23e4951a76d0f8ed

GHOST: use GHOST_ASSERT for non-release builds

GHOST_ASSERT now matches BLI_assert, which is only ignored for release
builds. Otherwise it prints or asserts when WITH_ASSERT_ABORT is enabled.

===

M   intern/ghost/intern/GHOST_Debug.h

===

diff --git a/intern/ghost/intern/GHOST_Debug.h 
b/intern/ghost/intern/GHOST_Debug.h
index e6bdf974d59..6b1bd3785ae 100644
--- a/intern/ghost/intern/GHOST_Debug.h
+++ b/intern/ghost/intern/GHOST_Debug.h
@@ -15,12 +15,12 @@
 #  endif
 #endif
 
-#ifdef WITH_GHOST_DEBUG
+#if defined(WITH_GHOST_DEBUG) || (!defined(NDEBUG))
 #  include 
 #  include   //for printf()
 #endif// WITH_GHOST_DEBUG
 
-#ifdef WITH_GHOST_DEBUG
+#if defined(WITH_GHOST_DEBUG) || (!defined(NDEBUG))
 #  define GHOST_PRINT(x) \
 { \
   std::cout << x; \
@@ -31,10 +31,10 @@
   printf(x, __VA_ARGS__); \
 } \
 (void)0
-#else  // WITH_GHOST_DEBUG
+#else
 #  define GHOST_PRINT(x)
 #  define GHOST_PRINTF(x, ...)
-#endif  // WITH_GHOST_DEBUG
+#endif /* `defined(WITH_GHOST_DEBUG) || (!defined(NDEBUG))` */
 
 #ifdef WITH_ASSERT_ABORT
 #  include//for fprintf()
@@ -49,7 +49,8 @@
   } \
 } \
 (void)0
-#elif defined(WITH_GHOST_DEBUG)
+/* Assert in non-release builds too. */
+#elif defined(WITH_GHOST_DEBUG) || (!defined(NDEBUG))
 #  define GHOST_ASSERT(x, info) \
 { \
   if (!(x)) { \
@@ -59,6 +60,6 @@
   } \
 } \
 (void)0
-#else  // WITH_GHOST_DEBUG
+#else /* `defined(WITH_GHOST_DEBUG) || (!defined(NDEBUG))` */
 #  define GHOST_ASSERT(x, info) ((void)0)
-#endif  // WITH_GHOST_DEBUG
+#endif /* `defined(WITH_GHOST_DEBUG) || (!defined(NDEBUG))` */

___
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] [93de6b912f8] master: Docs: correct GHOST_TimerProcPtr time doc-string

2022-06-23 Thread Campbell Barton
Commit: 93de6b912f82dd22530a69af79c648cff0a4b6d6
Author: Campbell Barton
Date:   Fri Jun 24 08:43:18 2022 +1000
Branches: master
https://developer.blender.org/rB93de6b912f82dd22530a69af79c648cff0a4b6d6

Docs: correct GHOST_TimerProcPtr time doc-string

===

M   intern/ghost/GHOST_Types.h

===

diff --git a/intern/ghost/GHOST_Types.h b/intern/ghost/GHOST_Types.h
index 35bde3d4413..76e6525ebfe 100644
--- a/intern/ghost/GHOST_Types.h
+++ b/intern/ghost/GHOST_Types.h
@@ -610,7 +610,7 @@ typedef int GHOST_TEmbedderWindowID;
 /**
  * A timer task callback routine.
  * \param task: The timer task object.
- * \param time: The current time.
+ * \param time: Time since this timer started (in milliseconds).
  */
 #ifdef __cplusplus
 class GHOST_ITimerTask;

___
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] [18f78ba33cf] refactor-mesh-bevel-weight-generic: Merge branch 'temp-legacy-mesh-format-option' into refactor-mesh-bevel-weight-generic

2022-06-23 Thread Hans Goudey
Commit: 18f78ba33cfe4e369135e1c9c80f88bb24a90f2e
Author: Hans Goudey
Date:   Thu Jun 23 16:59:05 2022 -0500
Branches: refactor-mesh-bevel-weight-generic
https://developer.blender.org/rB18f78ba33cfe4e369135e1c9c80f88bb24a90f2e

Merge branch 'temp-legacy-mesh-format-option' into 
refactor-mesh-bevel-weight-generic

===



===

diff --cc source/blender/blenkernel/BKE_blender_version.h
index 2cd753da9d3,04767a742ce..19bb4826956
--- a/source/blender/blenkernel/BKE_blender_version.h
+++ b/source/blender/blenkernel/BKE_blender_version.h
@@@ -25,7 -25,7 +25,7 @@@ extern "C" 
  
  /* Blender file format version. */
  #define BLENDER_FILE_VERSION BLENDER_VERSION
- #define BLENDER_FILE_SUBVERSION 1
 -#define BLENDER_FILE_SUBVERSION 3
++#define BLENDER_FILE_SUBVERSION 4
  
  /* Minimum Blender version that supports reading file written with the current
   * version. Older Blender versions will test this and show a warning if the 
file
diff --cc source/blender/blenloader/intern/versioning_300.c
index b0a8fa7e24a,844354c8bc3..80a8e9b7fd4
--- a/source/blender/blenloader/intern/versioning_300.c
+++ b/source/blender/blenloader/intern/versioning_300.c
@@@ -29,9 -30,9 +30,10 @@@
  #include "DNA_gpencil_modifier_types.h"
  #include "DNA_lineart_types.h"
  #include "DNA_listBase.h"
+ #include "DNA_mask_types.h"
  #include "DNA_material_types.h"
  #include "DNA_mesh_types.h"
 +#include "DNA_meshdata_types.h"
  #include "DNA_modifier_types.h"
  #include "DNA_screen_types.h"
  #include "DNA_space_types.h"
@@@ -3053,33 -3160,21 +3161,41 @@@ void blo_do_versions_300(FileData *fd, 
  }
  FOREACH_NODETREE_END;
  
- /* Initialize brush curves sculpt settings. */
- LISTBASE_FOREACH (Brush *, brush, &bmain->brushes) {
-   if (brush->ob_mode != OB_MODE_SCULPT_CURVES) {
- continue;
-   }
-   if (brush->curves_sculpt_settings->points_per_curve == 0) {
- brush->curves_sculpt_settings->points_per_curve = 8;
-   }
+ LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
+   version_fix_image_format_copy(bmain, &scene->r.im_format);
  }
+   }
  
- /* UDIM Packing. */
- if (!DNA_struct_elem_find(fd->filesdna, "ImagePackedFile", "int", 
"tile_number")) {
-   for (Image *ima = bmain->images.first; ima; ima = ima->id.next) {
- int view;
- LISTBASE_FOREACH_INDEX (ImagePackedFile *, imapf, &ima->packedfiles, 
view) {
-   imapf->view = view;
-   imapf->tile_number = 1001;
++  if (!MAIN_VERSION_ATLEAST(bmain, 303, 1)) {
++/* Move mesh bevel weights from structs to dedicated custom data layers, 
like edit mode. */
++LISTBASE_FOREACH (Mesh *, mesh, &bmain->meshes) {
++  if (mesh->cd_flag & ME_CDFLAG_EDGE_BWEIGHT) {
++float *weights = (float *)CustomData_add_layer(
++&mesh->edata, CD_BWEIGHT, CD_DEFAULT, NULL, mesh->totedge);
++for (int i = 0; i < mesh->totedge; i++) {
++  weights[i] = mesh->medge[i].bweight / 255.0f;
 +}
 +  }
- }
- 
- /* Merge still offsets into start/end offsets. */
- LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
-   Editing *ed = SEQ_editing_get(scene);
-   if (ed != NULL) {
- SEQ_for_each_callback(&ed->seqbase, version_merge_still_offsets, 
NULL);
++  if (mesh->cd_flag & ME_CDFLAG_VERT_BWEIGHT) {
++float *weights = (float *)CustomData_add_layer(
++&mesh->vdata, CD_BWEIGHT, CD_DEFAULT, NULL, mesh->totvert);
++for (int i = 0; i < mesh->totvert; i++) {
++  weights[i] = mesh->mvert[i].bweight / 255.0f;
++}
 +  }
 +}
 +  }
++
+   /**
+* Versioning code until next subversion bump goes here.
+*
+* \note Be sure to check when bumping the version:
+* - "versioning_userdef.c", #blo_do_versions_userdef
+* - "versioning_userdef.c", #do_versions_theme
+*
+* \note Keep this message at the bottom of the function.
+*/
+   {
+ /* Keep this block, even when empty. */
+   }
  }

___
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] [4919403c299] master: Fix outdated pressure/tilt for tablet motions events under GHOST/Wayland

2022-06-23 Thread Campbell Barton
Commit: 4919403c299682901702234a735e27c053bfe96d
Author: Campbell Barton
Date:   Fri Jun 24 08:19:08 2022 +1000
Branches: master
https://developer.blender.org/rB4919403c299682901702234a735e27c053bfe96d

Fix outdated pressure/tilt for tablet motions events under GHOST/Wayland

Accumulate tablet data before generating an event using the 'frame'
callback.

===

M   intern/ghost/intern/GHOST_SystemWayland.cpp

===

diff --git a/intern/ghost/intern/GHOST_SystemWayland.cpp 
b/intern/ghost/intern/GHOST_SystemWayland.cpp
index 2adbca7ee40..85860bccbe3 100644
--- a/intern/ghost/intern/GHOST_SystemWayland.cpp
+++ b/intern/ghost/intern/GHOST_SystemWayland.cpp
@@ -1447,21 +1447,11 @@ static void tablet_tool_handle_motion(void *data,
 {
   tablet_tool_input_t *tool_input = static_cast(data);
   input_t *input = tool_input->input;
-  GHOST_WindowWayland *win = window_from_surface(input->focus_tablet);
-  if (!win) {
-return;
-  }
 
   input->xy[0] = x;
   input->xy[1] = y;
 
-  const wl_fixed_t scale = win->scale();
-  input->system->pushEvent(new 
GHOST_EventCursor(input->system->getMilliSeconds(),
- GHOST_kEventCursorMove,
- win,
- wl_fixed_to_int(scale * 
input->xy[0]),
- wl_fixed_to_int(scale * 
input->xy[1]),
- tool_input->data));
+  /* NOTE: #tablet_tool_handle_frame generates the event (with updated 
pressure, tilt... etc). */
 }
 
 static void tablet_tool_handle_pressure(void *data,
@@ -1575,10 +1565,24 @@ static void tablet_tool_handle_button(void *data,
   input->system->pushEvent(new GHOST_EventButton(
   input->system->getMilliSeconds(), etype, win, ebutton, 
tool_input->data));
 }
-static void tablet_tool_handle_frame(void * /*data*/,
+static void tablet_tool_handle_frame(void *data,
  struct zwp_tablet_tool_v2 * 
/*zwp_tablet_tool_v2*/,
  uint32_t /*time*/)
 {
+  tablet_tool_input_t *tool_input = static_cast(data);
+  input_t *input = tool_input->input;
+  GHOST_WindowWayland *win = window_from_surface(input->focus_tablet);
+  if (!win) {
+return;
+  }
+
+  const wl_fixed_t scale = win->scale();
+  input->system->pushEvent(new 
GHOST_EventCursor(input->system->getMilliSeconds(),
+ GHOST_kEventCursorMove,
+ win,
+ wl_fixed_to_int(scale * 
input->xy[0]),
+ wl_fixed_to_int(scale * 
input->xy[1]),
+ tool_input->data));
 }
 
 static const struct zwp_tablet_tool_v2_listener tablet_tool_listner = {

___
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] [7a05b5d2aaf] temp-legacy-mesh-format-option: Merge branch 'master' into temp-legacy-mesh-format-option

2022-06-23 Thread Hans Goudey
Commit: 7a05b5d2aaf6854a34c8eb796011a9ec90cc0281
Author: Hans Goudey
Date:   Thu Jun 23 16:56:47 2022 -0500
Branches: temp-legacy-mesh-format-option
https://developer.blender.org/rB7a05b5d2aaf6854a34c8eb796011a9ec90cc0281

Merge branch 'master' into temp-legacy-mesh-format-option

===



===



___
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] [b0fe0e6a304] master: Cleanup: Make function static

2022-06-23 Thread Hans Goudey
Commit: b0fe0e6a3047e18d35d0f6ca8e9fc39f60e9f787
Author: Hans Goudey
Date:   Thu Jun 23 13:03:31 2022 -0500
Branches: master
https://developer.blender.org/rBb0fe0e6a3047e18d35d0f6ca8e9fc39f60e9f787

Cleanup: Make function static

===

M   source/blender/blenkernel/BKE_mesh.h
M   source/blender/blenkernel/intern/mesh_tessellate.c

===

diff --git a/source/blender/blenkernel/BKE_mesh.h 
b/source/blender/blenkernel/BKE_mesh.h
index 8e038a1d3d9..66e0ff8e81a 100644
--- a/source/blender/blenkernel/BKE_mesh.h
+++ b/source/blender/blenkernel/BKE_mesh.h
@@ -336,21 +336,10 @@ void BKE_mesh_vert_coords_apply(struct Mesh *mesh, const 
float (*vert_coords)[3]
 /**
  * Recreate #MFace Tessellation.
  *
- * \param do_face_nor_copy: Controls whether the normals from the poly
- * are copied to the tessellated faces.
- *
- * \return number of tessellation faces.
- *
  * \note This doesn't use multi-threading like #BKE_mesh_recalc_looptri since
  * it's not used in many places and #MFace should be phased out.
  */
-int BKE_mesh_tessface_calc_ex(struct CustomData *fdata,
-  struct CustomData *ldata,
-  struct CustomData *pdata,
-  struct MVert *mvert,
-  int totface,
-  int totloop,
-  int totpoly);
+
 void BKE_mesh_tessface_calc(struct Mesh *mesh);
 
 /**
@@ -897,9 +886,6 @@ enum {
  * Actually this later behavior could apply to the Mirror Modifier as well,
  * but the additional checks are costly and not necessary in the case of 
mirror,
  * because each vertex is only merged to its own mirror.
- *
- * \note #BKE_mesh_tessface_calc_ex has to run on the returned DM
- * if you want to access tess-faces.
  */
 struct Mesh *BKE_mesh_merge_verts(struct Mesh *mesh,
   const int *vtargetmap,
diff --git a/source/blender/blenkernel/intern/mesh_tessellate.c 
b/source/blender/blenkernel/intern/mesh_tessellate.c
index 7cb656d2357..71d5722cb0e 100644
--- a/source/blender/blenkernel/intern/mesh_tessellate.c
+++ b/source/blender/blenkernel/intern/mesh_tessellate.c
@@ -138,7 +138,7 @@ static void mesh_loops_to_tessdata(CustomData *fdata,
   }
 }
 
-int BKE_mesh_tessface_calc_ex(CustomData *fdata,
+static int mesh_tessface_calc(CustomData *fdata,
   CustomData *ldata,
   CustomData *pdata,
   MVert *mvert,
@@ -382,13 +382,13 @@ int BKE_mesh_tessface_calc_ex(CustomData *fdata,
 
 void BKE_mesh_tessface_calc(Mesh *mesh)
 {
-  mesh->totface = BKE_mesh_tessface_calc_ex(&mesh->fdata,
-&mesh->ldata,
-&mesh->pdata,
-mesh->mvert,
-mesh->totface,
-mesh->totloop,
-mesh->totpoly);
+  mesh->totface = mesh_tessface_calc(&mesh->fdata,
+ &mesh->ldata,
+ &mesh->pdata,
+ mesh->mvert,
+ mesh->totface,
+ mesh->totloop,
+ mesh->totpoly);
 
   BKE_mesh_update_customdata_pointers(mesh, true);
 }

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


[Bf-blender-cvs] [04734622415] master: Geometry Nodes: Speed up Separate color node in RGB mode

2022-06-23 Thread Hans Goudey
Commit: 047346224155211ab86faaebc9d31f9dc457f9a7
Author: Hans Goudey
Date:   Thu Jun 23 12:33:58 2022 -0500
Branches: master
https://developer.blender.org/rB047346224155211ab86faaebc9d31f9dc457f9a7

Geometry Nodes: Speed up Separate color node in RGB mode

This applies the same optimization as b8bd304bd45397b8c to the separate
color node. I observed about a 50% improvement with 10 million values
when only extracting one channel-- from about 17ms to 11ms.

===

M   source/blender/nodes/function/nodes/node_fn_separate_color.cc

===

diff --git a/source/blender/nodes/function/nodes/node_fn_separate_color.cc 
b/source/blender/nodes/function/nodes/node_fn_separate_color.cc
index 1701dfdc6fa..19613427835 100644
--- a/source/blender/nodes/function/nodes/node_fn_separate_color.cc
+++ b/source/blender/nodes/function/nodes/node_fn_separate_color.cc
@@ -60,22 +60,41 @@ class SeparateRGBAFunction : public fn::MultiFunction {
   {
 const VArray &colors = 
params.readonly_single_input(0,

   "Color");
-MutableSpan red = params.uninitialized_single_output(1, 
"Red");
-MutableSpan green = params.uninitialized_single_output(2, 
"Green");
-MutableSpan blue = params.uninitialized_single_output(3, 
"Blue");
+
+MutableSpan red = 
params.uninitialized_single_output_if_required(1, "Red");
+MutableSpan green = 
params.uninitialized_single_output_if_required(2, "Green");
+MutableSpan blue = 
params.uninitialized_single_output_if_required(3, "Blue");
 MutableSpan alpha = 
params.uninitialized_single_output_if_required(4, "Alpha");
 
-for (int64_t i : mask) {
-  red[i] = colors[i].r;
-  green[i] = colors[i].g;
-  blue[i] = colors[i].b;
+std::array, 4> outputs = {red, green, blue, alpha};
+Vector used_outputs;
+if (!red.is_empty()) {
+  used_outputs.append(0);
+}
+if (!green.is_empty()) {
+  used_outputs.append(1);
+}
+if (!blue.is_empty()) {
+  used_outputs.append(2);
 }
-
 if (!alpha.is_empty()) {
-  for (int64_t i : mask) {
-alpha[i] = colors[i].a;
-  }
+  used_outputs.append(3);
 }
+
+devirtualize_varray(colors, [&](auto colors) {
+  mask.to_best_mask_type([&](auto mask) {
+const int used_outputs_num = used_outputs.size();
+const int *used_outputs_data = used_outputs.data();
+
+for (const int64_t i : mask) {
+  const ColorGeometry4f &color = colors[i];
+  for (const int out_i : IndexRange(used_outputs_num)) {
+const int channel = used_outputs_data[out_i];
+outputs[channel][i] = color[channel];
+  }
+}
+  });
+});
   }
 };

___
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] [a5ff46e0fc4] master: Cleanup: make format

2022-06-23 Thread Brecht Van Lommel
Commit: a5ff46e0fc4c6b1871f92c5232ddeb605a8c096e
Author: Brecht Van Lommel
Date:   Thu Jun 23 19:28:39 2022 +0200
Branches: master
https://developer.blender.org/rBa5ff46e0fc4c6b1871f92c5232ddeb605a8c096e

Cleanup: make format

===

M   intern/cycles/device/metal/device_impl.mm
M   release/scripts/startup/bl_operators/vertexpaint_dirt.py
M   source/blender/editors/space_spreadsheet/spreadsheet_row_filter.cc
M   source/blender/editors/space_spreadsheet/spreadsheet_row_filter_ui.cc

===

diff --git a/intern/cycles/device/metal/device_impl.mm 
b/intern/cycles/device/metal/device_impl.mm
index a0abb3fca37..87c83242240 100644
--- a/intern/cycles/device/metal/device_impl.mm
+++ b/intern/cycles/device/metal/device_impl.mm
@@ -285,7 +285,8 @@ bool MetalDevice::load_kernels(const uint _kernel_features)
 
   mtlLibrary[PSO_GENERIC] = compile(source[PSO_GENERIC]);
 
-  metal_printf("Front-end compilation finished in %.1f seconds (generic)\n", 
time_dt() - starttime);
+  metal_printf("Front-end compilation finished in %.1f seconds (generic)\n",
+   time_dt() - starttime);
 
   MD5Hash md5;
   md5.append(source[PSO_GENERIC]);
diff --git a/release/scripts/startup/bl_operators/vertexpaint_dirt.py 
b/release/scripts/startup/bl_operators/vertexpaint_dirt.py
index fc14879cf18..74c20a774a3 100644
--- a/release/scripts/startup/bl_operators/vertexpaint_dirt.py
+++ b/release/scripts/startup/bl_operators/vertexpaint_dirt.py
@@ -7,6 +7,7 @@ def ensure_active_color_attribute(me):
 return me.attributes.active_color
 return me.color_attributes.new("Color", 'BYTE_COLOR', 'FACE_CORNER')
 
+
 def applyVertexDirt(me, blur_iterations, blur_strength, clamp_dirt, 
clamp_clean, dirt_only, normalize):
 from mathutils import Vector
 from math import acos
diff --git a/source/blender/editors/space_spreadsheet/spreadsheet_row_filter.cc 
b/source/blender/editors/space_spreadsheet/spreadsheet_row_filter.cc
index efebe7be491..d71a355850f 100644
--- a/source/blender/editors/space_spreadsheet/spreadsheet_row_filter.cc
+++ b/source/blender/editors/space_spreadsheet/spreadsheet_row_filter.cc
@@ -200,7 +200,9 @@ static void apply_row_filter(const SpreadsheetRowFilter 
&row_filter,
 const float threshold_sq = pow2f(row_filter.threshold);
 apply_filter_operation(
 column_data.typed(),
-[&](const ColorGeometry4f cell) { return len_squared_v4v4(cell, 
value) <= threshold_sq; },
+[&](const ColorGeometry4f cell) {
+  return len_squared_v4v4(cell, value) <= threshold_sq;
+},
 prev_mask,
 new_indices);
 break;
@@ -231,16 +233,18 @@ static void apply_row_filter(const SpreadsheetRowFilter 
&row_filter,
 const ColorGeometry4b value = row_filter.value_byte_color;
 switch (row_filter.operation) {
   case SPREADSHEET_ROW_FILTER_EQUAL: {
-const float4 value_floats = {(float)value.r, (float)value.g, 
(float)value.b, (float)value.a};
+const float4 value_floats = {
+(float)value.r, (float)value.g, (float)value.b, (float)value.a};
 const float threshold_sq = pow2f(row_filter.threshold);
 apply_filter_operation(
 column_data.typed(),
 [&](const ColorGeometry4b cell) {
-const float4 cell_floats = {(float)cell.r, (float)cell.g, 
(float)cell.b, (float)cell.a};
-return len_squared_v4v4(value_floats, cell_floats) <= threshold_sq;
+  const float4 cell_floats = {
+  (float)cell.r, (float)cell.g, (float)cell.b, (float)cell.a};
+  return len_squared_v4v4(value_floats, cell_floats) <= 
threshold_sq;
 },
-prev_mask,
-new_indices);
+prev_mask,
+new_indices);
 break;
   }
   case SPREADSHEET_ROW_FILTER_GREATER: {
diff --git 
a/source/blender/editors/space_spreadsheet/spreadsheet_row_filter_ui.cc 
b/source/blender/editors/space_spreadsheet/spreadsheet_row_filter_ui.cc
index 8ab71fe3416..6d8febc0e45 100644
--- a/source/blender/editors/space_spreadsheet/spreadsheet_row_filter_ui.cc
+++ b/source/blender/editors/space_spreadsheet/spreadsheet_row_filter_ui.cc
@@ -39,9 +39,7 @@ static void filter_panel_id_fn(void *UNUSED(row_filter_v), 
char *r_name)
 static std::string operation_string(const eSpreadsheetColumnValueType 
data_type,
 const eSpreadsheetFilterOperation 
operation)
 {
-  if (ELEM(data_type,
-   SPREADSHEET_VALUE_TYPE_BOOL,
-   SPREADSHEET_VALUE_TYPE_INSTANCES)) {
+  if (ELEM(data_type, SPREADSHEET_VALUE_TYPE_BOOL, 
SPREADSHEET_VALUE_TYPE_INSTANCES)) {
 return "=";
   }

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

[Bf-blender-cvs] [dc64673f6e0] master: Fix T97691: undefined behavior sanitizer warning for alignment in RNA functions

2022-06-23 Thread Brecht Van Lommel
Commit: dc64673f6e096408f5bf5ba646512aebac4e0a59
Author: Brecht Van Lommel
Date:   Wed Jun 22 19:02:52 2022 +0200
Branches: master
https://developer.blender.org/rBdc64673f6e096408f5bf5ba646512aebac4e0a59

Fix T97691: undefined behavior sanitizer warning for alignment in RNA functions

Thanks Loren Osborn for investigating this and proposing solutions.

Ref D14798

===

M   source/blender/makesrna/intern/makesrna.c
M   source/blender/makesrna/intern/rna_access.c
M   source/blender/makesrna/intern/rna_define.c
M   source/blender/makesrna/intern/rna_internal.h

===

diff --git a/source/blender/makesrna/intern/makesrna.c 
b/source/blender/makesrna/intern/makesrna.c
index 400944d60d4..b5354514205 100644
--- a/source/blender/makesrna/intern/makesrna.c
+++ b/source/blender/makesrna/intern/makesrna.c
@@ -3030,7 +3030,7 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA 
*dsrna, FunctionDefRNA
 }
 
 if (dparm->next) {
-  fprintf(f, "\t_data += %d;\n", rna_parameter_size(dparm->prop));
+  fprintf(f, "\t_data += %d;\n", 
rna_parameter_size_pad(rna_parameter_size(dparm->prop)));
 }
   }
 
diff --git a/source/blender/makesrna/intern/rna_access.c 
b/source/blender/makesrna/intern/rna_access.c
index 0bc35d86490..a0b25cf60b2 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -7130,7 +7130,7 @@ ParameterList *RNA_parameter_list_create(ParameterList 
*parms,
 
   /* allocate data */
   for (parm = func->cont.properties.first; parm; parm = parm->next) {
-alloc_size += rna_parameter_size(parm);
+alloc_size += rna_parameter_size_pad(rna_parameter_size(parm));
 
 if (parm->flag_parameter & PARM_OUTPUT) {
   parms->ret_count++;
@@ -7206,7 +7206,7 @@ ParameterList *RNA_parameter_list_create(ParameterList 
*parms,
   }
 }
 
-data = ((char *)data) + rna_parameter_size(parm);
+data = ((char *)data) + rna_parameter_size_pad(size);
   }
 
   return parms;
@@ -7230,7 +7230,7 @@ void RNA_parameter_list_free(ParameterList *parms)
   }
 }
 
-tot += rna_parameter_size(parm);
+tot += rna_parameter_size_pad(rna_parameter_size(parm));
   }
 
   MEM_freeN(parms->data);
@@ -7272,7 +7272,7 @@ void RNA_parameter_list_begin(ParameterList *parms, 
ParameterIterator *iter)
 
 void RNA_parameter_list_next(ParameterIterator *iter)
 {
-  iter->offset += iter->size;
+  iter->offset += rna_parameter_size_pad(iter->size);
   iter->parm = iter->parm->next;
   iter->valid = iter->parm != NULL;
 
diff --git a/source/blender/makesrna/intern/rna_define.c 
b/source/blender/makesrna/intern/rna_define.c
index 9d26797aa88..a747a5d11d8 100644
--- a/source/blender/makesrna/intern/rna_define.c
+++ b/source/blender/makesrna/intern/rna_define.c
@@ -4421,6 +4421,16 @@ int rna_parameter_size(PropertyRNA *parm)
   return sizeof(void *);
 }
 
+int rna_parameter_size_pad(const int size)
+{
+  /* Pad parameters in memory so the next parameter is properly aligned.
+   * This silences warnings in ubsan. More complicated logic to pack parameters
+   * more tightly in memory is unlikely to improve performance, and aligning
+   * to the requirements for pointers is enough for all data types we use. */
+  const int alignment = sizeof(void *);
+  return (size + alignment - 1) & ~(alignment - 1);
+}
+
 /* Dynamic Enums */
 
 void RNA_enum_item_add(EnumPropertyItem **items, int *totitem, const 
EnumPropertyItem *item)
diff --git a/source/blender/makesrna/intern/rna_internal.h 
b/source/blender/makesrna/intern/rna_internal.h
index 9e743a4f205..6ca8e668fa0 100644
--- a/source/blender/makesrna/intern/rna_internal.h
+++ b/source/blender/makesrna/intern/rna_internal.h
@@ -635,6 +635,7 @@ PointerRNA rna_pointer_inherit_refine(struct PointerRNA 
*ptr, struct StructRNA *
 /* Functions */
 
 int rna_parameter_size(struct PropertyRNA *parm);
+int rna_parameter_size_pad(const int size);
 
 /* XXX, these should not need to be defined here~! */
 struct MTex *rna_mtex_texture_slots_add(struct ID *self,

___
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] [56435b3268b] master: Fix T94621: Missing selection indication for virtual node sockets

2022-06-23 Thread Max Edge
Commit: 56435b3268bceaf24c13336976c84a91a33f9283
Author: Max Edge
Date:   Thu Jun 23 12:22:23 2022 -0500
Branches: master
https://developer.blender.org/rB56435b3268bceaf24c13336976c84a91a33f9283

Fix T94621: Missing selection indication for virtual node sockets

A small regression as a result of adding a custom outline to the empty
virtual socket, which ended up overriding the colors when selected with
Shift+LMB.

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

===

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

===

diff --git a/source/blender/editors/space_node/node_draw.cc 
b/source/blender/editors/space_node/node_draw.cc
index 7003d51b2b6..b879219e39c 100644
--- a/source/blender/editors/space_node/node_draw.cc
+++ b/source/blender/editors/space_node/node_draw.cc
@@ -749,15 +749,14 @@ static void node_socket_outline_color_get(const bool 
selected,
   if (selected) {
 UI_GetThemeColor4fv(TH_ACTIVE, r_outline_color);
   }
+  else if (socket_type == SOCK_CUSTOM) {
+/* Until there is a better place for per socket color,
+ * the outline color for virtual sockets is set  here. */
+copy_v4_v4(r_outline_color, virtual_node_socket_outline_color);
+  }
   else {
 UI_GetThemeColor4fv(TH_WIRE, r_outline_color);
   }
-
-  /* Until there is a better place for per socket color,
-   * the outline color for virtual sockets is set  here. */
-  if (socket_type == SOCK_CUSTOM) {
-copy_v4_v4(r_outline_color, virtual_node_socket_outline_color);
-  }
 }
 
 void node_socket_color_get(const bContext &C,

___
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] [792bf82f11a] master: Spreadsheet: Support operations for filtering colors

2022-06-23 Thread Angel Bueno
Commit: 792bf82f11a57c36734ef16b48137eda87a942cd
Author: Angel Bueno
Date:   Thu Jun 23 12:16:18 2022 -0500
Branches: master
https://developer.blender.org/rB792bf82f11a57c36734ef16b48137eda87a942cd

Spreadsheet: Support operations for filtering colors

Support choosing an operation when filtering colors,
like the other types.

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

===

M   source/blender/editors/space_spreadsheet/spreadsheet_row_filter.cc
M   source/blender/editors/space_spreadsheet/spreadsheet_row_filter_ui.cc

===

diff --git a/source/blender/editors/space_spreadsheet/spreadsheet_row_filter.cc 
b/source/blender/editors/space_spreadsheet/spreadsheet_row_filter.cc
index e1ff4b59b14..efebe7be491 100644
--- a/source/blender/editors/space_spreadsheet/spreadsheet_row_filter.cc
+++ b/source/blender/editors/space_spreadsheet/spreadsheet_row_filter.cc
@@ -195,25 +195,75 @@ static void apply_row_filter(const SpreadsheetRowFilter 
&row_filter,
   }
   else if (column_data.type().is()) {
 const ColorGeometry4f value = row_filter.value_color;
-const float threshold_sq = pow2f(row_filter.threshold);
-apply_filter_operation(
-column_data.typed(),
-[&](const ColorGeometry4f cell) { return len_squared_v4v4(cell, value) 
<= threshold_sq; },
-prev_mask,
-new_indices);
+switch (row_filter.operation) {
+  case SPREADSHEET_ROW_FILTER_EQUAL: {
+const float threshold_sq = pow2f(row_filter.threshold);
+apply_filter_operation(
+column_data.typed(),
+[&](const ColorGeometry4f cell) { return len_squared_v4v4(cell, 
value) <= threshold_sq; },
+prev_mask,
+new_indices);
+break;
+  }
+  case SPREADSHEET_ROW_FILTER_GREATER: {
+apply_filter_operation(
+column_data.typed(),
+[&](const ColorGeometry4f cell) {
+  return cell.r > value.r && cell.g > value.g && cell.b > value.b 
&& cell.a > value.a;
+},
+prev_mask,
+new_indices);
+break;
+  }
+  case SPREADSHEET_ROW_FILTER_LESS: {
+apply_filter_operation(
+column_data.typed(),
+[&](const ColorGeometry4f cell) {
+  return cell.r < value.r && cell.g < value.g && cell.b < value.b 
&& cell.a < value.a;
+},
+prev_mask,
+new_indices);
+break;
+  }
+}
   }
   else if (column_data.type().is()) {
 const ColorGeometry4b value = row_filter.value_byte_color;
-const float4 value_floats = {(float)value.r, (float)value.g, 
(float)value.b, (float)value.a};
-const float threshold_sq = pow2f(row_filter.threshold);
-apply_filter_operation(
-column_data.typed(),
-[&](const ColorGeometry4b cell) {
-  const float4 cell_floats = {(float)cell.r, (float)cell.g, 
(float)cell.b, (float)cell.a};
-  return len_squared_v4v4(value_floats, cell_floats) <= threshold_sq;
-},
+switch (row_filter.operation) {
+  case SPREADSHEET_ROW_FILTER_EQUAL: {
+const float4 value_floats = {(float)value.r, (float)value.g, 
(float)value.b, (float)value.a};
+const float threshold_sq = pow2f(row_filter.threshold);
+apply_filter_operation(
+column_data.typed(),
+[&](const ColorGeometry4b cell) {
+const float4 cell_floats = {(float)cell.r, (float)cell.g, 
(float)cell.b, (float)cell.a};
+return len_squared_v4v4(value_floats, cell_floats) <= threshold_sq;
+},
 prev_mask,
 new_indices);
+break;
+  }
+  case SPREADSHEET_ROW_FILTER_GREATER: {
+apply_filter_operation(
+column_data.typed(),
+[&](const ColorGeometry4b cell) {
+  return cell.r > value.r && cell.g > value.g && cell.b > value.b 
&& cell.a > value.a;
+},
+prev_mask,
+new_indices);
+break;
+  }
+  case SPREADSHEET_ROW_FILTER_LESS: {
+apply_filter_operation(
+column_data.typed(),
+[&](const ColorGeometry4b cell) {
+  return cell.r < value.r && cell.g < value.g && cell.b < value.b 
&& cell.a < value.a;
+},
+prev_mask,
+new_indices);
+break;
+  }
+}
   }
   else if (column_data.type().is()) {
 const StringRef value = row_filter.value_string;
diff --git 
a/source/blender/editors/space_spreadsheet/spreadsheet_row_filter_ui.cc 
b/source/blender/editors/space_spreadsheet/spreadsheet_row_filter_ui.cc
index d42a371c666..8ab71fe3416 100644
--- a/source/blender/editors/space_spreadsheet/spreadsheet_row_filter_ui.cc
+++ b/source/blender/editors/space_spreadsheet/spreadsheet_row_filter_ui.cc
@@ -41,9 +41,7 @@ static std::string operation_string(const 
eSpreadsh

[Bf-blender-cvs] [9b775ebad74] master: Cleanup: Remove unused array in vertex paint code

2022-06-23 Thread Hans Goudey
Commit: 9b775ebad747c0da896c6a4ed2c3b60e62315065
Author: Hans Goudey
Date:   Thu Jun 23 12:10:12 2022 -0500
Branches: master
https://developer.blender.org/rB9b775ebad747c0da896c6a4ed2c3b60e62315065

Cleanup: Remove unused array in vertex paint code

Unused since 4f616c93f7cb8c8c8e038

===

M   source/blender/editors/sculpt_paint/paint_vertex.cc

===

diff --git a/source/blender/editors/sculpt_paint/paint_vertex.cc 
b/source/blender/editors/sculpt_paint/paint_vertex.cc
index ec7ba1741b7..b8403b1e34b 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.cc
+++ b/source/blender/editors/sculpt_paint/paint_vertex.cc
@@ -2822,10 +2822,6 @@ struct VPaintData : public VPaintDataBase {
   struct VertProjHandle *vp_handle;
   CoNo *vertexcosnos;
 
-  /* loops tagged as having been painted, to apply shared vertex color
-   * blending only to modified loops */
-  bool *mlooptag;
-
   bool is_texbrush;
 
   /* Special storage for smear brush, avoid feedback loop - update each step. 
*/
@@ -2871,11 +2867,6 @@ static void *vpaint_init_vpaint(bContext *C,
 
   vpd->is_texbrush = !(brush->vertexpaint_tool == VPAINT_TOOL_BLUR) && 
brush->mtex.tex;
 
-  /* to keep tracked of modified loops for shared vertex color blending */
-  if (brush->vertexpaint_tool == VPAINT_TOOL_BLUR) {
-vpd->mlooptag = (bool *)MEM_mallocN(sizeof(bool) * elem_num, "VPaintData 
mlooptag");
-  }
-
   if (brush->vertexpaint_tool == VPAINT_TOOL_SMEAR) {
 CustomDataLayer *layer = BKE_id_attributes_active_color_get(&me->id);
 
@@ -3911,9 +3902,6 @@ static void vpaint_free_vpaintdata(Object *UNUSED(ob), 
void *_vpd)
 ED_vpaint_proj_handle_free(vpd->vp_handle);
   }
 
-  if (vpd->mlooptag) {
-MEM_freeN(vpd->mlooptag);
-  }
   if (vpd->smear.color_prev) {
 MEM_freeN(vpd->smear.color_prev);
   }

___
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] [6dde88c5366] master: Vertex paint mode tried to do a "fast update" by trying to avoid tagging the mesh ID for a full update. The conditions it uses are troublesome: 1. There must be

2022-06-23 Thread Hans Goudey
Commit: 6dde88c5366be0d855fded2588290818fbf53928
Author: Hans Goudey
Date:   Thu Jun 23 12:05:48 2022 -0500
Branches: master
https://developer.blender.org/rB6dde88c5366be0d855fded2588290818fbf53928

Vertex paint mode tried to do a "fast update" by trying to avoid tagging
the mesh ID for a full update. The conditions it uses are troublesome:
 1. There must be an evaluated mesh
 2. The evaluated mesh's active byte color layer must equal the original's

This logic doesn't make sense for a few reasons. First of all, the
`mloopcol` pointer doesn't make sense in the context of color
attributes (rather than the old vertex colors), since it only points
to byte color attribute on face corners. Second, just because the
layer pointers are equal doesn't mean something doesn't depend
on the attribute's values.

I think the best solution currently is to remove this "fast update"
case and instead work on optimizing the general case.

Also, T95842 suggests removing these pointers, and this is one
of the last remaining uses of `Mesh.mloopcol`.

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

===

M   source/blender/editors/sculpt_paint/paint_vertex.cc

===

diff --git a/source/blender/editors/sculpt_paint/paint_vertex.cc 
b/source/blender/editors/sculpt_paint/paint_vertex.cc
index 67b60acc667..ec7ba1741b7 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.cc
+++ b/source/blender/editors/sculpt_paint/paint_vertex.cc
@@ -227,22 +227,6 @@ static MDeformVert *defweight_prev_init(MDeformVert 
*dvert_prev,
   return dv_prev;
 }
 
-/* check if we can do partial updates and have them draw realtime
- * (without evaluating modifiers) */
-static bool vertex_paint_use_fast_update_check(Object *ob)
-{
-  const Mesh *me_eval = BKE_object_get_evaluated_mesh(ob);
-
-  if (me_eval != nullptr) {
-const Mesh *me = BKE_mesh_from_object(ob);
-if (me && me->mloopcol) {
-  return (me->mloopcol == CustomData_get_layer(&me_eval->ldata, 
CD_PROP_BYTE_COLOR));
-}
-  }
-
-  return false;
-}
-
 static void paint_last_stroke_update(Scene *scene, const float location[3])
 {
   UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
@@ -2838,12 +2822,6 @@ struct VPaintData : public VPaintDataBase {
   struct VertProjHandle *vp_handle;
   CoNo *vertexcosnos;
 
-  /**
-   * Modify #Mesh.mloopcol directly, since the derived mesh is drawing from 
this
-   * array, otherwise we need to refresh the modifier stack.
-   */
-  bool use_fast_update;
-
   /* loops tagged as having been painted, to apply shared vertex color
* blending only to modified loops */
   bool *mlooptag;
@@ -2893,15 +2871,6 @@ static void *vpaint_init_vpaint(bContext *C,
 
   vpd->is_texbrush = !(brush->vertexpaint_tool == VPAINT_TOOL_BLUR) && 
brush->mtex.tex;
 
-  /* are we painting onto a modified mesh?,
-   * if not we can skip face map trickiness */
-  if (vertex_paint_use_fast_update_check(ob)) {
-vpd->use_fast_update = true;
-  }
-  else {
-vpd->use_fast_update = false;
-  }
-
   /* to keep tracked of modified loops for shared vertex color blending */
   if (brush->vertexpaint_tool == VPAINT_TOOL_BLUR) {
 vpd->mlooptag = (bool *)MEM_mallocN(sizeof(bool) * elem_num, "VPaintData 
mlooptag");
@@ -3901,15 +3870,7 @@ static void vpaint_stroke_update_step_intern(bContext 
*C, PaintStroke *stroke, P
 
   ED_region_tag_redraw(vc->region);
 
-  if (vpd->use_fast_update == false) {
-/* recalculate modifier stack to get new colors, slow,
- * avoid this if we can! */
-DEG_id_tag_update((ID *)ob->data, 0);
-  }
-  else {
-/* Flush changes through DEG. */
-DEG_id_tag_update((ID *)ob->data, ID_RECALC_COPY_ON_WRITE);
-  }
+  DEG_id_tag_update((ID *)ob->data, ID_RECALC_GEOMETRY);
 }
 
 static void vpaint_stroke_update_step(bContext *C,

___
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] [54182e4925d] master: Mesh: Add an explicit "positions changed" function

2022-06-23 Thread Hans Goudey
Commit: 54182e4925de4ee7e49e4351479e79cb257acc73
Author: Hans Goudey
Date:   Thu Jun 23 12:00:25 2022 -0500
Branches: master
https://developer.blender.org/rB54182e4925de4ee7e49e4351479e79cb257acc73

Mesh: Add an explicit "positions changed" function

We store various lazily calculated caches on meshes, some of which
depend on the vertex positions staying the same. The current API to
invalidate these caches is a bit confusing. With an explicit set of
functions modeled after the functions in `BKE_node_tree_update.h`,
it becomes clear which function to call. This may become more
important if more lazy caches are added in the future.

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

===

M   source/blender/blenkernel/BKE_mesh.h
M   source/blender/blenkernel/intern/cloth.c
M   source/blender/blenkernel/intern/dynamicpaint.c
M   source/blender/blenkernel/intern/geometry_component_mesh.cc
M   source/blender/blenkernel/intern/mesh.cc
M   source/blender/blenkernel/intern/mesh_runtime.cc
M   source/blender/blenkernel/intern/multires_reshape_apply_base.c
M   source/blender/editors/sculpt_paint/sculpt.c
M   source/blender/editors/sculpt_paint/sculpt_undo.c
M   source/blender/makesrna/intern/rna_mesh.c
M   source/blender/modifiers/intern/MOD_boolean.cc
M   source/blender/modifiers/intern/MOD_ocean.c
M   source/blender/nodes/geometry/nodes/node_geo_scale_elements.cc

===

diff --git a/source/blender/blenkernel/BKE_mesh.h 
b/source/blender/blenkernel/BKE_mesh.h
index 23ec69babc8..8e038a1d3d9 100644
--- a/source/blender/blenkernel/BKE_mesh.h
+++ b/source/blender/blenkernel/BKE_mesh.h
@@ -52,6 +52,18 @@ extern "C" {
 #  define BKE_MESH_OMP_LIMIT 1
 #endif
 
+/*  mesh_runtime.cc  */
+
+/**
+ * Call after changing vertex positions to tag lazily calculated caches for 
recomputation.
+ */
+void BKE_mesh_tag_coords_changed(struct Mesh *mesh);
+
+/**
+ * Call after moving every mesh vertex by the same translation.
+ */
+void BKE_mesh_tag_coords_changed_uniformly(struct Mesh *mesh);
+
 /* *** mesh.c *** */
 
 struct BMesh *BKE_mesh_to_bmesh_ex(const struct Mesh *me,
diff --git a/source/blender/blenkernel/intern/cloth.c 
b/source/blender/blenkernel/intern/cloth.c
index ab9a27a3996..8622174231c 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -1171,7 +1171,7 @@ static Mesh *cloth_make_rest_mesh(ClothModifierData 
*clmd, Mesh *mesh)
   for (unsigned i = 0; i < mesh->totvert; i++, verts++) {
 copy_v3_v3(mvert[i].co, verts->xrest);
   }
-  BKE_mesh_normals_tag_dirty(new_mesh);
+  BKE_mesh_tag_coords_changed(new_mesh);
 
   return new_mesh;
 }
diff --git a/source/blender/blenkernel/intern/dynamicpaint.c 
b/source/blender/blenkernel/intern/dynamicpaint.c
index e5bb70f8cda..a4262e08e39 100644
--- a/source/blender/blenkernel/intern/dynamicpaint.c
+++ b/source/blender/blenkernel/intern/dynamicpaint.c
@@ -2024,13 +2024,13 @@ static Mesh 
*dynamicPaint_Modifier_apply(DynamicPaintModifierData *pmd, Object *
 settings.use_threading = (sData->total_points > 1000);
 BLI_task_parallel_range(
 0, sData->total_points, &data, 
dynamic_paint_apply_surface_wave_cb, &settings);
-BKE_mesh_normals_tag_dirty(result);
+BKE_mesh_tag_coords_changed(result);
   }
 
   /* displace */
   if (surface->type == MOD_DPAINT_SURFACE_T_DISPLACE) {
 dynamicPaint_applySurfaceDisplace(surface, result);
-BKE_mesh_normals_tag_dirty(result);
+BKE_mesh_tag_coords_changed(result);
   }
 }
   }
diff --git a/source/blender/blenkernel/intern/geometry_component_mesh.cc 
b/source/blender/blenkernel/intern/geometry_component_mesh.cc
index 8a021e596bd..88ea1af8a8d 100644
--- a/source/blender/blenkernel/intern/geometry_component_mesh.cc
+++ b/source/blender/blenkernel/intern/geometry_component_mesh.cc
@@ -864,11 +864,11 @@ static void set_vertex_position(MVert &vert, float3 
position)
   copy_v3_v3(vert.co, position);
 }
 
-static void tag_normals_dirty_when_writing_position(GeometryComponent 
&component)
+static void tag_component_positions_changed(GeometryComponent &component)
 {
   Mesh *mesh = get_mesh_from_component_for_write(component);
   if (mesh != nullptr) {
-BKE_mesh_normals_tag_dirty(mesh);
+BKE_mesh_tag_coords_changed(mesh);
   }
 }
 
@@ -1213,7 +1213,7 @@ static ComponentAttributeProviders 
create_attribute_providers_for_mesh()
   point_access,
   make_derived_read_attribute,
   make_derived_write_attribute,
-  tag_normals_dirty_when_writing_position);
+  tag_component_positions_changed);
 
   static NormalAttributeProvider normal;
 
diff --git a/source/blender/blenkernel/intern/mesh.cc 
b/source/blender/blenkernel/intern/mesh.cc
index 7c86aff6624..ff

[Bf-blender-cvs] [3e5a4d14124] master: Geometry Nodes: Optimize selection for virtual array input

2022-06-23 Thread Hans Goudey
Commit: 3e5a4d14124029dd3ccb111de2db299bb405d668
Author: Hans Goudey
Date:   Thu Jun 23 11:50:53 2022 -0500
Branches: master
https://developer.blender.org/rB3e5a4d14124029dd3ccb111de2db299bb405d668

Geometry Nodes: Optimize selection for virtual array input

This makes calculation of selected indices slightly faster when the
input is a virtual array (the direct output of various nodes like
Face Area, etc). The utility can be helpful for other areas that
need to find selected indices besides field evaluation.

With the face area node used as a selection with 4 million faces,
the speedup is 3.51 ms to 3.39 ms, just a slight speedup.

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

===

M   source/blender/blenlib/BLI_index_mask_ops.hh
M   source/blender/blenlib/intern/index_mask.cc
M   source/blender/editors/sculpt_paint/paint_vertex_color_ops.cc
M   source/blender/functions/intern/field.cc

===

diff --git a/source/blender/blenlib/BLI_index_mask_ops.hh 
b/source/blender/blenlib/BLI_index_mask_ops.hh
index 48a1f27a2fa..f67abb1d550 100644
--- a/source/blender/blenlib/BLI_index_mask_ops.hh
+++ b/source/blender/blenlib/BLI_index_mask_ops.hh
@@ -13,6 +13,7 @@
 #include "BLI_index_mask.hh"
 #include "BLI_task.hh"
 #include "BLI_vector.hh"
+#include "BLI_virtual_array.hh"
 
 namespace blender::index_mask_ops {
 
@@ -57,4 +58,17 @@ inline IndexMask find_indices_based_on_predicate(const 
IndexMask indices_to_chec
   return detail::find_indices_based_on_predicate__merge(indices_to_check, 
sub_masks, r_indices);
 }
 
+/**
+ * Find the true indices in a virtual array. This is a version of
+ * #find_indices_based_on_predicate optimised for a virtual array input.
+ *
+ * \param parallel_grain_size: The grain size for when the virtual array isn't 
a span or a single
+ * value internally. This should be adjusted based on the expected cost of 
evaluating the virtual
+ * array-- more expensive virtual arrays should have smaller grain sizes.
+ */
+IndexMask find_indices_from_virtual_array(IndexMask indices_to_check,
+  const VArray &virtual_array,
+  int64_t parallel_grain_size,
+  Vector &r_indices);
+
 }  // namespace blender::index_mask_ops
diff --git a/source/blender/blenlib/intern/index_mask.cc 
b/source/blender/blenlib/intern/index_mask.cc
index 1e301bc5fb9..f3590e4a41c 100644
--- a/source/blender/blenlib/intern/index_mask.cc
+++ b/source/blender/blenlib/intern/index_mask.cc
@@ -128,7 +128,9 @@ Vector IndexMask::extract_ranges_invert(const 
IndexRange full_range,
 
 }  // namespace blender
 
-namespace blender::index_mask_ops::detail {
+namespace blender::index_mask_ops {
+
+namespace detail {
 
 IndexMask find_indices_based_on_predicate__merge(
 IndexMask indices_to_check,
@@ -193,4 +195,47 @@ IndexMask find_indices_based_on_predicate__merge(
   return r_indices.as_span();
 }
 
-}  // namespace blender::index_mask_ops::detail
+}  // namespace detail
+
+IndexMask find_indices_from_virtual_array(const IndexMask indices_to_check,
+  const VArray &virtual_array,
+  const int64_t parallel_grain_size,
+  Vector &r_indices)
+{
+  if (virtual_array.is_single()) {
+return virtual_array.get_internal_single() ? indices_to_check : 
IndexMask(0);
+  }
+  if (virtual_array.is_span()) {
+const Span span = virtual_array.get_internal_span();
+return find_indices_based_on_predicate(
+indices_to_check, 4096, r_indices, [&](const int64_t i) { return 
span[i]; });
+  }
+
+  threading::EnumerableThreadSpecific> materialize_buffers;
+  threading::EnumerableThreadSpecific>> sub_masks;
+
+  threading::parallel_for(
+  indices_to_check.index_range(), parallel_grain_size, [&](const 
IndexRange range) {
+const IndexMask sliced_mask = indices_to_check.slice(range);
+
+/* To avoid virtual function call overhead from accessing the virtual 
array,
+ * materialize the necessary indices for this chunk into a reused 
buffer. */
+Vector &buffer = materialize_buffers.local();
+buffer.reinitialize(sliced_mask.size());
+virtual_array.materialize_compressed(sliced_mask, buffer);
+
+Vector masked_indices;
+sliced_mask.to_best_mask_type([&](auto best_mask) {
+  for (const int64_t i : IndexRange(best_mask.size())) {
+if (buffer[i]) {
+  masked_indices.append(best_mask[i]);
+}
+  }
+});
+sub_masks.local().append(std::move(masked_indices));
+  });
+
+  return detail::find_indices_based_on_predicate__merge(indices_to_check, 
sub_masks, r_indices);
+}
+
+}  // namespace blender::index_mask_ops
diff --git a/source/bl

[Bf-blender-cvs] [633c2f07da2] master: Cyles: switch primitive.h inline hints to forceinline

2022-06-23 Thread Xavier Hallade
Commit: 633c2f07da2926e42f5bb5d43d16dd23767c498c
Author: Xavier Hallade
Date:   Thu Jun 23 18:30:49 2022 +0200
Branches: master
https://developer.blender.org/rB633c2f07da2926e42f5bb5d43d16dd23767c498c

Cyles: switch primitive.h inline hints to forceinline

This change helps decrease Intel GPU binaries compile time by 5-10
minutes without impacting other backends.

Reviewed By: sergey, brecht

Differential Revision: http://developer.blender.org/D15273

===

M   intern/cycles/kernel/geom/primitive.h

===

diff --git a/intern/cycles/kernel/geom/primitive.h 
b/intern/cycles/kernel/geom/primitive.h
index 9b4b61fbd84..0f1a3fc11bc 100644
--- a/intern/cycles/kernel/geom/primitive.h
+++ b/intern/cycles/kernel/geom/primitive.h
@@ -18,11 +18,11 @@ CCL_NAMESPACE_BEGIN
  * attributes for performance, mainly for GPU performance to avoid bringing in
  * heavy volume interpolation code. */
 
-ccl_device_inline float primitive_surface_attribute_float(KernelGlobals kg,
-  ccl_private const 
ShaderData *sd,
-  const 
AttributeDescriptor desc,
-  ccl_private float 
*dx,
-  ccl_private float 
*dy)
+ccl_device_forceinline float primitive_surface_attribute_float(KernelGlobals 
kg,
+   ccl_private 
const ShaderData *sd,
+   const 
AttributeDescriptor desc,
+   ccl_private 
float *dx,
+   ccl_private 
float *dy)
 {
   if (sd->type & PRIMITIVE_TRIANGLE) {
 if (subd_triangle_patch(kg, sd) == ~0)
@@ -49,11 +49,11 @@ ccl_device_inline float 
primitive_surface_attribute_float(KernelGlobals kg,
   }
 }
 
-ccl_device_inline float2 primitive_surface_attribute_float2(KernelGlobals kg,
-ccl_private const 
ShaderData *sd,
-const 
AttributeDescriptor desc,
-ccl_private float2 
*dx,
-ccl_private float2 
*dy)
+ccl_device_forceinline float2 primitive_surface_attribute_float2(KernelGlobals 
kg,
+ ccl_private 
const ShaderData *sd,
+ const 
AttributeDescriptor desc,
+ ccl_private 
float2 *dx,
+ ccl_private 
float2 *dy)
 {
   if (sd->type & PRIMITIVE_TRIANGLE) {
 if (subd_triangle_patch(kg, sd) == ~0)
@@ -80,11 +80,11 @@ ccl_device_inline float2 
primitive_surface_attribute_float2(KernelGlobals kg,
   }
 }
 
-ccl_device_inline float3 primitive_surface_attribute_float3(KernelGlobals kg,
-ccl_private const 
ShaderData *sd,
-const 
AttributeDescriptor desc,
-ccl_private float3 
*dx,
-ccl_private float3 
*dy)
+ccl_device_forceinline float3 primitive_surface_attribute_float3(KernelGlobals 
kg,
+ ccl_private 
const ShaderData *sd,
+ const 
AttributeDescriptor desc,
+ ccl_private 
float3 *dx,
+ ccl_private 
float3 *dy)
 {
   if (sd->type & PRIMITIVE_TRIANGLE) {
 if (subd_triangle_patch(kg, sd) == ~0)
@@ -149,15 +149,15 @@ ccl_device_forceinline float4 
primitive_surface_attribute_float4(KernelGlobals k
  * attributes for performance, mainly for GPU performance to avoid bringing in
  * heavy volume interpolation code. */
 
-ccl_device_inline bool primitive_is_volume_attribute(ccl_private const 
ShaderData *sd,
- const AttributeDescriptor 
desc)
+ccl_device_forceinline bool primitive_is_volume_attribute(ccl_private const 
ShaderData *sd,
+  const 
AttributeDescriptor desc)
 {
   return sd->type == PRIMITIVE_VOLUME;
 }
 
-ccl_device_inline float primitive_volume_attribute_float(KernelGlobals kg,
- ccl_private const 
ShaderData *

[Bf-blender-cvs] [2eba15d3e86] master: Fix T98975: Broken vertex paint mode operators

2022-06-23 Thread Hans Goudey
Commit: 2eba15d3e862fdf112edda6b26b7e1535f0fdb07
Author: Hans Goudey
Date:   Thu Jun 23 11:32:53 2022 -0500
Branches: master
https://developer.blender.org/rB2eba15d3e862fdf112edda6b26b7e1535f0fdb07

Fix T98975: Broken vertex paint mode operators

All of the operators in vertex paint mode didn't work properly with
the new color attribute system. They only worked on byte color type
attributes on the face corner domain.

Since there are four possible combinations of domains and types now,
it mostly ended up being simpler to convert the code to C++ and use
the geometry component API for retrieving attributes, interpolating
between domains, etc. The code changes ended up being fairly large,
but the result should be simpler now.

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

===

M   release/scripts/startup/bl_operators/vertexpaint_dirt.py
M   source/blender/editors/sculpt_paint/CMakeLists.txt
M   source/blender/editors/sculpt_paint/paint_intern.h
M   source/blender/editors/sculpt_paint/paint_vertex_color_ops.cc
D   source/blender/editors/sculpt_paint/paint_vertex_color_utils.c

===

diff --git a/release/scripts/startup/bl_operators/vertexpaint_dirt.py 
b/release/scripts/startup/bl_operators/vertexpaint_dirt.py
index a3c0b73fc0e..fc14879cf18 100644
--- a/release/scripts/startup/bl_operators/vertexpaint_dirt.py
+++ b/release/scripts/startup/bl_operators/vertexpaint_dirt.py
@@ -2,15 +2,10 @@
 # Copyright Campbell Barton.
 
 
-def get_vcolor_layer_data(me):
-for lay in me.vertex_colors:
-if lay.active:
-return lay.data
-
-lay = me.vertex_colors.new()
-lay.active = True
-return lay.data
-
+def ensure_active_color_attribute(me):
+if me.attributes.active_color:
+return me.attributes.active_color
+return me.color_attributes.new("Color", 'BYTE_COLOR', 'FACE_CORNER')
 
 def applyVertexDirt(me, blur_iterations, blur_strength, clamp_dirt, 
clamp_clean, dirt_only, normalize):
 from mathutils import Vector
@@ -99,17 +94,21 @@ def applyVertexDirt(me, blur_iterations, blur_strength, 
clamp_dirt, clamp_clean,
 else:
 tone_range = 1.0 / tone_range
 
-active_col_layer = get_vcolor_layer_data(me)
-if not active_col_layer:
+active_color_attribute = ensure_active_color_attribute(me)
+if not active_color_attribute:
 return {'CANCELLED'}
 
+point_domain = active_color_attribute.domain == 'POINT'
+
+attribute_data = active_color_attribute.data
+
 use_paint_mask = me.use_paint_mask
 for i, p in enumerate(me.polygons):
 if not use_paint_mask or p.select:
 for loop_index in p.loop_indices:
 loop = me.loops[loop_index]
 v = loop.vertex_index
-col = active_col_layer[loop_index].color
+col = attribute_data[v if point_domain else loop_index].color
 tone = vert_tone[v]
 tone = (tone - min_tone) * tone_range
 
diff --git a/source/blender/editors/sculpt_paint/CMakeLists.txt 
b/source/blender/editors/sculpt_paint/CMakeLists.txt
index 8879161d2af..34247b4ef75 100644
--- a/source/blender/editors/sculpt_paint/CMakeLists.txt
+++ b/source/blender/editors/sculpt_paint/CMakeLists.txt
@@ -53,7 +53,6 @@ set(SRC
   paint_utils.c
   paint_vertex.cc
   paint_vertex_color_ops.cc
-  paint_vertex_color_utils.c
   paint_vertex_proj.c
   paint_vertex_weight_ops.c
   paint_vertex_weight_utils.c
diff --git a/source/blender/editors/sculpt_paint/paint_intern.h 
b/source/blender/editors/sculpt_paint/paint_intern.h
index 3f4e660b229..ea17114efa5 100644
--- a/source/blender/editors/sculpt_paint/paint_intern.h
+++ b/source/blender/editors/sculpt_paint/paint_intern.h
@@ -134,18 +134,10 @@ void PAINT_OT_vertex_paint(struct wmOperatorType *ot);
 
 unsigned int vpaint_get_current_color(struct Scene *scene, struct VPaint *vp, 
bool secondary);
 
-/* paint_vertex_color_utils.c */
-
 /**
  * \note weight-paint has an equivalent function: #ED_wpaint_blend_tool
  */
 unsigned int ED_vpaint_blend_tool(int tool, uint col, uint paintcol, int 
alpha_i);
-/**
- * Apply callback to each vertex of the active vertex color layer.
- */
-bool ED_vpaint_color_transform(struct Object *ob,
-   VPaintTransform_Callback vpaint_tx_fn,
-   const void *user_data);
 
 /* paint_vertex_weight_utils.c */
 
diff --git a/source/blender/editors/sculpt_paint/paint_vertex_color_ops.cc 
b/source/blender/editors/sculpt_paint/paint_vertex_color_ops.cc
index 6a47aceb2b0..bd015784ad7 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex_color_ops.cc
+++ b/source/blender/editors/sculpt_paint/paint_vertex_color_ops.cc
@@ -12,11 +12,15 @@
 #include "DNA_scene_types.h"
 
 #include "BLI_array.hh"
+#include "BLI_index_mask_ops.hh"
 #include "BLI_math_base.h"
 #include "BLI_ma

[Bf-blender-cvs] [5c6ffd07e0d] master: Fix T99110: Crash after running view_all operator in VSE

2022-06-23 Thread Richard Antalik
Commit: 5c6ffd07e0de8f4917927da69a68db9af205973d
Author: Richard Antalik
Date:   Thu Jun 23 18:11:33 2022 +0200
Branches: master
https://developer.blender.org/rB5c6ffd07e0de8f4917927da69a68db9af205973d

Fix T99110: Crash after running view_all operator in VSE

Crash caused by NULL dereference, when `Editing` is not initialized.

Check if data is initialized in poll function.

===

M   source/blender/editors/space_sequencer/sequencer_edit.c
M   source/blender/editors/space_sequencer/sequencer_intern.h
M   source/blender/editors/space_sequencer/sequencer_view.c

===

diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c 
b/source/blender/editors/space_sequencer/sequencer_edit.c
index 86c438c616e..16f663110ec 100644
--- a/source/blender/editors/space_sequencer/sequencer_edit.c
+++ b/source/blender/editors/space_sequencer/sequencer_edit.c
@@ -173,6 +173,11 @@ bool sequencer_edit_poll(bContext *C)
   return (SEQ_editing_get(CTX_data_scene(C)) != NULL);
 }
 
+bool sequencer_editing_initialized_and_active(bContext *C)
+{
+  return ED_operator_sequencer_active(C) && sequencer_edit_poll(C);
+}
+
 #if 0 /* UNUSED */
 bool sequencer_strip_poll(bContext *C)
 {
diff --git a/source/blender/editors/space_sequencer/sequencer_intern.h 
b/source/blender/editors/space_sequencer/sequencer_intern.h
index 3307c3fde2f..3f91be9e9e8 100644
--- a/source/blender/editors/space_sequencer/sequencer_intern.h
+++ b/source/blender/editors/space_sequencer/sequencer_intern.h
@@ -133,6 +133,7 @@ int seq_effect_find_selected(struct Scene *scene,
 
 /* Operator helpers. */
 bool sequencer_edit_poll(struct bContext *C);
+bool sequencer_editing_initialized_and_active(struct bContext *C);
 /* UNUSED */
 /* bool sequencer_strip_poll(struct bContext *C); */
 bool sequencer_strip_has_path_poll(struct bContext *C);
diff --git a/source/blender/editors/space_sequencer/sequencer_view.c 
b/source/blender/editors/space_sequencer/sequencer_view.c
index 857ca6d989b..f7ca753c052 100644
--- a/source/blender/editors/space_sequencer/sequencer_view.c
+++ b/source/blender/editors/space_sequencer/sequencer_view.c
@@ -373,7 +373,7 @@ void SEQUENCER_OT_view_selected(wmOperatorType *ot)
 
   /* Api callbacks. */
   ot->exec = sequencer_view_selected_exec;
-  ot->poll = ED_operator_sequencer_active;
+  ot->poll = sequencer_editing_initialized_and_active;
 
   /* Flags. */
   ot->flag = OPTYPE_REGISTER;

___
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] [d1ea39aac77] master: Fix T99091: Freeze when changing strip source with thumbnails enabled

2022-06-23 Thread Richard Antalik
Commit: d1ea39aac77203a2f7517b3d0d2ec56ee2e30a22
Author: Richard Antalik
Date:   Thu Jun 23 17:49:26 2022 +0200
Branches: master
https://developer.blender.org/rBd1ea39aac77203a2f7517b3d0d2ec56ee2e30a22

Fix T99091: Freeze when changing strip source with thumbnails enabled

When input file is changed, `orig_height` and `orig_width` fields are
reset, which causes thumbnail dimensions to be incorrectly calculated.

Only draw thumbnails if both mentioned fields are non 0.

===

M   source/blender/editors/space_sequencer/sequencer_thumbnails.c

===

diff --git a/source/blender/editors/space_sequencer/sequencer_thumbnails.c 
b/source/blender/editors/space_sequencer/sequencer_thumbnails.c
index 984d3b1f374..5c929e6673a 100644
--- a/source/blender/editors/space_sequencer/sequencer_thumbnails.c
+++ b/source/blender/editors/space_sequencer/sequencer_thumbnails.c
@@ -427,6 +427,11 @@ void draw_seq_strip_thumbnail(View2D *v2d,
   float image_height, image_width, thumb_width;
   rcti crop;
 
+  StripElem *se = seq->strip->stripdata;
+  if (se->orig_height == 0 || se->orig_width == 0) {
+return;
+  }
+
   /* If width of the strip too small ignore drawing thumbnails. */
   if ((y2 - y1) / pixely <= 20 * U.dpi_fac) {
 return;

___
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] [c2a2f3553ae] master: Cycles: unify math functions names

2022-06-23 Thread Andrii Symkin
Commit: c2a2f3553aed58ae9e4c165f8bfcad2b31dcf74b
Author: Andrii Symkin
Date:   Thu Jun 23 14:29:17 2022 +0200
Branches: master
https://developer.blender.org/rBc2a2f3553aed58ae9e4c165f8bfcad2b31dcf74b

Cycles: unify math functions names

This patch unifies the names of math functions for different data types and uses
overloading instead. The goal is to make it possible to swap out all the float3
variables containing RGB data with something else, with as few as possible
changes to the code. It's a requirement for future spectral rendering patches.

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

===

M   intern/cycles/kernel/bake/bake.h
M   intern/cycles/kernel/closure/alloc.h
M   intern/cycles/kernel/closure/bsdf.h
M   intern/cycles/kernel/closure/bsdf_hair_principled.h
M   intern/cycles/kernel/closure/bsdf_microfacet.h
M   intern/cycles/kernel/closure/bsdf_microfacet_multi.h
M   intern/cycles/kernel/closure/volume.h
M   intern/cycles/kernel/film/accumulate.h
M   intern/cycles/kernel/film/passes.h
M   intern/cycles/kernel/geom/curve_intersect.h
M   intern/cycles/kernel/integrator/init_from_bake.h
M   intern/cycles/kernel/integrator/mnee.h
M   intern/cycles/kernel/integrator/path_state.h
M   intern/cycles/kernel/integrator/shade_surface.h
M   intern/cycles/kernel/integrator/shade_volume.h
M   intern/cycles/kernel/integrator/subsurface_random_walk.h
M   intern/cycles/kernel/light/sample.h
M   intern/cycles/kernel/svm/color_util.h
M   intern/cycles/kernel/svm/map_range.h
M   intern/cycles/kernel/svm/mapping_util.h
M   intern/cycles/kernel/svm/math_util.h
M   intern/cycles/kernel/svm/voronoi.h
M   intern/cycles/scene/mesh.cpp
M   intern/cycles/scene/mesh_displace.cpp
M   intern/cycles/scene/object.cpp
M   intern/cycles/util/color.h
M   intern/cycles/util/math.h
M   intern/cycles/util/math_float3.h
M   intern/cycles/util/math_float4.h
M   intern/cycles/util/time.cpp
M   intern/cycles/util/transform.cpp
M   intern/cycles/util/transform.h

===

diff --git a/intern/cycles/kernel/bake/bake.h b/intern/cycles/kernel/bake/bake.h
index 544a8217bef..ec87990b699 100644
--- a/intern/cycles/kernel/bake/bake.h
+++ b/intern/cycles/kernel/bake/bake.h
@@ -29,14 +29,14 @@ ccl_device void kernel_displace_evaluate(KernelGlobals kg,
   object_inverse_dir_transform(kg, &sd, &D);
 
 #ifdef __KERNEL_DEBUG_NAN__
-  if (!isfinite3_safe(D)) {
+  if (!isfinite_safe(D)) {
 kernel_assert(!"Cycles displacement with non-finite value detected");
   }
 #endif
 
   /* Ensure finite displacement, preventing BVH from becoming degenerate and 
avoiding possible
* traversal issues caused by non-finite math. */
-  D = ensure_finite3(D);
+  D = ensure_finite(D);
 
   /* Write output. */
   output[offset * 3 + 0] += D.x;
@@ -68,13 +68,13 @@ ccl_device void kernel_background_evaluate(KernelGlobals kg,
   float3 color = shader_background_eval(&sd);
 
 #ifdef __KERNEL_DEBUG_NAN__
-  if (!isfinite3_safe(color)) {
+  if (!isfinite_safe(color)) {
 kernel_assert(!"Cycles background with non-finite value detected");
   }
 #endif
 
   /* Ensure finite color, avoiding possible numerical instabilities in the 
path tracing kernels. */
-  color = ensure_finite3(color);
+  color = ensure_finite(color);
 
   /* Write output. */
   output[offset * 3 + 0] += color.x;
diff --git a/intern/cycles/kernel/closure/alloc.h 
b/intern/cycles/kernel/closure/alloc.h
index a6975a63d5d..933c07a5102 100644
--- a/intern/cycles/kernel/closure/alloc.h
+++ b/intern/cycles/kernel/closure/alloc.h
@@ -51,7 +51,7 @@ ccl_device_inline ccl_private ShaderClosure 
*bsdf_alloc(ccl_private ShaderData *
 int size,
 float3 weight)
 {
-  kernel_assert(isfinite3_safe(weight));
+  kernel_assert(isfinite_safe(weight));
 
   const float sample_weight = fabsf(average(weight));
 
@@ -77,7 +77,7 @@ ccl_device_inline ShaderClosure *bsdf_alloc_osl(ShaderData 
*sd,
 float3 weight,
 void *data)
 {
-  kernel_assert(isfinite3_safe(weight));
+  kernel_assert(isfinite_safe(weight));
 
   const float sample_weight = fabsf(average(weight));
 
diff --git a/intern/cycles/kernel/closure/bsdf.h 
b/intern/cycles/kernel/closure/bsdf.h
index 6f3c2092c64..4feb21c43e3 100644
--- a/intern/cycles/kernel/closure/bsdf.h
+++ b/intern/cycles/kernel/closure/bsdf.h
@@ -439,7 +439,7 @@ ccl_device_inline int bsdf_sample(KernelGlobals kg,
   *eval *= shift_cos_in(dot(*omega_in, sc->N), frequency_multiplier);
 }
 if (label & LABEL_DIFFUSE) {
-  if (!isequal_float3(sc->N, sd->N)) {
+  if (!isequal(sc->N, sd->N)) {
 *eval *= bump_sh

[Bf-blender-cvs] [1c83354c63a] master: Fix T99028: crash deleting file output node with color management override

2022-06-23 Thread Brecht Van Lommel
Commit: 1c83354c63a334a57118579d653e642524f23fce
Author: Brecht Van Lommel
Date:   Thu Jun 23 16:00:43 2022 +0200
Branches: master
https://developer.blender.org/rB1c83354c63a334a57118579d653e642524f23fce

Fix T99028: crash deleting file output node with color management override

One case of copying image formats was not properly using BKE_image_format_copy.
To fix this for existing .blend file we need to do versioning, ensuring the 
curve
mapping is properly copied.

===

M   source/blender/blenloader/intern/versioning_300.c
M   source/blender/nodes/composite/nodes/node_composite_output_file.cc

===

diff --git a/source/blender/blenloader/intern/versioning_300.c 
b/source/blender/blenloader/intern/versioning_300.c
index eac27bc57ed..844354c8bc3 100644
--- a/source/blender/blenloader/intern/versioning_300.c
+++ b/source/blender/blenloader/intern/versioning_300.c
@@ -46,6 +46,7 @@
 #include "BKE_asset.h"
 #include "BKE_attribute.h"
 #include "BKE_collection.h"
+#include "BKE_colortools.h"
 #include "BKE_curve.h"
 #include "BKE_data_transfer.h"
 #include "BKE_deform.h"
@@ -1620,6 +1621,31 @@ static void 
versioning_replace_legacy_combined_and_separate_color_nodes(bNodeTre
   }
 }
 
+static void version_fix_image_format_copy(Main *bmain, ImageFormatData *format)
+{
+  /* Fix bug where curves in image format were not properly copied to file 
output
+   * node, incorrectly sharing a pointer with the scene settings. Copy the data
+   * structure now as it should have been done in the first place. */
+  if (format->view_settings.curve_mapping) {
+LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
+  if (format != &scene->r.im_format && 
ELEM(format->view_settings.curve_mapping,
+
scene->view_settings.curve_mapping,
+
scene->r.im_format.view_settings.curve_mapping)) {
+format->view_settings.curve_mapping = BKE_curvemapping_copy(
+format->view_settings.curve_mapping);
+break;
+  }
+}
+
+/* Remove any invalid curves with missing data. */
+if (format->view_settings.curve_mapping->cm[0].curve == NULL) {
+  BKE_curvemapping_free(format->view_settings.curve_mapping);
+  format->view_settings.curve_mapping = NULL;
+  format->view_settings.flag &= ~COLORMANAGE_VIEW_USE_CURVES;
+}
+  }
+}
+
 /* NOLINTNEXTLINE: readability-function-size */
 void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain)
 {
@@ -3112,6 +3138,33 @@ void blo_do_versions_300(FileData *fd, Library 
*UNUSED(lib), Main *bmain)
 }
   }
 
+  if (!MAIN_VERSION_ATLEAST(bmain, 303, 4)) {
+FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
+  if (ntree->type == NTREE_COMPOSIT) {
+LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
+  if (node->type == CMP_NODE_OUTPUT_FILE) {
+LISTBASE_FOREACH (bNodeSocket *, sock, &node->inputs) {
+  if (sock->storage) {
+NodeImageMultiFileSocket *sockdata = (NodeImageMultiFileSocket 
*)sock->storage;
+version_fix_image_format_copy(bmain, &sockdata->format);
+  }
+}
+
+if (node->storage) {
+  NodeImageMultiFile *nimf = (NodeImageMultiFile *)node->storage;
+  version_fix_image_format_copy(bmain, &nimf->format);
+}
+  }
+}
+  }
+}
+FOREACH_NODETREE_END;
+
+LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
+  version_fix_image_format_copy(bmain, &scene->r.im_format);
+}
+  }
+
   /**
* Versioning code until next subversion bump goes here.
*
diff --git a/source/blender/nodes/composite/nodes/node_composite_output_file.cc 
b/source/blender/nodes/composite/nodes/node_composite_output_file.cc
index 1fd6e62b4c5..f1621f83ac3 100644
--- a/source/blender/nodes/composite/nodes/node_composite_output_file.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_output_file.cc
@@ -130,7 +130,8 @@ bNodeSocket *ntreeCompositOutputFileAddSocket(bNodeTree 
*ntree,
   ntreeCompositOutputFileUniqueLayer(&node->inputs, sock, name, '_');
 
   if (im_format) {
-sockdata->format = *im_format;
+BKE_image_format_copy(&sockdata->format, im_format);
+sockdata->format.color_management = R_IMF_COLOR_MANAGEMENT_FOLLOW_SCENE;
 if (BKE_imtype_is_movie(sockdata->format.imtype)) {
   sockdata->format.imtype = R_IMF_IMTYPE_OPENEXR;
 }
@@ -198,7 +199,8 @@ static void init_output_file(const bContext *C, PointerRNA 
*ptr)
 RenderData *rd = &scene->r;
 
 BLI_strncpy(nimf->base_path, rd->pic, sizeof(nimf->base_path));
-nimf->format = rd->im_format;
+BKE_image_format_copy(&nimf->format, &rd->im_format);
+nimf->format.color_management = R_IMF_COLOR_MANAGEMENT_FOLLOW_SCENE;
 if (BKE_imtype_is_movie(nimf->format.imtyp

[Bf-blender-cvs] [dae7ae87baa] cycles_oneapi: Build Deps: Implement DPC++/SYCL harvesting for Linux

2022-06-23 Thread Sergey Sharybin
Commit: dae7ae87b6ae70b389a529a261d4c3181ebd
Author: Sergey Sharybin
Date:   Thu Jun 23 16:33:28 2022 +0200
Branches: cycles_oneapi
https://developer.blender.org/rBdae7ae87b6ae70b389a529a261d4c3181ebd

Build Deps: Implement DPC++/SYCL harvesting for Linux

- Restore more typical install paths for all dependencies
  (don't install to a dpcpp/lib, since the harvesting is
  implemented anyway).

- Perform simple harvesting of all components we need for
  DPC++/SYCL.

Windows harvesting is not done yet.

Tweaks are possible to ignore binaries we don't need.

===

M   build_files/build_environment/cmake/harvest.cmake
M   build_files/build_environment/cmake/igc.cmake
M   build_files/build_environment/cmake/ocloc.cmake

===

diff --git a/build_files/build_environment/cmake/harvest.cmake 
b/build_files/build_environment/cmake/harvest.cmake
index aeaa6fbd2b5..2865a5304d7 100644
--- a/build_files/build_environment/cmake/harvest.cmake
+++ b/build_files/build_environment/cmake/harvest.cmake
@@ -192,6 +192,10 @@ harvest(zstd/lib zstd/lib "*.a")
 if(UNIX AND NOT APPLE)
   harvest(libglu/lib mesa/lib "*.so*")
   harvest(mesa/lib64 mesa/lib "*.so*")
-endif()
+
+  harvest(dpcpp dpcpp "*")
+  harvest(igc dpcpp/lib/igc "*")
+  harvest(ocloc dpcpp/lib/ocloc "*")
+ endif()
 
 endif()
diff --git a/build_files/build_environment/cmake/igc.cmake 
b/build_files/build_environment/cmake/igc.cmake
index 2d6e19de34d..64f30064a3a 100644
--- a/build_files/build_environment/cmake/igc.cmake
+++ b/build_files/build_environment/cmake/igc.cmake
@@ -88,7 +88,7 @@ ExternalProject_Add(external_igc
   URL file://${PACKAGE_DIR}/${IGC_FILE}
   DOWNLOAD_DIR ${DOWNLOAD_DIR}
   URL_HASH ${IGC_HASH_TYPE}=${IGC_HASH}
-  CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/dpcpp/lib/igc 
${DEFAULT_CMAKE_FLAGS} ${IGC_EXTRA_ARGS}
+  CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/igc ${DEFAULT_CMAKE_FLAGS} 
${IGC_EXTRA_ARGS}
 
   # IGC is pretty set in its way where sub projects ought to live, for some it 
offers
   # hooks to supply alternatives folders, other are just hardocded with no way 
to configure
@@ -103,6 +103,7 @@ ExternalProject_Add(external_igc
 ${CMAKE_COMMAND} -E create_symlink 
${BUILD_DIR}/igc_vcintrinsics/src/external_igc_vcintrinsics/ 
${BUILD_DIR}/igc/src/vc-intrinsics
   PREFIX ${BUILD_DIR}/igc
   INSTALL_DIR ${LIBDIR}/igc
+  INSTALL_COMMAND ${CMAKE_COMMAND} --install . --strip
   CMAKE_GENERATOR ${IGC_GENERATOR}
 )
 
diff --git a/build_files/build_environment/cmake/ocloc.cmake 
b/build_files/build_environment/cmake/ocloc.cmake
index 2dda7239a00..f686d2dd4fc 100644
--- a/build_files/build_environment/cmake/ocloc.cmake
+++ b/build_files/build_environment/cmake/ocloc.cmake
@@ -4,7 +4,7 @@ set(OCLOC_EXTRA_ARGS
   -DNEO_SKIP_UNIT_TESTS=1
   -DNEO_BUILD_WITH_OCL=0
   -DBUILD_WITH_L0=0
-  -DIGC_DIR=${LIBDIR}/dpcpp/lib/igc
+  -DIGC_DIR=${LIBDIR}/igc
   -DGMM_DIR=${LIBDIR}/gmmlib
 )
 
@@ -13,7 +13,7 @@ ExternalProject_Add(external_ocloc
   URL_HASH ${OCLOC_HASH_TYPE}=${OCLOC_HASH}
   DOWNLOAD_DIR ${DOWNLOAD_DIR}
   PREFIX ${BUILD_DIR}/ocloc
-  CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/dpcpp/lib/ocloc 
${DEFAULT_CMAKE_FLAGS} ${OCLOC_EXTRA_ARGS}
+  CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/ocloc ${DEFAULT_CMAKE_FLAGS} 
${OCLOC_EXTRA_ARGS}
   INSTALL_DIR ${LIBDIR}/ocloc
 )

___
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] [e59b8c14a0c] cycles_oneapi: Build Deps: Only install SYCL related part of DPC++

2022-06-23 Thread Sergey Sharybin
Commit: e59b8c14a0cc82d370b9d102ce94b818e42ad397
Author: Sergey Sharybin
Date:   Thu Jun 23 16:32:42 2022 +0200
Branches: cycles_oneapi
https://developer.blender.org/rBe59b8c14a0cc82d370b9d102ce94b818e42ad397

Build Deps: Only install SYCL related part of DPC++

Saves a lot of space, and we don't need the omitted parts anyway.

===

M   build_files/build_environment/cmake/dpcpp.cmake

===

diff --git a/build_files/build_environment/cmake/dpcpp.cmake 
b/build_files/build_environment/cmake/dpcpp.cmake
index 586bef16b13..1c7dd4c7c1c 100644
--- a/build_files/build_environment/cmake/dpcpp.cmake
+++ b/build_files/build_environment/cmake/dpcpp.cmake
@@ -80,6 +80,7 @@ ExternalProject_Add(external_dpcpp
   CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/dpcpp ${DEFAULT_CMAKE_FLAGS} 
${DPCPP_EXTRA_ARGS}
   #CONFIGURE_COMMAND ${PYTHON_BINARY} 
${BUILD_DIR}/dpcpp/src/external_dpcpp/buildbot/configure.py 
${DPCPP_CONFIGURE_ARGS}
   #BUILD_COMMAND echo "." #${PYTHON_BINARY} 
${BUILD_DIR}/dpcpp/src/external_dpcpp/buildbot/compile.py
+  INSTALL_COMMAND ${CMAKE_COMMAND} --build . -- deploy-sycl-toolchain
   PATCH_COMMAND ${PATCH_CMD} -p 1 -d ${BUILD_DIR}/dpcpp/src/external_dpcpp < 
${PATCH_DIR}/dpcpp.diff
   INSTALL_DIR ${LIBDIR}/dpcpp
 )

___
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] [0831b5ce865] cycles_path_guiding: Build: OpenPGL removed version number form the destination folder of the cmake configs

2022-06-23 Thread Sebastian Herholz
Commit: 0831b5ce865910a427239c29b499c90a740f94a8
Author: Sebastian Herholz
Date:   Thu Jun 23 16:00:23 2022 +0200
Branches: cycles_path_guiding
https://developer.blender.org/rB0831b5ce865910a427239c29b499c90a740f94a8

Build: OpenPGL removed version number form the destination folder of the cmake 
configs

===

M   build_files/build_environment/cmake/harvest.cmake

===

diff --git a/build_files/build_environment/cmake/harvest.cmake 
b/build_files/build_environment/cmake/harvest.cmake
index 21944071e98..282cc7a7a44 100644
--- a/build_files/build_environment/cmake/harvest.cmake
+++ b/build_files/build_environment/cmake/harvest.cmake
@@ -143,7 +143,7 @@ harvest(embree/include embree/include "*.h")
 harvest(embree/lib embree/lib "*.a")
 harvest(openpgl/include openpgl/include "*.h")
 harvest(openpgl/lib openpgl/lib "*.a")
-harvest(openpgl/lib/cmake/openpgl-${OPENPGL_SHORT_VERSION} 
openpgl/lib/cmake/openpgl-${OPENPGL_SHORT_VERSION} "*.cmake")
+harvest(openpgl/lib/cmake/openpgl-${OPENPGL_SHORT_VERSION} 
openpgl/lib/cmake/openpgl "*.cmake")
 harvest(openjpeg/include/openjpeg-${OPENJPEG_SHORT_VERSION} openjpeg/include 
"*.h")
 harvest(openjpeg/lib openjpeg/lib "*.a")
 harvest(opensubdiv/include opensubdiv/include "*.h")

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


[Bf-blender-cvs] [b8403b065e2] master: Fix T99027: Touch typing in text fields results in dropped key presses

2022-06-23 Thread Campbell Barton
Commit: b8403b065e222faff3dfb3e2e9aa1b3d3f56c555
Author: Campbell Barton
Date:   Thu Jun 23 21:19:22 2022 +1000
Branches: master
https://developer.blender.org/rBb8403b065e222faff3dfb3e2e9aa1b3d3f56c555

Fix T99027: Touch typing in text fields results in dropped key presses

Fix by always testing unhandled double-click events as press events,
irrespective of the previous event type.

**Details**

Handling double-click events only ran when the previously pressed-key
matched the current pressed-key.

Originally when double-click support was added the previous type was
compared (ignoring it's press/release value) and while not necessary
it was harmless as it matched the check for double-click events being
generated.

As of [0] the logic for click/drag detection changed to ignore release
events as release this could interrupt dragging.
This made it possible to generate double-click events that failed the
`event->prev_press_type == event->type` comparison.
In these cases it was possible to generate double-click
events that would not fall-back to a 'press' value when unhandled.

[0]: 102644cb8cbb8b21e55643cebe2ed364885023a6

===

M   source/blender/windowmanager/intern/wm_event_system.cc

===

diff --git a/source/blender/windowmanager/intern/wm_event_system.cc 
b/source/blender/windowmanager/intern/wm_event_system.cc
index d3ae4177e4d..51486f664c7 100644
--- a/source/blender/windowmanager/intern/wm_event_system.cc
+++ b/source/blender/windowmanager/intern/wm_event_system.cc
@@ -3376,9 +3376,8 @@ static int wm_handlers_do(bContext *C, wmEvent *event, 
ListBase *handlers)
 }
   }
 
-  if (event->prev_press_type == event->type) {
-
-if (event->val == KM_RELEASE) {
+  if (event->val == KM_RELEASE) {
+if (event->prev_press_type == event->type) {
   if (event->prev_val == KM_PRESS) {
 if (win->event_queue_check_click) {
   if (WM_event_drag_test(event, event->prev_press_xy)) {
@@ -3408,15 +3407,15 @@ static int wm_handlers_do(bContext *C, wmEvent *event, 
ListBase *handlers)
 }
   }
 }
-else if (event->val == KM_DBL_CLICK) {
-  /* The underlying event is a press, so try and handle this. */
-  event->val = KM_PRESS;
-  action |= wm_handlers_do_intern(C, win, event, handlers);
+  }
+  else if (event->val == KM_DBL_CLICK) {
+/* The underlying event is a press, so try and handle this. */
+event->val = KM_PRESS;
+action |= wm_handlers_do_intern(C, win, event, handlers);
 
-  /* Revert value if not handled. */
-  if (wm_action_not_handled(action)) {
-event->val = KM_DBL_CLICK;
-  }
+/* Revert value if not handled. */
+if (wm_action_not_handled(action)) {
+  event->val = KM_DBL_CLICK;
 }
   }
 }

___
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] [751dde236b9] cycles_oneapi: Cleanup: fix Cycles float3 endif comment

2022-06-23 Thread Xavier Hallade
Commit: 751dde236b946d01f5ae046cb1e24f9309a86b3f
Author: Xavier Hallade
Date:   Thu Jun 23 13:11:57 2022 +0200
Branches: cycles_oneapi
https://developer.blender.org/rB751dde236b946d01f5ae046cb1e24f9309a86b3f

Cleanup: fix Cycles float3 endif comment

oneAPI backend uses its own smaller float3 type.

===

M   intern/cycles/util/types_float3_impl.h

===

diff --git a/intern/cycles/util/types_float3_impl.h 
b/intern/cycles/util/types_float3_impl.h
index 7fbceafb493..2e6e864c8ea 100644
--- a/intern/cycles/util/types_float3_impl.h
+++ b/intern/cycles/util/types_float3_impl.h
@@ -83,7 +83,7 @@ ccl_device_inline void print_float3(const char *label, const 
float3 &a)
 {
   printf("%s: %.8f %.8f %.8f\n", label, (double)a.x, (double)a.y, (double)a.z);
 }
-#endif /* !defined(__KERNEL_GPU__) || defined(__KERNEL_ONEAPI__) */
+#endif /* !defined(__KERNEL_GPU__) */
 
 CCL_NAMESPACE_END

___
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] [e63799e7911] master: Cleanup: fix typo that deactivated clang-format in rna_brush.c

2022-06-23 Thread Jacques Lucke
Commit: e63799e791109bc4357995566e421648bf9c5c4c
Author: Jacques Lucke
Date:   Thu Jun 23 13:10:26 2022 +0200
Branches: master
https://developer.blender.org/rBe63799e791109bc4357995566e421648bf9c5c4c

Cleanup: fix typo that deactivated clang-format in rna_brush.c

===

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

===

diff --git a/source/blender/makesrna/intern/rna_brush.c 
b/source/blender/makesrna/intern/rna_brush.c
index 423cb084f27..80a61543b5a 100644
--- a/source/blender/makesrna/intern/rna_brush.c
+++ b/source/blender/makesrna/intern/rna_brush.c
@@ -253,7 +253,7 @@ const EnumPropertyItem 
rna_enum_brush_curves_sculpt_tool_items[] = {
 {CURVES_SCULPT_TOOL_SELECTION_PAINT, "SELECTION_PAINT", 
ICON_BRUSH_PAINT_SELECT, "Paint Selection", ""},
 {0, NULL, 0, NULL, NULL},
 };
-/* clang-format om */
+/* clang-format on */
 
 #ifndef RNA_RUNTIME
 static EnumPropertyItem rna_enum_gpencil_brush_eraser_modes_items[] = {

___
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] [04bd58e2323] cycles_oneapi: Build Deps: Correct path to igc for ocloc

2022-06-23 Thread Sergey Sharybin
Commit: 04bd58e2323f28157001b6d7b0f35ac7f1e2
Author: Sergey Sharybin
Date:   Thu Jun 23 12:55:51 2022 +0200
Branches: cycles_oneapi
https://developer.blender.org/rB04bd58e2323f28157001b6d7b0f35ac7f1e2

Build Deps: Correct path to igc for ocloc

The path got changed in an earlier commit in the hopes of simplifying
harvesting process.

===

M   build_files/build_environment/cmake/ocloc.cmake

===

diff --git a/build_files/build_environment/cmake/ocloc.cmake 
b/build_files/build_environment/cmake/ocloc.cmake
index b38f31de189..2dda7239a00 100644
--- a/build_files/build_environment/cmake/ocloc.cmake
+++ b/build_files/build_environment/cmake/ocloc.cmake
@@ -4,7 +4,7 @@ set(OCLOC_EXTRA_ARGS
   -DNEO_SKIP_UNIT_TESTS=1
   -DNEO_BUILD_WITH_OCL=0
   -DBUILD_WITH_L0=0
-  -DIGC_DIR=${LIBDIR}/igc
+  -DIGC_DIR=${LIBDIR}/dpcpp/lib/igc
   -DGMM_DIR=${LIBDIR}/gmmlib
 )

___
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] [0a3f4c9d457] temp-deform-curves-with-surface: support normal smoothing

2022-06-23 Thread Jacques Lucke
Commit: 0a3f4c9d457ef9410fa2d08ff06c27739db0f817
Author: Jacques Lucke
Date:   Thu Jun 23 12:34:54 2022 +0200
Branches: temp-deform-curves-with-surface
https://developer.blender.org/rB0a3f4c9d457ef9410fa2d08ff06c27739db0f817

support normal smoothing

===

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

===

diff --git 
a/source/blender/nodes/geometry/nodes/node_geo_sample_mesh_deformation.cc 
b/source/blender/nodes/geometry/nodes/node_geo_sample_mesh_deformation.cc
index 9ba3c2a4dc0..4e51000ebb3 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_sample_mesh_deformation.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_sample_mesh_deformation.cc
@@ -2,6 +2,7 @@
 
 #include "BKE_attribute_math.hh"
 #include "BKE_curves.hh"
+#include "BKE_mesh.h"
 #include "BKE_mesh_runtime.h"
 #include "BKE_type_conversions.hh"
 
@@ -33,6 +34,7 @@ static void node_declare(NodeDeclarationBuilder &b)
   b.add_input(N_("Rest Position")).hide_value().supports_field();
   b.add_input(N_("UV Map")).hide_value().supports_field();
   b.add_input(N_("Sample UV")).supports_field();
+  b.add_input(N_("Smooth Normals")).default_value(true);
   b.add_output(N_("Translation")).dependent_field({3});
   b.add_output(N_("Rotation")).dependent_field({3});
 }
@@ -52,24 +54,39 @@ static void node_update(bNodeTree *UNUSED(ntree), bNode 
*UNUSED(node))
 class SampleMeshDeformationFunction : public fn::MultiFunction {
  private:
   GeometrySet geometry_;
-  const Mesh *mesh_;
+  Mesh *mesh_;
   Span verts_;
   Array rest_positions_;
   Array uv_map_;
+  Span corner_normals_;
+  Span face_normals_;
   std::optional reverse_uv_sampler;
+  bool smooth_normals_;
 
  public:
   SampleMeshDeformationFunction(GeometrySet geometry,
 VArray rest_positions,
-VArray uv_map)
+VArray uv_map,
+const bool smooth_normals)
   : geometry_(std::move(geometry)),
 rest_positions_(VArray_Span(rest_positions)),
-uv_map_(VArray_Span(uv_map))
+uv_map_(VArray_Span(uv_map)),
+smooth_normals_(smooth_normals)
   {
-mesh_ = geometry_.get_mesh_for_read();
+mesh_ = geometry_.get_mesh_for_write();
 verts_ = Span(mesh_->mvert, mesh_->totvert);
 const Span looptris{BKE_mesh_runtime_looptri_ensure(mesh_),
   BKE_mesh_runtime_looptri_len(mesh_)};
+
+if (!CustomData_has_layer(&mesh_->ldata, CD_NORMAL)) {
+  BKE_mesh_calc_normals_split(mesh_);
+}
+corner_normals_ = {
+reinterpret_cast(CustomData_get_layer(&mesh_->ldata, 
CD_NORMAL)),
+mesh_->totloop};
+face_normals_ = {reinterpret_cast(BKE_mesh_poly_normals_ensure(mesh_)),
+ mesh_->totpoly};
+
 reverse_uv_sampler.emplace(uv_map_, looptris);
 
 static fn::MFSignature signature = create_signature();
@@ -141,11 +158,22 @@ class SampleMeshDeformationFunction : public 
fn::MultiFunction {
 const float3 old_dir_2 = old_pos_2 - old_pos_0;
 const float3 new_dir_1 = new_pos_1 - new_pos_0;
 const float3 new_dir_2 = new_pos_2 - new_pos_0;
+
+/* This can lead to issues if the original face was not planar. */
 const float3 old_normal = math::normalize(math::cross(old_dir_1, 
old_dir_2));
-const float3 new_normal = math::normalize(math::cross(new_dir_1, 
new_dir_2));
-const float3 old_tangent_x = math::normalize(old_dir_1);
-const float3 new_tangent_x = math::normalize(new_dir_1);
+const float3 old_tangent_x = math::normalize(math::cross(old_normal, 
old_dir_1));
 const float3 old_tangent_y = math::cross(old_normal, old_tangent_x);
+
+const float3 new_normal = [&]() {
+  if (smooth_normals_) {
+const float3 &new_normal_0 = corner_normals_[corner_0];
+const float3 &new_normal_1 = corner_normals_[corner_1];
+const float3 &new_normal_2 = corner_normals_[corner_2];
+return math::normalize(mix3(bary_weights, new_normal_0, 
new_normal_1, new_normal_2));
+  }
+  return face_normals_[looptri.poly];
+}();
+const float3 new_tangent_x = math::normalize(math::cross(new_normal, 
new_dir_1));
 const float3 new_tangent_y = math::cross(new_normal, new_tangent_x);
 
 float3x3 old_transform;
@@ -175,6 +203,7 @@ static void node_geo_exec(GeoNodeExecParams params)
   Field rest_positions_field = 
params.extract_input>("Rest Position");
   Field uv_map_field = params.extract_input>("UV Map");
   Field sample_uv_field = params.extract_input>("Sample 
UV");
+  const bool smooth_normals = params.extract_input("Smooth Normals");
 
   if (!geometry.has_mesh()) {
 params.set_default_remaining_outputs();
@@ -196,7 +225,7 @@ static void node_geo

[Bf-blender-cvs] [b8302631865] master: Fix T98871: Drivers not updated when joining an armature

2022-06-23 Thread Sebastian Parborg
Commit: b8302631865538eb967896455ea59b62f0f8711c
Author: Sebastian Parborg
Date:   Thu Jun 23 11:44:29 2022 +0200
Branches: master
https://developer.blender.org/rBb8302631865538eb967896455ea59b62f0f8711c

Fix T98871: Drivers not updated when joining an armature

If the some driver had been flagged as "invalid", the flag would not be
cleared when joining armatures which could lead to now valid drivers
still being flagged as invalid.

Now we clear this invalid flag on all drivers to force a recheck after
joining the armatures.

===

M   source/blender/editors/armature/armature_relations.c

===

diff --git a/source/blender/editors/armature/armature_relations.c 
b/source/blender/editors/armature/armature_relations.c
index 950178e865d..0825d6968c6 100644
--- a/source/blender/editors/armature/armature_relations.c
+++ b/source/blender/editors/armature/armature_relations.c
@@ -159,6 +159,11 @@ static void joined_armature_fix_animdata_cb(ID *id, FCurve 
*fcu, void *user_data
 ChannelDriver *driver = fcu->driver;
 DriverVar *dvar;
 
+/* Ensure that invalid drivers gets re-evaluated in case they become valid 
once the join
+ * operation is finished. */
+fcu->flag &= ~FCURVE_DISABLED;
+driver->flag &= ~DRIVER_FLAG_INVALID;
+
 /* Fix driver references to invalid ID's */
 for (dvar = driver->variables.first; dvar; dvar = dvar->next) {
   /* only change the used targets, since the others will need fixing 
manually anyway */

___
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] [091100bfd75] master: Animation: Add function to remove all FCurves from an Action

2022-06-23 Thread Colin Basnett
Commit: 091100bfd757b886527b465aef19a88ba261d7ec
Author: Colin Basnett
Date:   Thu Jun 23 11:41:44 2022 +0200
Branches: master
https://developer.blender.org/rB091100bfd757b886527b465aef19a88ba261d7ec

Animation: Add function to remove all FCurves from an Action

Add a `BKE_action_fcurves_clear(action)` function, which removes all the
Action's FCurves, and expose it as `ActionFCurves.clear()` in RNA.

This is more ergonomic than calling `remove` on f-curves until the list
is empty.

Reviewed By: sybren

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

===

M   source/blender/blenkernel/BKE_action.h
M   source/blender/blenkernel/intern/action.c
M   source/blender/makesrna/intern/rna_action.c

===

diff --git a/source/blender/blenkernel/BKE_action.h 
b/source/blender/blenkernel/BKE_action.h
index d5487b3558a..79d0fe6e20a 100644
--- a/source/blender/blenkernel/BKE_action.h
+++ b/source/blender/blenkernel/BKE_action.h
@@ -92,6 +92,11 @@ bool action_has_motion(const struct bAction *act);
  */
 bool BKE_action_is_cyclic(const struct bAction *act);
 
+/**
+ * Remove all fcurves from the action.
+ */
+void BKE_action_fcurves_clear(struct bAction *act);
+
 /* Action Groups API - */
 
 /**
diff --git a/source/blender/blenkernel/intern/action.c 
b/source/blender/blenkernel/intern/action.c
index 05b51e0c9fa..fee7582acb3 100644
--- a/source/blender/blenkernel/intern/action.c
+++ b/source/blender/blenkernel/intern/action.c
@@ -1983,3 +1983,16 @@ void BKE_pose_blend_read_expand(BlendExpander *expander, 
bPose *pose)
 BLO_expand(expander, chan->custom);
   }
 }
+
+void BKE_action_fcurves_clear(bAction *act)
+{
+  if (!act) {
+return;
+  }
+  while (act->curves.first) {
+FCurve *fcu = act->curves.first;
+action_groups_remove_channel(act, fcu);
+BKE_fcurve_free(fcu);
+  }
+  DEG_id_tag_update(&act->id, ID_RECALC_ANIMATION_NO_FLUSH);
+}
diff --git a/source/blender/makesrna/intern/rna_action.c 
b/source/blender/makesrna/intern/rna_action.c
index a1266443631..ac90ec69784 100644
--- a/source/blender/makesrna/intern/rna_action.c
+++ b/source/blender/makesrna/intern/rna_action.c
@@ -168,6 +168,12 @@ static void rna_Action_fcurve_remove(bAction *act, 
ReportList *reports, PointerR
   WM_main_add_notifier(NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
 }
 
+static void rna_Action_fcurve_clear(bAction *act)
+{
+  BKE_action_fcurves_clear(act);
+  WM_main_add_notifier(NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
+}
+
 static TimeMarker *rna_Action_pose_markers_new(bAction *act, const char name[])
 {
   TimeMarker *marker = MEM_callocN(sizeof(TimeMarker), "TimeMarker");
@@ -788,6 +794,10 @@ static void rna_def_action_fcurves(BlenderRNA *brna, 
PropertyRNA *cprop)
   parm = RNA_def_pointer(func, "fcurve", "FCurve", "", "F-Curve to remove");
   RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
   RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
+
+  /* Action.fcurves.clear() */
+  func = RNA_def_function(srna, "clear", "rna_Action_fcurve_clear");
+  RNA_def_function_ui_description(func, "Remove all F-Curves");
 }
 
 static void rna_def_action_pose_markers(BlenderRNA *brna, PropertyRNA *cprop)

___
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] [2ae4397ec99] master: Armature: Add poll message explaining bone groups need pose mode

2022-06-23 Thread Colin Basnett
Commit: 2ae4397ec9905a0055ad80675ade2696137a7ca2
Author: Colin Basnett
Date:   Thu Jun 23 11:21:43 2022 +0200
Branches: master
https://developer.blender.org/rB2ae4397ec9905a0055ad80675ade2696137a7ca2

Armature: Add poll message explaining bone groups need pose mode

Add a poll message to the bone group operators, to explain they only
work in pose mode. Before, the buttons would be greyed out with no
explanation.

Reviewed By: sybren

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

===

M   source/blender/editors/armature/pose_group.c

===

diff --git a/source/blender/editors/armature/pose_group.c 
b/source/blender/editors/armature/pose_group.c
index d0f0bd55eea..1b78d3cc77e 100644
--- a/source/blender/editors/armature/pose_group.c
+++ b/source/blender/editors/armature/pose_group.c
@@ -42,6 +42,7 @@
 static bool pose_group_poll(bContext *C)
 {
   if (!ED_operator_posemode_context(C)) {
+CTX_wm_operator_poll_msg_set(C, "Bone groups can only be edited in pose 
mode");
 return 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] [57816a6435c] master: Dopesheet: Add Custom Properties panel

2022-06-23 Thread Colin Basnett
Commit: 57816a6435c3a6efc98c575ec0a02ad0dd07622c
Author: Colin Basnett
Date:   Thu Jun 23 11:11:53 2022 +0200
Branches: master
https://developer.blender.org/rB57816a6435c3a6efc98c575ec0a02ad0dd07622c

Dopesheet: Add Custom Properties panel

Adds a custom property panel for the active `Action` to the Dopesheet
editor. There was previously no way to edit these properties outside of
the Python API.

This panel will show up when
`context.active_object.animation_data.action` is set.

Reviewed By: sybren

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

===

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

===

diff --git a/release/scripts/startup/bl_ui/space_dopesheet.py 
b/release/scripts/startup/bl_ui/space_dopesheet.py
index 3d792eec3e0..d4b55d5e536 100644
--- a/release/scripts/startup/bl_ui/space_dopesheet.py
+++ b/release/scripts/startup/bl_ui/space_dopesheet.py
@@ -15,6 +15,8 @@ from bl_ui.properties_grease_pencil_common import (
 GreasePencilLayerDisplayPanel,
 )
 
+from rna_prop_ui import PropertyPanel
+
 ###
 # DopeSheet Filtering - Header Buttons
 
@@ -544,6 +546,20 @@ class DopesheetActionPanelBase:
 col.prop(action, "use_cyclic")
 
 
+class DOPESHEET_PT_custom_props_action(PropertyPanel, Panel):
+bl_space_type = 'DOPESHEET_EDITOR'
+bl_region_type = 'UI'
+bl_context = 'data'
+_context_path = "active_object.animation_data.action"
+_property_type = bpy.types.Action
+
+@classmethod
+def poll(cls, context):
+return context.active_object \
+and context.active_object.animation_data \
+and context.active_object.animation_data.action
+
+
 class DOPESHEET_PT_action(DopesheetActionPanelBase, Panel):
 bl_space_type = 'DOPESHEET_EDITOR'
 bl_category = "Item"
@@ -817,6 +833,7 @@ classes = (
 DOPESHEET_PT_gpencil_layer_adjustments,
 DOPESHEET_PT_gpencil_layer_relations,
 DOPESHEET_PT_gpencil_layer_display,
+DOPESHEET_PT_custom_props_action,
 )
 
 if __name__ == "__main__":  # only for live edit.

___
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] [d8e9647ae26] master: Cycles: Add diagnostic tracing of MTLLibrary compilation time

2022-06-23 Thread Michael Jones
Commit: d8e9647ae26b1681f1a2345975e52c512ff15e20
Author: Michael Jones
Date:   Thu Jun 23 10:05:45 2022 +0100
Branches: master
https://developer.blender.org/rBd8e9647ae26b1681f1a2345975e52c512ff15e20

Cycles: Add diagnostic tracing of MTLLibrary compilation time

Reviewed By: sergey

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

===

M   intern/cycles/device/metal/device_impl.mm

===

diff --git a/intern/cycles/device/metal/device_impl.mm 
b/intern/cycles/device/metal/device_impl.mm
index 8edcd8d118d..a0abb3fca37 100644
--- a/intern/cycles/device/metal/device_impl.mm
+++ b/intern/cycles/device/metal/device_impl.mm
@@ -280,14 +280,17 @@ bool MetalDevice::load_kernels(const uint 
_kernel_features)
   motion_blur = kernel_features & KERNEL_FEATURE_OBJECT_MOTION;
 
   source[PSO_GENERIC] = get_source(kernel_features);
+
+  const double starttime = time_dt();
+
   mtlLibrary[PSO_GENERIC] = compile(source[PSO_GENERIC]);
 
+  metal_printf("Front-end compilation finished in %.1f seconds (generic)\n", 
time_dt() - starttime);
+
   MD5Hash md5;
   md5.append(source[PSO_GENERIC]);
   source_md5[PSO_GENERIC] = md5.get_hex();
 
-  metal_printf("Front-end compilation finished (generic)\n");
-
   bool result = MetalDeviceKernels::load(this, false);
 
   reserve_local_memory(kernel_features);

___
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] [cb0879e9fb8] gpencil-new-data-proposal: Merge branch 'master' into gpencil-new-data-proposal

2022-06-23 Thread Antonio Vazquez
Commit: cb0879e9fb882e807837be8a2a6c891b81ca7e53
Author: Antonio Vazquez
Date:   Thu Jun 23 11:06:06 2022 +0200
Branches: gpencil-new-data-proposal
https://developer.blender.org/rBcb0879e9fb882e807837be8a2a6c891b81ca7e53

Merge branch 'master' into gpencil-new-data-proposal

===



===



___
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