[Bf-blender-cvs] [e00f76c6a8c] master: ViewLayer: fix missing sync in object APIs (fixes T101128, T101204)

2022-09-19 Thread Aras Pranckevicius
Commit: e00f76c6a8ccaafbdd09b069923176ad23e3ce7e
Author: Aras Pranckevicius
Date:   Tue Sep 20 09:45:18 2022 +0300
Branches: master
https://developer.blender.org/rBe00f76c6a8ccaafbdd09b069923176ad23e3ce7e

ViewLayer: fix missing sync in object APIs (fixes T101128, T101204)

Since D15885, most (all?) python based importers are failing with an
error like RuntimeError: Error: Object 'Cube' can't be selected
because it is not in View Layer, whenever they try to mark
just-created objects selected via obj.select_set(True). Happens at
least in FBX and (legacy) OBJ importers -- effectively they end up
creating just the first imported object before failing with this
exception.

Looks like BKE_view_layer_synced_ensure calls were missing before
BKE_view_layer_base_find in rna_object_api.c.

Reviewed By: Campbell Barton
Differential Revision: https://developer.blender.org/D16004

===

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

===

diff --git a/source/blender/makesrna/intern/rna_object_api.c 
b/source/blender/makesrna/intern/rna_object_api.c
index 0b8cf601bfd..c99c5fb723d 100644
--- a/source/blender/makesrna/intern/rna_object_api.c
+++ b/source/blender/makesrna/intern/rna_object_api.c
@@ -77,13 +77,36 @@ static const EnumPropertyItem space_items[] = {
 
 #  include "MEM_guardedalloc.h"
 
-static void rna_Object_select_set(
-Object *ob, bContext *C, ReportList *reports, bool select, ViewLayer 
*view_layer)
+static Base *find_view_layer_base_with_synced_ensure(
+Object *ob, bContext *C, PointerRNA *view_layer_ptr, Scene **r_scene, 
ViewLayer **r_view_layer)
 {
-  if (view_layer == NULL) {
+  Scene *scene;
+  ViewLayer *view_layer;
+  if (view_layer_ptr->data) {
+scene = (Scene *)view_layer_ptr->owner_id;
+view_layer = view_layer_ptr->data;
+  }
+  else {
+scene = CTX_data_scene(C);
 view_layer = CTX_data_view_layer(C);
   }
-  Base *base = BKE_view_layer_base_find(view_layer, ob);
+  if (r_scene != NULL) {
+*r_scene = scene;
+  }
+  if (r_view_layer != NULL) {
+*r_view_layer = view_layer;
+  }
+
+  BKE_view_layer_synced_ensure(scene, view_layer);
+  return BKE_view_layer_base_find(view_layer, ob);
+}
+
+static void rna_Object_select_set(
+Object *ob, bContext *C, ReportList *reports, bool select, PointerRNA 
*view_layer_ptr)
+{
+  Scene *scene;
+  ViewLayer *view_layer;
+  Base *base = find_view_layer_base_with_synced_ensure(ob, C, view_layer_ptr, 
&scene, &view_layer);
 
   if (!base) {
 if (select) {
@@ -98,19 +121,14 @@ static void rna_Object_select_set(
 
   ED_object_base_select(base, select ? BA_SELECT : BA_DESELECT);
 
-  Scene *scene = CTX_data_scene(C);
   DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
   WM_main_add_notifier(NC_SCENE | ND_OB_SELECT, scene);
   ED_outliner_select_sync_from_object_tag(C);
 }
 
-static bool rna_Object_select_get(Object *ob, bContext *C, ViewLayer 
*view_layer)
+static bool rna_Object_select_get(Object *ob, bContext *C, PointerRNA 
*view_layer_ptr)
 {
-  if (view_layer == NULL) {
-view_layer = CTX_data_view_layer(C);
-  }
-  Base *base = BKE_view_layer_base_find(view_layer, ob);
-
+  Base *base = find_view_layer_base_with_synced_ensure(ob, C, view_layer_ptr, 
NULL, NULL);
   if (!base) {
 return false;
   }
@@ -119,13 +137,11 @@ static bool rna_Object_select_get(Object *ob, bContext 
*C, ViewLayer *view_layer
 }
 
 static void rna_Object_hide_set(
-Object *ob, bContext *C, ReportList *reports, bool hide, ViewLayer 
*view_layer)
+Object *ob, bContext *C, ReportList *reports, bool hide, PointerRNA 
*view_layer_ptr)
 {
-  if (view_layer == NULL) {
-view_layer = CTX_data_view_layer(C);
-  }
-  Base *base = BKE_view_layer_base_find(view_layer, ob);
-
+  Scene *scene;
+  ViewLayer *view_layer;
+  Base *base = find_view_layer_base_with_synced_ensure(ob, C, view_layer_ptr, 
&scene, &view_layer);
   if (!base) {
 if (hide) {
   BKE_reportf(reports,
@@ -144,19 +160,14 @@ static void rna_Object_hide_set(
 base->flag &= ~BASE_HIDDEN;
   }
 
-  Scene *scene = CTX_data_scene(C);
   BKE_view_layer_need_resync_tag(view_layer);
   DEG_id_tag_update(&scene->id, ID_RECALC_BASE_FLAGS);
   WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
 }
 
-static bool rna_Object_hide_get(Object *ob, bContext *C, ViewLayer *view_layer)
+static bool rna_Object_hide_get(Object *ob, bContext *C, PointerRNA 
*view_layer_ptr)
 {
-  if (view_layer == NULL) {
-view_layer = CTX_data_view_layer(C);
-  }
-  Base *base = BKE_view_layer_base_find(view_layer, ob);
-
+  Base *base = find_view_layer_base_with_synced_ensure(ob, C, view_layer_ptr, 
NULL, NULL);
   if (!base) {
 return false;
   }
@@ -164,15 +175,15 @@ static bool rna_Object_hide_get(Object *ob, bContext *C, 
ViewLayer *view_layer)
   return ((base->flag & BASE_HIDDEN) != 0);
 }
 
-static bool rna_Object_visible_get(Object *ob, bContext 

[Bf-blender-cvs] [b950a8fb797] master: Painting: Don't calculate rake rotation when texture is not set.

2022-09-19 Thread Jeroen Bakker
Commit: b950a8fb797a6248f0a89e47b960ae9a3638ac89
Author: Jeroen Bakker
Date:   Tue Sep 20 08:28:35 2022 +0200
Branches: master
https://developer.blender.org/rBb950a8fb797a6248f0a89e47b960ae9a3638ac89

Painting: Don't calculate rake rotation when texture is not set.

Currently the rake rotation is calculated when the angle mode is set. Even when 
the texture isn't valid.
This change will only calculate the rake rotation when the texture is valid and 
the angle mode is set.

===

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

===

diff --git a/source/blender/blenkernel/intern/paint.cc 
b/source/blender/blenkernel/intern/paint.cc
index 5dc8e3e0112..0181c6e7eac 100644
--- a/source/blender/blenkernel/intern/paint.cc
+++ b/source/blender/blenkernel/intern/paint.cc
@@ -1315,13 +1315,22 @@ void 
paint_update_brush_rake_rotation(UnifiedPaintSettings *ups, Brush *brush, f
   }
 }
 
+static bool paint_rake_rotation_active(const MTex &mtex)
+{
+  return mtex.tex && mtex.brush_angle_mode & MTEX_ANGLE_RAKE;
+}
+
+static bool paint_rake_rotation_active(const Brush &brush)
+{
+  return paint_rake_rotation_active(brush.mtex) || 
paint_rake_rotation_active(brush.mask_mtex);
+}
+
 bool paint_calculate_rake_rotation(UnifiedPaintSettings *ups,
Brush *brush,
const float mouse_pos[2])
 {
   bool ok = false;
-  if ((brush->mtex.brush_angle_mode & MTEX_ANGLE_RAKE) ||
-  (brush->mask_mtex.brush_angle_mode & MTEX_ANGLE_RAKE)) {
+  if (paint_rake_rotation_active(*brush)) {
 const float r = RAKE_THRESHHOLD;
 float rotation;

___
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] [c279a0d931a] master: GHOST/Wayland: refactor modifier handling on window activation

2022-09-19 Thread Campbell Barton
Commit: c279a0d931afab9dab9b7f5516d24fbe304d2103
Author: Campbell Barton
Date:   Tue Sep 20 15:56:09 2022 +1000
Branches: master
https://developer.blender.org/rBc279a0d931afab9dab9b7f5516d24fbe304d2103

GHOST/Wayland: refactor modifier handling on window activation

GHOST_SystemWayland::getModifierKeys() now returns the correct
modifier keys held instead of guessing that both left/right modifiers
were held.

===

M   intern/ghost/GHOST_Types.h
M   intern/ghost/intern/GHOST_SystemWayland.cpp
M   intern/ghost/intern/GHOST_SystemWin32.cpp

===

diff --git a/intern/ghost/GHOST_Types.h b/intern/ghost/GHOST_Types.h
index b3799c53a8d..80a71bb7dfe 100644
--- a/intern/ghost/GHOST_Types.h
+++ b/intern/ghost/GHOST_Types.h
@@ -321,7 +321,8 @@ typedef enum {
   GHOST_kKeyBackslash = 0x5C,
   GHOST_kKeyAccentGrave = '`',
 
-  /* Modifiers: See #GHOST_KEY_IS_MODIFIER. */
+#define _GHOST_KEY_MODIFIER_MIN GHOST_kKeyLeftShift
+  /* Modifiers: See #GHOST_KEY_MODIFIER_CHECK. */
   GHOST_kKeyLeftShift = 0x100,
   GHOST_kKeyRightShift,
   GHOST_kKeyLeftControl,
@@ -330,7 +331,7 @@ typedef enum {
   GHOST_kKeyRightAlt,
   GHOST_kKeyLeftOS, /* Command key on Apple, Windows key(s) on Windows. */
   GHOST_kKeyRightOS,
-  /* End modifiers. */
+#define _GHOST_KEY_MODIFIER_MAX GHOST_kKeyRightOS
 
   GHOST_kKeyGrLess, /* German PC only! */
   GHOST_kKeyApp,/* Also known as menu key. */
@@ -405,7 +406,11 @@ typedef enum {
   GHOST_kKeyMediaLast
 } GHOST_TKey;
 
-#define GHOST_KEY_IS_MODIFIER(key) (key >= GHOST_kKeyLeftShift && key <= 
GHOST_kKeyRightOS);
+#define GHOST_KEY_MODIFIER_NUM ((_GHOST_KEY_MODIFIER_MAX - 
_GHOST_KEY_MODIFIER_MIN) + 1)
+#define GHOST_KEY_MODIFIER_TO_INDEX(key) ((unsigned 
int)(key)-_GHOST_KEY_MODIFIER_MIN)
+#define GHOST_KEY_MODIFIER_FROM_INDEX(key) \
+  (GHOST_TKey)(((unsigned int)(key) + _GHOST_KEY_MODIFIER_MIN))
+#define GHOST_KEY_MODIFIER_CHECK(key) (GHOST_KEY_MODIFIER_TO_INDEX(key) < 
GHOST_KEY_MODIFIER_NUM)
 
 typedef enum {
   /** Grab not set. */
diff --git a/intern/ghost/intern/GHOST_SystemWayland.cpp 
b/intern/ghost/intern/GHOST_SystemWayland.cpp
index 4da1ace37b2..d01193f5784 100644
--- a/intern/ghost/intern/GHOST_SystemWayland.cpp
+++ b/intern/ghost/intern/GHOST_SystemWayland.cpp
@@ -263,6 +263,15 @@ struct GWL_SeatStateKeyboard {
   struct wl_surface *wl_surface = nullptr;
 };
 
+/**
+ * Store held keys (only modifiers), could store other keys in the future.
+ *
+ * Needed as #GWL_Seat.xkb_state doesn't store which modifier keys are held.
+ */
+struct WGL_KeyboardDepressedState {
+  int16_t mods[GHOST_KEY_MODIFIER_NUM] = {0};
+};
+
 struct GWL_Seat {
   GHOST_SystemWayland *system = nullptr;
 
@@ -310,6 +319,9 @@ struct GWL_Seat {
*/
   struct xkb_state *xkb_state_empty_with_numlock = nullptr;
 
+  /** Keys held matching `xkb_state`. */
+  struct WGL_KeyboardDepressedState key_depressed;
+
   /**
* Cache result of `xkb_keymap_mod_get_index`
* so every time a modifier is accessed a string lookup isn't required.
@@ -857,6 +869,78 @@ static wl_buffer *ghost_wl_buffer_create_for_image(struct 
wl_shm *shm,
 
 /** \} */
 
+/*  */
+/** \name Private Keyboard Depressed Key Tracking
+ *
+ * Don't track physical key-codes because there may be multiple keyboards 
connected.
+ * Instead, count the number of #GHOST_kKey are pressed.
+ * This may seem susceptible to bugs with sticky-keys however XKB works this 
way internally.
+ * \{ */
+
+static CLG_LogRef LOG_WL_KEYBOARD_DEPRESSED_STATE = 
{"ghost.wl.keyboard.depressed"};
+#define LOG (&LOG_WL_KEYBOARD_DEPRESSED_STATE)
+
+static void keyboard_depressed_state_reset(GWL_Seat *seat)
+{
+  for (int i = 0; i < GHOST_KEY_MODIFIER_NUM; i++) {
+seat->key_depressed.mods[i] = 0;
+  }
+}
+
+static void keyboard_depressed_state_key_event(GWL_Seat *seat,
+   const GHOST_TKey gkey,
+   const GHOST_TEventType etype)
+{
+  if (GHOST_KEY_MODIFIER_CHECK(gkey)) {
+const int index = GHOST_KEY_MODIFIER_TO_INDEX(gkey);
+int16_t &value = seat->key_depressed.mods[index];
+if (etype == GHOST_kEventKeyUp) {
+  value -= 1;
+  if (UNLIKELY(value < 0)) {
+CLOG_WARN(LOG, "modifier (%d) has negative keys held (%d)!", index, 
value);
+value = 0;
+  }
+}
+else {
+  value += 1;
+}
+  }
+}
+
+static void keyboard_depressed_state_push_events_from_change(
+GWL_Seat *seat, const WGL_KeyboardDepressedState &key_depressed_prev)
+{
+  GHOST_IWindow *win = ghost_wl_surface_user_data(seat->keyboard.wl_surface);
+  GHOST_SystemWayland *system = seat->system;
+
+  /* Separate key up and down into separate passes so key down events always 
come after key up.
+   * Do this so users of GHOST can use the last pressed or released modifier 
t

[Bf-blender-cvs] [09308c4b6a2] master: CMake: fail to build with unsupported versions of wayland-scanner

2022-09-19 Thread Campbell Barton
Commit: 09308c4b6a2b5fa7d5d74e55f484bfd1ca18c273
Author: Campbell Barton
Date:   Tue Sep 20 12:53:06 2022 +1000
Branches: master
https://developer.blender.org/rB09308c4b6a2b5fa7d5d74e55f484bfd1ca18c273

CMake: fail to build with unsupported versions of wayland-scanner

When WITH_GHOST_WAYLAND_DYNLOAD is enabled.

===

M   build_files/cmake/platform/platform_unix.cmake

===

diff --git a/build_files/cmake/platform/platform_unix.cmake 
b/build_files/cmake/platform/platform_unix.cmake
index aceddf7295b..d9f06811984 100644
--- a/build_files/cmake/platform/platform_unix.cmake
+++ b/build_files/cmake/platform/platform_unix.cmake
@@ -770,6 +770,39 @@ if(WITH_GHOST_WAYLAND)
 endif()
 
 pkg_get_variable(WAYLAND_SCANNER wayland-scanner wayland_scanner)
+
+# When using dynamic loading, headers generated
+# from older versions of `wayland-scanner` aren't compatible.
+if(WITH_GHOST_WAYLAND_DYNLOAD)
+  execute_process(
+COMMAND ${WAYLAND_SCANNER} --version
+# The version is written to the `stderr`.
+ERROR_VARIABLE _wayland_scanner_out
+ERROR_STRIP_TRAILING_WHITESPACE
+  )
+  if(NOT "${_wayland_scanner_out}" STREQUAL "")
+string(
+  REGEX REPLACE
+  "^wayland-scanner[ \t]+([0-9]+)\.([0-9]+).*"
+  "\\1.\\2"
+  _wayland_scanner_ver
+  "${_wayland_scanner_out}"
+)
+if("${_wayland_scanner_ver}" VERSION_LESS "1.20")
+  message(
+FATAL_ERROR
+"Found ${WAYLAND_SCANNER} version \"${_wayland_scanner_ver}\", "
+"the minimum version is 1.20!"
+  )
+endif()
+unset(_wayland_scanner_ver)
+  else()
+message(WARNING "Unable to access the version from ${WAYLAND_SCANNER}, 
continuing.")
+  endif()
+  unset(_wayland_scanner_out)
+endif()
+# End wayland-scanner version check.
+
   endif()
 endif()

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


[Bf-blender-cvs] [9c35f103c0d] master: Cleanup: quiet warning

2022-09-19 Thread Campbell Barton
Commit: 9c35f103c0d7eaa1ddd0b0c54be9c681a7c39dc3
Author: Campbell Barton
Date:   Tue Sep 20 12:53:05 2022 +1000
Branches: master
https://developer.blender.org/rB9c35f103c0d7eaa1ddd0b0c54be9c681a7c39dc3

Cleanup: quiet warning

===

M   source/blender/draw/engines/overlay/overlay_engine.cc

===

diff --git a/source/blender/draw/engines/overlay/overlay_engine.cc 
b/source/blender/draw/engines/overlay/overlay_engine.cc
index 9ee7cc4a10c..bb9f2e3a8ce 100644
--- a/source/blender/draw/engines/overlay/overlay_engine.cc
+++ b/source/blender/draw/engines/overlay/overlay_engine.cc
@@ -50,7 +50,7 @@ static void OVERLAY_engine_init(void *vedata)
   }
 
   OVERLAY_PrivateData *pd = stl->pd;
-  pd->space_type = v3d != nullptr ? SPACE_VIEW3D : 
draw_ctx->space_data->spacetype;
+  pd->space_type = v3d != nullptr ? (int)SPACE_VIEW3D : 
draw_ctx->space_data->spacetype;
 
   if (pd->space_type == SPACE_IMAGE) {
 const SpaceImage *sima = (SpaceImage *)draw_ctx->space_data;

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


[Bf-blender-cvs] [710b8b79295] master: GNUmakefile: fix error showing final message with the 'dash' shell

2022-09-19 Thread Campbell Barton
Commit: 710b8b79295896024e401178440a75b41bce32f6
Author: Campbell Barton
Date:   Tue Sep 20 12:53:03 2022 +1000
Branches: master
https://developer.blender.org/rB710b8b79295896024e401178440a75b41bce32f6

GNUmakefile: fix error showing final message with the 'dash' shell

The bpy module check wasn't working with dash,
use posix compliant check for empty string.

===

M   GNUmakefile

===

diff --git a/GNUmakefile b/GNUmakefile
index 884d2232d71..439b435f5f4 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -364,7 +364,7 @@ all: .FORCE
$(BUILD_COMMAND) -C "$(BUILD_DIR)" -j $(NPROCS) install
@echo
@echo Edit build configuration with: \"$(BUILD_DIR)/CMakeCache.txt\" 
run make again to rebuild.
-   @if test "$(BLENDER_IS_PYTHON_MODULE)" == ""; then \
+   @if test -z "$(BLENDER_IS_PYTHON_MODULE)"; then \
echo Blender successfully built, run from: $(BLENDER_BIN); \
else \
echo Blender successfully built as a Python module, \"bpy\" can 
be imported from: $(BLENDER_BIN_DIR); \

___
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] [3d5e0c8b9dc] master: Cleanup: Move mesh_mapping.c to C++

2022-09-19 Thread Hans Goudey
Commit: 3d5e0c8b9dc18892bbad3542246212682a63d61c
Author: Hans Goudey
Date:   Mon Sep 19 18:44:51 2022 -0500
Branches: master
https://developer.blender.org/rB3d5e0c8b9dc18892bbad3542246212682a63d61c

Cleanup: Move mesh_mapping.c to C++

===

M   source/blender/blenkernel/CMakeLists.txt
R089source/blender/blenkernel/intern/mesh_mapping.c 
source/blender/blenkernel/intern/mesh_mapping.cc

===

diff --git a/source/blender/blenkernel/CMakeLists.txt 
b/source/blender/blenkernel/CMakeLists.txt
index 2e4b2508646..039ece8eadf 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -201,7 +201,7 @@ set(SRC
   intern/mesh_fair.cc
   intern/mesh_iterators.c
   intern/mesh_legacy_convert.cc
-  intern/mesh_mapping.c
+  intern/mesh_mapping.cc
   intern/mesh_merge.c
   intern/mesh_merge_customdata.cc
   intern/mesh_mirror.c
diff --git a/source/blender/blenkernel/intern/mesh_mapping.c 
b/source/blender/blenkernel/intern/mesh_mapping.cc
similarity index 89%
rename from source/blender/blenkernel/intern/mesh_mapping.c
rename to source/blender/blenkernel/intern/mesh_mapping.cc
index f57effd49f4..db091361223 100644
--- a/source/blender/blenkernel/intern/mesh_mapping.c
+++ b/source/blender/blenkernel/intern/mesh_mapping.cc
@@ -12,6 +12,7 @@
 #include "DNA_meshdata_types.h"
 #include "DNA_vec_types.h"
 
+#include "BLI_array.hh"
 #include "BLI_bitmap.h"
 #include "BLI_buffer.h"
 #include "BLI_math.h"
@@ -65,7 +66,7 @@ UvVertMap *BKE_mesh_uv_vert_map_create(const MPoly *mpoly,
   buf = vmap->buf = (UvMapVert *)MEM_callocN(sizeof(*vmap->buf) * 
(size_t)totuv, "UvMapVert");
   vmap->vert = (UvMapVert **)MEM_callocN(sizeof(*vmap->vert) * totvert, 
"UvMapVert*");
   if (use_winding) {
-winding = MEM_callocN(sizeof(*winding) * totpoly, "winding");
+winding = static_cast(MEM_callocN(sizeof(*winding) * totpoly, 
"winding"));
   }
 
   if (!vmap->vert || !vmap->buf) {
@@ -194,11 +195,12 @@ static void mesh_vert_poly_or_loop_map_create(MeshElemMap 
**r_map,
   int totloop,
   const bool do_loops)
 {
-  MeshElemMap *map = MEM_callocN(sizeof(MeshElemMap) * (size_t)totvert, 
__func__);
+  MeshElemMap *map = MEM_cnew_array((size_t)totvert, __func__);
   int *indices, *index_iter;
   int i, j;
 
-  indices = index_iter = MEM_mallocN(sizeof(int) * (size_t)totloop, __func__);
+  indices = static_cast(MEM_mallocN(sizeof(int) * (size_t)totloop, 
__func__));
+  index_iter = indices;
 
   /* Count number of polys for each vertex */
   for (i = 0; i < totpoly; i++) {
@@ -265,8 +267,8 @@ void BKE_mesh_vert_looptri_map_create(MeshElemMap **r_map,
   const MLoop *mloop,
   const int UNUSED(totloop))
 {
-  MeshElemMap *map = MEM_callocN(sizeof(MeshElemMap) * (size_t)totvert, 
__func__);
-  int *indices = MEM_mallocN(sizeof(int) * (size_t)totlooptri * 3, __func__);
+  MeshElemMap *map = MEM_cnew_array((size_t)totvert, __func__);
+  int *indices = static_cast(MEM_mallocN(sizeof(int) * 
(size_t)totlooptri * 3, __func__));
   int *index_step;
   const MLoopTri *mlt;
   int i;
@@ -303,8 +305,8 @@ void BKE_mesh_vert_looptri_map_create(MeshElemMap **r_map,
 void BKE_mesh_vert_edge_map_create(
 MeshElemMap **r_map, int **r_mem, const MEdge *medge, int totvert, int 
totedge)
 {
-  MeshElemMap *map = MEM_callocN(sizeof(MeshElemMap) * (size_t)totvert, 
"vert-edge map");
-  int *indices = MEM_mallocN(sizeof(int[2]) * (size_t)totedge, "vert-edge map 
mem");
+  MeshElemMap *map = MEM_cnew_array((size_t)totvert, __func__);
+  int *indices = static_cast(MEM_mallocN(sizeof(int[2]) * 
(size_t)totedge, __func__));
   int *i_pt = indices;
 
   int i;
@@ -342,8 +344,8 @@ void BKE_mesh_vert_edge_map_create(
 void BKE_mesh_vert_edge_vert_map_create(
 MeshElemMap **r_map, int **r_mem, const MEdge *medge, int totvert, int 
totedge)
 {
-  MeshElemMap *map = MEM_callocN(sizeof(MeshElemMap) * (size_t)totvert, 
"vert-edge map");
-  int *indices = MEM_mallocN(sizeof(int[2]) * (size_t)totedge, "vert-edge map 
mem");
+  MeshElemMap *map = MEM_cnew_array((size_t)totvert, __func__);
+  int *indices = static_cast(MEM_mallocN(sizeof(int[2]) * 
(size_t)totedge, __func__));
   int *i_pt = indices;
 
   int i;
@@ -387,8 +389,8 @@ void BKE_mesh_edge_loop_map_create(MeshElemMap **r_map,
const MLoop *mloop,
const int totloop)
 {
-  MeshElemMap *map = MEM_callocN(sizeof(MeshElemMap) * (size_t)totedge, 
"edge-poly map");
-  int *indices = MEM_mallocN(sizeof(int) * (size_t)totloop * 2, "edge-poly map 
mem");
+  MeshElemMap *map = MEM_cnew_array((size_t)totedge, __func__);
+  int *indices = static_cast(MEM_mallocN(sizeof(int) * (size_t)totloop 
* 2, __func__));
   int *index_st

[Bf-blender-cvs] [cc927b359c5] soc-2022-many-lights-sampling: Fix an illegal address and assert issue with Many Lights Sampling

2022-09-19 Thread Brecht Van Lommel
Commit: cc927b359c5925a9d0cc566cd5689b8063ba849a
Author: Brecht Van Lommel
Date:   Tue Sep 20 00:08:54 2022 +0200
Branches: soc-2022-many-lights-sampling
https://developer.blender.org/rBcc927b359c5925a9d0cc566cd5689b8063ba849a

Fix an illegal address and assert issue with Many Lights Sampling

If the emitter_index in light_tree_emitter_reservoir_weight() is less than 0,
then this lead to an error when using the kernel_data_fetch function.

This patch fixes this by returning a weight of 0 and ending the function before
we reach kernel_data_fetch in this situation.  Returning a weight of 0 is safe
here as an emitter_index less than 0 indicates that no lights were picked. So
they will have a weight of 0.

Contributed by Alaska

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

===

M   intern/cycles/kernel/light/light_tree.h

===

diff --git a/intern/cycles/kernel/light/light_tree.h 
b/intern/cycles/kernel/light/light_tree.h
index f5eb4347492..1d1ea67a467 100644
--- a/intern/cycles/kernel/light/light_tree.h
+++ b/intern/cycles/kernel/light/light_tree.h
@@ -83,6 +83,10 @@ ccl_device float 
light_tree_emitter_reservoir_weight(KernelGlobals kg,
  const float3 N,
  int emitter_index)
 {
+  if (emitter_index < 0) {
+return 0.0f;
+  }
+
   ccl_global const KernelLightTreeEmitter *kemitter = 
&kernel_data_fetch(light_tree_emitters,
  
emitter_index);
   const int prim = kemitter->prim_id;
@@ -235,7 +239,6 @@ ccl_device int 
light_tree_cluster_select_emitter(KernelGlobals kg,
 total_emitter_importance += light_tree_emitter_importance(kg, P, N, 
prim_index);
   }
 
-  /* to-do: need to handle a case when total importance is 0. */
   if (total_emitter_importance == 0.0f) {
 return -1;
   }

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


[Bf-blender-cvs] [a24fc6bbc1a] master: UV: extend custom grid sizes to set each axis separately

2022-09-19 Thread Chris Blackbourn
Commit: a24fc6bbc1ae3c0ee5a26c5b964af219215de692
Author: Chris Blackbourn
Date:   Sun Sep 18 17:03:40 2022 +1200
Branches: master
https://developer.blender.org/rBa24fc6bbc1ae3c0ee5a26c5b964af219215de692

UV: extend custom grid sizes to set each axis separately

For example, allows a custom UV grid size of 4 x 12.

TODO: Fix snapping with custom UV grid sizes.

Manifest Tasks: T78391

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

===

M   release/scripts/startup/bl_ui/space_image.py
M   source/blender/blenloader/intern/versioning_300.cc
M   source/blender/draw/engines/overlay/overlay_grid.cc
M   source/blender/draw/engines/overlay/shaders/overlay_grid_frag.glsl
M   source/blender/editors/include/ED_image.h
M   source/blender/editors/space_image/image_draw.c
M   source/blender/editors/space_image/space_image.c
M   source/blender/editors/transform/transform.c
M   source/blender/makesdna/DNA_space_types.h
M   source/blender/makesrna/intern/rna_space.c

===

diff --git a/release/scripts/startup/bl_ui/space_image.py 
b/release/scripts/startup/bl_ui/space_image.py
index da752b5fe00..b624d024843 100644
--- a/release/scripts/startup/bl_ui/space_image.py
+++ b/release/scripts/startup/bl_ui/space_image.py
@@ -1537,9 +1537,12 @@ class IMAGE_PT_overlay_guides(Panel):
 row = col.row(align=True)
 sub = row.row(align=True)
 sub.prop(uvedit, "use_custom_grid", text="")
-sub = sub.row(align=True)
-sub.active = uvedit.use_custom_grid
-sub.prop(uvedit, "custom_grid_subdivisions", text="")
+if uvedit.use_custom_grid:
+row = layout.row()
+row.use_property_split = True
+row.use_property_decorate = False
+sub = sub.row(align=True)
+sub.prop(uvedit, "custom_grid_subdivisions", text="")
 
 row = layout.row()
 row.use_property_split = True
diff --git a/source/blender/blenloader/intern/versioning_300.cc 
b/source/blender/blenloader/intern/versioning_300.cc
index e789cd66632..8f1f2fa2c17 100644
--- a/source/blender/blenloader/intern/versioning_300.cc
+++ b/source/blender/blenloader/intern/versioning_300.cc
@@ -2401,11 +2401,6 @@ void blo_do_versions_300(FileData *fd, Library 
*UNUSED(lib), Main *bmain)
   }
   break;
 }
-case SPACE_IMAGE: {
-  SpaceImage *sima = (SpaceImage *)sl;
-  sima->custom_grid_subdiv = 10;
-  break;
-}
   }
 }
   }
@@ -3426,5 +3421,21 @@ void blo_do_versions_300(FileData *fd, Library 
*UNUSED(lib), Main *bmain)
 }
   }
 }
+
+/* Custom grids in UV Editor have separate X and Y divisions. */
+LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) {
+  LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
+LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
+  switch (sl->spacetype) {
+case SPACE_IMAGE: {
+  SpaceImage *sima = (SpaceImage *)sl;
+  sima->custom_grid_subdiv[0] = 10;
+  sima->custom_grid_subdiv[1] = 10;
+  break;
+}
+  }
+}
+  }
+}
   }
 }
diff --git a/source/blender/draw/engines/overlay/overlay_grid.cc 
b/source/blender/draw/engines/overlay/overlay_grid.cc
index 71abcf91223..4a4d9ee6c19 100644
--- a/source/blender/draw/engines/overlay/overlay_grid.cc
+++ b/source/blender/draw/engines/overlay/overlay_grid.cc
@@ -31,6 +31,7 @@ void OVERLAY_grid_init(OVERLAY_Data *vedata)
   float *zplane_axes = pd->grid.zplane_axes;
   float grid_steps[SI_GRID_STEPS_LEN] = {
   0.001f, 0.01f, 0.1f, 1.0f, 10.0f, 100.0f, 1000.0f, 1.0f};
+  float grid_steps_y[SI_GRID_STEPS_LEN] = {0.0f}; /* When zero, use value from 
grid_steps. */
   OVERLAY_GridBits grid_flag = OVERLAY_GridBits(0), zneg_flag = 
OVERLAY_GridBits(0),
zpos_flag = OVERLAY_GridBits(0);
   grid->line_size = max_ff(0.0f, U.pixelsize - 1.0f) * 0.5f;
@@ -68,7 +69,7 @@ void OVERLAY_grid_init(OVERLAY_Data *vedata)
 }
 
 grid->zoom_factor = ED_space_image_zoom_level(v2d, SI_GRID_STEPS_LEN);
-ED_space_image_grid_steps(sima, grid_steps, SI_GRID_STEPS_LEN);
+ED_space_image_grid_steps(sima, grid_steps, grid_steps_y, 
SI_GRID_STEPS_LEN);
   }
   else {
 /* SPACE_VIEW3D */
@@ -197,6 +198,7 @@ void OVERLAY_grid_init(OVERLAY_Data *vedata)
   /* Convert to UBO alignment. */
   for (int i = 0; i < SI_GRID_STEPS_LEN; i++) {
 grid->steps[i][0] = grid_steps[i];
+grid->steps[i][1] = (grid_steps_y[i] != 0.0f) ? grid_steps_y[i] : 
grid_steps[i];
   }
   pd->grid.grid_flag = grid_flag;
   pd->grid.zneg_flag = zneg_flag;
diff --git a/source/blender/draw/engines/overlay/shaders/overlay_grid_frag.glsl 
b/source

[Bf-blender-cvs] [7a67d69ca4f] master: Cleanup: spelling

2022-09-19 Thread Chris Blackbourn
Commit: 7a67d69ca4fe807ea36c57166b89a6e42c25b909
Author: Chris Blackbourn
Date:   Tue Sep 20 09:20:55 2022 +1200
Branches: master
https://developer.blender.org/rB7a67d69ca4fe807ea36c57166b89a6e42c25b909

Cleanup: spelling

===

M   source/blender/editors/include/ED_image.h
M   source/blender/editors/space_image/image_draw.c

===

diff --git a/source/blender/editors/include/ED_image.h 
b/source/blender/editors/include/ED_image.h
index 91ae8286531..ef75277b1ea 100644
--- a/source/blender/editors/include/ED_image.h
+++ b/source/blender/editors/include/ED_image.h
@@ -39,7 +39,7 @@ void ED_space_image_grid_steps(struct SpaceImage *sima,
  * The code in here (except the offset part) is used in `grid_frag.glsl` (see 
`grid_res`) for
  * drawing the grid overlay for the UV/Image editor.
  */
-float ED_space_image_increment_snap_value(int grid_dimesnions,
+float ED_space_image_increment_snap_value(int grid_dimensions,
   const float 
grid_steps[SI_GRID_STEPS_LEN],
   float zoom_factor);
 
diff --git a/source/blender/editors/space_image/image_draw.c 
b/source/blender/editors/space_image/image_draw.c
index b55bac0bc2f..37a6e6dfcb1 100644
--- a/source/blender/editors/space_image/image_draw.c
+++ b/source/blender/editors/space_image/image_draw.c
@@ -601,18 +601,18 @@ void ED_space_image_grid_steps(SpaceImage *sima,
   }
 }
 
-float ED_space_image_increment_snap_value(const int grid_dimesnions,
+float ED_space_image_increment_snap_value(const int grid_dimensions,
   const float 
grid_steps[SI_GRID_STEPS_LEN],
   const float zoom_factor)
 {
   /* Small offset on each grid_steps[] so that snapping value doesn't change 
until grid lines are
* significantly visible.
-   * `Offset = 3/4 * (grid_steps[i] - (grid_steps[i] / grid_dimesnsions))`
+   * `Offset = 3/4 * (grid_steps[i] - (grid_steps[i] / grid_dimensions))`
*
* Refer `grid_frag.glsl` to find out when grid lines actually start 
appearing */
 
   for (int step = 0; step < SI_GRID_STEPS_LEN; step++) {
-float offset = (3.0f / 4.0f) * (grid_steps[step] - (grid_steps[step] / 
grid_dimesnions));
+float offset = (3.0f / 4.0f) * (grid_steps[step] - (grid_steps[step] / 
grid_dimensions));
 
 if ((grid_steps[step] - offset) > zoom_factor) {
   return grid_steps[step];

___
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] [c0ea7275b45] refactor-mesh-position-generic: Merge branch 'refactor-mesh-selection-generic' into refactor-mesh-position-generic

2022-09-19 Thread Hans Goudey
Commit: c0ea7275b45f9bb0e76970e1f0ac348fd147778c
Author: Hans Goudey
Date:   Mon Sep 19 15:19:41 2022 -0500
Branches: refactor-mesh-position-generic
https://developer.blender.org/rBc0ea7275b45f9bb0e76970e1f0ac348fd147778c

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

===



===

diff --cc source/blender/blenkernel/intern/paint.cc
index 59eac492db4,5dc8e3e0112..97b1b91e604
--- a/source/blender/blenkernel/intern/paint.cc
+++ b/source/blender/blenkernel/intern/paint.cc
@@@ -65,10 -66,19 +66,20 @@@
  
  #include "bmesh.h"
  
 +using blender::float3;
 +using blender::MutableSpan;
 +using blender::Span;
 +
+ static void sculpt_attribute_update_refs(Object *ob);
+ static SculptAttribute *sculpt_attribute_ensure_ex(Object *ob,
+eAttrDomain domain,
+eCustomDataType proptype,
+const char *name,
+const 
SculptAttributeParams *params,
+PBVHType pbvhtype,
+bool flat_array_for_bmesh);
+ void sculptsession_bmesh_add_layers(Object *ob);
+ 
 -using blender::MutableSpan;
 -using blender::Span;
 -
  static void palette_init_data(ID *id)
  {
Palette *palette = (Palette *)id;
@@@ -2136,10 -2169,10 +2170,10 @@@ static PBVH *build_pbvh_from_regular_me
  {
Mesh *me = BKE_object_get_original_mesh(ob);
const int looptris_num = poly_to_tri_count(me->totpoly, me->totloop);
-   PBVH *pbvh = BKE_pbvh_new();
+   PBVH *pbvh = BKE_pbvh_new(PBVH_FACES);
BKE_pbvh_respect_hide_set(pbvh, respect_hide);
  
 -  MutableSpan verts = me->verts_for_write();
 +  MutableSpan positions = me->positions_for_write();
const Span polys = me->polys();
const Span loops = me->loops();

___
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] [b76b908c8c7] refactor-mesh-selection-generic: Merge branch 'master' into refactor-mesh-selection-generic

2022-09-19 Thread Hans Goudey
Commit: b76b908c8c76c0e909ff63c31e8a70261f6a05b4
Author: Hans Goudey
Date:   Mon Sep 19 15:13:39 2022 -0500
Branches: refactor-mesh-selection-generic
https://developer.blender.org/rBb76b908c8c76c0e909ff63c31e8a70261f6a05b4

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

===



===



___
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] [bdb57541475] master: Nodes: Add node group assets to search menus

2022-09-19 Thread Hans Goudey
Commit: bdb57541475f20ccc4f6e5f8fc075ac424becc19
Author: Hans Goudey
Date:   Mon Sep 19 11:57:10 2022 -0500
Branches: master
https://developer.blender.org/rBbdb57541475f20ccc4f6e5f8fc075ac424becc19

Nodes: Add node group assets to search menus

Currently node group assets are supported, but using them by dragging
from the asset browser is cumbersome. This patch adds all node group
assets from user asset libraries and the current file libraries to the
add node search menu and the link drag search menu.

Node groups added through the search will have their "options" hidden,
meaning the data-block selector is displayed. This helps keep the UI
clean, and the selector shouldn't be necessary anyway.

To make that possible, metadata like the node tree type and its inputs
and outputs has to be saved in the file. This requires re-saving the
files that contain the assets with the patch applied.

The node add search operator is moved from Python to C++ to ease
development and allow more flexibility. It supports a tooltip that
gives the description of assets.

Currently the node groups are added with the asset system's existing
"Append & Reuse" behavior. It's likely that linking should be possible
in the future too, but for now the idea is to use the more foolproof
option that doesn't create dependencies between files.

Because loading assets can potentially take a long time, the search
menu refreshes its items as new assets are loaded. However, changing
the search field is necessary to see the update.

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

===

M   release/scripts/startup/bl_operators/node.py
M   source/blender/blenkernel/intern/node.cc
M   source/blender/editors/asset/ED_asset_handle.h
M   source/blender/editors/asset/intern/asset_handle.cc
M   source/blender/editors/include/UI_interface.h
M   source/blender/editors/interface/interface.cc
M   source/blender/editors/interface/interface_intern.h
M   source/blender/editors/interface/interface_region_search.cc
M   source/blender/editors/space_node/CMakeLists.txt
A   source/blender/editors/space_node/add_node_search.cc
M   source/blender/editors/space_node/link_drag_search.cc
M   source/blender/editors/space_node/node_add.cc
M   source/blender/editors/space_node/node_intern.hh
M   source/blender/editors/space_node/node_ops.cc

===

diff --git a/release/scripts/startup/bl_operators/node.py 
b/release/scripts/startup/bl_operators/node.py
index ff9b5a06fb7..5cc9c850ebe 100644
--- a/release/scripts/startup/bl_operators/node.py
+++ b/release/scripts/startup/bl_operators/node.py
@@ -149,78 +149,6 @@ class NODE_OT_add_node(NodeAddOperator, Operator):
 bl_options = {'REGISTER', 'UNDO'}
 
 
-class NODE_OT_add_search(NodeAddOperator, Operator):
-'''Add a node to the active tree'''
-bl_idname = "node.add_search"
-bl_label = "Search and Add Node"
-bl_options = {'REGISTER', 'UNDO'}
-bl_property = "node_item"
-
-_enum_item_hack = []
-
-# Create an enum list from node items
-def node_enum_items(self, context):
-import nodeitems_utils
-
-enum_items = NODE_OT_add_search._enum_item_hack
-enum_items.clear()
-
-for index, item in enumerate(nodeitems_utils.node_items_iter(context)):
-if isinstance(item, nodeitems_utils.NodeItem):
-enum_items.append(
-(str(index),
- item.label,
- "",
- index,
- ))
-return enum_items
-
-# Look up the item based on index
-def find_node_item(self, context):
-import nodeitems_utils
-
-node_item = int(self.node_item)
-for index, item in enumerate(nodeitems_utils.node_items_iter(context)):
-if index == node_item:
-return item
-return None
-
-node_item: EnumProperty(
-name="Node Type",
-description="Node type",
-items=NODE_OT_add_search.node_enum_items,
-)
-
-def execute(self, context):
-item = self.find_node_item(context)
-
-# no need to keep
-self._enum_item_hack.clear()
-
-if item:
-# apply settings from the node item
-for setting in item.settings.items():
-ops = self.settings.add()
-ops.name = setting[0]
-ops.value = setting[1]
-
-self.create_node(context, item.nodetype)
-
-if self.use_transform:
-bpy.ops.node.translate_attach_remove_on_cancel(
-'INVOKE_DEFAULT')
-
-return {'FINISHED'}
-else:
-return {'CANCELLED'}
-
-def invoke(self, context, event):
-self.store_mouse_cursor(context, event)
-# Delayed execution in the search popup
-conte

[Bf-blender-cvs] [862de9187f1] master: Cleanup: Move versioning_300.c to C++

2022-09-19 Thread Hans Goudey
Commit: 862de9187f1b914358c33dd9700e338f0174bbf0
Author: Hans Goudey
Date:   Mon Sep 19 11:06:21 2022 -0500
Branches: master
https://developer.blender.org/rB862de9187f1b914358c33dd9700e338f0174bbf0

Cleanup: Move versioning_300.c to C++

===

M   source/blender/blenloader/CMakeLists.txt
R092source/blender/blenloader/intern/versioning_300.c   
source/blender/blenloader/intern/versioning_300.cc

===

diff --git a/source/blender/blenloader/CMakeLists.txt 
b/source/blender/blenloader/CMakeLists.txt
index bf99ca2cd9a..f0209d1337c 100644
--- a/source/blender/blenloader/CMakeLists.txt
+++ b/source/blender/blenloader/CMakeLists.txt
@@ -43,7 +43,7 @@ set(SRC
   intern/versioning_270.c
   intern/versioning_280.c
   intern/versioning_290.c
-  intern/versioning_300.c
+  intern/versioning_300.cc
   intern/versioning_400.cc
   intern/versioning_common.cc
   intern/versioning_cycles.c
diff --git a/source/blender/blenloader/intern/versioning_300.c 
b/source/blender/blenloader/intern/versioning_300.cc
similarity index 92%
rename from source/blender/blenloader/intern/versioning_300.c
rename to source/blender/blenloader/intern/versioning_300.cc
index 244f74cfe59..e789cd66632 100644
--- a/source/blender/blenloader/intern/versioning_300.c
+++ b/source/blender/blenloader/intern/versioning_300.cc
@@ -6,7 +6,7 @@
 /* allow readfile to use deprecated functionality */
 #define DNA_DEPRECATED_ALLOW
 
-#include 
+#include 
 
 #include "CLG_log.h"
 
@@ -86,39 +86,40 @@ static IDProperty *idproperty_find_ui_container(IDProperty 
*idprop_group)
   return prop;
 }
   }
-  return NULL;
+  return nullptr;
 }
 
 static void version_idproperty_move_data_int(IDPropertyUIDataInt *ui_data,
  const IDProperty *prop_ui_data)
 {
   IDProperty *min = IDP_GetPropertyFromGroup(prop_ui_data, "min");
-  if (min != NULL) {
+  if (min != nullptr) {
 ui_data->min = ui_data->soft_min = IDP_coerce_to_int_or_zero(min);
   }
   IDProperty *max = IDP_GetPropertyFromGroup(prop_ui_data, "max");
-  if (max != NULL) {
+  if (max != nullptr) {
 ui_data->max = ui_data->soft_max = IDP_coerce_to_int_or_zero(max);
   }
   IDProperty *soft_min = IDP_GetPropertyFromGroup(prop_ui_data, "soft_min");
-  if (soft_min != NULL) {
+  if (soft_min != nullptr) {
 ui_data->soft_min = IDP_coerce_to_int_or_zero(soft_min);
 ui_data->soft_min = MIN2(ui_data->soft_min, ui_data->min);
   }
   IDProperty *soft_max = IDP_GetPropertyFromGroup(prop_ui_data, "soft_max");
-  if (soft_max != NULL) {
+  if (soft_max != nullptr) {
 ui_data->soft_max = IDP_coerce_to_int_or_zero(soft_max);
 ui_data->soft_max = MAX2(ui_data->soft_max, ui_data->max);
   }
   IDProperty *step = IDP_GetPropertyFromGroup(prop_ui_data, "step");
-  if (step != NULL) {
+  if (step != nullptr) {
 ui_data->step = IDP_coerce_to_int_or_zero(soft_max);
   }
   IDProperty *default_value = IDP_GetPropertyFromGroup(prop_ui_data, 
"default");
-  if (default_value != NULL) {
+  if (default_value != nullptr) {
 if (default_value->type == IDP_ARRAY) {
   if (default_value->subtype == IDP_INT) {
-ui_data->default_array = MEM_malloc_arrayN(default_value->len, 
sizeof(int), __func__);
+ui_data->default_array = static_cast(
+MEM_malloc_arrayN(default_value->len, sizeof(int), __func__));
 memcpy(ui_data->default_array, IDP_Array(default_value), sizeof(int) * 
default_value->len);
 ui_data->default_array_len = default_value->len;
   }
@@ -133,45 +134,47 @@ static void 
version_idproperty_move_data_float(IDPropertyUIDataFloat *ui_data,
const IDProperty *prop_ui_data)
 {
   IDProperty *min = IDP_GetPropertyFromGroup(prop_ui_data, "min");
-  if (min != NULL) {
+  if (min != nullptr) {
 ui_data->min = ui_data->soft_min = IDP_coerce_to_double_or_zero(min);
   }
   IDProperty *max = IDP_GetPropertyFromGroup(prop_ui_data, "max");
-  if (max != NULL) {
+  if (max != nullptr) {
 ui_data->max = ui_data->soft_max = IDP_coerce_to_double_or_zero(max);
   }
   IDProperty *soft_min = IDP_GetPropertyFromGroup(prop_ui_data, "soft_min");
-  if (soft_min != NULL) {
+  if (soft_min != nullptr) {
 ui_data->soft_min = IDP_coerce_to_double_or_zero(soft_min);
 ui_data->soft_min = MAX2(ui_data->soft_min, ui_data->min);
   }
   IDProperty *soft_max = IDP_GetPropertyFromGroup(prop_ui_data, "soft_max");
-  if (soft_max != NULL) {
+  if (soft_max != nullptr) {
 ui_data->soft_max = IDP_coerce_to_double_or_zero(soft_max);
 ui_data->soft_max = MIN2(ui_data->soft_max, ui_data->max);
   }
   IDProperty *step = IDP_GetPropertyFromGroup(prop_ui_data, "step");
-  if (step != NULL) {
+  if (step != nullptr) {
 ui_data->step = IDP_coerce_to_float_or_zero(step);
   }
   IDProperty *precision = IDP_GetPropertyFromGroup(prop_ui_data, "

[Bf-blender-cvs] [b6e26a410cd] master: Geometry Nodes: Distribute Points in Volume

2022-09-19 Thread Iyad Ahmed
Commit: b6e26a410cd29f32da1e8112607a61f29c2863c4
Author: Iyad Ahmed
Date:   Mon Sep 19 10:13:55 2022 -0500
Branches: master
https://developer.blender.org/rBb6e26a410cd29f32da1e8112607a61f29c2863c4

Geometry Nodes: Distribute Points in Volume

This commit adds a node to distribute points inside of volume grids.
The "Random" mode usese OpenVDB's "point scatter" implementation, and
there is also a "Grid" mode for uniform distributions. Both methods
operate on all of the float grids in the volume, using every voxel with
a value higher than the threshold. The random method is not stable as
the input volume deforms.

Based on a patch by Angus Stanton (@abstanton), which was based on a
patch by Kenzie (@kenziemac130).

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

===

M   release/scripts/startup/nodeitems_builtins.py
M   source/blender/blenkernel/BKE_node.h
M   source/blender/blenkernel/intern/node.cc
M   source/blender/makesdna/DNA_node_types.h
M   source/blender/makesrna/intern/rna_nodetree.c
M   source/blender/nodes/NOD_geometry.h
M   source/blender/nodes/NOD_static_types.h
M   source/blender/nodes/geometry/CMakeLists.txt
A   
source/blender/nodes/geometry/nodes/node_geo_distribute_points_in_volume.cc

===

diff --git a/release/scripts/startup/nodeitems_builtins.py 
b/release/scripts/startup/nodeitems_builtins.py
index 89b729595db..9c0635d7bd4 100644
--- a/release/scripts/startup/nodeitems_builtins.py
+++ b/release/scripts/startup/nodeitems_builtins.py
@@ -241,6 +241,7 @@ def point_node_items(context):
 space = context.space_data
 if not space:
 return
+yield NodeItem("GeometryNodeDistributePointsInVolume")
 yield NodeItem("GeometryNodeDistributePointsOnFaces")
 yield NodeItem("GeometryNodePoints")
 yield NodeItem("GeometryNodePointsToVertices")
diff --git a/source/blender/blenkernel/BKE_node.h 
b/source/blender/blenkernel/BKE_node.h
index 7d019dcc7cb..35d3fbf0b73 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -1526,6 +1526,7 @@ struct TexResult;
 #define GEO_NODE_EDGE_PATHS_TO_CURVES 1169
 #define GEO_NODE_EDGE_PATHS_TO_SELECTION 1170
 #define GEO_NODE_MESH_FACE_SET_BOUNDARIES 1171
+#define GEO_NODE_DISTRIBUTE_POINTS_IN_VOLUME 1172
 
 /** \} */
 
diff --git a/source/blender/blenkernel/intern/node.cc 
b/source/blender/blenkernel/intern/node.cc
index 1af04d3034c..04f5b131743 100644
--- a/source/blender/blenkernel/intern/node.cc
+++ b/source/blender/blenkernel/intern/node.cc
@@ -4702,6 +4702,7 @@ static void registerGeometryNodes()
   register_node_type_geo_curve_trim();
   register_node_type_geo_deform_curves_on_surface();
   register_node_type_geo_delete_geometry();
+  register_node_type_geo_distribute_points_in_volume();
   register_node_type_geo_distribute_points_on_faces();
   register_node_type_geo_dual_mesh();
   register_node_type_geo_duplicate_elements();
diff --git a/source/blender/makesdna/DNA_node_types.h 
b/source/blender/makesdna/DNA_node_types.h
index a416e184d2b..7832541e360 100644
--- a/source/blender/makesdna/DNA_node_types.h
+++ b/source/blender/makesdna/DNA_node_types.h
@@ -1595,6 +1595,11 @@ typedef struct NodeGeometryUVUnwrap {
   uint8_t method;
 } NodeGeometryUVUnwrap;
 
+typedef struct NodeGeometryDistributePointsInVolume {
+  /* GeometryNodePointDistributeVolumeMode. */
+  uint8_t mode;
+} NodeGeometryDistributePointsInVolume;
+
 typedef struct NodeFunctionCompare {
   /* NodeCompareOperation */
   int8_t operation;
@@ -2176,6 +2181,11 @@ typedef enum GeometryNodeTriangulateQuads {
   GEO_NODE_TRIANGULATE_QUAD_LONGEDGE = 4,
 } GeometryNodeTriangulateQuads;
 
+typedef enum GeometryNodeDistributePointsInVolumeMode {
+  GEO_NODE_DISTRIBUTE_POINTS_IN_VOLUME_DENSITY_RANDOM = 0,
+  GEO_NODE_DISTRIBUTE_POINTS_IN_VOLUME_DENSITY_GRID = 1,
+} GeometryNodeDistributePointsInVolumeMode;
+
 typedef enum GeometryNodeDistributePointsOnFacesMode {
   GEO_NODE_POINT_DISTRIBUTE_POINTS_ON_FACES_RANDOM = 0,
   GEO_NODE_POINT_DISTRIBUTE_POINTS_ON_FACES_POISSON = 1,
diff --git a/source/blender/makesrna/intern/rna_nodetree.c 
b/source/blender/makesrna/intern/rna_nodetree.c
index daae1d6f3e4..971043158e1 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -9614,6 +9614,31 @@ static void def_geo_extrude_mesh(StructRNA *srna)
   RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
 }
 
+static void def_geo_distribute_points_in_volume(StructRNA *srna)
+{
+  PropertyRNA *prop;
+
+  static const EnumPropertyItem mode_items[] = {
+  {GEO_NODE_DISTRIBUTE_POINTS_IN_VOLUME_DENSITY_RANDOM,
+   "DENSITY_RANDOM",
+   0,
+   "Random",
+   "Distribute points randomly inside of the volume"},
+  {GEO_NODE_DISTRIBUTE_POINTS_IN_VOLUME_DENSITY_GRID,
+   "DENSITY_GRID"

[Bf-blender-cvs] [0e6a8df6df2] master: GPencil: Make format

2022-09-19 Thread Antonio Vazquez
Commit: 0e6a8df6df28fc785ad25aef91a4599865d156f0
Author: Antonio Vazquez
Date:   Mon Sep 19 16:31:00 2022 +0200
Branches: master
https://developer.blender.org/rB0e6a8df6df28fc785ad25aef91a4599865d156f0

GPencil: Make format

Missing in previous commit

===

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

===

diff --git a/source/blender/editors/gpencil/gpencil_fill.c 
b/source/blender/editors/gpencil/gpencil_fill.c
index fa7863df725..34f983151d2 100644
--- a/source/blender/editors/gpencil/gpencil_fill.c
+++ b/source/blender/editors/gpencil/gpencil_fill.c
@@ -661,8 +661,7 @@ static void gpencil_draw_basic_stroke(tGPDfill *tgpf,
 col[3] = (gps->flag & GP_STROKE_TAG) ? 0.0f : 0.5f;
   }
   else if ((is_extend) && (!tgpf->is_render)) {
-if ((gps->flag & GP_STROKE_COLLIDE) || (tgpf->fill_extend_mode == 
GP_FILL_EMODE_RADIUS))
-  {
+if ((gps->flag & GP_STROKE_COLLIDE) || (tgpf->fill_extend_mode == 
GP_FILL_EMODE_RADIUS)) {
   copy_v4_v4(col, extend_col);
 }
 else {

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


[Bf-blender-cvs] [5c13c7cd30d] master: GPencil: Cut Extended lines in Fill tool when collide

2022-09-19 Thread Antonio Vazquez
Commit: 5c13c7cd30d14ef5199f080fb8194f8c3e9da393
Author: Antonio Vazquez
Date:   Mon Sep 19 16:03:53 2022 +0200
Branches: master
https://developer.blender.org/rB5c13c7cd30d14ef5199f080fb8194f8c3e9da393

GPencil: Cut Extended lines in Fill tool when collide

Before, the lines could be extended endless, but this added too noise. 
Now, the lines are not extended more if collide.

Before:

{F13504186}

After:

{F13504187}

Reviewed By: mendio, frogstomp

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

===

M   source/blender/editors/gpencil/gpencil_fill.c
M   source/blender/makesdna/DNA_gpencil_types.h

===

diff --git a/source/blender/editors/gpencil/gpencil_fill.c 
b/source/blender/editors/gpencil/gpencil_fill.c
index 6eb49cd933a..fa7863df725 100644
--- a/source/blender/editors/gpencil/gpencil_fill.c
+++ b/source/blender/editors/gpencil/gpencil_fill.c
@@ -283,6 +283,99 @@ static void extrapolate_points_by_length(bGPDspoint *a,
   add_v3_v3v3(r_point, &b->x, ab);
 }
 
+/* Cut the extended lines if collide. */
+static void gpencil_cut_extensions(tGPDfill *tgpf, const int gpl_active_index)
+{
+  bGPdata *gpd = tgpf->gpd;
+  Brush *brush = tgpf->brush;
+  BrushGpencilSettings *brush_settings = brush->gpencil_settings;
+
+  LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
+if (gpl->flag & GP_LAYER_HIDE) {
+  continue;
+}
+
+/* Decide if the strokes of layers are included or not depending on the 
layer mode. */
+const int gpl_index = BLI_findindex(&gpd->layers, gpl);
+bool skip = skip_layer_check(brush_settings->fill_layer_mode, 
gpl_active_index, gpl_index);
+if (skip) {
+  continue;
+}
+
+bGPDframe *gpf = BKE_gpencil_layer_frame_get(gpl, tgpf->active_cfra, 
GP_GETFRAME_USE_PREV);
+if (gpf == NULL) {
+  continue;
+}
+int size = BLI_listbase_count(&gpf->strokes);
+if (size == 0) {
+  continue;
+}
+
+float diff_mat[4][4];
+BKE_gpencil_layer_transform_matrix_get(tgpf->depsgraph, tgpf->ob, gpl, 
diff_mat);
+/* Save all extend strokes in array.*/
+int tot_idx = 0;
+bGPDstroke **gps_array = MEM_callocN(sizeof(bGPDstroke *) * size, 
__func__);
+
+LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
+  if ((gps->flag & (GP_STROKE_NOFILL | GP_STROKE_TAG)) == 0) {
+continue;
+  }
+  gps_array[tot_idx] = gps;
+  tot_idx++;
+}
+
+/* Compare all strokes. */
+for (int i = 0; i < tot_idx; i++) {
+  bGPDstroke *gps_a = gps_array[i];
+
+  bGPDspoint pt2;
+  float a1xy[2], a2xy[2];
+  float b1xy[2], b2xy[2];
+
+  /* First stroke. */
+  bGPDspoint *pt = &gps_a->points[0];
+  gpencil_point_to_parent_space(pt, diff_mat, &pt2);
+  gpencil_point_to_xy_fl(&tgpf->gsc, gps_a, &pt2, &a1xy[0], &a1xy[1]);
+
+  pt = &gps_a->points[1];
+  gpencil_point_to_parent_space(pt, diff_mat, &pt2);
+  gpencil_point_to_xy_fl(&tgpf->gsc, gps_a, &pt2, &a2xy[0], &a2xy[1]);
+  bGPDspoint *extreme_a = &gps_a->points[1];
+
+  /* Loop all strokes. */
+  for (int z = 0; z < tot_idx; z++) {
+bGPDstroke *gps_b = gps_array[z];
+if (i == z) {
+  continue;
+}
+pt = &gps_b->points[0];
+gpencil_point_to_parent_space(pt, diff_mat, &pt2);
+gpencil_point_to_xy_fl(&tgpf->gsc, gps_b, &pt2, &b1xy[0], &b1xy[1]);
+
+pt = &gps_b->points[1];
+gpencil_point_to_parent_space(pt, diff_mat, &pt2);
+gpencil_point_to_xy_fl(&tgpf->gsc, gps_b, &pt2, &b2xy[0], &b2xy[1]);
+bGPDspoint *extreme_b = &gps_b->points[1];
+
+/* Check if extensions collide and cut the overlength. */
+if (isect_seg_seg_v2_simple(a1xy, a2xy, b1xy, b2xy)) {
+  float intersection[2];
+  isect_line_line_v2_point(a1xy, a2xy, b1xy, b2xy, intersection);
+  float intersection3D[3];
+  gpencil_point_xy_to_3d(&tgpf->gsc, tgpf->scene, intersection, 
intersection3D);
+  copy_v3_v3(&extreme_a->x, intersection3D);
+  copy_v3_v3(&extreme_b->x, intersection3D);
+  gps_a->flag |= GP_STROKE_COLLIDE;
+  gps_b->flag |= GP_STROKE_COLLIDE;
+}
+  }
+}
+
+MEM_SAFE_FREE(gps_array);
+  }
+}
+
 /* Loop all layers create stroke extensions. */
 static void gpencil_create_extensions(tGPDfill *tgpf)
 {
@@ -483,6 +576,11 @@ static void gpencil_create_extensions(tGPDfill *tgpf)
   }
 
   BLI_gset_free(connected_endpoints, NULL);
+
+  /* Cut overlength strokes. */
+  if (tgpf->fill_extend_mode == GP_FILL_EMODE_EXTEND) {
+gpencil_cut_extensions(tgpf, gpl_active_index);
+  }
 }
 
 static void gpencil_update_extend(tGPDfill *tgpf)
@@ -563,7 +661,13 @@ static void gpencil_draw_basic_stroke(tGPDfill *tgpf,
 col[3] = (gps->flag & GP_STROKE_TAG) ? 0.0f : 0.5f;
   }
   else if ((is_extend) && (!tgpf->is_render)) {
-copy_v4_v4(col

[Bf-blender-cvs] [be863506b84] master: Cleanup: Improve comment for curve component legacy curves

2022-09-19 Thread Hans Goudey
Commit: be863506b842f9db40c736889e4a2521aad0d51f
Author: Hans Goudey
Date:   Mon Sep 19 08:46:28 2022 -0500
Branches: master
https://developer.blender.org/rBbe863506b842f9db40c736889e4a2521aad0d51f

Cleanup: Improve comment for curve component legacy curves

===

M   source/blender/blenkernel/BKE_geometry_set.hh

===

diff --git a/source/blender/blenkernel/BKE_geometry_set.hh 
b/source/blender/blenkernel/BKE_geometry_set.hh
index dce80373189..2ef9556afc7 100644
--- a/source/blender/blenkernel/BKE_geometry_set.hh
+++ b/source/blender/blenkernel/BKE_geometry_set.hh
@@ -464,7 +464,7 @@ class PointCloudComponent : public GeometryComponent {
 };
 
 /**
- * A geometry component that stores a group of curves, corresponding the 
#Curves data-block type
+ * A geometry component that stores a group of curves, corresponding the 
#Curves data-block
  * and the #CurvesGeometry type. Attributes are stored on the control point 
domain and the
  * curve domain.
  */
@@ -474,10 +474,9 @@ class CurveComponent : public GeometryComponent {
   GeometryOwnershipType ownership_ = GeometryOwnershipType::Owned;
 
   /**
-   * Curve data necessary to hold the draw cache for rendering, consistent 
over multiple redraws.
-   * This is necessary because Blender assumes that objects evaluate to an 
object data type, and
-   * we use #CurveEval rather than #Curve here. It also allows us to mostly 
reuse the same
-   * batch cache implementation.
+   * Because rendering #Curves isn't fully working yet, we must provide a 
#Curve for the render
+   * engine and depsgraph object iterator in some cases. This allows using the 
old curve rendering
+   * even when the new curve data structure is used.
*/
   mutable Curve *curve_for_render_ = nullptr;
   mutable std::mutex curve_for_render_mutex_;

___
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] [bcf2ab95ccc] temp-T96708-brush-texture-refactoring: Merge branch 'master' into temp-T96708-brush-texture-refactoring

2022-09-19 Thread Jeroen Bakker
Commit: bcf2ab95ccc2aefd2e9c73dd8ade1e313c503d69
Author: Jeroen Bakker
Date:   Mon Sep 19 14:57:31 2022 +0200
Branches: temp-T96708-brush-texture-refactoring
https://developer.blender.org/rBbcf2ab95ccc2aefd2e9c73dd8ade1e313c503d69

Merge branch 'master' into temp-T96708-brush-texture-refactoring

===



===

diff --cc source/blender/blenkernel/BKE_blender_version.h
index 1651ea243f2,ee9c7a964d9..a80f46a440d
--- 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 10
 -#define BLENDER_FILE_SUBVERSION 0
++#define BLENDER_FILE_SUBVERSION 1
  
  /* 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 12c7652a95b,244f74cfe59..6b45917fad0
--- a/source/blender/blenloader/intern/versioning_300.c
+++ b/source/blender/blenloader/intern/versioning_300.c
@@@ -2574,5 -3346,37 +3347,49 @@@ void blo_do_versions_300(FileData *fd, 
 */
{
  /* Keep this block, even when empty. */
+ 
+ /* Image generation information transferred to tiles. */
+ if (!DNA_struct_elem_find(fd->filesdna, "ImageTile", "int", "gen_x")) {
+   for (Image *ima = bmain->images.first; ima; ima = ima->id.next) {
+ for (ImageTile *tile = ima->tiles.first; tile; tile = tile->next) {
+   tile->gen_x = ima->gen_x;
+   tile->gen_y = ima->gen_y;
+   tile->gen_type = ima->gen_type;
+   tile->gen_flag = ima->gen_flag;
+   tile->gen_depth = ima->gen_depth;
+   copy_v4_v4(tile->gen_color, ima->gen_color);
+ }
+   }
+ }
+ 
+ /* Convert mix rgb node to new mix node and add storage. */
+ {
+   FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
+ versioning_replace_legacy_mix_rgb_node(ntree);
+   }
+   FOREACH_NODETREE_END;
+ }
+ 
+ /* Face sets no longer store whether the corresponding face is hidden. */
+ LISTBASE_FOREACH (Mesh *, mesh, &bmain->meshes) {
+   int *face_sets = (int *)CustomData_get_layer(&mesh->pdata, 
CD_SCULPT_FACE_SETS);
+   if (face_sets) {
+ for (int i = 0; i < mesh->totpoly; i++) {
+   face_sets[i] = abs(face_sets[i]);
+ }
+   }
+ }
++
++/* Sculpting brushes used mtex for masking, image brushes used mtex for 
coloring and mask_mtex
++ * for masking. Converting sculpting brushes to use mask_tex for masking 
to make brushes more
++ * compatible with each other. */
++// TODO(jbakker): this needs a version bump.
++MTex default_texture = _DNA_DEFAULT_MTex;
++LISTBASE_FOREACH (Brush *, brush, &bmain->brushes) {
++  if (brush->sculpt_tool != 0) {
++memcpy(&brush->mask_mtex, &brush->mtex, sizeof(MTex));
++memcpy(&brush->mtex, &default_texture, sizeof(MTex));
++  }
++}
}
  }
diff --cc source/blender/editors/sculpt_paint/sculpt.c
index fe172d5e7ae,1f64a2445aa..74639ce1ee0
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@@ -4926,10 -5082,10 +5082,10 @@@ bool SCULPT_stroke_get_location(bContex
return hit;
  }
  
- static void sculpt_brush_init_tex(const Scene *scene, Sculpt *sd, 
SculptSession *ss)
+ static void sculpt_brush_init_tex(Sculpt *sd, SculptSession *ss)
  {
Brush *brush = BKE_paint_brush(&sd->paint);
 -  MTex *mtex = &brush->mtex;
 +  MTex *mtex = &brush->mask_mtex;
  
/* Init mtex nodes. */
if (mtex->tex && mtex->tex->nodetree) {
diff --cc source/blender/editors/sculpt_paint/sculpt_expand.c
index b5eec705283,53972709a3e..ef4f1ce4d9d
--- a/source/blender/editors/sculpt_paint/sculpt_expand.c
+++ b/source/blender/editors/sculpt_paint/sculpt_expand.c
@@@ -167,14 -170,16 +170,16 @@@ static bool sculpt_expand_is_face_in_ac
   */
  static float sculpt_expand_falloff_value_vertex_get(SculptSession *ss,
  ExpandCache *expand_cache,
- const int v)
+ const PBVHVertRef v)
  {
+   int v_i = BKE_pbvh_vertex_to_index(ss->pbvh, v);
+ 
if (expand_cache->texture_distortion_strength == 0.0f) {
- return expand_cache->vert_falloff[v];
+ return expand_cache->vert_falloff[v_i];
}
  
 -  if (!expand_cache->brush->mtex.tex) {
 +  if (!expand_cache->brush->mask_mtex.tex) {
- return expand_cache->vert_falloff[v];
+ return expand_cache->vert_falloff[v_i];
}
  
float rgba[4];
@@@ -2000,10 -2058,10 +2058,10 @@@ static void sculpt_expand_cache_initial
BKE_curvemapping_init(expand_cache->brush->cu

[Bf-blender-cvs] [fd248e6bf99] blender-v2.93-release: Fix T100578: Surface Deform modifier displays wrong in editmode

2022-09-19 Thread Philipp Oeser
Commit: fd248e6bf9947f4a1d9da07ebf788fbcf2018293
Author: Philipp Oeser
Date:   Tue Aug 23 09:51:36 2022 +0200
Branches: blender-v2.93-release
https://developer.blender.org/rBfd248e6bf9947f4a1d9da07ebf788fbcf2018293

Fix T100578: Surface Deform modifier displays wrong in editmode

This was the case when the "Show in Editmode" option was used and a
vertexgroup affected the areas.

Probably an oversight in {rBdeaff945d0b9}?, seems like deforming
modifiers always need to call `BKE_mesh_wrapper_ensure_mdata` in
`deformVertsEM` when a vertex group is used.

Maniphest Tasks: T100578

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

===

M   source/blender/modifiers/intern/MOD_surfacedeform.c

===

diff --git a/source/blender/modifiers/intern/MOD_surfacedeform.c 
b/source/blender/modifiers/intern/MOD_surfacedeform.c
index 99011c5e351..44fa974b3ee 100644
--- a/source/blender/modifiers/intern/MOD_surfacedeform.c
+++ b/source/blender/modifiers/intern/MOD_surfacedeform.c
@@ -1511,6 +1511,11 @@ static void deformVertsEM(ModifierData *md,
 mesh_src = MOD_deform_mesh_eval_get(ctx->object, em, mesh, NULL, numVerts, 
false, false);
   }
 
+  /* TODO(@campbellbarton): use edit-mode data only (remove this line). */
+  if (mesh_src != NULL) {
+BKE_mesh_wrapper_ensure_mdata(mesh_src);
+  }
+
   surfacedeformModifier_do(md, ctx, vertexCos, numVerts, ctx->object, 
mesh_src);
 
   if (!ELEM(mesh_src, NULL, mesh)) {

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


[Bf-blender-cvs] [6d24de6c433] blender-v2.93-release: Fix T99979: GPencil strokes cannot be edited after set origin

2022-09-19 Thread Antonio Vazquez
Commit: 6d24de6c4336365330d285ba133f606c15f0dd21
Author: Antonio Vazquez
Date:   Tue Jul 26 10:53:08 2022 +0200
Branches: blender-v2.93-release
https://developer.blender.org/rB6d24de6c4336365330d285ba133f606c15f0dd21

Fix T99979: GPencil strokes cannot be edited after set origin

The stroke points were changed but the bounding box calculation was not
done and this produced a problem in any bounding box check done by
different tools.

===

M   source/blender/editors/object/object_transform.c

===

diff --git a/source/blender/editors/object/object_transform.c 
b/source/blender/editors/object/object_transform.c
index ba867afe31f..d7863c54c51 100644
--- a/source/blender/editors/object/object_transform.c
+++ b/source/blender/editors/object/object_transform.c
@@ -1406,6 +1406,7 @@ static int object_origin_set_exec(bContext *C, wmOperator 
*op)
 sub_v3_v3(mpt, offset_local);
 mul_v3_m4v3(&pt->x, diff_mat, mpt);
   }
+  BKE_gpencil_stroke_geometry_update(gpd, gps);
 }
   }
 }

___
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] [8c148a4f3b8] blender-v2.93-release: Fix T100851: Sync markers does not work for numinput

2022-09-19 Thread Philipp Oeser
Commit: 8c148a4f3b8f3c74c18b40340462de00ebdc9cec
Author: Philipp Oeser
Date:   Tue Sep 6 12:58:29 2022 +0200
Branches: blender-v2.93-release
https://developer.blender.org/rB8c148a4f3b8f3c74c18b40340462de00ebdc9cec

Fix T100851: Sync markers does not work for numinput

special_aftertrans_update would always use TransInfo values (not
the values_final -- we need the final values to follow numinput, snapping,
etc).

Maniphest Tasks: T100851

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

===

M   source/blender/editors/transform/transform_convert_action.c
M   source/blender/editors/transform/transform_convert_sequencer.c

===

diff --git a/source/blender/editors/transform/transform_convert_action.c 
b/source/blender/editors/transform/transform_convert_action.c
index 8204264e105..c51204b96a8 100644
--- a/source/blender/editors/transform/transform_convert_action.c
+++ b/source/blender/editors/transform/transform_convert_action.c
@@ -888,18 +888,18 @@ void special_aftertrans_update__actedit(bContext *C, 
TransInfo *t)
 if (ELEM(t->frame_side, 'L', 'R')) { /* TFM_TIME_EXTEND */
   /* same as below */
   ED_markers_post_apply_transform(
-  ED_context_get_markers(C), t->scene, t->mode, t->values[0], 
t->frame_side);
+  ED_context_get_markers(C), t->scene, t->mode, 
t->values_final[0], t->frame_side);
 }
 else /* TFM_TIME_TRANSLATE */
 #endif
   {
 ED_markers_post_apply_transform(
-ED_context_get_markers(C), t->scene, t->mode, t->values[0], 
t->frame_side);
+ED_context_get_markers(C), t->scene, t->mode, t->values_final[0], 
t->frame_side);
   }
 }
 else if (t->mode == TFM_TIME_SCALE) {
   ED_markers_post_apply_transform(
-  ED_context_get_markers(C), t->scene, t->mode, t->values[0], 
t->frame_side);
+  ED_context_get_markers(C), t->scene, t->mode, t->values_final[0], 
t->frame_side);
 }
   }
 
diff --git a/source/blender/editors/transform/transform_convert_sequencer.c 
b/source/blender/editors/transform/transform_convert_sequencer.c
index 30418471d6d..49d4601f395 100644
--- a/source/blender/editors/transform/transform_convert_sequencer.c
+++ b/source/blender/editors/transform/transform_convert_sequencer.c
@@ -805,12 +805,12 @@ void special_aftertrans_update__sequencer(bContext 
*UNUSED(C), TransInfo *t)
 if (t->mode == TFM_SEQ_SLIDE) {
   if (t->frame_side == 'B') {
 ED_markers_post_apply_transform(
-&t->scene->markers, t->scene, TFM_TIME_TRANSLATE, t->values[0], 
t->frame_side);
+&t->scene->markers, t->scene, TFM_TIME_TRANSLATE, 
t->values_final[0], t->frame_side);
   }
 }
 else if (ELEM(t->frame_side, 'L', 'R')) {
   ED_markers_post_apply_transform(
-  &t->scene->markers, t->scene, TFM_TIME_EXTEND, t->values[0], 
t->frame_side);
+  &t->scene->markers, t->scene, TFM_TIME_EXTEND, t->values_final[0], 
t->frame_side);
 }
   }
 }

___
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] [238cd2b2a4b] blender-v2.93-release: Release cycle: Blender 2.93.11 candidate.

2022-09-19 Thread Philipp Oeser
Commit: 238cd2b2a4b662b303e7037d2939fa2a4c994be9
Author: Philipp Oeser
Date:   Mon Sep 19 14:36:14 2022 +0200
Branches: blender-v2.93-release
https://developer.blender.org/rB238cd2b2a4b662b303e7037d2939fa2a4c994be9

Release cycle: Blender 2.93.11 candidate.

===

M   source/blender/blenkernel/BKE_blender_version.h

===

diff --git a/source/blender/blenkernel/BKE_blender_version.h 
b/source/blender/blenkernel/BKE_blender_version.h
index c31701eba4f..13318b92a29 100644
--- a/source/blender/blenkernel/BKE_blender_version.h
+++ b/source/blender/blenkernel/BKE_blender_version.h
@@ -33,9 +33,9 @@ extern "C" {
 /* Blender major and minor version. */
 #define BLENDER_VERSION 293
 /* Blender patch version for bugfix releases. */
-#define BLENDER_VERSION_PATCH 10
+#define BLENDER_VERSION_PATCH 11
 /** Blender release cycle stage: alpha/beta/rc/release. */
-#define BLENDER_VERSION_CYCLE release
+#define BLENDER_VERSION_CYCLE rc
 
 /* Blender file format version. */
 #define BLENDER_FILE_VERSION BLENDER_VERSION

___
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] [52a5c80313c] blender-v2.93-release: Fix T100191: Crash with the wave modifier using normals in edit-mode

2022-09-19 Thread Campbell Barton
Commit: 52a5c80313c206eb7c1b31af3079bffdda4b09c6
Author: Campbell Barton
Date:   Fri Aug 12 21:45:21 2022 +1000
Branches: blender-v2.93-release
https://developer.blender.org/rB52a5c80313c206eb7c1b31af3079bffdda4b09c6

Fix T100191: Crash with the wave modifier using normals in edit-mode

===

M   source/blender/modifiers/intern/MOD_wave.c

===

diff --git a/source/blender/modifiers/intern/MOD_wave.c 
b/source/blender/modifiers/intern/MOD_wave.c
index 863656b85a5..0fe023687c2 100644
--- a/source/blender/modifiers/intern/MOD_wave.c
+++ b/source/blender/modifiers/intern/MOD_wave.c
@@ -340,8 +340,12 @@ static void deformVertsEM(ModifierData *md,
   Mesh *mesh_src = NULL;
 
   if (wmd->flag & MOD_WAVE_NORM) {
+/* NOTE(@campbellbarton): don't request normals here because `use_normals 
== false`
+ * because #BKE_mesh_wrapper_ensure_mdata has not run yet.
+ * While this could be supported the argument is documented to be removed,
+ * so pass false here and let the normals be created when requested. */
 mesh_src = MOD_deform_mesh_eval_get(
-ctx->object, editData, mesh, vertexCos, numVerts, true, false);
+ctx->object, editData, mesh, vertexCos, numVerts, false, false);
   }
   else if (wmd->texture != NULL || wmd->defgrp_name[0] != '\0') {
 mesh_src = MOD_deform_mesh_eval_get(ctx->object, editData, mesh, NULL, 
numVerts, false, false);
@@ -355,6 +359,12 @@ static void deformVertsEM(ModifierData *md,
   waveModifier_do(wmd, ctx, ctx->object, mesh_src, vertexCos, numVerts);
 
   if (!ELEM(mesh_src, NULL, mesh)) {
+/* Important not to free `vertexCos` owned by the caller. */
+EditMeshData *edit_data = mesh_src->runtime.edit_data;
+if (edit_data->vertexCos == vertexCos) {
+  edit_data->vertexCos = NULL;
+}
+
 BKE_id_free(NULL, mesh_src);
   }
 }

___
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] [2ce8b01c597] master: PyGPU: call 'GPU_shader_bind' in 'GPUShader.uniform_' methods

2022-09-19 Thread Germano Cavalcante
Commit: 2ce8b01c597c232d165ef2c004e3cd8d9db22cbf
Author: Germano Cavalcante
Date:   Mon Sep 19 09:39:48 2022 -0300
Branches: master
https://developer.blender.org/rB2ce8b01c597c232d165ef2c004e3cd8d9db22cbf

PyGPU: call 'GPU_shader_bind' in 'GPUShader.uniform_' methods

This simplifies python code.

When we call a method like shader.uniform_float("color", (1,1,1,1)),
we expect the shader's uniform to be updated regardless of whether the
shader is bound or not.

And `batch.draw()` already calls `GPU_shader_bind` inside.

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

===

M   doc/python_api/examples/gpu.1.py
M   doc/python_api/examples/gpu.10.py
M   doc/python_api/examples/gpu.2.py
M   doc/python_api/examples/gpu.3.py
M   doc/python_api/examples/gpu.5.py
M   doc/python_api/examples/gpu.6.py
M   doc/python_api/examples/gpu.7.py
M   release/scripts/modules/bpy_types.py
M   release/scripts/modules/gpu_extras/presets.py
M   release/scripts/templates_py/operator_modal_draw.py
M   source/blender/python/gpu/gpu_py_shader.c

===

diff --git a/doc/python_api/examples/gpu.1.py b/doc/python_api/examples/gpu.1.py
index a014e69c2d2..c44e79a77aa 100644
--- a/doc/python_api/examples/gpu.1.py
+++ b/doc/python_api/examples/gpu.1.py
@@ -134,7 +134,6 @@ batch = batch_for_shader(shader, 'LINES', {"pos": coords})
 
 
 def draw():
-shader.bind()
 shader.uniform_float("color", (1, 1, 0, 1))
 batch.draw(shader)
 
diff --git a/doc/python_api/examples/gpu.10.py 
b/doc/python_api/examples/gpu.10.py
index b47ff732e2b..6c438bd396e 100644
--- a/doc/python_api/examples/gpu.10.py
+++ b/doc/python_api/examples/gpu.10.py
@@ -58,7 +58,6 @@ batch = batch_for_shader(
 
 
 def draw():
-shader.bind()
 matrix = bpy.context.region_data.perspective_matrix
 shader.uniform_float("u_ViewProjectionMatrix", matrix)
 shader.uniform_float("u_Scale", 10)
diff --git a/doc/python_api/examples/gpu.2.py b/doc/python_api/examples/gpu.2.py
index 2a46e833752..e308ce7f78e 100644
--- a/doc/python_api/examples/gpu.2.py
+++ b/doc/python_api/examples/gpu.2.py
@@ -41,7 +41,6 @@ batch = batch_for_shader(shader, 'TRIS', {"position": coords})
 
 
 def draw():
-shader.bind()
 matrix = bpy.context.region_data.perspective_matrix
 shader.uniform_float("viewProjectionMatrix", matrix)
 shader.uniform_float("brightness", 0.5)
diff --git a/doc/python_api/examples/gpu.3.py b/doc/python_api/examples/gpu.3.py
index 0c86b52bcf5..9e8f762d9c9 100644
--- a/doc/python_api/examples/gpu.3.py
+++ b/doc/python_api/examples/gpu.3.py
@@ -22,7 +22,6 @@ batch = batch_for_shader(shader, 'LINES', {"pos": coords}, 
indices=indices)
 
 
 def draw():
-shader.bind()
 shader.uniform_float("color", (1, 0, 0, 1))
 batch.draw(shader)
 
diff --git a/doc/python_api/examples/gpu.5.py b/doc/python_api/examples/gpu.5.py
index 2edde46a364..983372706c1 100644
--- a/doc/python_api/examples/gpu.5.py
+++ b/doc/python_api/examples/gpu.5.py
@@ -18,7 +18,6 @@ batch = batch_for_shader(shader, 'TRIS', {"pos": vertices}, 
indices=indices)
 
 
 def draw():
-shader.bind()
 shader.uniform_float("color", (0, 0.5, 0.5, 1.0))
 batch.draw(shader)
 
diff --git a/doc/python_api/examples/gpu.6.py b/doc/python_api/examples/gpu.6.py
index 5576b2d0bfe..96decf571ee 100644
--- a/doc/python_api/examples/gpu.6.py
+++ b/doc/python_api/examples/gpu.6.py
@@ -56,7 +56,6 @@ batch = batch_for_shader(
 
 
 def draw():
-shader.bind()
 shader.uniform_sampler("image", texture)
 batch.draw(shader)
 
diff --git a/doc/python_api/examples/gpu.7.py b/doc/python_api/examples/gpu.7.py
index e3bfbd14e34..5d25b42728d 100644
--- a/doc/python_api/examples/gpu.7.py
+++ b/doc/python_api/examples/gpu.7.py
@@ -76,7 +76,6 @@ batch = batch_for_shader(
 
 
 def draw():
-shader.bind()
 shader.uniform_float("modelMatrix", Matrix.Translation((1, 2, 3)) @ 
Matrix.Scale(3, 4))
 shader.uniform_float("viewProjectionMatrix", 
bpy.context.region_data.perspective_matrix)
 shader.uniform_sampler("image", offscreen.texture_color)
diff --git a/release/scripts/modules/bpy_types.py 
b/release/scripts/modules/bpy_types.py
index b2f4d71ed92..d8d6a9123f2 100644
--- a/release/scripts/modules/bpy_types.py
+++ b/release/scripts/modules/bpy_types.py
@@ -742,7 +742,6 @@ class Gizmo(StructRNA):
 matrix = self.matrix_world
 
 batch, shader = shape
-shader.bind()
 
 if select_id is not None:
 gpu.select.load_id(select_id)
diff --git a/release/scripts/modules/gpu_extras/presets.py 
b/release/scripts/modules/gpu_extras/presets.py
index f68824d76c8..f0d80e855c1 100644
--- a/release/scripts/modules/gpu_extras/presets.py
+++ b/release/scripts/modules/gpu_extras/presets.py
@@ -78,7 +78,6 @@ def draw_texture_2d(texture, position, width, height):
 gpu.matrix.scale((wid

[Bf-blender-cvs] [2fffd7d7a85] master: Move overlay engine to C++

2022-09-19 Thread Jacques Lucke
Commit: 2fffd7d7a85d9e35d4f2b6e0de15504178b26e07
Author: Jacques Lucke
Date:   Mon Sep 19 14:29:58 2022 +0200
Branches: master
https://developer.blender.org/rB2fffd7d7a85d9e35d4f2b6e0de15504178b26e07

Move overlay engine to C++

This just makes the minimum changes to make the files compile.

===

M   source/blender/draw/CMakeLists.txt
R098source/blender/draw/engines/overlay/overlay_antialiasing.c  
source/blender/draw/engines/overlay/overlay_antialiasing.cc
R093source/blender/draw/engines/overlay/overlay_armature.c  
source/blender/draw/engines/overlay/overlay_armature.cc
R094source/blender/draw/engines/overlay/overlay_background.c
source/blender/draw/engines/overlay/overlay_background.cc
R098source/blender/draw/engines/overlay/overlay_edit_curve.c
source/blender/draw/engines/overlay/overlay_edit_curve.cc
M   source/blender/draw/engines/overlay/overlay_edit_curves.cc
R094source/blender/draw/engines/overlay/overlay_edit_mesh.c 
source/blender/draw/engines/overlay/overlay_edit_mesh.cc
R097source/blender/draw/engines/overlay/overlay_edit_text.c 
source/blender/draw/engines/overlay/overlay_edit_text.cc
R087source/blender/draw/engines/overlay/overlay_edit_uv.c   
source/blender/draw/engines/overlay/overlay_edit_uv.cc
R072source/blender/draw/engines/overlay/overlay_engine.c
source/blender/draw/engines/overlay/overlay_engine.cc
M   source/blender/draw/engines/overlay/overlay_engine.h
R097source/blender/draw/engines/overlay/overlay_extra.c 
source/blender/draw/engines/overlay/overlay_extra.cc
R098source/blender/draw/engines/overlay/overlay_facing.c
source/blender/draw/engines/overlay/overlay_facing.cc
R098source/blender/draw/engines/overlay/overlay_fade.c  
source/blender/draw/engines/overlay/overlay_fade.cc
R091source/blender/draw/engines/overlay/overlay_gpencil.c   
source/blender/draw/engines/overlay/overlay_gpencil.cc
R094source/blender/draw/engines/overlay/overlay_grid.c  
source/blender/draw/engines/overlay/overlay_grid.cc
R093source/blender/draw/engines/overlay/overlay_image.c 
source/blender/draw/engines/overlay/overlay_image.cc
R098source/blender/draw/engines/overlay/overlay_lattice.c   
source/blender/draw/engines/overlay/overlay_lattice.cc
R094source/blender/draw/engines/overlay/overlay_metaball.c  
source/blender/draw/engines/overlay/overlay_metaball.cc
R099source/blender/draw/engines/overlay/overlay_mode_transfer.c 
source/blender/draw/engines/overlay/overlay_mode_transfer.cc
R095source/blender/draw/engines/overlay/overlay_motion_path.c   
source/blender/draw/engines/overlay/overlay_motion_path.cc
R094source/blender/draw/engines/overlay/overlay_outline.c   
source/blender/draw/engines/overlay/overlay_outline.cc
R093source/blender/draw/engines/overlay/overlay_paint.c 
source/blender/draw/engines/overlay/overlay_paint.cc
R092source/blender/draw/engines/overlay/overlay_particle.c  
source/blender/draw/engines/overlay/overlay_particle.cc
R100source/blender/draw/engines/overlay/overlay_private.h   
source/blender/draw/engines/overlay/overlay_private.hh
R094source/blender/draw/engines/overlay/overlay_sculpt.c
source/blender/draw/engines/overlay/overlay_sculpt.cc
M   source/blender/draw/engines/overlay/overlay_sculpt_curves.cc
R099source/blender/draw/engines/overlay/overlay_shader.c
source/blender/draw/engines/overlay/overlay_shader.cc
M   source/blender/draw/engines/overlay/overlay_shader_shared.h
R089source/blender/draw/engines/overlay/overlay_volume.c
source/blender/draw/engines/overlay/overlay_volume.cc
R094source/blender/draw/engines/overlay/overlay_wireframe.c 
source/blender/draw/engines/overlay/overlay_wireframe.cc
M   source/blender/draw/tests/shaders_test.cc

===

diff --git a/source/blender/draw/CMakeLists.txt 
b/source/blender/draw/CMakeLists.txt
index 32103692421..8b61d8686cd 100644
--- a/source/blender/draw/CMakeLists.txt
+++ b/source/blender/draw/CMakeLists.txt
@@ -176,33 +176,33 @@ set(SRC
   engines/gpencil/gpencil_shader_fx.c
   engines/select/select_draw_utils.c
   engines/select/select_engine.c
-  engines/overlay/overlay_antialiasing.c
-  engines/overlay/overlay_armature.c
-  engines/overlay/overlay_background.c
-  engines/overlay/overlay_edit_curve.c
+  engines/overlay/overlay_antialiasing.cc
+  engines/overlay/overlay_armature.cc
+  engines/overlay/overlay_background.cc
+  engines/overlay/overlay_edit_curve.cc
   engines/overlay/overlay_edit_curves.cc
-  engines/overlay/overlay_edit_mesh.c
-  engines/overlay/overlay_edit_text.c
-  engines/overlay/overlay_edit_uv.c
-  engines/overlay/overlay_engine.c
-  engines/overlay/overlay_extra.c
-  engines/overlay/overlay_facing.c
-  engines/overlay/overlay_fade.c
-  engines/overlay/overlay_gpencil.c
-  engines/overlay/overlay_gri

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

2022-09-19 Thread Antonio Vazquez
Commit: 6be6d4145fa385da504456b28b79d249751f5f4d
Author: Antonio Vazquez
Date:   Mon Sep 19 13:24:48 2022 +0200
Branches: asset-lite-greasepencil
https://developer.blender.org/rB6be6d4145fa385da504456b28b79d249751f5f4d

Merge branch 'master' into asset-lite-greasepencil

===



===



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


[Bf-blender-cvs] [327802b86f6] master: DNA: Remove unnecessary studio light & light probe struct paddings

2022-09-19 Thread Julian Eisel
Commit: 327802b86f6b4dd0614d67796cc8ef02f4363a9b
Author: Julian Eisel
Date:   Fri Sep 16 11:12:31 2022 +0200
Branches: master
https://developer.blender.org/rB327802b86f6b4dd0614d67796cc8ef02f4363a9b

DNA: Remove unnecessary studio light & light probe struct paddings

===

M   source/blender/makesdna/DNA_lightprobe_types.h
M   source/blender/makesdna/DNA_userdef_types.h

===

diff --git a/source/blender/makesdna/DNA_lightprobe_types.h 
b/source/blender/makesdna/DNA_lightprobe_types.h
index d6afaf33052..5b5bc4c7392 100644
--- a/source/blender/makesdna/DNA_lightprobe_types.h
+++ b/source/blender/makesdna/DNA_lightprobe_types.h
@@ -64,7 +64,6 @@ typedef struct LightProbe {
 
   /* Runtime display data */
   float distfalloff, distgridinf;
-  char _pad[8];
 } LightProbe;
 
 /* Probe->type */
diff --git a/source/blender/makesdna/DNA_userdef_types.h 
b/source/blender/makesdna/DNA_userdef_types.h
index 39fb3690da4..ed4bea97aa0 100644
--- a/source/blender/makesdna/DNA_userdef_types.h
+++ b/source/blender/makesdna/DNA_userdef_types.h
@@ -581,7 +581,6 @@ typedef struct bUserAssetLibrary {
 typedef struct SolidLight {
   int flag;
   float smooth;
-  char _pad0[8];
   float col[4], spec[4], vec[4];
 } SolidLight;

___
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] [a89e1c439e2] cycles_path_guiding: Guiding: Added support for guiding in overlapping volumes

2022-09-19 Thread Sebastian Herhoz
Commit: a89e1c439e2a89e4d6894f4b222112565b2afabf
Author: Sebastian Herhoz
Date:   Mon Sep 19 11:06:09 2022 +0200
Branches: cycles_path_guiding
https://developer.blender.org/rBa89e1c439e2a89e4d6894f4b222112565b2afabf

Guiding: Added support for guiding in overlapping volumes

===

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

===

diff --git a/intern/cycles/kernel/integrator/volume_shader.h 
b/intern/cycles/kernel/integrator/volume_shader.h
index 1f494c3a7a3..003de13b1d4 100644
--- a/intern/cycles/kernel/integrator/volume_shader.h
+++ b/intern/cycles/kernel/integrator/volume_shader.h
@@ -97,7 +97,7 @@ ccl_device_inline void 
volume_shader_prepare_guiding(KernelGlobals kg,
  ccl_private const 
RNGState *rng_state,
  const float3 P,
  const float3 W,
- ccl_private const 
ShaderVolumePhases *phases,
+ ccl_private 
ShaderVolumePhases *phases,
  const VolumeSampleMethod 
direct_sample_method)
 {
   const bool guiding = kernel_data.integrator.use_guiding;
@@ -112,28 +112,60 @@ ccl_device_inline void 
volume_shader_prepare_guiding(KernelGlobals kg,
 
   int num_phases = phases->num_closure;
 
-  if (guiding && volume_guiding && (direct_sample_method == 
VOLUME_SAMPLE_DISTANCE)) {
+  if (guiding && volume_guiding /*&& (direct_sample_method == 
VOLUME_SAMPLE_DISTANCE)*/) {
 
-if (num_phases == 1) {  // for now we only support a single phase function
-  ccl_private const ShaderVolumeClosure *svc = &phases->closure[0];
-  const float mean_cosine = svc->g;
+if (num_phases > 0) {
+
+  grand = path_state_rng_1D(kg, rng_state, PRNG_VOLUME_PHASE_GUIDING);
+  int phaseId = 0;
+  float phaseSampleWeight = 1.0f;
+  /* if we have more than one ohase function we select one random
+   * based on its sampleweight to caclulate the product distribution
+   * for guiding */
+  if (num_phases > 1) {
+/* pick a phase closure based on sample weights */
+float sum = 0.0f;
+
+for (phaseId = 0; phaseId < num_phases; phaseId++) {
+  ccl_private const ShaderVolumeClosure *svc = 
&phases->closure[phaseId];
+  sum += svc->sample_weight;
+}
 
-  // if (fabsf(mean_cosine) < 0.1f ) { // for now we only support HG phase 
function with very
-  // low anisotropy
-  if (true) {
-grand = path_state_rng_1D(kg, rng_state, PRNG_VOLUME_PHASE_GUIDING);
+float r = grand * sum;
+float partial_sum = 0.0f;
 
-pgl_point3f pgl_P = openpgl::cpp::Point3(P[0], P[1], P[2]);
-pgl_point3f pgl_W = openpgl::cpp::Vector3(W[0], W[1], W[2]);
+for (phaseId = 0; phaseId < num_phases; phaseId++) {
+  ccl_private const ShaderVolumeClosure *svc = 
&phases->closure[phaseId];
+  float next_sum = partial_sum + svc->sample_weight;
 
-useGuiding = state->guiding.volume_sampling_distribution->Init(
-kg->opgl_guiding_field, pgl_P, grand, true);
+  if (r <= next_sum) {
+// Rescale to reuse
+grand = (r - partial_sum) / svc->sample_weight;
+phaseSampleWeight = svc->sample_weight / sum;
+break;
+  }
 
-if (useGuiding) {
-  
state->guiding.volume_sampling_distribution->ApplySingleLobeHenyeyGreensteinProduct(
-  pgl_W, mean_cosine);
-  guiding_sampling_prob = volume_guiding_probability;
+  partial_sum = next_sum;
 }
+/* adjust the sample weight of the component used for guiding */
+phases->closure[phaseId].sample_weight *= volume_guiding_probability;
+  }
+
+  /* get the selected pahse function and apply its product with the
+   * guiding distriubtion*/
+  ccl_private const ShaderVolumeClosure *svc = &phases->closure[phaseId];
+  const float mean_cosine = svc->g;
+
+  pgl_point3f pgl_P = openpgl::cpp::Point3(P[0], P[1], P[2]);
+  pgl_point3f pgl_W = openpgl::cpp::Vector3(W[0], W[1], W[2]);
+
+  useGuiding = state->guiding.volume_sampling_distribution->Init(
+  kg->opgl_guiding_field, pgl_P, grand, true);
+
+  if (useGuiding) {
+
state->guiding.volume_sampling_distribution->ApplySingleLobeHenyeyGreensteinProduct(
+pgl_W, mean_cosine);
+guiding_sampling_prob = volume_guiding_probability * phaseSampleWeight;
   }
 }
   }

___
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] [00f984f9ae4] cycles_path_guiding: Guiding: Code cleanup as well as adding functions to validate bsdf_label and bsdf_roughness_eta

2022-09-19 Thread Sebastian Herhoz
Commit: 00f984f9ae4f47df9a5e47d57a2e35a402392df7
Author: Sebastian Herhoz
Date:   Sun Sep 18 11:52:16 2022 +0200
Branches: cycles_path_guiding
https://developer.blender.org/rB00f984f9ae4f47df9a5e47d57a2e35a402392df7

Guiding: Code cleanup as well as adding functions to validate bsdf_label and 
bsdf_roughness_eta

===

M   intern/cycles/integrator/path_trace.cpp
M   intern/cycles/kernel/integrator/shade_volume.h
M   intern/cycles/kernel/integrator/surface_shader.h

===

diff --git a/intern/cycles/integrator/path_trace.cpp 
b/intern/cycles/integrator/path_trace.cpp
index 2ee8718d4de..673f2b39076 100644
--- a/intern/cycles/integrator/path_trace.cpp
+++ b/intern/cycles/integrator/path_trace.cpp
@@ -1338,43 +1338,27 @@ void PathTrace::guiding_update_structures()
 {
 #ifdef WITH_PATH_GUIDING
 #  ifdef WITH_PATH_GUIDING_DEBUG_PRINT
-  VLOG_WORK << "Path Guiding: update guiding structures";
-  VLOG_WORK << "SampleDataStrorage: #surface samples = "
+  VLOG_INFO << "Path Guiding: update guiding structures";
+  VLOG_INFO << "SampleDataStrorage: #surface samples = "
 << guiding_sample_data_storage_->GetSizeSurface()
 << "\t#volumesamples = " << 
guiding_sample_data_storage_->GetSizeVolume();
 #  endif
-  if (true) {
-const size_t num_valid_samples = 
guiding_sample_data_storage_->GetSizeSurface() +
- 
guiding_sample_data_storage_->GetSizeVolume();
-if (num_valid_samples >= 128) {
-
-  /*
-if(guiding_update_count == 128)
-{
-  std::string dump_sds_file_name =
- "/data/sherholz/Data/openpgl/guiding_sample_storage_" +
- std::to_string(guiding_update_count) +  ".sds";
-  guiding_sample_data_storage_->Store(dump_sds_file_name);
-
-  if(guiding_update_count>0)
-  {
-std::string fieldFileName = 
"/data/sherholz/Data/openpgl/guiding_field_" +
- std::to_string(guiding_update_count) +  ".field"; 
guiding_field_->Store(fieldFileName);
-  }
-}
-  */
+  const size_t num_valid_samples = 
guiding_sample_data_storage_->GetSizeSurface() +
+   
guiding_sample_data_storage_->GetSizeVolume();
+  /* we wait until we have at least 1024 samples */
+  if (num_valid_samples >= 1024) {
+
 #  if OPENPGL_VERSION_MINOR < 4
-  const size_t num_samples = 1;
-  guiding_field_->Update(*guiding_sample_data_storage_, num_samples);
+const size_t num_samples = 1;
+guiding_field_->Update(*guiding_sample_data_storage_, num_samples);
 #  else
-  guiding_field_->Update(*guiding_sample_data_storage_);
+guiding_field_->Update(*guiding_sample_data_storage_);
 #  endif
-  guiding_update_count++;
+guiding_update_count++;
 #  if defined(WITH_PATH_GUIDING_DEBUG_PRINT) && PATH_GUIDING_DEBUG_VALIDATE
-  VLOG_WORK << "Field: valid = " << guiding_field_->Validate();
+VLOG_DEBUG << "Field: valid = " << guiding_field_->Validate();
 #  endif
-  guiding_sample_data_storage_->Clear();
-}
+guiding_sample_data_storage_->Clear();
   }
 #endif
 }
diff --git a/intern/cycles/kernel/integrator/shade_volume.h 
b/intern/cycles/kernel/integrator/shade_volume.h
index 45557e8858f..33f7875368a 100644
--- a/intern/cycles/kernel/integrator/shade_volume.h
+++ b/intern/cycles/kernel/integrator/shade_volume.h
@@ -852,10 +852,6 @@ ccl_device_forceinline void integrate_volume_direct_light(
   state, path, transmission_bounce);
   INTEGRATOR_STATE_WRITE(shadow_state, shadow_path, throughput) = 
throughput_phase;
 
-#  ifdef __PATH_GUIDING__
-  // TODO add scattered contriubtion
-#  endif
-
   if (kernel_data.kernel_features & KERNEL_FEATURE_SHADOW_PASS) {
 INTEGRATOR_STATE_WRITE(shadow_state, shadow_path, unshadowed_throughput) = 
throughput;
   }
diff --git a/intern/cycles/kernel/integrator/surface_shader.h 
b/intern/cycles/kernel/integrator/surface_shader.h
index 8024385b77a..5b6a4facd3e 100644
--- a/intern/cycles/kernel/integrator/surface_shader.h
+++ b/intern/cycles/kernel/integrator/surface_shader.h
@@ -14,6 +14,8 @@
 
 #include "kernel/svm/svm.h"
 
+#include "util/log.h"
+
 #ifdef __OSL__
 #  include "kernel/osl/shader.h"
 #endif
@@ -186,6 +188,49 @@ ccl_device_inline bool 
surface_shader_is_transmission_sc(const ShaderClosure *sc
   return dot(sc->N, omega_in) < 0.0f;
 }
 
+ccl_device_inline bool surface_shader_validate_bsdf_label(const KernelGlobals 
kg,
+  const ShaderClosure 
*sc,
+  const float3 
*omega_in,
+  const int org_label)
+{
+  bool is_transmission = surface_shader_is_transmission_sc(sc, *omega_in);
+  int comp_label = bsdf_label(kg, sc, is_transmission);
+  if (org_label !=