[Bf-blender-cvs] [4067e6bc415] master: Cleanup: format

2022-11-28 Thread Chris Blackbourn
Commit: 4067e6bc41507f81dcb398afdede8828eeb43624
Author: Chris Blackbourn
Date:   Tue Nov 29 17:32:28 2022 +1300
Branches: master
https://developer.blender.org/rB4067e6bc41507f81dcb398afdede8828eeb43624

Cleanup: format

===

M   source/blender/blenkernel/BKE_uv_islands.hh
M   source/blender/editors/sculpt_paint/sculpt_paint_image.cc

===

diff --git a/source/blender/blenkernel/BKE_uv_islands.hh 
b/source/blender/blenkernel/BKE_uv_islands.hh
index cf274e415b9..406ecf39b71 100644
--- a/source/blender/blenkernel/BKE_uv_islands.hh
+++ b/source/blender/blenkernel/BKE_uv_islands.hh
@@ -17,7 +17,6 @@
 
 #include "DNA_meshdata_types.h"
 
-
 namespace blender::bke::uv_islands {
 
 struct MeshEdge;
diff --git a/source/blender/editors/sculpt_paint/sculpt_paint_image.cc 
b/source/blender/editors/sculpt_paint/sculpt_paint_image.cc
index d9981cbb557..6244cf8e33d 100644
--- a/source/blender/editors/sculpt_paint/sculpt_paint_image.cc
+++ b/source/blender/editors/sculpt_paint/sculpt_paint_image.cc
@@ -362,12 +362,18 @@ static void do_paint_pixels(void *__restrict userdata,
   }
   bool pixels_painted = false;
   if (image_buffer->rect_float != nullptr) {
-pixels_painted = kernel_float4.paint(
-pbvh_data.geom_primitives, node_data.uv_primitives, pixel_row, 
image_buffer, &automask_data);
+pixels_painted = kernel_float4.paint(pbvh_data.geom_primitives,
+ node_data.uv_primitives,
+ pixel_row,
+ image_buffer,
+ &automask_data);
   }
   else {
-pixels_painted = kernel_byte4.paint(
-pbvh_data.geom_primitives, node_data.uv_primitives, pixel_row, 
image_buffer, &automask_data);
+pixels_painted = kernel_byte4.paint(pbvh_data.geom_primitives,
+node_data.uv_primitives,
+pixel_row,
+image_buffer,
+&automask_data);
   }
 
   if (pixels_painted) {

___
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] [91ba17da8b2] tmp-dynamic-usd: USD import textures option.

2022-11-28 Thread Michael Kowalski
Commit: 91ba17da8b26cd7e9eb9ed77ea27a7327f7c4e96
Author: Michael Kowalski
Date:   Mon Nov 28 09:56:15 2022 -0500
Branches: tmp-dynamic-usd
https://developer.blender.org/rB91ba17da8b26cd7e9eb9ed77ea27a7327f7c4e96

USD import textures option.

Added USD import option to copy textures which are
not on the local file system (e.g., textures in USDZ
archives or those specified by custom URIs) to a
designated directory using the USD ArResolver.

===

M   source/blender/editors/io/io_usd.c
M   source/blender/io/usd/intern/usd_asset_utils.cc
M   source/blender/io/usd/intern/usd_asset_utils.h
M   source/blender/io/usd/intern/usd_reader_material.cc
M   source/blender/io/usd/usd.h

===

diff --git a/source/blender/editors/io/io_usd.c 
b/source/blender/editors/io/io_usd.c
index 313e2488ace..131e86af1df 100644
--- a/source/blender/editors/io/io_usd.c
+++ b/source/blender/editors/io/io_usd.c
@@ -1103,6 +1103,13 @@ static int wm_usd_import_exec(bContext *C, wmOperator 
*op)
 
   const bool validate_meshes = RNA_boolean_get(op->ptr, "validate_meshes");
 
+  const bool import_textures = RNA_boolean_get(op->ptr, "import_textures");
+
+  char import_textures_dir[FILE_MAX];
+  RNA_string_get(op->ptr, "import_textures_dir", import_textures_dir);
+
+  const bool overwrite_textures = RNA_boolean_get(op->ptr, 
"overwrite_textures");
+
   /* TODO(makowalski): Add support for sequences. */
   const bool is_sequence = false;
   int offset = 0;
@@ -1147,9 +1154,12 @@ static int wm_usd_import_exec(bContext *C, wmOperator 
*op)
.create_background_shader = 
create_background_shader,
.mtl_name_collision_mode = 
mtl_name_collision_mode,
.attr_import_mode = attr_import_mode,
-   .import_shapes = import_shapes};
+   .import_shapes = import_shapes,
+   .import_textures = import_textures,
+   .overwrite_textures = overwrite_textures};
 
   STRNCPY(params.prim_path_mask, prim_path_mask);
+  STRNCPY(params.import_textures_dir, import_textures_dir);
 
   const bool ok = USD_import(C, filename, ¶ms, as_background_job);
 
@@ -1221,6 +1231,16 @@ static void wm_usd_import_draw(bContext *UNUSED(C), 
wmOperator *op)
   row = uiLayoutRow(col, true);
   uiItemR(row, ptr, "set_material_blend", 0, NULL, ICON_NONE);
   uiLayoutSetEnabled(row, import_mtls);
+  col = uiLayoutColumn(box, true);
+  uiItemR(col, ptr, "import_textures", 0, NULL, ICON_NONE);
+  bool import_textures = RNA_boolean_get(ptr, "import_textures");
+  row = uiLayoutRow(col, true);
+  uiItemR(row, ptr, "import_textures_dir", 0, NULL, ICON_NONE);
+  uiLayoutSetEnabled(row, import_textures);
+  row = uiLayoutRow(col, true);
+  uiItemR(row, ptr, "overwrite_textures", 0, NULL, ICON_NONE);
+  uiLayoutSetEnabled(row, import_textures);
+  uiLayoutSetEnabled(col, import_mtls);
 }
 
 void WM_OT_usd_import(struct wmOperatorType *ot)
@@ -1407,6 +1427,27 @@ void WM_OT_usd_import(struct wmOperatorType *ot)
   false,
   "Validate Meshes",
   "Validate meshes for degenerate geometry on import");
+
+   RNA_def_boolean(ot->srna,
+  "import_textures",
+  false,
+  "Import Textures",
+  "Copy textures which not on the local file system "
+  "(e.g., textures in USDZ archives or referenced by custom 
URIs) "
+  "to the directory given by the Import Textures Directory 
option");
+
+  RNA_def_string(ot->srna,
+  "import_textures_dir",
+  "//textures/",
+  FILE_MAX,
+  "Textures Directory",
+  "Path to the directory where imported textures will be 
copied");
+
+  RNA_def_boolean(ot->srna,
+  "overwrite_textures",
+  false,
+  "Overwrite Textures",
+  "Allow overwriting existing files when copying imported 
textures");
 }
 
 #endif /* WITH_USD */
diff --git a/source/blender/io/usd/intern/usd_asset_utils.cc 
b/source/blender/io/usd/intern/usd_asset_utils.cc
index c2aa0d142ab..ec97d0d2b2d 100644
--- a/source/blender/io/usd/intern/usd_asset_utils.cc
+++ b/source/blender/io/usd/intern/usd_asset_utils.cc
@@ -4,9 +4,13 @@
 #include "usd_asset_utils.h"
 
 #include 
+#include 
 #include 
 #include 
 
+#include "BKE_main.h"
+
+#include "BLI_fileops.h"
 #include "BLI_path_util.h"
 #include "BLI_string.h"
 
@@ -15,8 +19,128 @@
 
 #include 
 
+static const char UDIM_PATTERN[] = "";
+static const char UDIM_PATTERN2[] = "%3CUDIM%3E";
+static const int UDIM_START_TILE = 1001;
+static const int UDIM_END_TILE = 1100;
+
 namespace blender::io::usd {
 
+static std::string g

[Bf-blender-cvs] [396a8b8ad81] tmp-dynamic-usd: USD import: import textures for UMM.

2022-11-28 Thread Michael Kowalski
Commit: 396a8b8ad81a1cbf5aeb6c30ac73bf9a6b1dd601
Author: Michael Kowalski
Date:   Mon Nov 28 19:14:45 2022 -0500
Branches: tmp-dynamic-usd
https://developer.blender.org/rB396a8b8ad81a1cbf5aeb6c30ac73bf9a6b1dd601

USD import: import textures for UMM.

Added logic to support importing textures when invoking
UMM shader conversion.

===

M   source/blender/io/usd/intern/usd_asset_utils.h
M   source/blender/io/usd/intern/usd_reader_material.cc
M   source/blender/io/usd/intern/usd_umm.cc
M   source/blender/io/usd/intern/usd_umm.h

===

diff --git a/source/blender/io/usd/intern/usd_asset_utils.h 
b/source/blender/io/usd/intern/usd_asset_utils.h
index 683047254d2..e3bc7dd7fc9 100644
--- a/source/blender/io/usd/intern/usd_asset_utils.h
+++ b/source/blender/io/usd/intern/usd_asset_utils.h
@@ -19,6 +19,6 @@ namespace blender::io::usd {
 
   bool usd_paths_equal(const char *p1, const char *p2);
 
-  std::string usd_import_texture(const char *src, const char *basepath, bool 
overwrite);
+  std::string usd_import_texture(const char *src, const char 
*import_textures_dir, bool overwrite);
 
 }  // namespace blender::io::usd
diff --git a/source/blender/io/usd/intern/usd_reader_material.cc 
b/source/blender/io/usd/intern/usd_reader_material.cc
index c1e1e393617..93d2a6336e3 100644
--- a/source/blender/io/usd/intern/usd_reader_material.cc
+++ b/source/blender/io/usd/intern/usd_reader_material.cc
@@ -390,7 +390,7 @@ Material *USDMaterialReader::add_material(const 
pxr::UsdShadeMaterial &usd_mater
 bool has_mdl = false;
 #ifdef WITH_PYTHON
 /* Invoke UMM to convert to MDL. */
-bool mdl_imported = umm_import_mdl_material(mtl, usd_material, true /* 
Verbose */, &has_mdl);
+bool mdl_imported = umm_import_mdl_material(params_, mtl, usd_material, 
true /* Verbose */, &has_mdl);
 #endif
 if (!(has_mdl && mdl_imported) && usd_preview) {
   /* The material has no MDL shader or we couldn't convert the MDL,
diff --git a/source/blender/io/usd/intern/usd_umm.cc 
b/source/blender/io/usd/intern/usd_umm.cc
index c648c2f2c23..1fc0f146ab2 100644
--- a/source/blender/io/usd/intern/usd_umm.cc
+++ b/source/blender/io/usd/intern/usd_umm.cc
@@ -19,6 +19,7 @@
 
 #  include "usd_umm.h"
 #  include "usd.h"
+#  include "usd_asset_utils.h"
 #  include "usd_exporter_context.h"
 #  include "usd_writer_material.h"
 
@@ -380,7 +381,8 @@ static void test_python()
   PyGILState_Release(gilstate);
 }
 
-static PyObject *get_shader_source_data(const pxr::UsdShadeShader &usd_shader)
+static PyObject *get_shader_source_data(const USDImportParams ¶ms,
+const pxr::UsdShadeShader &usd_shader)
 {
   if (!usd_shader) {
 return nullptr;
@@ -463,6 +465,11 @@ static PyObject *get_shader_source_data(const 
pxr::UsdShadeShader &usd_shader)
  asset_path.GetAssetPath());
   }
 
+  if (params.import_textures) {
+resolved_path = usd_import_texture(
+resolved_path.c_str(), params.import_textures_dir, 
params.overwrite_textures);
+  }
+
   pxr::TfToken color_space_tok = usd_attr.GetColorSpace();
 
   if (color_space_tok.IsEmpty() && have_connected_source) {
@@ -527,7 +534,8 @@ static PyObject *get_shader_source_data(const 
pxr::UsdShadeShader &usd_shader)
   return ret;
 }
 
-static bool import_material(Material *mtl,
+static bool import_material(const USDImportParams ¶ms,
+Material *mtl,
 const pxr::UsdShadeShader &usd_shader,
 const std::string &source_class)
 {
@@ -558,7 +566,7 @@ static bool import_material(Material *mtl,
 return false;
   }
 
-  PyObject *source_data = get_shader_source_data(usd_shader);
+  PyObject *source_data = get_shader_source_data(params, usd_shader);
 
   if (!source_data) {
 std::cout << "WARNING:  Couldn't get source data for shader " << 
usd_shader.GetPath()
@@ -747,7 +755,8 @@ bool umm_module_loaded()
   return loaded;
 }
 
-bool umm_import_mdl_material(Material *mtl,
+bool umm_import_mdl_material(const USDImportParams ¶ms,
+ Material *mtl,
  const pxr::UsdShadeMaterial &usd_material,
  bool verbose,
  bool *r_has_mdl)
@@ -796,7 +805,7 @@ bool umm_import_mdl_material(Material *mtl,
 }
 
 std::string source_class = path + "|" + 
source_asset_sub_identifier.GetString();
-return import_material(mtl, surf_shader, source_class);
+return import_material(params, mtl, surf_shader, source_class);
   }
 
   return false;
diff --git a/source/blender/io/usd/intern/usd_umm.h 
b/source/blender/io/usd/intern/usd_umm.h
index 718f54f53ab..af1d5e7c1b4 100644
--- a/source/blender/io/usd/intern/usd_umm.h
+++ b/source/blender/io/usd/intern/usd_umm.h
@@ -24,6 +

[Bf-blender-cvs] [e176dba6de0] tmp-dynamic-usd: USD: export in-memory textures through resolver.

2022-11-28 Thread Michael Kowalski
Commit: e176dba6de0579c161c251ce1fd5fee98516a5d2
Author: Michael Kowalski
Date:   Fri Nov 25 16:03:07 2022 -0500
Branches: tmp-dynamic-usd
https://developer.blender.org/rBe176dba6de0579c161c251ce1fd5fee98516a5d2

USD: export in-memory textures through resolver.

Also, added allow_overwrite paramter to export_textures().

===

M   source/blender/io/usd/intern/usd_writer_abstract.cc
M   source/blender/io/usd/intern/usd_writer_material.cc
M   source/blender/io/usd/intern/usd_writer_material.h

===

diff --git a/source/blender/io/usd/intern/usd_writer_abstract.cc 
b/source/blender/io/usd/intern/usd_writer_abstract.cc
index 70c3268d01d..57f8474f543 100644
--- a/source/blender/io/usd/intern/usd_writer_abstract.cc
+++ b/source/blender/io/usd/intern/usd_writer_abstract.cc
@@ -233,13 +233,13 @@ pxr::UsdShadeMaterial 
USDAbstractWriter::ensure_usd_material(const HierarchyCont
usd_material,
this->usd_export_context_.export_params);
 if (this->usd_export_context_.export_params.export_textures) {
-  export_textures(material, this->usd_export_context_.stage);
+  export_textures(material, this->usd_export_context_.stage, 
this->usd_export_context_.export_params.overwrite_textures);
 }
   }
   if (material->use_nodes && 
this->usd_export_context_.export_params.generate_mdl) {
 create_mdl_material(this->usd_export_context_, material, usd_material);
 if (this->usd_export_context_.export_params.export_textures) {
-  export_textures(material, this->usd_export_context_.stage);
+  export_textures(material, this->usd_export_context_.stage, 
this->usd_export_context_.export_params.overwrite_textures);
 }
   }
   if (material->use_nodes && 
this->usd_export_context_.export_params.generate_preview_surface) {
diff --git a/source/blender/io/usd/intern/usd_writer_material.cc 
b/source/blender/io/usd/intern/usd_writer_material.cc
index f9520151355..2677b72fa5d 100644
--- a/source/blender/io/usd/intern/usd_writer_material.cc
+++ b/source/blender/io/usd/intern/usd_writer_material.cc
@@ -7,6 +7,7 @@
 #include "usd_exporter_context.h"
 #include "usd_umm.h"
 
+#include "BKE_appdir.h"
 #include "BKE_colorband.h"
 #include "BKE_colortools.h"
 #include "BKE_curve.h"
@@ -394,6 +395,7 @@ static void export_in_memory_texture(Image *ima,
  const std::string &export_dir,
  const bool allow_overwrite)
 {
+  printf("allow_overwrite %d\n", allow_overwrite);
   char image_abs_path[FILE_MAX];
 
   char file_name[FILE_MAX];
@@ -422,21 +424,39 @@ static void export_in_memory_texture(Image *ima,
 
   char export_path[FILE_MAX];
   BLI_path_join(export_path, FILE_MAX, export_dir.c_str(), file_name);
+  BLI_str_replace_char(export_path, '\\', '/');
 
-  if (!allow_overwrite && BLI_exists(export_path)) {
+  if (!allow_overwrite && usd_path_exists(export_path)) {
 return;
   }
 
-  if ((BLI_path_cmp_normalized(export_path, image_abs_path) == 0) && 
BLI_exists(image_abs_path)) {
+  if (usd_paths_equal(export_path, image_abs_path) && 
usd_path_exists(image_abs_path)) {
 /* As a precaution, don't overwrite the original path. */
 return;
   }
 
   std::cout << "Exporting in-memory texture to " << export_path << std::endl;
 
-  if (BKE_imbuf_write_as(imbuf, export_path, &imageFormat, true) == 0) {
-WM_reportf(RPT_WARNING, "USD export: couldn't export in-memory texture to 
%s", export_path);
+  /* We save the image to a temporary location on disk before copying
+   * it to its final destination. */
+  char temp_filepath[FILE_MAX];
+  BLI_path_join(temp_filepath, FILE_MAX, BKE_tempdir_session(), file_name);
+  BLI_str_replace_char(export_path, '\\', '/');
+
+  std::cout << "Saving in-memory texture to temporary location " << 
temp_filepath << std::endl;
+
+  if (BKE_imbuf_write_as(imbuf, temp_filepath, &imageFormat, true) == 0) {
+WM_reportf(RPT_WARNING, "USD export: couldn't save in-memory texture to 
temporary location %s", temp_filepath);
   }
+
+  /* Copy to destination. */
+  if (!copy_usd_asset(temp_filepath, export_path, allow_overwrite)) {
+WM_reportf(RPT_WARNING,
+   "USD export: couldn't export in-memory texture to %s",
+   temp_filepath);
+  }
+
+  BLI_delete(temp_filepath, false, false);
 }
 
 /* Get the absolute filepath of the given image.  Assumes
@@ -2404,7 +2424,7 @@ void export_texture(bNode *node,
 
 
 /* Export the texture of every texture image node in the given material's node 
tree. */
-void export_textures(const Material *material, const pxr::UsdStageRefPtr stage)
+void export_textures(const Material *material, const pxr::UsdStageRefPtr 
stage, const bool allow_overwrite)
 {
   if (!(material && material->use_nodes)) {
 return;
@@ -2416,7 +2436,7 @@ void export_textures(const Material *

[Bf-blender-cvs] [35c7e74af9e] tmp-dynamic-usd: Merge branch 'tmp-vfx-platform-2023' into tmp-dynamic-usd

2022-11-28 Thread Michael Kowalski
Commit: 35c7e74af9e794e95a10085b0dac6e4052f6ddcd
Author: Michael Kowalski
Date:   Mon Nov 28 18:32:32 2022 -0500
Branches: tmp-dynamic-usd
https://developer.blender.org/rB35c7e74af9e794e95a10085b0dac6e4052f6ddcd

Merge branch 'tmp-vfx-platform-2023' into tmp-dynamic-usd

===



===



___
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] [bb8433f76aa] tmp-dynamic-usd: USD export: copy UDIM textures with resolver.

2022-11-28 Thread Michael Kowalski
Commit: bb8433f76aa7f7abcdfc98645d03a28532a820f3
Author: Michael Kowalski
Date:   Tue Nov 15 19:42:08 2022 -0500
Branches: tmp-dynamic-usd
https://developer.blender.org/rBbb8433f76aa7f7abcdfc98645d03a28532a820f3

USD export: copy UDIM textures with resolver.

===

M   source/blender/io/usd/intern/usd_writer_material.cc

===

diff --git a/source/blender/io/usd/intern/usd_writer_material.cc 
b/source/blender/io/usd/intern/usd_writer_material.cc
index a471a9bad57..f9520151355 100644
--- a/source/blender/io/usd/intern/usd_writer_material.cc
+++ b/source/blender/io/usd/intern/usd_writer_material.cc
@@ -2322,21 +2322,19 @@ static void copy_tiled_textures(Image *ima,
 
 char dest_tile_path[FILE_MAX];
 BLI_path_join(dest_tile_path, FILE_MAX, dest_dir.c_str(), dest_filename);
+BLI_str_replace_char(dest_tile_path, SEP, ALTSEP);
 
-if (!allow_overwrite && BLI_exists(dest_tile_path)) {
+if (!allow_overwrite && usd_path_exists(dest_tile_path)) {
   continue;
 }
 
-if (BLI_path_cmp_normalized(src_tile_path, dest_tile_path) == 0) {
+if (usd_paths_equal(src_tile_path, dest_tile_path)) {
   /* Source and destination paths are the same, don't copy. */
   continue;
 }
 
-std::cout << "Copying texture tile from " << src_tile_path << " to " << 
dest_tile_path
-  << std::endl;
-
 /* Copy the file. */
-if (BLI_copy(src_tile_path, dest_tile_path) != 0) {
+if (!copy_usd_asset(src_tile_path, dest_tile_path, allow_overwrite)) {
   WM_reportf(RPT_WARNING,
  "USD export:  couldn't copy texture tile from %s to %s",
  src_tile_path,

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


[Bf-blender-cvs] [19a7c7f4e17] tmp-dynamic-usd: USD export: added get_textures_dir() utility.

2022-11-28 Thread Michael Kowalski
Commit: 19a7c7f4e17ea7deb547e8122b336a576fb276d1
Author: Michael Kowalski
Date:   Mon Nov 14 20:55:20 2022 -0500
Branches: tmp-dynamic-usd
https://developer.blender.org/rB19a7c7f4e17ea7deb547e8122b336a576fb276d1

USD export: added get_textures_dir() utility.

===

M   source/blender/io/usd/intern/usd_asset_utils.cc
M   source/blender/io/usd/intern/usd_asset_utils.h
M   source/blender/io/usd/intern/usd_writer_material.cc

===

diff --git a/source/blender/io/usd/intern/usd_asset_utils.cc 
b/source/blender/io/usd/intern/usd_asset_utils.cc
index a01e8ae953f..85cbd4cc85b 100644
--- a/source/blender/io/usd/intern/usd_asset_utils.cc
+++ b/source/blender/io/usd/intern/usd_asset_utils.cc
@@ -7,6 +7,8 @@
 #include 
 #include 
 
+#include "BLI_path_util.h"
+
 #include "WM_api.h"
 #include "WM_types.h"
 
@@ -110,5 +112,18 @@ bool copy_usd_asset(const char *src, const char *dst, bool 
overwrite)
   return bytes_written > 0;
 }
 
+ std::string get_textures_dir(const pxr::UsdStageRefPtr stage)
+{
+   pxr::SdfLayerHandle layer = stage->GetRootLayer();
+   std::string stage_path = layer->GetRealPath();
+   if (stage_path.empty()) {
+ return "";
+   }
+
+   char usd_dir_path[FILE_MAX];
+   BLI_split_dir_part(stage_path.c_str(), usd_dir_path, FILE_MAX);
+
+   return std::string(usd_dir_path) + std::string("textures/");
+ }
 
 }  // namespace blender::io::usd
diff --git a/source/blender/io/usd/intern/usd_asset_utils.h 
b/source/blender/io/usd/intern/usd_asset_utils.h
index 1a4fe83c59d..aeefde3a859 100644
--- a/source/blender/io/usd/intern/usd_asset_utils.h
+++ b/source/blender/io/usd/intern/usd_asset_utils.h
@@ -2,9 +2,17 @@
  * Copyright 2021  NVIDIA Corporation. All rights reserved. */
 #pragma once
 
+#include 
+
+#include 
+
 namespace blender::io::usd {
 
   /* Invoke the the USD asset resolver to copy assets. */
   bool copy_usd_asset(const char *src, const char *dst, bool overwrite);
 
+  /* Return the path to a 'textures' directory which is a sibling to the given
+   * stage's root layer path. */
+  std::string get_textures_dir(const pxr::UsdStageRefPtr stage);
+
 }  // namespace blender::io::usd
diff --git a/source/blender/io/usd/intern/usd_writer_material.cc 
b/source/blender/io/usd/intern/usd_writer_material.cc
index 39d56e6cb44..52035df6f3e 100644
--- a/source/blender/io/usd/intern/usd_writer_material.cc
+++ b/source/blender/io/usd/intern/usd_writer_material.cc
@@ -3,6 +3,7 @@
 #include "usd_writer_material.h"
 
 #include "usd.h"
+#include "usd_asset_utils.h"
 #include "usd_exporter_context.h"
 #include "usd_umm.h"
 
@@ -2392,21 +2393,7 @@ void export_texture(bNode *node,
 return;
   }
 
-  pxr::SdfLayerHandle layer = stage->GetRootLayer();
-  std::string stage_path = layer->GetRealPath();
-  if (stage_path.empty()) {
-return;
-  }
-
-  char usd_dir_path[FILE_MAX];
-  BLI_split_dir_part(stage_path.c_str(), usd_dir_path, FILE_MAX);
-
-  char tex_dir_path[FILE_MAX];
-  BLI_path_join(tex_dir_path, FILE_MAX, usd_dir_path, "textures", SEP_STR);
-
-  BLI_dir_create_recursive(tex_dir_path);
-
-  std::string dest_dir(tex_dir_path);
+  std::string dest_dir = get_textures_dir(stage);
 
   if (is_in_memory_texture(ima)) {
 export_in_memory_texture(ima, dest_dir, allow_overwrite);

___
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] [b8e64404305] tmp-dynamic-usd: USD export: copy textures with asset resolver.

2022-11-28 Thread Michael Kowalski
Commit: b8e6440430580ff79ff97738989ecfa59c5c013b
Author: Michael Kowalski
Date:   Tue Nov 15 15:44:49 2022 -0500
Branches: tmp-dynamic-usd
https://developer.blender.org/rBb8e6440430580ff79ff97738989ecfa59c5c013b

USD export: copy textures with asset resolver.

Refactored the texture export code to copy the texture
by invoking the asset resolver.

===

M   source/blender/io/usd/intern/usd_asset_utils.cc
M   source/blender/io/usd/intern/usd_asset_utils.h
M   source/blender/io/usd/intern/usd_common.cc
M   source/blender/io/usd/intern/usd_writer_material.cc

===

diff --git a/source/blender/io/usd/intern/usd_asset_utils.cc 
b/source/blender/io/usd/intern/usd_asset_utils.cc
index 85cbd4cc85b..c2aa0d142ab 100644
--- a/source/blender/io/usd/intern/usd_asset_utils.cc
+++ b/source/blender/io/usd/intern/usd_asset_utils.cc
@@ -8,6 +8,7 @@
 #include 
 
 #include "BLI_path_util.h"
+#include "BLI_string.h"
 
 #include "WM_api.h"
 #include "WM_types.h"
@@ -126,4 +127,22 @@ bool copy_usd_asset(const char *src, const char *dst, bool 
overwrite)
return std::string(usd_dir_path) + std::string("textures/");
  }
 
+ bool usd_path_exists(const char *src)
+ {
+   return src && !pxr::ArGetResolver().Resolve(src).IsEmpty();
+ }
+
+ bool usd_paths_equal(const char *p1, const char *p2)
+ {
+   BLI_assert_msg(!BLI_path_is_rel(p1) && !BLI_path_is_rel(p2),
+  "Paths arguments must be absolute");
+
+   pxr::ArResolver &ar = pxr::ArGetResolver();
+
+   std::string resolved_p1 = ar.ResolveForNewAsset(p1).GetPathString();
+   std::string resolved_p2 = ar.ResolveForNewAsset(p2).GetPathString();
+
+   return resolved_p1 == resolved_p2;
+ }
+
 }  // namespace blender::io::usd
diff --git a/source/blender/io/usd/intern/usd_asset_utils.h 
b/source/blender/io/usd/intern/usd_asset_utils.h
index aeefde3a859..fecc1bc6572 100644
--- a/source/blender/io/usd/intern/usd_asset_utils.h
+++ b/source/blender/io/usd/intern/usd_asset_utils.h
@@ -15,4 +15,8 @@ namespace blender::io::usd {
* stage's root layer path. */
   std::string get_textures_dir(const pxr::UsdStageRefPtr stage);
 
+  bool usd_path_exists(const char *src);
+
+  bool usd_paths_equal(const char *p1, const char *p2);
+
 }  // namespace blender::io::usd
diff --git a/source/blender/io/usd/intern/usd_common.cc 
b/source/blender/io/usd/intern/usd_common.cc
index bdb4212ece9..4c0e7db90cb 100644
--- a/source/blender/io/usd/intern/usd_common.cc
+++ b/source/blender/io/usd/intern/usd_common.cc
@@ -57,6 +57,8 @@ void USD_path_abs(char *path, const char *basepath, bool 
for_import)
   if (!path_str.empty()) {
 if (path_str.length() < FILE_MAX) {
   BLI_strncpy(path, path_str.c_str(), FILE_MAX);
+  /* Use forward slash separators, which is standard for USD. */
+  BLI_str_replace_char(path, SEP, ALTSEP);
 }
 else {
   WM_reportf(RPT_ERROR,
diff --git a/source/blender/io/usd/intern/usd_writer_material.cc 
b/source/blender/io/usd/intern/usd_writer_material.cc
index 52035df6f3e..a471a9bad57 100644
--- a/source/blender/io/usd/intern/usd_writer_material.cc
+++ b/source/blender/io/usd/intern/usd_writer_material.cc
@@ -445,8 +445,7 @@ static void get_absolute_path(Image *ima, char *r_path)
 {
   /* Make absolute source path. */
   BLI_strncpy(r_path, ima->filepath, FILE_MAX);
-  BLI_path_abs(r_path, ID_BLEND_PATH_FROM_GLOBAL(&ima->id));
-  BLI_path_normalize(nullptr, r_path);
+  USD_path_abs(r_path, ID_BLEND_PATH_FROM_GLOBAL(&ima->id), false /* Not for 
import */);
 }
 
 /* = Functions copied from inacessible source file
@@ -2358,20 +2357,19 @@ static void copy_single_file(Image *ima, const 
std::string &dest_dir, const bool
 
   char dest_path[FILE_MAX];
   BLI_path_join(dest_path, FILE_MAX, dest_dir.c_str(), file_name);
+  BLI_str_replace_char(dest_path, SEP, ALTSEP);
 
-  if (!allow_overwrite && BLI_exists(dest_path)) {
+  if (!allow_overwrite && usd_path_exists(dest_path)) {
 return;
   }
 
-  if (BLI_path_cmp_normalized(source_path, dest_path) == 0) {
+  if (usd_paths_equal(source_path, dest_path)) {
 /* Source and destination paths are the same, don't copy. */
 return;
   }
 
-  std::cout << "Copying texture from " << source_path << " to " << dest_path 
<< std::endl;
-
   /* Copy the file. */
-  if (BLI_copy(source_path, dest_path) != 0) {
+  if (!copy_usd_asset(source_path, dest_path, allow_overwrite)) {
 WM_reportf(
 RPT_WARNING, "USD export:  couldn't copy texture from %s to %s", 
source_path, dest_path);
   }

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


[Bf-blender-cvs] [922e3ef4c23] tmp-dynamic-usd: USD IO: USD_path_abs() logic update.

2022-11-28 Thread Michael Kowalski
Commit: 922e3ef4c23c3776b68b928fd898755af28cb8c0
Author: Michael Kowalski
Date:   Mon Nov 14 12:07:10 2022 -0500
Branches: tmp-dynamic-usd
https://developer.blender.org/rB922e3ef4c23c3776b68b928fd898755af28cb8c0

USD IO: USD_path_abs() logic update.

For Blender relative paths that start with "//",
now also invoking the USD resolver on the absolute
path resolved by Blender.

===

M   source/blender/io/usd/intern/usd_common.cc

===

diff --git a/source/blender/io/usd/intern/usd_common.cc 
b/source/blender/io/usd/intern/usd_common.cc
index f8b1fd92918..bdb4212ece9 100644
--- a/source/blender/io/usd/intern/usd_common.cc
+++ b/source/blender/io/usd/intern/usd_common.cc
@@ -41,22 +41,27 @@ void ensure_usd_plugin_path_registered()
 
 void USD_path_abs(char *path, const char *basepath, bool for_import)
 {
-  if (!BLI_path_is_rel(path)) {
-pxr::ArResolvedPath resolved_path = for_import ? 
pxr::ArGetResolver().Resolve(path) :
- 
pxr::ArGetResolver().ResolveForNewAsset(path);
-
-std::string path_str = resolved_path.GetPathString();
-
-if (!path_str.empty()) {
-  if (path_str.length() < FILE_MAX) {
-BLI_strncpy(path, path_str.c_str(), FILE_MAX);
-return;
-  }
-  WM_reportf(RPT_ERROR, "In USD_path_abs: resolved path %s exceeds path 
buffer length.", path_str.c_str());
-}
+  if (BLI_path_is_rel(path)) {
+/* The path is relative to the .blend file, so use Blender's
+ * standard absolute path resolution. */
+BLI_path_abs(path, basepath);
+/* Use forward slash separators, which is standard for USD. */
+BLI_str_replace_char(path, SEP, ALTSEP);
   }
 
-  /* If we got here, the path couldn't be resolved by the ArResolver, so we
-   * fall back on the standard Blender absolute path resolution. */
-  BLI_path_abs(path, basepath);
+  pxr::ArResolvedPath resolved_path = for_import ? 
pxr::ArGetResolver().Resolve(path) :
+   
pxr::ArGetResolver().ResolveForNewAsset(path);
+
+  std::string path_str = resolved_path.GetPathString();
+
+  if (!path_str.empty()) {
+if (path_str.length() < FILE_MAX) {
+  BLI_strncpy(path, path_str.c_str(), FILE_MAX);
+}
+else {
+  WM_reportf(RPT_ERROR,
+ "USD_path_abs: resolved path %s exceeds path buffer length.",
+ path_str.c_str());
+}
+  }
 }

___
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] [4d9b898e0ec] tmp-dynamic-usd: USD IO: invoke resolver to write USDZ.

2022-11-28 Thread Michael Kowalski
Commit: 4d9b898e0ecf7303d3799a7703b203dc45bd9443
Author: Michael Kowalski
Date:   Fri Nov 11 14:35:03 2022 -0500
Branches: tmp-dynamic-usd
https://developer.blender.org/rB4d9b898e0ecf7303d3799a7703b203dc45bd9443

USD IO: invoke resolver to write USDZ.

Added new copy_usd_asset() function to invoke the USD
asset resolver to copy a file.  Updated the USDZ export
logic to use this function when copying the temporary
USDZ file to its final destination.

===

M   source/blender/io/usd/CMakeLists.txt
A   source/blender/io/usd/intern/usd_asset_utils.cc
A   source/blender/io/usd/intern/usd_asset_utils.h
M   source/blender/io/usd/intern/usd_capi_export.cc

===

diff --git a/source/blender/io/usd/CMakeLists.txt 
b/source/blender/io/usd/CMakeLists.txt
index 1cbec8c471f..7a7539089df 100644
--- a/source/blender/io/usd/CMakeLists.txt
+++ b/source/blender/io/usd/CMakeLists.txt
@@ -65,6 +65,7 @@ set(INC_SYS
 )
 
 set(SRC
+  intern/usd_asset_utils.cc
   intern/usd_capi_export.cc
   intern/usd_capi_import.cc
   intern/usd_common.cc
@@ -107,6 +108,7 @@ set(SRC
 
   usd.h
 
+  intern/usd_asset_utils.h
   intern/usd_common.h
   intern/usd_exporter_context.h
   intern/usd_hierarchy_iterator.h
diff --git a/source/blender/io/usd/intern/usd_asset_utils.cc 
b/source/blender/io/usd/intern/usd_asset_utils.cc
new file mode 100644
index 000..a01e8ae953f
--- /dev/null
+++ b/source/blender/io/usd/intern/usd_asset_utils.cc
@@ -0,0 +1,114 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later
+ * Copyright 2022 NVIDIA Corportation. All rights reserved. */
+
+#include "usd_asset_utils.h"
+
+#include 
+#include 
+#include 
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+#include 
+
+namespace blender::io::usd {
+
+bool copy_usd_asset(const char *src, const char *dst, bool overwrite)
+{
+  if (!(src && dst)) {
+return false;
+  }
+
+  pxr::ArResolver &ar = pxr::ArGetResolver();
+
+  if (!overwrite) {
+if (!ar.Resolve(dst).IsEmpty()) {
+  /* The asset exists, so this is a no-op. */
+  WM_reportf(RPT_INFO, "copy_usd_asset(): Will not overwrite existing 
asset %s", dst);
+  return true;
+}
+  }
+
+  pxr::ArResolvedPath src_path = ar.Resolve(src);
+
+  if (src_path.IsEmpty()) {
+WM_reportf(RPT_ERROR, "copy_usd_asset(): Can't resolve path %s.", src);
+return false;
+  }
+
+  pxr::ArResolvedPath dst_path = ar.ResolveForNewAsset(dst);
+
+  if (dst_path.IsEmpty()) {
+WM_reportf(RPT_ERROR, "copy_usd_asset(): Can't resolve path %s for 
writing.", dst);
+return false;
+  }
+
+  std::string why_not;
+  if (!ar.CanWriteAssetToPath(dst_path, &why_not)) {
+WM_reportf(RPT_ERROR,
+   "copy_usd_asset(): Can't write to asset %s.  %s.",
+   dst_path.GetPathString().c_str(),
+   why_not.c_str());
+return false;
+  }
+
+  std::shared_ptr src_asset = ar.OpenAsset(src_path);
+  if (!src_asset) {
+WM_reportf(
+RPT_ERROR, "copy_usd_asset(): Can't open source asset %s.", 
src_path.GetPathString().c_str());
+return false;
+  }
+
+  const size_t size = src_asset->GetSize();
+
+  if (size == 0) {
+WM_reportf(RPT_WARNING,
+   "copy_usd_asset(): Will not copy zero size source asset %s.",
+   src_path.GetPathString().c_str());
+return false;
+  }
+
+  std::shared_ptr buf = src_asset->GetBuffer();
+
+  if (!buf) {
+WM_reportf(RPT_ERROR,
+   "copy_usd_asset(): Null buffer for source asset %s.",
+   src_path.GetPathString().c_str());
+return false;
+  }
+
+  std::shared_ptr dst_asset = ar.OpenAssetForWrite(
+  dst_path, pxr::ArResolver::WriteMode::Replace);
+  if (!dst_asset) {
+WM_reportf(RPT_ERROR,
+   "copy_usd_asset(): Can't open destination asset %s for 
writing.",
+   src_path.GetPathString().c_str());
+return false;
+  }
+
+  size_t bytes_written = dst_asset->Write(src_asset->GetBuffer().get(), 
src_asset->GetSize(), 0);
+
+  if (bytes_written == 0) {
+WM_reportf(RPT_ERROR,
+   "copy_usd_asset(): Error writing to destination asset %s.",
+   dst_path.GetPathString().c_str());
+  }
+  else {
+WM_reportf(RPT_INFO,
+   "copy_usd_asset(): Copied %s to %s.",
+   src_path.GetPathString().c_str(), 
dst_path.GetPathString().c_str());
+  }
+
+  if (!dst_asset->Close()) {
+WM_reportf(RPT_ERROR,
+   "copy_usd_asset(): Couldn't close destination asset %s.",
+   dst_path.GetPathString().c_str());
+return false;
+  }
+
+  return bytes_written > 0;
+}
+
+
+}  // namespace blender::io::usd
diff --git a/source/blender/io/usd/intern/usd_asset_utils.h 
b/source/blender/io/usd/intern/usd_asset_utils.h
new file mode 100644
index 000..1a4fe83c59d
--- /dev/null
+++ b/source/blender/io/usd/intern/usd_asset_utils.h
@@ -0,0 +1,10 @@
+/* SPDX-License-Identifier: G

[Bf-blender-cvs] [b157d0b97e3] tmp-dynamic-usd: Merge branch 'universal-scene-description' of git.blender.org:blender into tmp-dynamic-usd

2022-11-28 Thread Michael Kowalski
Commit: b157d0b97e3b897fbe61a598798e9b116251bc9e
Author: Michael Kowalski
Date:   Fri Nov 11 14:37:36 2022 -0500
Branches: tmp-dynamic-usd
https://developer.blender.org/rBb157d0b97e3b897fbe61a598798e9b116251bc9e

Merge branch 'universal-scene-description' of git.blender.org:blender into 
tmp-dynamic-usd

===



===



___
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] [4ab6ee68ab0] tmp-dynamic-usd: USD IO: function to resolve USD paths.

2022-11-28 Thread Michael Kowalski
Commit: 4ab6ee68ab09635d4065fb25f6d26c896942a35a
Author: Michael Kowalski
Date:   Thu Nov 10 13:41:56 2022 -0500
Branches: tmp-dynamic-usd
https://developer.blender.org/rB4ab6ee68ab09635d4065fb25f6d26c896942a35a

USD IO: function to resolve USD paths.

Added USD_path_abs() funcion, which is similar to BLI_path_abs(),
but which also invokes the USD asset resolver to determine the
absolute path. This is necessary for resolving paths with URIs
that BLI_path_abs() would otherwise alter when attempting to
normalize the path. Now calling USD_path_abs() where needed
to resolve USD paths for import.

===

M   source/blender/blenkernel/intern/cachefile.c
M   source/blender/io/usd/intern/usd_capi_import.cc
M   source/blender/io/usd/intern/usd_common.cc
M   source/blender/io/usd/usd.h

===

diff --git a/source/blender/blenkernel/intern/cachefile.c 
b/source/blender/blenkernel/intern/cachefile.c
index 5968a6b7296..b81d2c90502 100644
--- a/source/blender/blenkernel/intern/cachefile.c
+++ b/source/blender/blenkernel/intern/cachefile.c
@@ -387,7 +387,17 @@ bool BKE_cachefile_filepath_get(const Main *bmain,
 char r_filepath[FILE_MAX])
 {
   BLI_strncpy(r_filepath, cache_file->filepath, FILE_MAX);
+
+#ifdef WITH_USD
+  if (BLI_path_extension_check_glob(r_filepath, "*.usd;*.usda;*.usdc;*.usdz")) 
{
+USD_path_abs(r_filepath, ID_BLEND_PATH(bmain, &cache_file->id), true /* 
for import */);
+  }
+  else {
+BLI_path_abs(r_filepath, ID_BLEND_PATH(bmain, &cache_file->id));
+  }
+#else
   BLI_path_abs(r_filepath, ID_BLEND_PATH(bmain, &cache_file->id));
+#endif
 
   int fframe;
   int frame_len;
diff --git a/source/blender/io/usd/intern/usd_capi_import.cc 
b/source/blender/io/usd/intern/usd_capi_import.cc
index ca518249c91..8e597550a51 100644
--- a/source/blender/io/usd/intern/usd_capi_import.cc
+++ b/source/blender/io/usd/intern/usd_capi_import.cc
@@ -369,7 +369,7 @@ static void import_startjob(void *customdata, bool *stop, 
bool *do_update, float
 data->view_layer, import_collection);
   }
 
-  BLI_path_abs(data->filepath, BKE_main_blendfile_path_from_global());
+  USD_path_abs(data->filepath, BKE_main_blendfile_path_from_global(), true);
 
   *data->do_update = true;
   *data->progress = 0.05f;
diff --git a/source/blender/io/usd/intern/usd_common.cc 
b/source/blender/io/usd/intern/usd_common.cc
index e5a83442140..f8b1fd92918 100644
--- a/source/blender/io/usd/intern/usd_common.cc
+++ b/source/blender/io/usd/intern/usd_common.cc
@@ -2,10 +2,17 @@
  * Copyright 2021 Blender Foundation. All rights reserved. */
 
 #include "usd_common.h"
+#include "usd.h"
 
+#include 
 #include 
 
 #include "BKE_appdir.h"
+#include "BLI_path_util.h"
+#include "BLI_string.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
 
 namespace blender::io::usd {
 
@@ -30,3 +37,26 @@ void ensure_usd_plugin_path_registered()
 }
 
 }  // namespace blender::io::usd
+
+
+void USD_path_abs(char *path, const char *basepath, bool for_import)
+{
+  if (!BLI_path_is_rel(path)) {
+pxr::ArResolvedPath resolved_path = for_import ? 
pxr::ArGetResolver().Resolve(path) :
+ 
pxr::ArGetResolver().ResolveForNewAsset(path);
+
+std::string path_str = resolved_path.GetPathString();
+
+if (!path_str.empty()) {
+  if (path_str.length() < FILE_MAX) {
+BLI_strncpy(path, path_str.c_str(), FILE_MAX);
+return;
+  }
+  WM_reportf(RPT_ERROR, "In USD_path_abs: resolved path %s exceeds path 
buffer length.", path_str.c_str());
+}
+  }
+
+  /* If we got here, the path couldn't be resolved by the ArResolver, so we
+   * fall back on the standard Blender absolute path resolution. */
+  BLI_path_abs(path, basepath);
+}
diff --git a/source/blender/io/usd/usd.h b/source/blender/io/usd/usd.h
index 0d2077d3f13..1be7e5fb58f 100644
--- a/source/blender/io/usd/usd.h
+++ b/source/blender/io/usd/usd.h
@@ -203,6 +203,12 @@ bool USD_umm_module_loaded(void);
 
 /* USD Import and Mesh Cache interface. */
 
+/* Similar to BLI_path_abs(), but also invokes the USD asset resolver
+ * to determine the absolute path. This is necessary for resolving
+ * paths with URIs that BLI_path_abs() would otherwise alter when
+ * attempting to normalize the path. */
+void USD_path_abs(char *path, const char *basepath, bool for_import);
+
 struct CacheArchiveHandle *USD_create_handle(struct Main *bmain,
  const char *filepath,
  struct ListBase *object_paths);

___
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] [d51212c4f05] temp-asset-library-all: Integrate "All" library better with the asset system

2022-11-28 Thread Julian Eisel
Commit: d51212c4f05e38851580f7e9e75d174695dc1b82
Author: Julian Eisel
Date:   Mon Nov 28 19:37:00 2022 +0100
Branches: temp-asset-library-all
https://developer.blender.org/rBd51212c4f05e38851580f7e9e75d174695dc1b82

Integrate "All" library better with the asset system

Now it actually loads data from all asset libraries when this is
selected. The asset representations still need to be loaded by the file
browser backend, this won't change for now.

This adds the concept of nested asset libraries, which I'd prefer to
keep as implementation detail and not expose in the API. But for now
it's needed (for the asset representation loading by the file browser
backend).

===

M   source/blender/asset_system/AS_asset_library.hh
M   source/blender/asset_system/CMakeLists.txt
M   source/blender/asset_system/intern/asset_library.cc
M   source/blender/asset_system/intern/asset_library_service.cc
M   source/blender/asset_system/intern/asset_library_service.hh
A   source/blender/asset_system/intern/utils.cc
A   source/blender/asset_system/intern/utils.hh
M   source/blender/editors/space_file/filelist.cc

===

diff --git a/source/blender/asset_system/AS_asset_library.hh 
b/source/blender/asset_system/AS_asset_library.hh
index ece3426731c..3bbed9603a5 100644
--- a/source/blender/asset_system/AS_asset_library.hh
+++ b/source/blender/asset_system/AS_asset_library.hh
@@ -34,7 +34,9 @@ class AssetStorage;
  * to also include asset indexes and more.
  */
 class AssetLibrary {
-  bCallbackFuncStore on_save_callback_store_{};
+  /** If this is an asset library on disk, the top-level directory path. 
Normalized using
+   * #normalize_directory_path().*/
+  std::string root_path_;
 
   /** Storage for assets (better said their representations) that are 
considered to be part of this
* library. Assets are not automatically loaded into this when loading an 
asset library. Assets
@@ -51,6 +53,12 @@ class AssetLibrary {
*/
   std::unique_ptr asset_storage_;
 
+  /** In some cases an asset library is a combination of multiple other ones, 
these are then
+   * referenced here. "All" asset library only currently. */
+  Vector nested_libs_; /* Non-owning pointers. */
+
+  bCallbackFuncStore on_save_callback_store_{};
+
  public:
   /* Controlled by #ED_asset_catalogs_set_save_catalogs_when_file_is_saved,
* for managing the "Save Catalog Changes" in the quit-confirmation dialog 
box. */
@@ -58,11 +66,16 @@ class AssetLibrary {
 
   std::unique_ptr catalog_service;
 
+  friend class AssetLibraryService;
+
  public:
-  AssetLibrary();
+  /**
+   * \param root_path: If this is an asset library on disk, the top-level 
directory path.
+   */
+  AssetLibrary(StringRef root_path = "");
   ~AssetLibrary();
 
-  void load_catalogs(StringRefNull library_root_directory);
+  void load_catalogs();
 
   /** Load catalogs that have changed on disk. */
   void refresh();
@@ -85,6 +98,11 @@ class AssetLibrary {
* case when the reference is dangling). */
   bool remove_asset(AssetRepresentation &asset);
 
+  /** In some cases an asset library is a combination of multiple other ones 
("All" asset library
+   * only currently). Iterate over the contained asset libraries, executing \a 
fn for each of them.
+   */
+  void foreach_nested(FunctionRef fn);
+
   /**
* Remap ID pointers for local ID assets, see #BKE_lib_remap.h. When an ID 
pointer would be
* mapped to null (typically when an ID gets removed), the asset is removed, 
because we don't
@@ -105,6 +123,8 @@ class AssetLibrary {
 
   void on_blend_save_post(Main *bmain, PointerRNA **pointers, int 
num_pointers);
 
+  StringRefNull root_path() const;
+
  private:
   std::optional find_asset_index(const AssetRepresentation &asset);
 };
diff --git a/source/blender/asset_system/CMakeLists.txt 
b/source/blender/asset_system/CMakeLists.txt
index d00c3c72e3b..c9ef11d33f4 100644
--- a/source/blender/asset_system/CMakeLists.txt
+++ b/source/blender/asset_system/CMakeLists.txt
@@ -21,6 +21,7 @@ set(SRC
   intern/asset_library_service.cc
   intern/asset_representation.cc
   intern/asset_storage.cc
+  intern/utils.cc
 
   AS_asset_catalog.hh
   AS_asset_catalog_path.hh
@@ -29,6 +30,7 @@ set(SRC
   AS_asset_representation.hh
   intern/asset_library_service.hh
   intern/asset_storage.hh
+  intern/utils.hh
 
   AS_asset_library.h
   AS_asset_representation.h
diff --git a/source/blender/asset_system/intern/asset_library.cc 
b/source/blender/asset_system/intern/asset_library.cc
index eebbc8db837..79c3c55029c 100644
--- a/source/blender/asset_system/intern/asset_library.cc
+++ b/source/blender/asset_system/intern/asset_library.cc
@@ -22,6 +22,7 @@
 
 #include "asset_library_service.hh"
 #include "asset_storage.hh"
+#include "utils.hh"
 
 using namespace blender;
 using namespace blender::asset_system;
@@ -126,8 +127,9 @@ void AS_asset_l

[Bf-blender-cvs] [3d1594417b0] master: UV: support constrain-to-bounds for uv shear operator

2022-11-28 Thread Chris Blackbourn
Commit: 3d1594417b0ee8608230ad4941eccdc57271ec60
Author: Chris Blackbourn
Date:   Tue Nov 29 12:02:41 2022 +1300
Branches: master
https://developer.blender.org/rB3d1594417b0ee8608230ad4941eccdc57271ec60

UV: support constrain-to-bounds for uv shear operator

For uv rotation operator, see rBd527aa4dd53d4.

===

M   source/blender/editors/transform/transform_mode_shear.c

===

diff --git a/source/blender/editors/transform/transform_mode_shear.c 
b/source/blender/editors/transform/transform_mode_shear.c
index 68fe9f35965..d419916ee4c 100644
--- a/source/blender/editors/transform/transform_mode_shear.c
+++ b/source/blender/editors/transform/transform_mode_shear.c
@@ -175,53 +175,28 @@ static eRedrawFlag handleEventShear(TransInfo *t, const 
wmEvent *event)
   return status;
 }
 
-static void applyShear(TransInfo *t, const int UNUSED(mval[2]))
+static void apply_shear_value(TransInfo *t, const float value)
 {
-  float smat[3][3], axismat[3][3], axismat_inv[3][3], mat_final[3][3];
-  float value;
-  int i;
-  char str[UI_MAX_DRAW_STR];
-  const bool is_local_center = transdata_check_local_center(t, t->around);
-
-  value = t->values[0] + t->values_modal_offset[0];
-
-  transform_snap_increment(t, &value);
-
-  applyNumInput(&t->num, &value);
-
-  t->values_final[0] = value;
-
-  /* header print for NumInput */
-  if (hasNumInput(&t->num)) {
-char c[NUM_STR_REP_LEN];
-
-outputNumInput(&(t->num), c, &t->scene->unit);
-
-BLI_snprintf(str, sizeof(str), TIP_("Shear: %s %s"), c, t->proptext);
-  }
-  else {
-/* default header print */
-BLI_snprintf(str,
- sizeof(str),
- TIP_("Shear: %.3f %s (Press X or Y to set shear axis)"),
- value,
- t->proptext);
-  }
-
+  float smat[3][3];
   unit_m3(smat);
   smat[1][0] = value;
 
+  float axismat_inv[3][3];
   copy_v3_v3(axismat_inv[0], t->spacemtx[t->orient_axis_ortho]);
   copy_v3_v3(axismat_inv[2], t->spacemtx[t->orient_axis]);
   cross_v3_v3v3(axismat_inv[1], axismat_inv[0], axismat_inv[2]);
+  float axismat[3][3];
   invert_m3_m3(axismat, axismat_inv);
 
+  float mat_final[3][3];
   mul_m3_series(mat_final, axismat_inv, smat, axismat);
 
+  const bool is_local_center = transdata_check_local_center(t, t->around);
+
   FOREACH_TRANS_DATA_CONTAINER (t, tc) {
 if (tc->data_len < TRANSDATA_THREAD_LIMIT) {
   TransData *td = tc->data;
-  for (i = 0; i < tc->data_len; i++, td++) {
+  for (int i = 0; i < tc->data_len; i++, td++) {
 if (td->flag & TD_SKIP) {
   continue;
 }
@@ -241,16 +216,117 @@ static void applyShear(TransInfo *t, const int 
UNUSED(mval[2]))
   BLI_task_parallel_range(0, tc->data_len, &data, transdata_elem_shear_fn, 
&settings);
 }
   }
+}
+
+static bool uv_shear_in_clip_bounds_test(const TransInfo *t, const float value)
+{
+  const int axis = t->orient_axis_ortho;
+  if (axis < 0 || 1 < axis) {
+return true; /* Non standard axis, nothing to do. */
+  }
+  const float *center = t->center_global;
+  FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+TransData *td = tc->data;
+for (int i = 0; i < tc->data_len; i++, td++) {
+  if (td->flag & TD_SKIP) {
+continue;
+  }
+  if (td->factor < 1.0f) {
+continue; /* Proportional edit, will get picked up in next phase. */
+  }
+
+  float uv[2];
+  sub_v2_v2v2(uv, td->iloc, center);
+  uv[axis] = uv[axis] + value * uv[1 - axis] * (2 * axis - 1);
+  add_v2_v2(uv, center);
+  /* TODO: udim support. */
+  if (uv[axis] < 0.0f || 1.0f < uv[axis]) {
+return false;
+  }
+}
+  }
+  return true;
+}
+
+static bool clip_uv_transform_shear(const TransInfo *t, float *vec, float 
*vec_inside_bounds)
+{
+  float value = vec[0];
+  if (uv_shear_in_clip_bounds_test(t, value)) {
+vec_inside_bounds[0] = value; /* Store for next iteration. */
+return false; /* Nothing to do. */
+  }
+  float value_inside_bounds = vec_inside_bounds[0];
+  if (!uv_shear_in_clip_bounds_test(t, value_inside_bounds)) {
+return false; /* No known way to fix, may as well shear anyway. */
+  }
+  const int max_i = 32; /* Limit iteration, mainly for debugging. */
+  for (int i = 0; i < max_i; i++) {
+/* Binary search. */
+const float value_mid = (value_inside_bounds + value) / 2.0f;
+if (value_mid == value_inside_bounds || value_mid == value) {
+  break; /* float precision reached. */
+}
+if (uv_shear_in_clip_bounds_test(t, value_mid)) {
+  value_inside_bounds = value_mid;
+}
+else {
+  value = value_mid;
+}
+  }
+
+  vec_inside_bounds[0] = value_inside_bounds; /* Store for next iteration. */
+  vec[0] = value_inside_bounds;   /* Update shear value. */
+  return true;
+}
+
+static void apply_shear(TransInfo *t, const int UNUSED(mval[2]))
+{
+  float value =

[Bf-blender-cvs] [01dcca4283f] gpencil-new-data-proposal: Change sorting of frames in frame array

2022-11-28 Thread Falk David
Commit: 01dcca4283f575d7d687f200fdd98f578cd51f07
Author: Falk David
Date:   Mon Nov 28 23:40:22 2022 +0100
Branches: gpencil-new-data-proposal
https://developer.blender.org/rB01dcca4283f575d7d687f200fdd98f578cd51f07

Change sorting of frames in frame array

This change makes it so that frames are sorted by the
layer index first, then by the frame number.
The benefit is that we can return an `IndexRange` now
when getting all the frames on one layer.

===

M   source/blender/blenkernel/intern/gpencil_new_proposal.cc
M   source/blender/blenkernel/intern/gpencil_new_proposal.hh
M   source/blender/blenkernel/intern/gpencil_new_proposal_test.cc

===

diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal.cc 
b/source/blender/blenkernel/intern/gpencil_new_proposal.cc
index bf9911b3638..e543fa7d47b 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal.cc
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal.cc
@@ -49,12 +49,6 @@ IndexMask GPLayerGroup::layers_index_mask()
   return {reinterpret_cast(this->layer_indices), 
this->layer_indices_size};
 }
 
-/* GPDataRuntime */
-IndexMask GPDataRuntime::frame_index_masks_cache_for_layer(int layer_index)
-{
-  return frame_index_masks_cache.lookup(layer_index).as_span();
-}
-
 /* GPStroke */
 Span GPStroke::points_positions() const
 {
@@ -140,15 +134,18 @@ GPFrame::~GPFrame()
 
 bool GPFrame::operator<(const GPFrameKey key) const
 {
-  if (this->start_time == key.start_time) {
-return this->layer_index < key.layer_index;
+  if (this->layer_index == key.layer_index) {
+return this->start_time < key.start_time;
   }
-  return this->start_time < key.start_time;
+  return this->layer_index < key.layer_index;
 }
 
 bool GPFrame::operator<(const GPFrame &other) const
 {
-  return *this < other.get_frame_key();
+  if (this->layer_index == other.layer_index) {
+return this->start_time < other.start_time;
+  }
+  return this->layer_index < other.layer_index;
 }
 
 bool GPFrame::operator==(const GPFrame &other) const
@@ -316,44 +313,54 @@ GPFrame &GPData::frames_for_write(int index)
   return this->frames_for_write()[index];
 }
 
-IndexMask GPData::frames_on_layer(int layer_index) const
+IndexRange GPData::frames_on_layer(int layer_index) const
 {
   if (layer_index < 0 || layer_index > this->layers_size) {
-return IndexMask();
+return {};
   }
 
   /* If the indices are cached for this layer, use the cache. */
-  if (this->runtime->frame_index_masks_cache.contains(layer_index)) {
-return this->runtime->frame_index_masks_cache_for_layer(layer_index);
+  if (this->runtime->frames_index_range_cache.contains(layer_index)) {
+return this->runtime->frames_index_range_cache_for_layer(layer_index);
   }
 
   /* A double checked lock. */
-  std::scoped_lock{this->runtime->frame_index_masks_cache_mutex};
-  if (this->runtime->frame_index_masks_cache.contains(layer_index)) {
-return this->runtime->frame_index_masks_cache_for_layer(layer_index);
-  }
-
-  Vector indices;
-  const IndexMask mask = index_mask_ops::find_indices_based_on_predicate(
-  IndexMask(this->frames_size), 1024, indices, [&](const int index) {
-return this->frames()[index].layer_index == layer_index;
-  });
+  std::scoped_lock{this->runtime->frames_index_range_cache_mutex};
+  if (this->runtime->frames_index_range_cache.contains(layer_index)) {
+return this->runtime->frames_index_range_cache_for_layer(layer_index);
+  }
+
+  auto it_lower = std::lower_bound(
+  this->frames().begin(),
+  this->frames().end(),
+  layer_index,
+  [](const GPFrame &frame, const int index) { return frame.layer_index < 
index; });
+  auto it_upper = std::upper_bound(
+  this->frames().begin(),
+  this->frames().end(),
+  layer_index,
+  [](const int index, const GPFrame &frame) { return frame.layer_index < 
index; });
+
+  /* Get the index of the first frame. */
+  int start_idx = std::distance(this->frames().begin(), it_lower);
+  /* Calculate size of the layer. */
+  int frames_size = std::distance(it_lower, it_upper);
 
   /* Cache the resulting index mask. */
-  this->runtime->frame_index_masks_cache.add(layer_index, std::move(indices));
-  return mask;
+  this->runtime->frames_index_range_cache.add(layer_index, {start_idx, 
frames_size});
+  return {start_idx, frames_size};
 }
 
-IndexMask GPData::frames_on_layer(GPLayer &layer) const
+IndexRange GPData::frames_on_layer(GPLayer &layer) const
 {
   int index = this->layers().first_index_try(layer);
   if (index == -1) {
-return IndexMask();
+return {};
   }
   return frames_on_layer(index);
 }
 
-IndexMask GPData::frames_on_active_layer() const
+IndexRange GPData::frames_on_active_layer() const
 {
   return frames_on_layer(this->active_layer_index);
 }
@@ -625,11 +632,11 @@ int GPData::add_frame_on_layer_initialized(int 
layer_i

[Bf-blender-cvs] [f4cf31aee1c] gpencil-new-data-proposal: Merge branch 'master' of git.blender.org:blender into gpencil-new-data-proposal

2022-11-28 Thread Falk David
Commit: f4cf31aee1cecfab05397f0f26f0a9fc126c
Author: Falk David
Date:   Mon Nov 28 23:40:54 2022 +0100
Branches: gpencil-new-data-proposal
https://developer.blender.org/rBf4cf31aee1cecfab05397f0f26f0a9fc126c

Merge branch 'master' of git.blender.org:blender into gpencil-new-data-proposal

===



===

diff --cc build_files/utils/make_bpy_wheel.py
index 81d267c6e10,a0ac1306dda..a0ac1306dda
mode 100644,100755..100644
--- a/build_files/utils/make_bpy_wheel.py
+++ b/build_files/utils/make_bpy_wheel.py

___
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] [56e2b9901da] gpencil-new-data-proposal: Use GPFrameKey instead of std::pair for frame ordering

2022-11-28 Thread Falk David
Commit: 56e2b9901dad54b1de5c6257ab5e82e481faf192
Author: Falk David
Date:   Mon Nov 28 22:17:12 2022 +0100
Branches: gpencil-new-data-proposal
https://developer.blender.org/rB56e2b9901dad54b1de5c6257ab5e82e481faf192

Use GPFrameKey instead of std::pair for frame ordering

===

M   source/blender/blenkernel/intern/gpencil_new_proposal.cc
M   source/blender/blenkernel/intern/gpencil_new_proposal.hh

===

diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal.cc 
b/source/blender/blenkernel/intern/gpencil_new_proposal.cc
index e424cd32d37..bf9911b3638 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal.cc
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal.cc
@@ -138,20 +138,17 @@ GPFrame::~GPFrame()
   this->strokes = nullptr;
 }
 
-bool GPFrame::operator<(const GPFrame &other) const
+bool GPFrame::operator<(const GPFrameKey key) const
 {
-  if (this->start_time == other.start_time) {
-return this->layer_index < other.layer_index;
+  if (this->start_time == key.start_time) {
+return this->layer_index < key.layer_index;
   }
-  return this->start_time < other.start_time;
+  return this->start_time < key.start_time;
 }
 
-bool GPFrame::operator<(const std::pair elem) const
+bool GPFrame::operator<(const GPFrame &other) const
 {
-  if (this->start_time == elem.second) {
-return this->layer_index < elem.first;
-  }
-  return this->start_time < elem.second;
+  return *this < other.get_frame_key();
 }
 
 bool GPFrame::operator==(const GPFrame &other) const
@@ -606,15 +603,14 @@ int GPData::add_frame_on_layer_initialized(int 
layer_index, int frame_start, int
 
   /* Check if the frame can be appended at the end. */
   if (this->frames_size == 0 || this->frames_size == reserved ||
-  this->frames(last_index) < std::pair(layer_index, 
frame_start)) {
+  this->frames(last_index) < new_frame.get_frame_key()) {
 this->frames_for_write(last_index + 1) = std::move(new_frame);
 return last_index + 1;
   }
 
   /* Look for the first frame that is equal or greater than the new frame. */
-  auto it = std::lower_bound(this->frames().begin(),
- this->frames().drop_back(reserved).end(),
- std::pair(layer_index, frame_start));
+  auto it = std::lower_bound(
+  this->frames().begin(), this->frames().drop_back(reserved).end(), 
new_frame.get_frame_key());
   /* Get the index of the frame. */
   int index = std::distance(this->frames().begin(), it);
   /* Move all the frames and make space at index. */
diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal.hh 
b/source/blender/blenkernel/intern/gpencil_new_proposal.hh
index c8414713353..ed859e83ad9 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal.hh
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal.hh
@@ -81,7 +81,7 @@ typedef struct GPFrame {
   CurvesGeometry *strokes;
 
   /**
-   * The frame flag (see `eGPFrameFlag`). 
+   * The frame flag (see `eGPFrameFlag`).
*/
   int flag;
 
@@ -219,6 +219,13 @@ class GPStroke {
 };
 
 class GPFrame : public ::GPFrame {
+
+  /** Structure that defines a key for a frame. Used for ordering/sorting. */
+  struct GPFrameKey {
+int layer_index;
+int start_time;
+  };
+
  public:
   GPFrame() : GPFrame(-1, -1)
   {
@@ -237,9 +244,8 @@ class GPFrame : public ::GPFrame {
 
   ~GPFrame();
 
+  bool operator<(const GPFrameKey key) const;
   bool operator<(const GPFrame &other) const;
-  /* Assumes that elem.first is the layer index and elem.second is the start 
time. */
-  bool operator<(const std::pair elem) const;
 
   bool operator==(const GPFrame &other) const;
 
@@ -250,6 +256,11 @@ class GPFrame : public ::GPFrame {
 
   Vector strokes_for_write();
   GPStroke add_new_stroke(int new_points_num);
+
+  constexpr GPFrameKey get_frame_key() const
+  {
+return {layer_index, start_time};
+  };
 };
 
 class GPLayer : public ::GPLayer {

___
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] [01a38c2be92] master: Fix T102827: 3D View header layout broken after C++ conversion

2022-11-28 Thread Hans Goudey
Commit: 01a38c2be92857207ae844be35cc515007696fb2
Author: Hans Goudey
Date:   Mon Nov 28 15:52:58 2022 -0600
Branches: master
https://developer.blender.org/rB01a38c2be92857207ae844be35cc515007696fb2

Fix T102827: 3D View header layout broken after C++ conversion

I missed this flag when removing designated initializers.

===

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

===

diff --git a/source/blender/editors/interface/interface_layout.cc 
b/source/blender/editors/interface/interface_layout.cc
index 7da849c2a60..3d8c934fa17 100644
--- a/source/blender/editors/interface/interface_layout.cc
+++ b/source/blender/editors/interface/interface_layout.cc
@@ -3199,6 +3199,7 @@ void uiItemPopoverPanel_ptr(
 Panel panel{};
 panel.type = pt;
 panel.layout = layout;
+panel.flag = PNL_POPOVER;
 pt->draw_header(C, &panel);
   }
   uiBut *but = ui_item_menu(

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


[Bf-blender-cvs] [6fdddae2b05] master: Fix T102804: Click & Drag on toggles no longer possible

2022-11-28 Thread Hans Goudey
Commit: 6fdddae2b05a72c2f58d64d14dead4885460c151
Author: Hans Goudey
Date:   Mon Nov 28 16:29:30 2022 -0600
Branches: master
https://developer.blender.org/rB6fdddae2b05a72c2f58d64d14dead4885460c151

Fix T102804: Click & Drag on toggles no longer possible

Typo in 136ea84d9a3791aafb8

===

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

===

diff --git a/source/blender/editors/interface/interface_handlers.cc 
b/source/blender/editors/interface/interface_handlers.cc
index fdecfb4ea60..21410a3b9fc 100644
--- a/source/blender/editors/interface/interface_handlers.cc
+++ b/source/blender/editors/interface/interface_handlers.cc
@@ -1629,8 +1629,8 @@ static bool ui_drag_toggle_set_xy_xy(
   bool changed = false;
 
   LISTBASE_FOREACH (uiBlock *, block, ®ion->uiblocks) {
-float xy_a_block[2] = {float(xy_src[0]), float(xy_src[0])};
-float xy_b_block[2] = {float(xy_dst[0]), float(xy_dst[0])};
+float xy_a_block[2] = {float(xy_src[0]), float(xy_src[1])};
+float xy_b_block[2] = {float(xy_dst[0]), float(xy_dst[1])};
 
 ui_window_to_block_fl(region, block, &xy_a_block[0], &xy_a_block[1]);
 ui_window_to_block_fl(region, block, &xy_b_block[0], &xy_b_block[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] [b9fca048fc6] soc-2022-many-lights-sampling: Fix bounding cone angle not covering the whole sphere

2022-11-28 Thread Weizhen Huang
Commit: b9fca048fc630874d35a9459685c9a6f12569aa1
Author: Weizhen Huang
Date:   Mon Nov 28 23:26:13 2022 +0100
Branches: soc-2022-many-lights-sampling
https://developer.blender.org/rBb9fca048fc630874d35a9459685c9a6f12569aa1

Fix bounding cone angle not covering the whole sphere

===

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

===

diff --git a/intern/cycles/kernel/light/tree.h 
b/intern/cycles/kernel/light/tree.h
index de3eff956bc..568ce51ce23 100644
--- a/intern/cycles/kernel/light/tree.h
+++ b/intern/cycles/kernel/light/tree.h
@@ -18,6 +18,11 @@ ccl_device float light_tree_cos_bounding_box_angle(const 
BoundingBox bbox,
const float3 P,
const float3 
point_to_centroid)
 {
+  if (P.x > bbox.min.x && P.y > bbox.min.y && P.z > bbox.min.z && P.x < 
bbox.max.x &&
+  P.y < bbox.max.y && P.z < bbox.max.z) {
+/* If P is inside the bbox, `theta_u` covers the whole sphere */
+return -1.0f;
+  }
   float cos_theta_u = 1.0f;
   /* Iterate through all 8 possible points of the bounding box. */
   for (int i = 0; i < 8; ++i) {
@@ -362,7 +367,7 @@ ccl_device void light_tree_node_importance(KernelGlobals kg,
 return;
   }
   point_to_centroid = -bcone.axis;
-  cos_theta_u = fmaxf(fast_cosf(bcone.theta_o), 0.0f);
+  cos_theta_u = fast_cosf(bcone.theta_o);
   distance = 1.0f;
 }
 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] [695eb4505cc] soc-2022-many-lights-sampling: Cleanup: use `packed_float3` instead of `float[3]`

2022-11-28 Thread Weizhen Huang
Commit: 695eb4505cc5bfe252c7a338cde6ebde32461401
Author: Weizhen Huang
Date:   Mon Nov 28 22:16:19 2022 +0100
Branches: soc-2022-many-lights-sampling
https://developer.blender.org/rB695eb4505cc5bfe252c7a338cde6ebde32461401

Cleanup: use `packed_float3` instead of `float[3]`

===

M   intern/cycles/kernel/light/area.h
M   intern/cycles/kernel/light/background.h
M   intern/cycles/kernel/light/distant.h
M   intern/cycles/kernel/light/point.h
M   intern/cycles/kernel/light/spot.h
M   intern/cycles/kernel/light/tree.h
M   intern/cycles/kernel/types.h
M   intern/cycles/scene/light.cpp
M   release/datafiles/locale
M   release/scripts/addons
M   release/scripts/addons_contrib
M   source/tools

===

diff --git a/intern/cycles/kernel/light/area.h 
b/intern/cycles/kernel/light/area.h
index 7d6f2a5bef9..f7c52db1692 100644
--- a/intern/cycles/kernel/light/area.h
+++ b/intern/cycles/kernel/light/area.h
@@ -162,13 +162,11 @@ ccl_device_inline bool area_light_sample(const ccl_global 
KernelLight *klight,
  const float3 P,
  ccl_private LightSample *ls)
 {
-  ls->P = make_float3(klight->co[0], klight->co[1], klight->co[2]);
+  ls->P = klight->co;
 
-  float3 extentu = make_float3(
-  klight->area.extentu[0], klight->area.extentu[1], 
klight->area.extentu[2]);
-  float3 extentv = make_float3(
-  klight->area.extentv[0], klight->area.extentv[1], 
klight->area.extentv[2]);
-  float3 Ng = make_float3(klight->area.dir[0], klight->area.dir[1], 
klight->area.dir[2]);
+  float3 extentu = klight->area.extentu;
+  float3 extentv = klight->area.extentv;
+  float3 Ng = klight->area.dir;
   float invarea = fabsf(klight->area.invarea);
   bool is_round = (klight->area.invarea < 0.0f);
 
@@ -256,18 +254,16 @@ ccl_device_inline bool area_light_intersect(const 
ccl_global KernelLight *klight
 return false;
   }
 
-  const float3 extentu = make_float3(
-  klight->area.extentu[0], klight->area.extentu[1], 
klight->area.extentu[2]);
-  const float3 extentv = make_float3(
-  klight->area.extentv[0], klight->area.extentv[1], 
klight->area.extentv[2]);
-  const float3 Ng = make_float3(klight->area.dir[0], klight->area.dir[1], 
klight->area.dir[2]);
+  const float3 extentu = klight->area.extentu;
+  const float3 extentv = klight->area.extentv;
+  const float3 Ng = klight->area.dir;
 
   /* One sided. */
   if (dot(ray->D, Ng) >= 0.0f) {
 return false;
   }
 
-  const float3 light_P = make_float3(klight->co[0], klight->co[1], 
klight->co[2]);
+  const float3 light_P = klight->co;
 
   float3 P;
   return ray_quad_intersect(
@@ -285,12 +281,10 @@ ccl_device_inline bool 
area_light_sample_from_intersection(
   /* area light */
   float invarea = fabsf(klight->area.invarea);
 
-  float3 extentu = make_float3(
-  klight->area.extentu[0], klight->area.extentu[1], 
klight->area.extentu[2]);
-  float3 extentv = make_float3(
-  klight->area.extentv[0], klight->area.extentv[1], 
klight->area.extentv[2]);
-  float3 Ng = make_float3(klight->area.dir[0], klight->area.dir[1], 
klight->area.dir[2]);
-  float3 light_P = make_float3(klight->co[0], klight->co[1], klight->co[2]);
+  float3 extentu = klight->area.extentu;
+  float3 extentv = klight->area.extentv;
+  float3 Ng = klight->area.dir;
+  float3 light_P = klight->co;
 
   ls->u = isect->u;
   ls->v = isect->v;
@@ -332,13 +326,11 @@ ccl_device_inline float area_light_tree_weight(const 
ccl_global KernelLight *kli
const float3 P,
const float3 N)
 {
-  float3 light_P = make_float3(klight->co[0], klight->co[1], klight->co[2]);
+  float3 light_P = klight->co;
 
-  float3 extentu = make_float3(
-  klight->area.extentu[0], klight->area.extentu[1], 
klight->area.extentu[2]);
-  float3 extentv = make_float3(
-  klight->area.extentv[0], klight->area.extentv[1], 
klight->area.extentv[2]);
-  float3 Ng = make_float3(klight->area.dir[0], klight->area.dir[1], 
klight->area.dir[2]);
+  float3 extentu = klight->area.extentu;
+  float3 extentv = klight->area.extentv;
+  float3 Ng = klight->area.dir;
   bool is_round = (klight->area.invarea < 0.0f);
 
   if (dot(light_P - P, Ng) > 0.0f) {
diff --git a/intern/cycles/kernel/light/background.h 
b/intern/cycles/kernel/light/background.h
index 3fc9e0776a4..95bd5d47f9f 100644
--- a/intern/cycles/kernel/light/background.h
+++ b/intern/cycles/kernel/light/background.h
@@ -134,8 +134,8 @@ ccl_device_inline bool 
background_portal_data_fetch_and_check_side(
   int portal = kernel_data.integrator.portal_offset + index;
   const ccl_global KernelLight *klight = &kernel_data_fetch(lights, portal);
 
-  *lightpos = make_float3(klight->co[0], klight->co[1], klight->co[2]);
-  *dir = make_float3(klight->a

[Bf-blender-cvs] [48143ab0015] blender-v3.4-release: Sculpt: Fix T102337: Null pointer error circle (tube) brush test code

2022-11-28 Thread Joseph Eagar
Commit: 48143ab00156f94687dc74701e13a07ebd8a
Author: Joseph Eagar
Date:   Mon Nov 28 13:07:50 2022 -0800
Branches: blender-v3.4-release
https://developer.blender.org/rB48143ab00156f94687dc74701e13a07ebd8a

Sculpt: Fix T102337: Null pointer error circle (tube) brush test code

===

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

===

diff --git a/source/blender/editors/sculpt_paint/sculpt.c 
b/source/blender/editors/sculpt_paint/sculpt.c
index 6a38ef8bc8c..aad86ffc2b1 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -1824,14 +1824,27 @@ SculptBrushTestFn 
SCULPT_brush_test_init_with_falloff_shape(SculptSession *ss,
 SculptBrushTest 
*test,
 char falloff_shape)
 {
+  if (!ss->cache && !ss->filter_cache) {
+falloff_shape = PAINT_FALLOFF_SHAPE_SPHERE;
+  }
+
   SCULPT_brush_test_init(ss, test);
   SculptBrushTestFn sculpt_brush_test_sq_fn;
   if (falloff_shape == PAINT_FALLOFF_SHAPE_SPHERE) {
 sculpt_brush_test_sq_fn = SCULPT_brush_test_sphere_sq;
   }
   else {
+float view_normal[3];
+
+if (ss->cache) {
+  copy_v3_v3(view_normal, ss->cache->view_normal);
+}
+else {
+  copy_v3_v3(view_normal, ss->filter_cache->view_normal);
+}
+
 /* PAINT_FALLOFF_SHAPE_TUBE */
-plane_from_point_normal_v3(test->plane_view, test->location, 
ss->cache->view_normal);
+plane_from_point_normal_v3(test->plane_view, test->location, view_normal);
 sculpt_brush_test_sq_fn = SCULPT_brush_test_circle_sq;
   }
   return sculpt_brush_test_sq_fn;

___
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] [2e1a479e290] blender-v3.4-release: Sculpt: fix T102664: Broken multires solid shading

2022-11-28 Thread Joseph Eagar
Commit: 2e1a479e290aa703b31bbc59439af63299fec82c
Author: Joseph Eagar
Date:   Mon Nov 28 12:35:20 2022 -0800
Branches: blender-v3.4-release
https://developer.blender.org/rB2e1a479e290aa703b31bbc59439af63299fec82c

Sculpt: fix T102664: Broken multires solid shading

Calculate quad normal directly instead of averaging
the vertex normals.

===

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

===

diff --git a/source/blender/draw/intern/draw_pbvh.cc 
b/source/blender/draw/intern/draw_pbvh.cc
index 6c504e63511..2a13072ce83 100644
--- a/source/blender/draw/intern/draw_pbvh.cc
+++ b/source/blender/draw/intern/draw_pbvh.cc
@@ -374,12 +374,13 @@ struct PBVHBatches {
 no = CCG_elem_no(&args->ccg_key, elems[0]);
   }
   else {
-for (int j = 0; j < 4; j++) {
-  no += CCG_elem_no(&args->ccg_key, elems[j]);
-}
+normal_quad_v3(no,
+   CCG_elem_co(&args->ccg_key, elems[3]),
+   CCG_elem_co(&args->ccg_key, elems[2]),
+   CCG_elem_co(&args->ccg_key, elems[1]),
+   CCG_elem_co(&args->ccg_key, elems[0]));
   }
 
-  normalize_v3(no);
   short sno[3];
 
   normal_float_to_short_v3(sno, no);

___
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] [b1cc2a48f2a] blender-v3.4-release: Sculpt: fix T102348: Don't fold area normal automasking into cache

2022-11-28 Thread Joseph Eagar
Commit: b1cc2a48f2a57d4020b562f7d428ca8ed553b451
Author: Joseph Eagar
Date:   Mon Nov 28 12:59:53 2022 -0800
Branches: blender-v3.4-release
https://developer.blender.org/rBb1cc2a48f2a57d4020b562f7d428ca8ed553b451

Sculpt: fix T102348: Don't fold area normal automasking into cache

Certain automasking modes build a factor cache.  Modes
that rely on the mirror symmetry pass should not fold into
this pass.

===

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

===

diff --git a/source/blender/editors/sculpt_paint/sculpt_automasking.cc 
b/source/blender/editors/sculpt_paint/sculpt_automasking.cc
index 211ff14c906..e490cb762fc 100644
--- a/source/blender/editors/sculpt_paint/sculpt_automasking.cc
+++ b/source/blender/editors/sculpt_paint/sculpt_automasking.cc
@@ -185,9 +185,8 @@ static bool SCULPT_automasking_needs_factors_cache(const 
Sculpt *sd, const Brush
 return true;
   }
 
-  if (automasking_flags &
-  (BRUSH_AUTOMASKING_BOUNDARY_EDGES | BRUSH_AUTOMASKING_BOUNDARY_FACE_SETS 
|
-   BRUSH_AUTOMASKING_BRUSH_NORMAL | BRUSH_AUTOMASKING_VIEW_NORMAL)) {
+  if (automasking_flags & (BRUSH_AUTOMASKING_BOUNDARY_EDGES |
+   BRUSH_AUTOMASKING_BOUNDARY_FACE_SETS | 
BRUSH_AUTOMASKING_VIEW_NORMAL)) {
 return brush && brush->automasking_boundary_edges_propagation_steps != 1;
   }
   return false;
@@ -507,6 +506,16 @@ float SCULPT_automasking_factor_get(AutomaskingCache 
*automasking,
 return 1.0f;
   }
 
+  float mask = 1.0f;
+
+  /* Since brush normal mode depends on the current mirror symmery pass
+   * it is not folded into the factor cache (when it exists).
+   */
+  if ((ss->cache || ss->filter_cache) &&
+  (automasking->settings.flags & BRUSH_AUTOMASKING_BRUSH_NORMAL)) {
+mask *= automasking_brush_normal_factor(automasking, ss, vert, 
automask_data);
+  }
+
   /* If the cache is initialized with valid info, use the cache. This is used 
when the
* automasking information can't be computed in real time per vertex and 
needs to be
* initialized for the whole mesh when the stroke starts. */
@@ -517,7 +526,7 @@ float SCULPT_automasking_factor_get(AutomaskingCache 
*automasking,
   factor *= sculpt_automasking_cavity_factor(automasking, ss, vert);
 }
 
-return factor;
+return factor * mask;
   }
 
   uchar stroke_id = ss->attrs.automasking_stroke_id ?
@@ -554,13 +563,6 @@ float SCULPT_automasking_factor_get(AutomaskingCache 
*automasking,
 }
   }
 
-  float mask = 1.0f;
-
-  if ((ss->cache || ss->filter_cache) &&
-  (automasking->settings.flags & BRUSH_AUTOMASKING_BRUSH_NORMAL)) {
-mask *= automasking_brush_normal_factor(automasking, ss, vert, 
automask_data);
-  }
-
   if ((ss->cache || ss->filter_cache) &&
   (automasking->settings.flags & BRUSH_AUTOMASKING_VIEW_NORMAL)) {
 mask *= automasking_view_normal_factor(automasking, ss, vert, 
automask_data);
@@ -782,9 +784,6 @@ static void 
sculpt_normal_occlusion_automasking_fill(AutomaskingCache *automaski
 
 float f = *(float *)SCULPT_vertex_attr_get(vertex, 
ss->attrs.automasking_factor);
 
-if (int(mode) & BRUSH_AUTOMASKING_BRUSH_NORMAL) {
-  f *= automasking_brush_normal_factor(automasking, ss, vertex, &nodedata);
-}
 if (int(mode) & BRUSH_AUTOMASKING_VIEW_NORMAL) {
   if (int(mode) & BRUSH_AUTOMASKING_VIEW_OCCLUSION) {
 f *= automasking_view_occlusion_factor(automasking, ss, vertex, -1, 
&nodedata);
@@ -940,8 +939,7 @@ AutomaskingCache *SCULPT_automasking_cache_init(Sculpt *sd, 
Brush *brush, Object
 
   /* Subtractive modes. */
   int normal_bits = sculpt_automasking_mode_effective_bits(sd, brush) &
-(BRUSH_AUTOMASKING_BRUSH_NORMAL | 
BRUSH_AUTOMASKING_VIEW_NORMAL |
- BRUSH_AUTOMASKING_VIEW_OCCLUSION);
+(BRUSH_AUTOMASKING_VIEW_NORMAL | 
BRUSH_AUTOMASKING_VIEW_OCCLUSION);
 
   if (normal_bits) {
 sculpt_normal_occlusion_automasking_fill(automasking, ob, 
(eAutomasking_flag)normal_bits);

___
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] [0ed4865fd03] master: Sculpt: Fix T102337: Null pointer error circle (tube) brush test code

2022-11-28 Thread Joseph Eagar
Commit: 0ed4865fd030ea169ab700843b06b747b06382be
Author: Joseph Eagar
Date:   Mon Nov 28 13:07:50 2022 -0800
Branches: master
https://developer.blender.org/rB0ed4865fd030ea169ab700843b06b747b06382be

Sculpt: Fix T102337: Null pointer error circle (tube) brush test code

===

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

===

diff --git a/source/blender/editors/sculpt_paint/sculpt.cc 
b/source/blender/editors/sculpt_paint/sculpt.cc
index e7dd7a92d3f..e1dac167a32 100644
--- a/source/blender/editors/sculpt_paint/sculpt.cc
+++ b/source/blender/editors/sculpt_paint/sculpt.cc
@@ -1832,14 +1832,27 @@ SculptBrushTestFn 
SCULPT_brush_test_init_with_falloff_shape(SculptSession *ss,
 SculptBrushTest 
*test,
 char falloff_shape)
 {
+  if (!ss->cache && !ss->filter_cache) {
+falloff_shape = PAINT_FALLOFF_SHAPE_SPHERE;
+  }
+
   SCULPT_brush_test_init(ss, test);
   SculptBrushTestFn sculpt_brush_test_sq_fn;
   if (falloff_shape == PAINT_FALLOFF_SHAPE_SPHERE) {
 sculpt_brush_test_sq_fn = SCULPT_brush_test_sphere_sq;
   }
   else {
+float view_normal[3];
+
+if (ss->cache) {
+  copy_v3_v3(view_normal, ss->cache->view_normal);
+}
+else {
+  copy_v3_v3(view_normal, ss->filter_cache->view_normal);
+}
+
 /* PAINT_FALLOFF_SHAPE_TUBE */
-plane_from_point_normal_v3(test->plane_view, test->location, 
ss->cache->view_normal);
+plane_from_point_normal_v3(test->plane_view, test->location, view_normal);
 sculpt_brush_test_sq_fn = SCULPT_brush_test_circle_sq;
   }
   return sculpt_brush_test_sq_fn;

___
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] [1fc5dc3bf38] master: Sculpt: fix T102664: Broken multires solid shading

2022-11-28 Thread Joseph Eagar
Commit: 1fc5dc3bf3827e0bec2fe70d557280497730dc5a
Author: Joseph Eagar
Date:   Mon Nov 28 12:35:20 2022 -0800
Branches: master
https://developer.blender.org/rB1fc5dc3bf3827e0bec2fe70d557280497730dc5a

Sculpt: fix T102664: Broken multires solid shading

Calculate quad normal directly instead of averaging
the vertex normals.

===

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

===

diff --git a/source/blender/draw/intern/draw_pbvh.cc 
b/source/blender/draw/intern/draw_pbvh.cc
index 39d493003c2..cac3e3339fc 100644
--- a/source/blender/draw/intern/draw_pbvh.cc
+++ b/source/blender/draw/intern/draw_pbvh.cc
@@ -375,12 +375,13 @@ struct PBVHBatches {
 no = CCG_elem_no(&args->ccg_key, elems[0]);
   }
   else {
-for (int j = 0; j < 4; j++) {
-  no += CCG_elem_no(&args->ccg_key, elems[j]);
-}
+normal_quad_v3(no,
+   CCG_elem_co(&args->ccg_key, elems[3]),
+   CCG_elem_co(&args->ccg_key, elems[2]),
+   CCG_elem_co(&args->ccg_key, elems[1]),
+   CCG_elem_co(&args->ccg_key, elems[0]));
   }
 
-  normalize_v3(no);
   short sno[3];
 
   normal_float_to_short_v3(sno, no);

___
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] [0ad8f3ff585] master: Sculpt: fix T102348: Don't fold area normal automasking into cache

2022-11-28 Thread Joseph Eagar
Commit: 0ad8f3ff585c9693bb0cc84108ced00e8e0e1771
Author: Joseph Eagar
Date:   Mon Nov 28 12:59:53 2022 -0800
Branches: master
https://developer.blender.org/rB0ad8f3ff585c9693bb0cc84108ced00e8e0e1771

Sculpt: fix T102348: Don't fold area normal automasking into cache

Certain automasking modes build a factor cache.  Modes
that rely on the mirror symmetry pass should not fold into
this pass.

===

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

===

diff --git a/source/blender/editors/sculpt_paint/sculpt_automasking.cc 
b/source/blender/editors/sculpt_paint/sculpt_automasking.cc
index 211ff14c906..e490cb762fc 100644
--- a/source/blender/editors/sculpt_paint/sculpt_automasking.cc
+++ b/source/blender/editors/sculpt_paint/sculpt_automasking.cc
@@ -185,9 +185,8 @@ static bool SCULPT_automasking_needs_factors_cache(const 
Sculpt *sd, const Brush
 return true;
   }
 
-  if (automasking_flags &
-  (BRUSH_AUTOMASKING_BOUNDARY_EDGES | BRUSH_AUTOMASKING_BOUNDARY_FACE_SETS 
|
-   BRUSH_AUTOMASKING_BRUSH_NORMAL | BRUSH_AUTOMASKING_VIEW_NORMAL)) {
+  if (automasking_flags & (BRUSH_AUTOMASKING_BOUNDARY_EDGES |
+   BRUSH_AUTOMASKING_BOUNDARY_FACE_SETS | 
BRUSH_AUTOMASKING_VIEW_NORMAL)) {
 return brush && brush->automasking_boundary_edges_propagation_steps != 1;
   }
   return false;
@@ -507,6 +506,16 @@ float SCULPT_automasking_factor_get(AutomaskingCache 
*automasking,
 return 1.0f;
   }
 
+  float mask = 1.0f;
+
+  /* Since brush normal mode depends on the current mirror symmery pass
+   * it is not folded into the factor cache (when it exists).
+   */
+  if ((ss->cache || ss->filter_cache) &&
+  (automasking->settings.flags & BRUSH_AUTOMASKING_BRUSH_NORMAL)) {
+mask *= automasking_brush_normal_factor(automasking, ss, vert, 
automask_data);
+  }
+
   /* If the cache is initialized with valid info, use the cache. This is used 
when the
* automasking information can't be computed in real time per vertex and 
needs to be
* initialized for the whole mesh when the stroke starts. */
@@ -517,7 +526,7 @@ float SCULPT_automasking_factor_get(AutomaskingCache 
*automasking,
   factor *= sculpt_automasking_cavity_factor(automasking, ss, vert);
 }
 
-return factor;
+return factor * mask;
   }
 
   uchar stroke_id = ss->attrs.automasking_stroke_id ?
@@ -554,13 +563,6 @@ float SCULPT_automasking_factor_get(AutomaskingCache 
*automasking,
 }
   }
 
-  float mask = 1.0f;
-
-  if ((ss->cache || ss->filter_cache) &&
-  (automasking->settings.flags & BRUSH_AUTOMASKING_BRUSH_NORMAL)) {
-mask *= automasking_brush_normal_factor(automasking, ss, vert, 
automask_data);
-  }
-
   if ((ss->cache || ss->filter_cache) &&
   (automasking->settings.flags & BRUSH_AUTOMASKING_VIEW_NORMAL)) {
 mask *= automasking_view_normal_factor(automasking, ss, vert, 
automask_data);
@@ -782,9 +784,6 @@ static void 
sculpt_normal_occlusion_automasking_fill(AutomaskingCache *automaski
 
 float f = *(float *)SCULPT_vertex_attr_get(vertex, 
ss->attrs.automasking_factor);
 
-if (int(mode) & BRUSH_AUTOMASKING_BRUSH_NORMAL) {
-  f *= automasking_brush_normal_factor(automasking, ss, vertex, &nodedata);
-}
 if (int(mode) & BRUSH_AUTOMASKING_VIEW_NORMAL) {
   if (int(mode) & BRUSH_AUTOMASKING_VIEW_OCCLUSION) {
 f *= automasking_view_occlusion_factor(automasking, ss, vertex, -1, 
&nodedata);
@@ -940,8 +939,7 @@ AutomaskingCache *SCULPT_automasking_cache_init(Sculpt *sd, 
Brush *brush, Object
 
   /* Subtractive modes. */
   int normal_bits = sculpt_automasking_mode_effective_bits(sd, brush) &
-(BRUSH_AUTOMASKING_BRUSH_NORMAL | 
BRUSH_AUTOMASKING_VIEW_NORMAL |
- BRUSH_AUTOMASKING_VIEW_OCCLUSION);
+(BRUSH_AUTOMASKING_VIEW_NORMAL | 
BRUSH_AUTOMASKING_VIEW_OCCLUSION);
 
   if (normal_bits) {
 sculpt_normal_occlusion_automasking_fill(automasking, ob, 
(eAutomasking_flag)normal_bits);

___
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] [eec714350fa] tmp-workbench-rewrite2: Merge branch 'master' into tmp-workbench-rewrite2

2022-11-28 Thread Miguel Pozo
Commit: eec714350fa71ff3e486df907ce9acc99ce394cc
Author: Miguel Pozo
Date:   Mon Nov 28 21:18:56 2022 +0100
Branches: tmp-workbench-rewrite2
https://developer.blender.org/rBeec714350fa71ff3e486df907ce9acc99ce394cc

Merge branch 'master' into tmp-workbench-rewrite2

# Conflicts:
#   release/scripts/startup/bl_ui/space_userpref.py
#   source/blender/draw/CMakeLists.txt
#   source/blender/draw/engines/workbench/workbench_materials.cc
#   source/blender/makesdna/DNA_userdef_types.h

===



===

diff --cc release/scripts/startup/bl_ui/space_userpref.py
index 66213c12d97,11f5fdaa348..2f8a4768884
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@@ -2317,8 -2319,6 +2319,7 @@@ class USERPREF_PT_experimental_prototyp
  ({"property": "use_sculpt_texture_paint"}, "T96225"),
  ({"property": "use_full_frame_compositor"}, "T88150"),
  ({"property": "enable_eevee_next"}, "T93220"),
 +({"property": "enable_workbench_next"}, ""),
- ({"property": "use_draw_manager_acquire_lock"}, "T98016"),
  ),
  )
  
diff --cc source/blender/draw/CMakeLists.txt
index b2317025199,140354f5888..92d7d133f2f
--- a/source/blender/draw/CMakeLists.txt
+++ b/source/blender/draw/CMakeLists.txt
@@@ -156,25 -158,15 +158,25 @@@ set(SR
engines/eevee_next/eevee_world.cc
engines/workbench/workbench_data.c
engines/workbench/workbench_effect_antialiasing.c
 +  engines/workbench/workbench_effect_antialiasing.cc
engines/workbench/workbench_effect_cavity.c
 +  engines/workbench/workbench_effect_cavity.cc
engines/workbench/workbench_effect_dof.c
 +  engines/workbench/workbench_effect_dof.cc
engines/workbench/workbench_effect_outline.c
 +  engines/workbench/workbench_effect_outline.cc
engines/workbench/workbench_engine.c
 +  engines/workbench/workbench_engine.cc
-   engines/workbench/workbench_materials.c
engines/workbench/workbench_materials.cc
++  engines/workbench/workbench_materials_next.cc
 +  engines/workbench/workbench_mesh_passes.cc
engines/workbench/workbench_opaque.c
engines/workbench/workbench_render.c
 +  engines/workbench/workbench_resources.cc
engines/workbench/workbench_shader.cc
 +  engines/workbench/workbench_shader_cache.cc
engines/workbench/workbench_shadow.c
 +  engines/workbench/workbench_state.cc
engines/workbench/workbench_transparent.c
engines/workbench/workbench_volume.c
engines/external/external_engine.c
diff --cc 
source/blender/draw/engines/workbench/shaders/infos/workbench_merge_infront_info.hh
index 03dd3a266e4,8322d6891b7..56ad367451d
--- 
a/source/blender/draw/engines/workbench/shaders/infos/workbench_merge_infront_info.hh
+++ 
b/source/blender/draw/engines/workbench/shaders/infos/workbench_merge_infront_info.hh
@@@ -7,10 -7,5 +7,11 @@@ GPU_SHADER_CREATE_INFO(workbench_merge_
  .sampler(0, ImageType::DEPTH_2D, "depthBuffer")
  .fragment_source("workbench_merge_infront_frag.glsl")
  .additional_info("draw_fullscreen")
+ .depth_write(DepthWrite::ANY)
  .do_static_compilation(true);
 +
 +GPU_SHADER_CREATE_INFO(workbench_next_merge_depth)
 +.sampler(0, ImageType::DEPTH_2D, "depth_tx")
 +.fragment_source("workbench_next_merge_depth_frag.glsl")
 +.additional_info("draw_fullscreen")
 +.do_static_compilation(true);
diff --cc source/blender/draw/engines/workbench/workbench_materials_next.cc
index 000,000..6e4085b584e
new file mode 100644
--- /dev/null
+++ b/source/blender/draw/engines/workbench/workbench_materials_next.cc
@@@ -1,0 -1,0 +1,94 @@@
++/* SPDX-License-Identifier: GPL-2.0-or-later */
++
++#include "workbench_private.hh"
++
++#include "BLI_hash.h"
++/* get_image */
++#include "DNA_node_types.h"
++#include "ED_uvedit.h"
++//#include "BKE_image.h"
++#include "BKE_node.h"
++/* get_image */
++
++namespace blender::workbench {
++
++Material::Material() = default;
++
++Material::Material(float3 color)
++{
++  base_color = color;
++  packed_data = Material::pack_data(0.0f, 0.4f, 1.0f);
++}
++
++Material::Material(::Object &ob, bool random)
++{
++  if (random) {
++uint hash = BLI_ghashutil_strhash_p_murmur(ob.id.name);
++if (ob.id.lib) {
++  hash = (hash * 13) ^ 
BLI_ghashutil_strhash_p_murmur(ob.id.lib->filepath);
++}
++float3 hsv = float3(BLI_hash_int_01(hash), 0.5f, 0.8f);
++hsv_to_rgb_v(hsv, base_color);
++  }
++  else {
++base_color = ob.color;
++  }
++  packed_data = Material::pack_data(0.0f, 0.4f, ob.color[3]);
++}
++
++Material::Material(::Material &mat)
++{
++  base_color = &mat.r;
++  packed_data = Material::pack_data(mat.metallic, mat.roughness, mat.a);
++}
++
++bool Material::is_transparent()
++{
++  uint32_t full_alpha_ref = 0x00ff;
++  return (packed_data & full_alpha_ref) != full_alp

[Bf-blender-cvs] [b81e6ab2f0e] tmp-workbench-rewrite2: Link to Workbench Next Task in user prefs

2022-11-28 Thread Miguel Pozo
Commit: b81e6ab2f0e455110e1ab7afaedaff3185bed7bb
Author: Miguel Pozo
Date:   Mon Nov 28 21:22:00 2022 +0100
Branches: tmp-workbench-rewrite2
https://developer.blender.org/rBb81e6ab2f0e455110e1ab7afaedaff3185bed7bb

Link to Workbench Next Task in user prefs

===

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

===

diff --git a/release/scripts/startup/bl_ui/space_userpref.py 
b/release/scripts/startup/bl_ui/space_userpref.py
index 2f8a4768884..0e0ceca32e4 100644
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@ -2319,7 +2319,7 @@ class 
USERPREF_PT_experimental_prototypes(ExperimentalPanel, Panel):
 ({"property": "use_sculpt_texture_paint"}, "T96225"),
 ({"property": "use_full_frame_compositor"}, "T88150"),
 ({"property": "enable_eevee_next"}, "T93220"),
-({"property": "enable_workbench_next"}, ""),
+({"property": "enable_workbench_next"}, "T101619"),
 ),
 )

___
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] [d1d2946f593] master: Merge branch 'blender-v3.4-release'

2022-11-28 Thread Hans Goudey
Commit: d1d2946f59330941b1b45ae393a1320558f4aa92
Author: Hans Goudey
Date:   Mon Nov 28 14:12:04 2022 -0600
Branches: master
https://developer.blender.org/rBd1d2946f59330941b1b45ae393a1320558f4aa92

Merge branch 'blender-v3.4-release'

===



===

diff --cc source/blender/blenkernel/intern/subdiv_mesh.cc
index e1c434f2b2e,5de78cdfe91..d8ccb6f57df
--- a/source/blender/blenkernel/intern/subdiv_mesh.cc
+++ b/source/blender/blenkernel/intern/subdiv_mesh.cc
@@@ -791,10 -793,9 +793,9 @@@ static void subdiv_copy_edge_data(Subdi
  {
const int subdiv_edge_index = subdiv_edge - ctx->subdiv_edges;
if (coarse_edge == nullptr) {
- /* TODO: Ensure crease layer isn't copied to result. */
  subdiv_edge->flag = 0;
  if (!ctx->settings->use_optimal_display) {
 -  subdiv_edge->flag |= ME_EDGERENDER;
 +  subdiv_edge->flag |= ME_EDGEDRAW;
  }
  if (ctx->edge_origindex != nullptr) {
ctx->edge_origindex[subdiv_edge_index] = ORIGINDEX_NONE;

___
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] [745851e26b9] blender-v3.4-release: Fix T102772: Propagate edge creases in subdivision surface modifier

2022-11-28 Thread Hans Goudey
Commit: 745851e26b9f30693a9d09ca95f0d734bbcd25bc
Author: Hans Goudey
Date:   Mon Nov 28 14:06:18 2022 -0600
Branches: blender-v3.4-release
https://developer.blender.org/rB745851e26b9f30693a9d09ca95f0d734bbcd25bc

Fix T102772: Propagate edge creases in subdivision surface modifier

Before rBa8a454287a27, edge creases were copied to the result mesh as
part of `MEdge`. Now they are stored in a separate `CD_CREASE` layer,
which I mistakenly disabled for interpolation. However, to maintain
the geometry node uses a field input, remove the interpolated attribute
there.

===

M   source/blender/blenkernel/intern/subdiv_mesh.cc
M   source/blender/nodes/geometry/nodes/node_geo_subdivision_surface.cc

===

diff --git a/source/blender/blenkernel/intern/subdiv_mesh.cc 
b/source/blender/blenkernel/intern/subdiv_mesh.cc
index 3b97c1f5e68..5de78cdfe91 100644
--- a/source/blender/blenkernel/intern/subdiv_mesh.cc
+++ b/source/blender/blenkernel/intern/subdiv_mesh.cc
@@ -520,8 +520,10 @@ static bool subdiv_mesh_topology_info(const 
SubdivForeachContext *foreach_contex
* so don't try to preserve it and use memory. Crease values should also not 
be interpolated. */
   CustomData_MeshMasks mask = CD_MASK_EVERYTHING;
   mask.lmask &= ~CD_MASK_MULTIRES_GRIDS;
+  /* Propagate edge creases so they can be used in another subdivision 
modifier (maintaining
+   * existing behavior), but don't propagate vertex creases to avoid extra 
work when the result
+   * isn't useful anyway. */
   mask.vmask &= ~CD_MASK_CREASE;
-  mask.emask &= ~CD_MASK_CREASE;
 
   SubdivMeshContext *subdiv_context = static_cast(foreach_context->user_data);
   subdiv_context->subdiv_mesh = BKE_mesh_new_nomain_from_template_ex(
@@ -791,7 +793,6 @@ static void subdiv_copy_edge_data(SubdivMeshContext *ctx,
 {
   const int subdiv_edge_index = subdiv_edge - ctx->subdiv_edges;
   if (coarse_edge == nullptr) {
-/* TODO: Ensure crease layer isn't copied to result. */
 subdiv_edge->flag = 0;
 if (!ctx->settings->use_optimal_display) {
   subdiv_edge->flag |= ME_EDGERENDER;
diff --git 
a/source/blender/nodes/geometry/nodes/node_geo_subdivision_surface.cc 
b/source/blender/nodes/geometry/nodes/node_geo_subdivision_surface.cc
index 2e6ad02bfd5..e0afae76419 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_subdivision_surface.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_subdivision_surface.cc
@@ -170,6 +170,13 @@ static void node_geo_exec(GeoNodeExecParams params)
 
 Mesh *mesh_out = BKE_subdiv_to_mesh(subdiv, &mesh_settings, &mesh);
 
+if (use_creases) {
+  /* Remove the layer in case it was created by the node from the field 
input. The fact
+   * that this node uses #CD_CREASE to input creases to the subvision code 
is meant to be
+   * an implementation detail ideally. */
+  CustomData_free_layers(&mesh_out->edata, CD_CREASE, mesh_out->totedge);
+}
+
 geometry_set.replace_mesh(mesh_out);
 
 BKE_subdiv_free(subdiv);

___
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] [1bacd09abb6] blender-v3.4-release: Fix: Mishandled creases in Cycles adaptive subdivision

2022-11-28 Thread Hans Goudey
Commit: 1bacd09abb60a4b3febb6d8c78c784ce86f50e3e
Author: Hans Goudey
Date:   Mon Nov 28 13:49:55 2022 -0600
Branches: blender-v3.4-release
https://developer.blender.org/rB1bacd09abb60a4b3febb6d8c78c784ce86f50e3e

Fix: Mishandled creases in Cycles adaptive subdivision

Caused by a8a454287a27 which assumed it was possible
to access the raw data of the edge creases layer. Also allow
processing vertex creases even if there aren't any edge creases.

===

M   intern/cycles/blender/mesh.cpp

===

diff --git a/intern/cycles/blender/mesh.cpp b/intern/cycles/blender/mesh.cpp
index fbc470cada4..1887440bc67 100644
--- a/intern/cycles/blender/mesh.cpp
+++ b/intern/cycles/blender/mesh.cpp
@@ -1085,11 +1085,11 @@ static void create_subd_mesh(Scene *scene,
   const int edges_num = b_mesh.edges.length();
 
   if (edges_num != 0 && b_mesh.edge_creases.length() > 0) {
-size_t num_creases = 0;
-const float *creases = static_cast(b_mesh.edge_creases[0].ptr.data);
+BL::MeshEdgeCreaseLayer creases = b_mesh.edge_creases[0];
 
+size_t num_creases = 0;
 for (int i = 0; i < edges_num; i++) {
-  if (creases[i] != 0.0f) {
+  if (creases.data[i].value() != 0.0f) {
 num_creases++;
   }
 }
@@ -1098,17 +1098,18 @@ static void create_subd_mesh(Scene *scene,
 
 const MEdge *edges = static_cast(b_mesh.edges[0].ptr.data);
 for (int i = 0; i < edges_num; i++) {
-  if (creases[i] != 0.0f) {
+  const float crease = creases.data[i].value();
+  if (crease != 0.0f) {
 const MEdge &b_edge = edges[i];
-mesh->add_edge_crease(b_edge.v1, b_edge.v2, creases[i]);
+mesh->add_edge_crease(b_edge.v1, b_edge.v2, crease);
   }
 }
+  }
 
-for (BL::MeshVertexCreaseLayer &c : b_mesh.vertex_creases) {
-  for (int i = 0; i < c.data.length(); ++i) {
-if (c.data[i].value() != 0.0f) {
-  mesh->add_vertex_crease(i, c.data[i].value());
-}
+  for (BL::MeshVertexCreaseLayer &c : b_mesh.vertex_creases) {
+for (int i = 0; i < c.data.length(); ++i) {
+  if (c.data[i].value() != 0.0f) {
+mesh->add_vertex_crease(i, c.data[i].value());
   }
 }
   }

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


[Bf-blender-cvs] [07200eaa851] master: Merge branch 'blender-v3.4-release'

2022-11-28 Thread Brecht Van Lommel
Commit: 07200eaa851a8113dc9b0e1f129fe20245c61b05
Author: Brecht Van Lommel
Date:   Mon Nov 28 21:07:13 2022 +0100
Branches: master
https://developer.blender.org/rB07200eaa851a8113dc9b0e1f129fe20245c61b05

Merge branch 'blender-v3.4-release'

===



===



___
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] [719ad4f93f8] master: Fix T100537: wrong depth pass for background after recent fix for gaps

2022-11-28 Thread Brecht Van Lommel
Commit: 719ad4f93f83facca909ed2be69900a684ad27d0
Author: Brecht Van Lommel
Date:   Mon Nov 28 20:34:03 2022 +0100
Branches: master
https://developer.blender.org/rB719ad4f93f83facca909ed2be69900a684ad27d0

Fix T100537: wrong depth pass for background after recent fix for gaps

Also have to write if we hit the background and have not written any valid
value for the pass yet.

===

M   intern/cycles/kernel/film/data_passes.h
M   intern/cycles/kernel/integrator/shade_background.h

===

diff --git a/intern/cycles/kernel/film/data_passes.h 
b/intern/cycles/kernel/film/data_passes.h
index 4a63d6f8e7f..3c538a74978 100644
--- a/intern/cycles/kernel/film/data_passes.h
+++ b/intern/cycles/kernel/film/data_passes.h
@@ -157,4 +157,47 @@ ccl_device_inline void 
film_write_data_passes(KernelGlobals kg,
 #endif
 }
 
+ccl_device_inline void film_write_data_passes_background(
+KernelGlobals kg, IntegratorState state, ccl_global float *ccl_restrict 
render_buffer)
+{
+#ifdef __PASSES__
+  const uint32_t path_flag = INTEGRATOR_STATE(state, path, flag);
+
+  if (!(path_flag & PATH_RAY_TRANSPARENT_BACKGROUND)) {
+return;
+  }
+
+  /* Don't write data passes for paths that were split off for shadow catchers
+   * to avoid double-counting. */
+  if (path_flag & PATH_RAY_SHADOW_CATCHER_PASS) {
+return;
+  }
+
+  const int flag = kernel_data.film.pass_flag;
+
+  if (!(flag & PASS_ANY)) {
+return;
+  }
+
+  if (!(path_flag & PATH_RAY_SINGLE_PASS_DONE)) {
+ccl_global float *buffer = film_pass_pixel_render_buffer(kg, state, 
render_buffer);
+
+if (INTEGRATOR_STATE(state, path, sample) == 0) {
+  if (flag & PASSMASK(DEPTH)) {
+film_overwrite_pass_float(buffer + kernel_data.film.pass_depth, 0.0f);
+  }
+  if (flag & PASSMASK(OBJECT_ID)) {
+film_overwrite_pass_float(buffer + kernel_data.film.pass_object_id, 
0.0f);
+  }
+  if (flag & PASSMASK(MATERIAL_ID)) {
+film_overwrite_pass_float(buffer + kernel_data.film.pass_material_id, 
0.0f);
+  }
+  if (flag & PASSMASK(POSITION)) {
+film_overwrite_pass_float3(buffer + kernel_data.film.pass_position, 
zero_float3());
+  }
+}
+  }
+#endif
+}
+
 CCL_NAMESPACE_END
diff --git a/intern/cycles/kernel/integrator/shade_background.h 
b/intern/cycles/kernel/integrator/shade_background.h
index 8fc5689683a..f35a6d308f7 100644
--- a/intern/cycles/kernel/integrator/shade_background.h
+++ b/intern/cycles/kernel/integrator/shade_background.h
@@ -3,6 +3,7 @@
 
 #pragma once
 
+#include "kernel/film/data_passes.h"
 #include "kernel/film/light_passes.h"
 
 #include "kernel/integrator/guiding.h"
@@ -131,6 +132,7 @@ ccl_device_inline void integrate_background(KernelGlobals 
kg,
 
   /* Write to render buffer. */
   film_write_background(kg, state, L, transparent, 
is_transparent_background_ray, render_buffer);
+  film_write_data_passes_background(kg, state, render_buffer);
 }
 
 ccl_device_inline void integrate_distant_lights(KernelGlobals kg,

___
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] [7540842ca76] master: Fix T99592: Exact Boolean: Skip empty materials, add index-based option

2022-11-28 Thread Hans Goudey
Commit: 7540842ca7632dad4c2806989027a3a6b2a15668
Author: Hans Goudey
Date:   Mon Nov 28 12:42:08 2022 -0600
Branches: master
https://developer.blender.org/rB7540842ca7632dad4c2806989027a3a6b2a15668

Fix T99592: Exact Boolean: Skip empty materials, add index-based option

**Empty Slot Fix**
Currently the boolean modifier transfers the default material from
meshes with no materials and empty material slots to the faces on the
base mesh. I added this in a2d59b2dac9e for the sake of consistency,
but the behavior is actually not useful at all. The default empty
material isn't chosen by users, it just signifies "nothing," so when
it replaces a material chosen by users, it feels like a bug.

This commit corrects that behavior by only transferring materials from
non-empty material slots. The implementation is now consistent between
exact mode of the boolean modifier and the geometry node.

**Index-Based Option**

"Index-based" is the new default material method for the boolean
modifier, to access the old behavior from before the breaking commit.

a2d59b2dac9e actually broke some Boolean workflows fundamentally, since
it was important to set up matching slot indices on each operand. That
isn't the cleanest workflow, and it breaks when materials change
procedurally, but historically that hasn't been a problem. The
"transfer" behavior transfers all materials except for empty slots,
but the fundamental problem is that there isn't a good way to specify
the result materials besides using the slot indices.

Even then, the transfer option is a bit more intuitive and useful for
some simpler situations, and it allows accessing the behavior that has
been in 3.2 and 3.3 for a long time, so it's also left in as an option.
The geometry node doesn't get this new option, in the hope that we'll
find a better solution in the future.

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

===

M   source/blender/blenkernel/BKE_mesh_boolean_convert.hh
M   source/blender/blenkernel/intern/mesh_boolean_convert.cc
M   source/blender/makesdna/DNA_modifier_types.h
M   source/blender/makesrna/intern/rna_modifier.c
M   source/blender/modifiers/intern/MOD_boolean.cc
M   source/blender/nodes/geometry/nodes/node_geo_boolean.cc

===

diff --git a/source/blender/blenkernel/BKE_mesh_boolean_convert.hh 
b/source/blender/blenkernel/BKE_mesh_boolean_convert.hh
index 441783d46a1..77c90716d42 100644
--- a/source/blender/blenkernel/BKE_mesh_boolean_convert.hh
+++ b/source/blender/blenkernel/BKE_mesh_boolean_convert.hh
@@ -22,7 +22,7 @@ namespace blender::meshintersect {
  * It is allowed for the pointers to be null, meaning the transformation is 
the identity.
  * \param material_remaps: An array of maps from material slot numbers in the 
corresponding mesh
  * to the material slot in the first mesh. It is OK for material_remaps or any 
of its constituent
- * arrays to be empty.
+ * arrays to be empty. A -1 value means that the original index should be used 
with no mapping.
  * \param r_intersecting_edges: Array to store indices of edges on the 
resulting mesh in. These
  * 'new' edges are the result of the intersections.
  */
diff --git a/source/blender/blenkernel/intern/mesh_boolean_convert.cc 
b/source/blender/blenkernel/intern/mesh_boolean_convert.cc
index 21d9baf7f7e..1252e90e11c 100644
--- a/source/blender/blenkernel/intern/mesh_boolean_convert.cc
+++ b/source/blender/blenkernel/intern/mesh_boolean_convert.cc
@@ -430,12 +430,14 @@ static void copy_poly_attributes(Mesh *dest_mesh,
   const VArray src_material_indices = 
orig_me->attributes().lookup_or_default(
   "material_index", ATTR_DOMAIN_FACE, 0);
   const int src_index = src_material_indices[index_in_orig_me];
-  if (material_remap.size() > 0 && 
material_remap.index_range().contains(src_index)) {
-dst_material_indices[mp_index] = material_remap[src_index];
+  if (material_remap.index_range().contains(src_index)) {
+const int remapped_index = material_remap[src_index];
+dst_material_indices[mp_index] = remapped_index >= 0 ? remapped_index : 
src_index;
   }
   else {
 dst_material_indices[mp_index] = src_index;
   }
+  BLI_assert(dst_material_indices[mp_index] >= 0);
 }
 
 /* Similar to copy_vert_attributes but for edge attributes. */
diff --git a/source/blender/makesdna/DNA_modifier_types.h 
b/source/blender/makesdna/DNA_modifier_types.h
index c4180071352..97e42efd5ac 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -899,10 +899,18 @@ typedef struct BooleanModifierData {
   float double_threshold;
   char operation;
   char solver;
+  /** #BooleanModifierMaterialMode. */
+  char material_mode;
   char flag;
   char bm_flag;
+  char _pad[7];
 } BooleanModifierData;
 
+typedef enum BooleanModifierMaterialMode {
+  eBooleanModifierMaterialMode_Index = 0,
+

[Bf-blender-cvs] [9bdde6ca96d] master: Python Module: add source code and credits to project description

2022-11-28 Thread Brecht Van Lommel
Commit: 9bdde6ca96d993c81e9f674b004d015b9d984b97
Author: Brecht Van Lommel
Date:   Mon Nov 28 20:18:14 2022 +0100
Branches: master
https://developer.blender.org/rB9bdde6ca96d993c81e9f674b004d015b9d984b97

Python Module: add source code and credits to project description

===

M   build_files/utils/make_bpy_wheel.py

===

diff --git a/build_files/utils/make_bpy_wheel.py 
b/build_files/utils/make_bpy_wheel.py
index dd6663a72fb..a0ac1306dda 100755
--- a/build_files/utils/make_bpy_wheel.py
+++ b/build_files/utils/make_bpy_wheel.py
@@ -53,7 +53,18 @@ This package provides Blender as a Python module for use in 
studio pipelines, we
 
 [System requirements](https://www.blender.org/download/requirements/) are the 
same as Blender.
 
-Each Blender release supports one Python version, and the package is only 
compatible with that version."""
+Each Blender release supports one Python version, and the package is only 
compatible with that version.
+
+## Source Code
+
+* [Releases](https://download.blender.org/source/)
+* Repository: 
[git.blender.org/blender.git](https://git.blender.org/gitweb/gitweb.cgi/blender.git)
+
+## Credits
+
+Created by the [Blender developer 
community](https://www.blender.org/about/credits/).
+
+Thanks to Tyler Alden Gubala for maintaining the original version of this 
package."""
 
 # 
--
 # Generic Functions

___
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] [6d529750194] master: Cleanup: remove Cycles standalone repository lib detection

2022-11-28 Thread Brecht Van Lommel
Commit: 6d529750194171d4ac389337b37ddfb13a0351e3
Author: Brecht Van Lommel
Date:   Mon Nov 28 19:36:47 2022 +0100
Branches: master
https://developer.blender.org/rB6d529750194171d4ac389337b37ddfb13a0351e3

Cleanup: remove Cycles standalone repository lib detection

This is only needed in the Cycles repo and having it in the Blender repo
is making merging more complicated than it is helping.

===

M   intern/cycles/cmake/external_libs.cmake

===

diff --git a/intern/cycles/cmake/external_libs.cmake 
b/intern/cycles/cmake/external_libs.cmake
index 44542a08156..4b165e1a5be 100644
--- a/intern/cycles/cmake/external_libs.cmake
+++ b/intern/cycles/cmake/external_libs.cmake
@@ -1,584 +1,6 @@
 # SPDX-License-Identifier: Apache-2.0
 # Copyright 2011-2022 Blender Foundation
 
-###
-# Helper macros
-###
-
-macro(_set_default variable value)
-  if(NOT ${variable})
-set(${variable} ${value})
-  endif()
-endmacro()
-
-###
-# Precompiled libraries detection
-#
-# Use precompiled libraries from Blender repository
-###
-
-if(CYCLES_STANDALONE_REPOSITORY)
-  if(APPLE)
-if("${CMAKE_OSX_ARCHITECTURES}" STREQUAL "x86_64")
-  set(_cycles_lib_dir "${CMAKE_SOURCE_DIR}/../lib/darwin")
-else()
-  set(_cycles_lib_dir "${CMAKE_SOURCE_DIR}/../lib/darwin_arm64")
-endif()
-
-# Always use system zlib
-find_package(ZLIB REQUIRED)
-  elseif(WIN32)
-if(CMAKE_CL_64)
-  set(_cycles_lib_dir "${CMAKE_SOURCE_DIR}/../lib/win64_vc15")
-else()
-  message(FATAL_ERROR "Unsupported Visual Studio Version")
-endif()
-  else()
-# Path to a locally compiled libraries.
-set(LIBDIR_NAME ${CMAKE_SYSTEM_NAME}_${CMAKE_SYSTEM_PROCESSOR})
-string(TOLOWER ${LIBDIR_NAME} LIBDIR_NAME)
-set(LIBDIR_NATIVE_ABI ${CMAKE_SOURCE_DIR}/../lib/${LIBDIR_NAME})
-
-# Path to precompiled libraries with known CentOS 7 ABI.
-set(LIBDIR_CENTOS7_ABI ${CMAKE_SOURCE_DIR}/../lib/linux_centos7_x86_64)
-
-# Choose the best suitable libraries.
-if(EXISTS ${LIBDIR_NATIVE_ABI})
-  set(_cycles_lib_dir ${LIBDIR_NATIVE_ABI})
-elseif(EXISTS ${LIBDIR_CENTOS7_ABI})
-  set(_cycles_lib_dir ${LIBDIR_CENTOS7_ABI})
-  set(WITH_CXX11_ABI OFF)
-
-  if(CMAKE_COMPILER_IS_GNUCC AND
- CMAKE_C_COMPILER_VERSION VERSION_LESS 9.3)
-message(FATAL_ERROR "GCC version must be at least 9.3 for precompiled 
libraries, found ${CMAKE_C_COMPILER_VERSION}")
-  endif()
-endif()
-
-if(DEFINED _cycles_lib_dir)
-  message(STATUS "Using precompiled libraries at ${_cycles_lib_dir}")
-endif()
-
-# Avoid namespace pollustion.
-unset(LIBDIR_NATIVE_ABI)
-unset(LIBDIR_CENTOS7_ABI)
-  endif()
-
-  if(EXISTS ${_cycles_lib_dir})
-_set_default(ALEMBIC_ROOT_DIR "${_cycles_lib_dir}/alembic")
-_set_default(BOOST_ROOT "${_cycles_lib_dir}/boost")
-_set_default(BLOSC_ROOT_DIR "${_cycles_lib_dir}/blosc")
-_set_default(EMBREE_ROOT_DIR "${_cycles_lib_dir}/embree")
-_set_default(EPOXY_ROOT_DIR "${_cycles_lib_dir}/epoxy")
-_set_default(IMATH_ROOT_DIR "${_cycles_lib_dir}/imath")
-_set_default(GLEW_ROOT_DIR "${_cycles_lib_dir}/glew")
-_set_default(JPEG_ROOT "${_cycles_lib_dir}/jpeg")
-_set_default(LLVM_ROOT_DIR "${_cycles_lib_dir}/llvm")
-_set_default(CLANG_ROOT_DIR "${_cycles_lib_dir}/llvm")
-_set_default(NANOVDB_ROOT_DIR "${_cycles_lib_dir}/openvdb")
-_set_default(OPENCOLORIO_ROOT_DIR "${_cycles_lib_dir}/opencolorio")
-_set_default(OPENEXR_ROOT_DIR "${_cycles_lib_dir}/openexr")
-_set_default(OPENIMAGEDENOISE_ROOT_DIR 
"${_cycles_lib_dir}/openimagedenoise")
-_set_default(OPENIMAGEIO_ROOT_DIR "${_cycles_lib_dir}/openimageio")
-_set_default(OPENJPEG_ROOT_DIR "${_cycles_lib_dir}/openjpeg")
-_set_default(OPENSUBDIV_ROOT_DIR "${_cycles_lib_dir}/opensubdiv")
-_set_default(OPENVDB_ROOT_DIR "${_cycles_lib_dir}/openvdb")
-_set_default(OSL_ROOT_DIR "${_cycles_lib_dir}/osl")
-_set_default(PNG_ROOT "${_cycles_lib_dir}/png")
-_set_default(PUGIXML_ROOT_DIR "${_cycles_lib_dir}/pugixml")
-_set_default(SDL2_ROOT_DIR "${_cycles_lib_dir}/sdl")
-_set_default(TBB_ROOT_DIR "${_cycles_lib_dir}/tbb")
-_set_default(TIFF_ROOT "${_cycles_lib_dir}/tiff")
-_set_default(USD_ROOT_DIR "${_cycles_lib_dir}/usd")
-_set_default(WEBP_ROOT_DIR "${_cycles_lib_dir}/webp")
-_set_default(ZLIB_ROOT "${_cycles_lib_dir}/zlib")
-if(WIN32)
-  set(LEVEL_ZERO_ROOT_DIR ${_cycles_lib_dir}/level_zero)
-else()
-  set(LEVEL_ZERO_ROOT_DIR ${_cycles_lib_dir}/level-zero)
-endif()
-_set_default(SYCL_ROOT_DIR "${_cy

[Bf-blender-cvs] [1a34bbc27c2] blender-v3.4-release: Cleanup: remove Cycles standalone repository lib detection

2022-11-28 Thread Brecht Van Lommel
Commit: 1a34bbc27c2f908f64a87231ed334ed7a3c2b1ec
Author: Brecht Van Lommel
Date:   Mon Nov 28 19:36:47 2022 +0100
Branches: blender-v3.4-release
https://developer.blender.org/rB1a34bbc27c2f908f64a87231ed334ed7a3c2b1ec

Cleanup: remove Cycles standalone repository lib detection

This is only needed in the Cycles repo and having it in the Blender repo
is making merging more complicated than it is helping.

===

M   intern/cycles/cmake/external_libs.cmake

===

diff --git a/intern/cycles/cmake/external_libs.cmake 
b/intern/cycles/cmake/external_libs.cmake
index 44542a08156..4b165e1a5be 100644
--- a/intern/cycles/cmake/external_libs.cmake
+++ b/intern/cycles/cmake/external_libs.cmake
@@ -1,584 +1,6 @@
 # SPDX-License-Identifier: Apache-2.0
 # Copyright 2011-2022 Blender Foundation
 
-###
-# Helper macros
-###
-
-macro(_set_default variable value)
-  if(NOT ${variable})
-set(${variable} ${value})
-  endif()
-endmacro()
-
-###
-# Precompiled libraries detection
-#
-# Use precompiled libraries from Blender repository
-###
-
-if(CYCLES_STANDALONE_REPOSITORY)
-  if(APPLE)
-if("${CMAKE_OSX_ARCHITECTURES}" STREQUAL "x86_64")
-  set(_cycles_lib_dir "${CMAKE_SOURCE_DIR}/../lib/darwin")
-else()
-  set(_cycles_lib_dir "${CMAKE_SOURCE_DIR}/../lib/darwin_arm64")
-endif()
-
-# Always use system zlib
-find_package(ZLIB REQUIRED)
-  elseif(WIN32)
-if(CMAKE_CL_64)
-  set(_cycles_lib_dir "${CMAKE_SOURCE_DIR}/../lib/win64_vc15")
-else()
-  message(FATAL_ERROR "Unsupported Visual Studio Version")
-endif()
-  else()
-# Path to a locally compiled libraries.
-set(LIBDIR_NAME ${CMAKE_SYSTEM_NAME}_${CMAKE_SYSTEM_PROCESSOR})
-string(TOLOWER ${LIBDIR_NAME} LIBDIR_NAME)
-set(LIBDIR_NATIVE_ABI ${CMAKE_SOURCE_DIR}/../lib/${LIBDIR_NAME})
-
-# Path to precompiled libraries with known CentOS 7 ABI.
-set(LIBDIR_CENTOS7_ABI ${CMAKE_SOURCE_DIR}/../lib/linux_centos7_x86_64)
-
-# Choose the best suitable libraries.
-if(EXISTS ${LIBDIR_NATIVE_ABI})
-  set(_cycles_lib_dir ${LIBDIR_NATIVE_ABI})
-elseif(EXISTS ${LIBDIR_CENTOS7_ABI})
-  set(_cycles_lib_dir ${LIBDIR_CENTOS7_ABI})
-  set(WITH_CXX11_ABI OFF)
-
-  if(CMAKE_COMPILER_IS_GNUCC AND
- CMAKE_C_COMPILER_VERSION VERSION_LESS 9.3)
-message(FATAL_ERROR "GCC version must be at least 9.3 for precompiled 
libraries, found ${CMAKE_C_COMPILER_VERSION}")
-  endif()
-endif()
-
-if(DEFINED _cycles_lib_dir)
-  message(STATUS "Using precompiled libraries at ${_cycles_lib_dir}")
-endif()
-
-# Avoid namespace pollustion.
-unset(LIBDIR_NATIVE_ABI)
-unset(LIBDIR_CENTOS7_ABI)
-  endif()
-
-  if(EXISTS ${_cycles_lib_dir})
-_set_default(ALEMBIC_ROOT_DIR "${_cycles_lib_dir}/alembic")
-_set_default(BOOST_ROOT "${_cycles_lib_dir}/boost")
-_set_default(BLOSC_ROOT_DIR "${_cycles_lib_dir}/blosc")
-_set_default(EMBREE_ROOT_DIR "${_cycles_lib_dir}/embree")
-_set_default(EPOXY_ROOT_DIR "${_cycles_lib_dir}/epoxy")
-_set_default(IMATH_ROOT_DIR "${_cycles_lib_dir}/imath")
-_set_default(GLEW_ROOT_DIR "${_cycles_lib_dir}/glew")
-_set_default(JPEG_ROOT "${_cycles_lib_dir}/jpeg")
-_set_default(LLVM_ROOT_DIR "${_cycles_lib_dir}/llvm")
-_set_default(CLANG_ROOT_DIR "${_cycles_lib_dir}/llvm")
-_set_default(NANOVDB_ROOT_DIR "${_cycles_lib_dir}/openvdb")
-_set_default(OPENCOLORIO_ROOT_DIR "${_cycles_lib_dir}/opencolorio")
-_set_default(OPENEXR_ROOT_DIR "${_cycles_lib_dir}/openexr")
-_set_default(OPENIMAGEDENOISE_ROOT_DIR 
"${_cycles_lib_dir}/openimagedenoise")
-_set_default(OPENIMAGEIO_ROOT_DIR "${_cycles_lib_dir}/openimageio")
-_set_default(OPENJPEG_ROOT_DIR "${_cycles_lib_dir}/openjpeg")
-_set_default(OPENSUBDIV_ROOT_DIR "${_cycles_lib_dir}/opensubdiv")
-_set_default(OPENVDB_ROOT_DIR "${_cycles_lib_dir}/openvdb")
-_set_default(OSL_ROOT_DIR "${_cycles_lib_dir}/osl")
-_set_default(PNG_ROOT "${_cycles_lib_dir}/png")
-_set_default(PUGIXML_ROOT_DIR "${_cycles_lib_dir}/pugixml")
-_set_default(SDL2_ROOT_DIR "${_cycles_lib_dir}/sdl")
-_set_default(TBB_ROOT_DIR "${_cycles_lib_dir}/tbb")
-_set_default(TIFF_ROOT "${_cycles_lib_dir}/tiff")
-_set_default(USD_ROOT_DIR "${_cycles_lib_dir}/usd")
-_set_default(WEBP_ROOT_DIR "${_cycles_lib_dir}/webp")
-_set_default(ZLIB_ROOT "${_cycles_lib_dir}/zlib")
-if(WIN32)
-  set(LEVEL_ZERO_ROOT_DIR ${_cycles_lib_dir}/level_zero)
-else()
-  set(LEVEL_ZERO_ROOT_DIR ${_cycles_lib_dir}/level-zero)
-endif()
-_set_default(SYCL_R

[Bf-blender-cvs] [ca5062071c6] blender-v3.4-release: Fix T100537: wrong depth pass for background after recent fix for gaps

2022-11-28 Thread Brecht Van Lommel
Commit: ca5062071c6fd2db919da776a77f61bff2ad2132
Author: Brecht Van Lommel
Date:   Mon Nov 28 20:34:03 2022 +0100
Branches: blender-v3.4-release
https://developer.blender.org/rBca5062071c6fd2db919da776a77f61bff2ad2132

Fix T100537: wrong depth pass for background after recent fix for gaps

Also have to write if we hit the background and have not written any valid
value for the pass yet.

===

M   intern/cycles/kernel/film/data_passes.h
M   intern/cycles/kernel/integrator/shade_background.h

===

diff --git a/intern/cycles/kernel/film/data_passes.h 
b/intern/cycles/kernel/film/data_passes.h
index 4a63d6f8e7f..3c538a74978 100644
--- a/intern/cycles/kernel/film/data_passes.h
+++ b/intern/cycles/kernel/film/data_passes.h
@@ -157,4 +157,47 @@ ccl_device_inline void 
film_write_data_passes(KernelGlobals kg,
 #endif
 }
 
+ccl_device_inline void film_write_data_passes_background(
+KernelGlobals kg, IntegratorState state, ccl_global float *ccl_restrict 
render_buffer)
+{
+#ifdef __PASSES__
+  const uint32_t path_flag = INTEGRATOR_STATE(state, path, flag);
+
+  if (!(path_flag & PATH_RAY_TRANSPARENT_BACKGROUND)) {
+return;
+  }
+
+  /* Don't write data passes for paths that were split off for shadow catchers
+   * to avoid double-counting. */
+  if (path_flag & PATH_RAY_SHADOW_CATCHER_PASS) {
+return;
+  }
+
+  const int flag = kernel_data.film.pass_flag;
+
+  if (!(flag & PASS_ANY)) {
+return;
+  }
+
+  if (!(path_flag & PATH_RAY_SINGLE_PASS_DONE)) {
+ccl_global float *buffer = film_pass_pixel_render_buffer(kg, state, 
render_buffer);
+
+if (INTEGRATOR_STATE(state, path, sample) == 0) {
+  if (flag & PASSMASK(DEPTH)) {
+film_overwrite_pass_float(buffer + kernel_data.film.pass_depth, 0.0f);
+  }
+  if (flag & PASSMASK(OBJECT_ID)) {
+film_overwrite_pass_float(buffer + kernel_data.film.pass_object_id, 
0.0f);
+  }
+  if (flag & PASSMASK(MATERIAL_ID)) {
+film_overwrite_pass_float(buffer + kernel_data.film.pass_material_id, 
0.0f);
+  }
+  if (flag & PASSMASK(POSITION)) {
+film_overwrite_pass_float3(buffer + kernel_data.film.pass_position, 
zero_float3());
+  }
+}
+  }
+#endif
+}
+
 CCL_NAMESPACE_END
diff --git a/intern/cycles/kernel/integrator/shade_background.h 
b/intern/cycles/kernel/integrator/shade_background.h
index 8fc5689683a..f35a6d308f7 100644
--- a/intern/cycles/kernel/integrator/shade_background.h
+++ b/intern/cycles/kernel/integrator/shade_background.h
@@ -3,6 +3,7 @@
 
 #pragma once
 
+#include "kernel/film/data_passes.h"
 #include "kernel/film/light_passes.h"
 
 #include "kernel/integrator/guiding.h"
@@ -131,6 +132,7 @@ ccl_device_inline void integrate_background(KernelGlobals 
kg,
 
   /* Write to render buffer. */
   film_write_background(kg, state, L, transparent, 
is_transparent_background_ray, render_buffer);
+  film_write_data_passes_background(kg, state, render_buffer);
 }
 
 ccl_device_inline void integrate_distant_lights(KernelGlobals kg,

___
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] [008070e16c7] blender-v3.4-release: Python Module: add source code and credits to project description

2022-11-28 Thread Brecht Van Lommel
Commit: 008070e16c7ba1cc522a0c5df8677e639a711b37
Author: Brecht Van Lommel
Date:   Mon Nov 28 20:18:14 2022 +0100
Branches: blender-v3.4-release
https://developer.blender.org/rB008070e16c7ba1cc522a0c5df8677e639a711b37

Python Module: add source code and credits to project description

===

M   build_files/utils/make_bpy_wheel.py

===

diff --git a/build_files/utils/make_bpy_wheel.py 
b/build_files/utils/make_bpy_wheel.py
index dd6663a72fb..a0ac1306dda 100755
--- a/build_files/utils/make_bpy_wheel.py
+++ b/build_files/utils/make_bpy_wheel.py
@@ -53,7 +53,18 @@ This package provides Blender as a Python module for use in 
studio pipelines, we
 
 [System requirements](https://www.blender.org/download/requirements/) are the 
same as Blender.
 
-Each Blender release supports one Python version, and the package is only 
compatible with that version."""
+Each Blender release supports one Python version, and the package is only 
compatible with that version.
+
+## Source Code
+
+* [Releases](https://download.blender.org/source/)
+* Repository: 
[git.blender.org/blender.git](https://git.blender.org/gitweb/gitweb.cgi/blender.git)
+
+## Credits
+
+Created by the [Blender developer 
community](https://www.blender.org/about/credits/).
+
+Thanks to Tyler Alden Gubala for maintaining the original version of this 
package."""
 
 # 
--
 # Generic Functions

___
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] [da363d831b8] master: Fix assert when calling transform operators in python handles

2022-11-28 Thread Germano Cavalcante
Commit: da363d831b865df8636189d98499f16613419685
Author: Germano Cavalcante
Date:   Mon Nov 28 15:49:18 2022 -0300
Branches: master
https://developer.blender.org/rBda363d831b865df8636189d98499f16613419685

Fix assert when calling transform operators in python handles

In these cases `t->spacetype` is `SPACE_EMPTY`.

Returning 0 is not problematic as this space does not support snapping
anyway.

===

M   source/blender/editors/transform/transform_snap.cc

===

diff --git a/source/blender/editors/transform/transform_snap.cc 
b/source/blender/editors/transform/transform_snap.cc
index 78752ec7846..014e909b5f4 100644
--- a/source/blender/editors/transform/transform_snap.cc
+++ b/source/blender/editors/transform/transform_snap.cc
@@ -627,10 +627,9 @@ static eSnapFlag snap_flag_from_spacetype(TransInfo *t)
   /* These editors have their own "Auto-Snap" activation option.
* See #getAnimEdit_SnapMode. */
   return eSnapFlag(0);
-default:
-  BLI_assert(false);
-  break;
   }
+  /* #SPACE_EMPTY.
+   * It can happen when the operator is called via a handle in 
`bpy.app.handlers`. */
   return eSnapFlag(0);
 }

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


[Bf-blender-cvs] [bbb389589a0] blender-v3.4-release: Fix T99592: Exact Boolean: Skip empty materials, add index-based option

2022-11-28 Thread Hans Goudey
Commit: bbb389589a0555af9c516a2aacd96dc70bf2d522
Author: Hans Goudey
Date:   Mon Nov 28 12:42:08 2022 -0600
Branches: blender-v3.4-release
https://developer.blender.org/rBbbb389589a0555af9c516a2aacd96dc70bf2d522

Fix T99592: Exact Boolean: Skip empty materials, add index-based option

**Empty Slot Fix**
Currently the boolean modifier transfers the default material from
meshes with no materials and empty material slots to the faces on the
base mesh. I added this in a2d59b2dac9e for the sake of consistency,
but the behavior is actually not useful at all. The default empty
material isn't chosen by users, it just signifies "nothing," so when
it replaces a material chosen by users, it feels like a bug.

This commit corrects that behavior by only transferring materials from
non-empty material slots. The implementation is now consistent between
exact mode of the boolean modifier and the geometry node.

**Index-Based Option**

"Index-based" is the new default material method for the boolean
modifier, to access the old behavior from before the breaking commit.

a2d59b2dac9e actually broke some Boolean workflows fundamentally, since
it was important to set up matching slot indices on each operand. That
isn't the cleanest workflow, and it breaks when materials change
procedurally, but historically that hasn't been a problem. The
"transfer" behavior transfers all materials except for empty slots,
but the fundamental problem is that there isn't a good way to specify
the result materials besides using the slot indices.

Even then, the transfer option is a bit more intuitive and useful for
some simpler situations, and it allows accessing the behavior that has
been in 3.2 and 3.3 for a long time, so it's also left in as an option.
The geometry node doesn't get this new option, in the hope that we'll
find a better solution in the future.

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

===

M   source/blender/blenkernel/BKE_mesh_boolean_convert.hh
M   source/blender/blenkernel/intern/mesh_boolean_convert.cc
M   source/blender/makesdna/DNA_modifier_types.h
M   source/blender/makesrna/intern/rna_modifier.c
M   source/blender/modifiers/intern/MOD_boolean.cc
M   source/blender/nodes/geometry/nodes/node_geo_boolean.cc

===

diff --git a/source/blender/blenkernel/BKE_mesh_boolean_convert.hh 
b/source/blender/blenkernel/BKE_mesh_boolean_convert.hh
index 441783d46a1..77c90716d42 100644
--- a/source/blender/blenkernel/BKE_mesh_boolean_convert.hh
+++ b/source/blender/blenkernel/BKE_mesh_boolean_convert.hh
@@ -22,7 +22,7 @@ namespace blender::meshintersect {
  * It is allowed for the pointers to be null, meaning the transformation is 
the identity.
  * \param material_remaps: An array of maps from material slot numbers in the 
corresponding mesh
  * to the material slot in the first mesh. It is OK for material_remaps or any 
of its constituent
- * arrays to be empty.
+ * arrays to be empty. A -1 value means that the original index should be used 
with no mapping.
  * \param r_intersecting_edges: Array to store indices of edges on the 
resulting mesh in. These
  * 'new' edges are the result of the intersections.
  */
diff --git a/source/blender/blenkernel/intern/mesh_boolean_convert.cc 
b/source/blender/blenkernel/intern/mesh_boolean_convert.cc
index 21d9baf7f7e..1252e90e11c 100644
--- a/source/blender/blenkernel/intern/mesh_boolean_convert.cc
+++ b/source/blender/blenkernel/intern/mesh_boolean_convert.cc
@@ -430,12 +430,14 @@ static void copy_poly_attributes(Mesh *dest_mesh,
   const VArray src_material_indices = 
orig_me->attributes().lookup_or_default(
   "material_index", ATTR_DOMAIN_FACE, 0);
   const int src_index = src_material_indices[index_in_orig_me];
-  if (material_remap.size() > 0 && 
material_remap.index_range().contains(src_index)) {
-dst_material_indices[mp_index] = material_remap[src_index];
+  if (material_remap.index_range().contains(src_index)) {
+const int remapped_index = material_remap[src_index];
+dst_material_indices[mp_index] = remapped_index >= 0 ? remapped_index : 
src_index;
   }
   else {
 dst_material_indices[mp_index] = src_index;
   }
+  BLI_assert(dst_material_indices[mp_index] >= 0);
 }
 
 /* Similar to copy_vert_attributes but for edge attributes. */
diff --git a/source/blender/makesdna/DNA_modifier_types.h 
b/source/blender/makesdna/DNA_modifier_types.h
index c4180071352..97e42efd5ac 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -899,10 +899,18 @@ typedef struct BooleanModifierData {
   float double_threshold;
   char operation;
   char solver;
+  /** #BooleanModifierMaterialMode. */
+  char material_mode;
   char flag;
   char bm_flag;
+  char _pad[7];
 } BooleanModifierData;
 
+typedef enum BooleanModifierMaterialMode {
+  eBooleanModifierMaterialMod

[Bf-blender-cvs] [56ae4089eb3] master: GPencil: Allow interpolation to use breakdown keyframe as extremes

2022-11-28 Thread Antonio Vazquez
Commit: 56ae4089eb350d280580b38b6a9e9bd52c669809
Author: Antonio Vazquez
Date:   Mon Nov 28 19:32:18 2022 +0100
Branches: master
https://developer.blender.org/rB56ae4089eb350d280580b38b6a9e9bd52c669809

GPencil: Allow interpolation to use breakdown keyframe as extremes

Actually, the interpolation can be done only between keyframes different of 
breakdown type,
but in some cases, this is not convenient.

Now, a new option is displayed to allow the interpolation using breakdown 
keyframes
as interpolation extremes.

Reviewed By: mendio, pepeland

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

===

M   release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
M   source/blender/editors/gpencil/gpencil_interpolate.c
M   source/blender/makesdna/DNA_scene_types.h

===

diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py 
b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
index 20021762d5a..b15e55a44f9 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
@@ -2073,6 +2073,7 @@ class _defs_gpencil_paint:
 def draw_settings(_context, layout, tool):
 props = tool.operator_properties("gpencil.interpolate")
 layout.prop(props, "layers")
+layout.prop(props, "exclude_breakdowns")
 layout.prop(props, "flip")
 layout.prop(props, "smooth_factor")
 layout.prop(props, "smooth_steps")
@@ -2256,6 +2257,7 @@ class _defs_gpencil_edit:
 props = tool.operator_properties("gpencil.interpolate")
 layout.prop(props, "layers")
 layout.prop(props, "interpolate_selected_only")
+layout.prop(props, "exclude_breakdowns")
 layout.prop(props, "flip")
 layout.prop(props, "smooth_factor")
 layout.prop(props, "smooth_steps")
diff --git a/source/blender/editors/gpencil/gpencil_interpolate.c 
b/source/blender/editors/gpencil/gpencil_interpolate.c
index cc25ed66b3d..baf2919fd60 100644
--- a/source/blender/editors/gpencil/gpencil_interpolate.c
+++ b/source/blender/editors/gpencil/gpencil_interpolate.c
@@ -412,15 +412,19 @@ static void gpencil_interpolate_update_strokes(bContext 
*C, tGPDinterpolate *tgp
 }
 
 /* Helper: Get previous keyframe (exclude breakdown type). */
-static bGPDframe *gpencil_get_previous_keyframe(bGPDlayer *gpl, int cfra)
+static bGPDframe *gpencil_get_previous_keyframe(bGPDlayer *gpl,
+int cfra,
+const bool exclude_breakdowns)
 {
-  if (gpl->actframe != NULL && gpl->actframe->framenum < cfra &&
-  gpl->actframe->key_type != BEZT_KEYTYPE_BREAKDOWN) {
-return gpl->actframe;
+  if (gpl->actframe != NULL && gpl->actframe->framenum < cfra) {
+if ((!exclude_breakdowns) ||
+((exclude_breakdowns) && (gpl->actframe->key_type != 
BEZT_KEYTYPE_BREAKDOWN))) {
+  return gpl->actframe;
+}
   }
 
   LISTBASE_FOREACH_BACKWARD (bGPDframe *, gpf, &gpl->frames) {
-if (gpf->key_type == BEZT_KEYTYPE_BREAKDOWN) {
+if ((exclude_breakdowns) && (gpf->key_type == BEZT_KEYTYPE_BREAKDOWN)) {
   continue;
 }
 if (gpf->framenum >= cfra) {
@@ -433,10 +437,12 @@ static bGPDframe *gpencil_get_previous_keyframe(bGPDlayer 
*gpl, int cfra)
 }
 
 /* Helper: Get next keyframe (exclude breakdown type). */
-static bGPDframe *gpencil_get_next_keyframe(bGPDlayer *gpl, int cfra)
+static bGPDframe *gpencil_get_next_keyframe(bGPDlayer *gpl,
+int cfra,
+const bool exclude_breakdowns)
 {
   LISTBASE_FOREACH (bGPDframe *, gpf, &gpl->frames) {
-if (gpf->key_type == BEZT_KEYTYPE_BREAKDOWN) {
+if ((exclude_breakdowns) && (gpf->key_type == BEZT_KEYTYPE_BREAKDOWN)) {
   continue;
 }
 if (gpf->framenum <= cfra) {
@@ -455,6 +461,7 @@ static void gpencil_interpolate_set_points(bContext *C, 
tGPDinterpolate *tgpi)
   bGPdata *gpd = tgpi->gpd;
   bGPDlayer *active_gpl = CTX_data_active_gpencil_layer(C);
   bGPDframe *actframe = active_gpl->actframe;
+  const bool exclude_breakdowns = (tgpi->flag & 
GP_TOOLFLAG_INTERPOLATE_EXCLUDE_BREAKDOWNS) != 0;
 
   /* save initial factor for active layer to define shift limits */
   tgpi->init_factor = (float)(tgpi->cframe - actframe->framenum) /
@@ -483,10 +490,10 @@ static void gpencil_interpolate_set_points(bContext *C, 
tGPDinterpolate *tgpi)
 tgpil = MEM_callocN(sizeof(tGPDinterpolate_layer), "GPencil Interpolate 
Layer");
 
 tgpil->gpl = gpl;
-bGPDframe *gpf = gpencil_get_previous_keyframe(gpl, scene->r.cfra);
+bGPDframe *gpf = gpencil_get_previous_keyframe(gpl, scene->r.cfra, 
exclude_breakdowns);
 tgpil->prevFrame = BKE_gpencil_frame_duplicate(gpf, tru

[Bf-blender-cvs] [7e7c6bc4689] master: Cleanup: Use spans and lambdas for mesh normal calculation

2022-11-28 Thread Hans Goudey
Commit: 7e7c6bc46896ad3589320f062601b310070870b5
Author: Hans Goudey
Date:   Mon Nov 28 09:54:07 2022 -0600
Branches: master
https://developer.blender.org/rB7e7c6bc46896ad3589320f062601b310070870b5

Cleanup: Use spans and lambdas for mesh normal calculation

Makes code safer, easier to understand, and less verbose. I detected
negligible performance differences, only a slight improvement for the
normalize step where the function call overhead was probably more
of a bottleneck.

I kept `memset` instead of `.fill(float3(0))` because that gave
better performance in my tests. In the future that stage could be
parallelized, or we could make sure new arrays are allocated with
`calloc`.

===

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

===

diff --git a/source/blender/blenkernel/intern/mesh_normals.cc 
b/source/blender/blenkernel/intern/mesh_normals.cc
index d4ba2499140..e7788d82769 100644
--- a/source/blender/blenkernel/intern/mesh_normals.cc
+++ b/source/blender/blenkernel/intern/mesh_normals.cc
@@ -260,45 +260,32 @@ void BKE_mesh_calc_poly_normal_coords(const MPoly *mpoly,
   }
 }
 
-struct MeshCalcNormalsData_Poly {
-  const MVert *mvert;
-  const MLoop *mloop;
-  const MPoly *mpoly;
-
-  /** Polygon normal output. */
-  float (*pnors)[3];
-};
-
-static void mesh_calc_normals_poly_fn(void *__restrict userdata,
-  const int pidx,
-  const TaskParallelTLS *__restrict 
/*tls*/)
+static void calculate_normals_poly(const Span verts,
+   const Span polys,
+   const Span loops,
+   MutableSpan poly_normals)
 {
-  const MeshCalcNormalsData_Poly *data = (MeshCalcNormalsData_Poly *)userdata;
-  const MPoly *mp = &data->mpoly[pidx];
-  BKE_mesh_calc_poly_normal(mp, data->mloop + mp->loopstart, data->mvert, 
data->pnors[pidx]);
+  using namespace blender;
+  threading::parallel_for(polys.index_range(), 1024, [&](const IndexRange 
range) {
+for (const int poly_i : range) {
+  const MPoly &poly = polys[poly_i];
+  BKE_mesh_calc_poly_normal(&poly, &loops[poly.loopstart], verts.data(), 
poly_normals[poly_i]);
+}
+  });
 }
 
 void BKE_mesh_calc_normals_poly(const MVert *mvert,
-int /*mvert_len*/,
+const int mvert_len,
 const MLoop *mloop,
-int /*mloop_len*/,
+const int mloop_len,
 const MPoly *mpoly,
 int mpoly_len,
 float (*r_poly_normals)[3])
 {
-  TaskParallelSettings settings;
-  BLI_parallel_range_settings_defaults(&settings);
-  settings.min_iter_per_thread = 1024;
-
-  BLI_assert((r_poly_normals != nullptr) || (mpoly_len == 0));
-
-  MeshCalcNormalsData_Poly data = {};
-  data.mpoly = mpoly;
-  data.mloop = mloop;
-  data.mvert = mvert;
-  data.pnors = r_poly_normals;
-
-  BLI_task_parallel_range(0, mpoly_len, &data, mesh_calc_normals_poly_fn, 
&settings);
+  calculate_normals_poly({mvert, mvert_len},
+ {mpoly, mpoly_len},
+ {mloop, mloop_len},
+ {reinterpret_cast(r_poly_normals), 
mpoly_len});
 }
 
 /** \} */
@@ -310,123 +297,110 @@ void BKE_mesh_calc_normals_poly(const MVert *mvert,
  * meshes can slow down high-poly meshes. For details on performance, see 
D11993.
  * \{ */
 
-struct MeshCalcNormalsData_PolyAndVertex {
-  const MVert *mvert;
-  const MLoop *mloop;
-  const MPoly *mpoly;
-
-  /** Polygon normal output. */
-  float (*pnors)[3];
-  /** Vertex normal output. */
-  float (*vnors)[3];
-};
-
-static void mesh_calc_normals_poly_and_vertex_accum_fn(void *__restrict 
userdata,
-   const int pidx,
-   const TaskParallelTLS 
*__restrict /*tls*/)
+static void calculate_normals_poly_and_vert(const Span verts,
+const Span polys,
+const Span loops,
+MutableSpan poly_normals,
+MutableSpan vert_normals)
 {
-  const MeshCalcNormalsData_PolyAndVertex *data = 
(MeshCalcNormalsData_PolyAndVertex *)userdata;
-  const MPoly *mp = &data->mpoly[pidx];
-  const MLoop *ml = &data->mloop[mp->loopstart];
-  const MVert *mverts = data->mvert;
-  float(*vnors)[3] = data->vnors;
-
-  float pnor_temp[3];
-  float *pnor = data->pnors ? data->pnors[pidx] : pnor_temp;
-
-  const int i_end = mp->totloop - 1;
+  using namespace blender;
 
-  /* Polygon Normal and edge-vector. */
-  /* Inline version of #BKE_mesh_calc_poly_

[Bf-blender-cvs] [f9f834068e3] blender-v3.3-release: Cycles: Allow Intel GPUs under Metal

2022-11-28 Thread Morteza Mostajab
Commit: f9f834068e38f562f3590c12af35d3033db98995
Author: Morteza Mostajab
Date:   Wed Oct 19 17:09:23 2022 +0100
Branches: blender-v3.3-release
https://developer.blender.org/rBf9f834068e38f562f3590c12af35d3033db98995

Cycles: Allow Intel GPUs under Metal

Known Issues:
- Command buffer failures when using binary archives (binary archives is 
disabled for Intel GPUs as a workaround)
- Wrong texture sampler being applied (to be addressed in the future)

Ref T92212

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

===

M   intern/cycles/device/metal/device_impl.mm
M   intern/cycles/device/metal/kernel.mm
M   intern/cycles/device/metal/util.mm
M   intern/cycles/kernel/device/metal/context_begin.h

===

diff --git a/intern/cycles/device/metal/device_impl.mm 
b/intern/cycles/device/metal/device_impl.mm
index 6feeaa0707c..f40b056606f 100644
--- a/intern/cycles/device/metal/device_impl.mm
+++ b/intern/cycles/device/metal/device_impl.mm
@@ -338,6 +338,12 @@ bool MetalDevice::compile_and_load(MetalPipelineType 
pso_type)
 
   MTLCompileOptions *options = [[MTLCompileOptions alloc] init];
 
+  if (@available(macos 13.0, *)) {
+if (device_vendor == METAL_GPU_INTEL) {
+  [options setOptimizationLevel:MTLLibraryOptimizationLevelSize];
+}
+  }
+
   options.fastMathEnabled = YES;
   if (@available(macOS 12.0, *)) {
 options.languageVersion = MTLLanguageVersion2_4;
diff --git a/intern/cycles/device/metal/kernel.mm 
b/intern/cycles/device/metal/kernel.mm
index e22b0159108..e06858db3ce 100644
--- a/intern/cycles/device/metal/kernel.mm
+++ b/intern/cycles/device/metal/kernel.mm
@@ -325,6 +325,12 @@ bool MetalKernelPipeline::should_use_binary_archive() const
   }
 }
 
+/* Workaround for Intel GPU having issue using Binary Archives */
+MetalGPUVendor gpu_vendor = MetalInfo::get_device_vendor(mtlDevice);
+if (gpu_vendor == METAL_GPU_INTEL) {
+  return false;
+}
+
 if (pso_type == PSO_GENERIC) {
   /* Archive the generic kernels. */
   return true;
diff --git a/intern/cycles/device/metal/util.mm 
b/intern/cycles/device/metal/util.mm
index 65c67c400fe..eb77aeb6a54 100644
--- a/intern/cycles/device/metal/util.mm
+++ b/intern/cycles/device/metal/util.mm
@@ -110,6 +110,10 @@ vector> const 
&MetalInfo::get_usable_devices()
   usable |= (vendor == METAL_GPU_AMD);
 }
 
+if (@available(macos 13.0, *)) {
+  usable |= (vendor == METAL_GPU_INTEL);
+}
+
 if (usable) {
   metal_printf("- %s\n", device_name.c_str());
   [device retain];
diff --git a/intern/cycles/kernel/device/metal/context_begin.h 
b/intern/cycles/kernel/device/metal/context_begin.h
index 99cb1e3826e..e75ec9cadec 100644
--- a/intern/cycles/kernel/device/metal/context_begin.h
+++ b/intern/cycles/kernel/device/metal/context_begin.h
@@ -34,21 +34,48 @@ class MetalKernelContext {
   kernel_assert(0);
   return 0;
 }
-
+
+#ifdef __KERNEL_METAL_INTEL__
+template
+inline __attribute__((__always_inline__))
+auto ccl_gpu_tex_object_read_intel_workaround(TextureType texture_array,
+  const uint tid, const uint 
sid,
+  CoordsType coords) const
+{
+  switch(sid) {
+default:
+case 0: return texture_array[tid].tex.sample(sampler(address::repeat, 
filter::nearest), coords);
+case 1: return 
texture_array[tid].tex.sample(sampler(address::clamp_to_edge, filter::nearest), 
coords);
+case 2: return 
texture_array[tid].tex.sample(sampler(address::clamp_to_zero, filter::nearest), 
coords);
+case 3: return texture_array[tid].tex.sample(sampler(address::repeat, 
filter::linear), coords);
+case 4: return 
texture_array[tid].tex.sample(sampler(address::clamp_to_edge, filter::linear), 
coords);
+case 5: return 
texture_array[tid].tex.sample(sampler(address::clamp_to_zero, filter::linear), 
coords);
+  }
+}
+#endif
+
 // texture2d
 template<>
 inline __attribute__((__always_inline__))
 float4 ccl_gpu_tex_object_read_2D(ccl_gpu_tex_object_2D tex, float x, 
float y) const {
   const uint tid(tex);
   const uint sid(tex >> 32);
+#ifndef __KERNEL_METAL_INTEL__
   return 
metal_ancillaries->textures_2d[tid].tex.sample(metal_samplers[sid], float2(x, 
y));
+#else
+  return 
ccl_gpu_tex_object_read_intel_workaround(metal_ancillaries->textures_2d, tid, 
sid, float2(x, y));
+#endif
 }
 template<>
 inline __attribute__((__always_inline__))
 float ccl_gpu_tex_object_read_2D(ccl_gpu_tex_object_2D tex, float x, float 
y) const {
   const uint tid(tex);
   const uint sid(tex >> 32);
+#ifndef __KERNEL_METAL_INTEL__
   return 
metal_ancillaries->textures_2d[tid].tex.sample(metal_samplers[sid], float2(x, 
y)).x;
+#else
+

[Bf-blender-cvs] [3e247f0f76e] blender-v3.3-release: Cycles: Enable MetalRT pointclouds & other fixes

2022-11-28 Thread Michael Jones
Commit: 3e247f0f76ec98a09ce0f206a7e6878cb1521807
Author: Michael Jones
Date:   Mon Nov 14 16:51:48 2022 +
Branches: blender-v3.3-release
https://developer.blender.org/rB3e247f0f76ec98a09ce0f206a7e6878cb1521807

Cycles: Enable MetalRT pointclouds & other fixes

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

===

M   intern/cycles/device/metal/bvh.mm
M   intern/cycles/device/metal/device_impl.mm
M   intern/cycles/device/metal/kernel.h
M   intern/cycles/device/metal/kernel.mm
M   intern/cycles/kernel/data_template.h
M   intern/cycles/kernel/device/metal/bvh.h
M   intern/cycles/kernel/device/metal/kernel.metal
M   intern/cycles/scene/object.cpp

===

diff --git a/intern/cycles/device/metal/bvh.mm 
b/intern/cycles/device/metal/bvh.mm
index 09c4ace081e..a7fd64d3c98 100644
--- a/intern/cycles/device/metal/bvh.mm
+++ b/intern/cycles/device/metal/bvh.mm
@@ -496,7 +496,7 @@ bool BVHMetal::build_BLAS_pointcloud(Progress &progress,
   num_motion_steps = pointcloud->get_motion_steps();
 }
 
-const size_t num_aabbs = num_motion_steps;
+const size_t num_aabbs = num_motion_steps * num_points;
 
 MTLResourceOptions storage_mode;
 if (device.hasUnifiedMemory) {
@@ -757,6 +757,10 @@ bool BVHMetal::build_TLAS(Progress &progress,
   }
 }
 
+if (num_instances == 0) {
+  return false;
+}
+
 /**/
 BVH_status("Building TLAS  | %7d instances", (int)num_instances);
 /**/
diff --git a/intern/cycles/device/metal/device_impl.mm 
b/intern/cycles/device/metal/device_impl.mm
index d1250b83d22..6feeaa0707c 100644
--- a/intern/cycles/device/metal/device_impl.mm
+++ b/intern/cycles/device/metal/device_impl.mm
@@ -301,6 +301,9 @@ void MetalDevice::make_source(MetalPipelineType pso_type, 
const uint kernel_feat
   MD5Hash md5;
   md5.append(baked_constants);
   md5.append(source);
+  if (use_metalrt) {
+md5.append(std::to_string(kernel_features & METALRT_FEATURE_MASK));
+  }
   source_md5[pso_type] = md5.get_hex();
 }
 
diff --git a/intern/cycles/device/metal/kernel.h 
b/intern/cycles/device/metal/kernel.h
index 11393f8b7e1..3e88d2daea7 100644
--- a/intern/cycles/device/metal/kernel.h
+++ b/intern/cycles/device/metal/kernel.h
@@ -54,6 +54,10 @@ enum MetalPipelineType {
   PSO_NUM
 };
 
+#  define METALRT_FEATURE_MASK \
+(KERNEL_FEATURE_HAIR | KERNEL_FEATURE_HAIR_THICK | 
KERNEL_FEATURE_POINTCLOUD | \
+ KERNEL_FEATURE_OBJECT_MOTION)
+
 const char *kernel_type_as_string(MetalPipelineType pso_type);
 
 struct MetalKernelPipeline {
@@ -67,9 +71,7 @@ struct MetalKernelPipeline {
 
   KernelData kernel_data_;
   bool use_metalrt;
-  bool metalrt_hair;
-  bool metalrt_hair_thick;
-  bool metalrt_pointcloud;
+  uint32_t metalrt_features = 0;
 
   int threads_per_threadgroup;
 
diff --git a/intern/cycles/device/metal/kernel.mm 
b/intern/cycles/device/metal/kernel.mm
index f3a2fc9ec6c..e22b0159108 100644
--- a/intern/cycles/device/metal/kernel.mm
+++ b/intern/cycles/device/metal/kernel.mm
@@ -225,12 +225,9 @@ void ShaderCache::load_kernel(DeviceKernel device_kernel,
 
   /* metalrt options */
   request.pipeline->use_metalrt = device->use_metalrt;
-  request.pipeline->metalrt_hair = device->use_metalrt &&
-   (device->kernel_features & 
KERNEL_FEATURE_HAIR);
-  request.pipeline->metalrt_hair_thick = device->use_metalrt &&
- (device->kernel_features & 
KERNEL_FEATURE_HAIR_THICK);
-  request.pipeline->metalrt_pointcloud = device->use_metalrt &&
- (device->kernel_features & 
KERNEL_FEATURE_POINTCLOUD);
+  request.pipeline->metalrt_features = device->use_metalrt ?
+   (device->kernel_features & 
METALRT_FEATURE_MASK) :
+   0;
 
   {
 thread_scoped_lock lock(cache_mutex);
@@ -267,9 +264,13 @@ MetalKernelPipeline 
*ShaderCache::get_best_pipeline(DeviceKernel kernel, const M
 
   /* metalrt options */
   bool use_metalrt = device->use_metalrt;
-  bool metalrt_hair = use_metalrt && (device->kernel_features & 
KERNEL_FEATURE_HAIR);
-  bool metalrt_hair_thick = use_metalrt && (device->kernel_features & 
KERNEL_FEATURE_HAIR_THICK);
-  bool metalrt_pointcloud = use_metalrt && (device->kernel_features & 
KERNEL_FEATURE_POINTCLOUD);
+  bool device_metalrt_hair = use_metalrt && device->kernel_features & 
KERNEL_FEATURE_HAIR;
+  bool device_metalrt_hair_thick = use_metalrt &&
+   device->kernel_features & 
KERNEL_FEATURE_HAIR_THICK;
+  bool device_metalrt_pointcloud = use_metalrt &&
+   device->kernel_features & 
KERNEL_FEATURE_POINTCLOUD;
+  bool device_metalrt_motion = use

[Bf-blender-cvs] [86abbf71769] blender-v3.3-release: Fix macOS build error after recent changes to enable Intel GPUs

2022-11-28 Thread Brecht Van Lommel
Commit: 86abbf717691c016077c89692b29349ec22d255b
Author: Brecht Van Lommel
Date:   Wed Oct 19 20:31:12 2022 +0200
Branches: blender-v3.3-release
https://developer.blender.org/rB86abbf717691c016077c89692b29349ec22d255b

Fix macOS build error after recent changes to enable Intel GPUs

This will only work once we upgrade to the macOS 13 SDK.

Ref D16253

===

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

===

diff --git a/intern/cycles/device/metal/device_impl.mm 
b/intern/cycles/device/metal/device_impl.mm
index f40b056606f..92aa783ed92 100644
--- a/intern/cycles/device/metal/device_impl.mm
+++ b/intern/cycles/device/metal/device_impl.mm
@@ -338,11 +338,13 @@ bool MetalDevice::compile_and_load(MetalPipelineType 
pso_type)
 
   MTLCompileOptions *options = [[MTLCompileOptions alloc] init];
 
+#if defined(MAC_OS_VERSION_13_0)
   if (@available(macos 13.0, *)) {
 if (device_vendor == METAL_GPU_INTEL) {
   [options setOptimizationLevel:MTLLibraryOptimizationLevelSize];
 }
   }
+#endif
 
   options.fastMathEnabled = YES;
   if (@available(macOS 12.0, *)) {
diff --git a/intern/cycles/device/metal/util.mm 
b/intern/cycles/device/metal/util.mm
index eb77aeb6a54..63f84a9df33 100644
--- a/intern/cycles/device/metal/util.mm
+++ b/intern/cycles/device/metal/util.mm
@@ -110,9 +110,11 @@ vector> const 
&MetalInfo::get_usable_devices()
   usable |= (vendor == METAL_GPU_AMD);
 }
 
+#if defined(MAC_OS_VERSION_13_0)
 if (@available(macos 13.0, *)) {
   usable |= (vendor == METAL_GPU_INTEL);
 }
+#endif
 
 if (usable) {
   metal_printf("- %s\n", device_name.c_str());

___
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] [021c8c7cd0c] blender-v3.3-release: Cycles: Tweak inlining policy on Metal

2022-11-28 Thread Michael Jones
Commit: 021c8c7cd0c7472eb182d72c11d7201faa13c1f2
Author: Michael Jones
Date:   Tue Sep 27 17:01:17 2022 +0100
Branches: blender-v3.3-release
https://developer.blender.org/rB021c8c7cd0c7472eb182d72c11d7201faa13c1f2

Cycles: Tweak inlining policy on Metal

This patch optimises the Metal inlining policy. It gives a small speedup
(2-3% on M1 Max) with no notable compilation slowdown vs what is already
in master. Previously noted compilation slowdowns (as reported in T100102)
were caused by forcing inlining for `ccl_device`, but we get better
rendering perf by relying on compiler heuristics in these cases.

Backported to 3.3 because this also fixes a test failure.

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

===

M   intern/cycles/kernel/device/metal/compat.h

===

diff --git a/intern/cycles/kernel/device/metal/compat.h 
b/intern/cycles/kernel/device/metal/compat.h
index b86d1f64307..c321f4451f6 100644
--- a/intern/cycles/kernel/device/metal/compat.h
+++ b/intern/cycles/kernel/device/metal/compat.h
@@ -29,28 +29,13 @@ using namespace metal::raytracing;
 
 /* Qualifiers */
 
-/* Inline everything for Apple GPUs. This gives ~1.1x speedup and 10% spill
- * reduction for integator_shade_surface. However it comes at the cost of
- * longer compile times (~4.5 minutes on M1 Max) and is disabled for that
- * reason, until there is a user option to manually enable it. */
-
-#if 0  // defined(__KERNEL_METAL_APPLE__)
-
-#  define ccl_device __attribute__((always_inline))
-#  define ccl_device_inline __attribute__((always_inline))
-#  define ccl_device_forceinline __attribute__((always_inline))
-#  define ccl_device_noinline __attribute__((always_inline))
-
+#define ccl_device
+#define ccl_device_inline ccl_device __attribute__((always_inline))
+#define ccl_device_forceinline ccl_device __attribute__((always_inline))
+#if defined(__KERNEL_METAL_APPLE__)
+#  define ccl_device_noinline ccl_device
 #else
-
-#  define ccl_device
-#  define ccl_device_inline ccl_device
-#  define ccl_device_forceinline ccl_device
-#  if defined(__KERNEL_METAL_APPLE__)
-#define ccl_device_noinline ccl_device
-#  else
-#define ccl_device_noinline ccl_device __attribute__((noinline))
-#  endif
+#  define ccl_device_noinline ccl_device __attribute__((noinline))
 #endif
 
 #define ccl_device_noinline_cpu ccl_device

___
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] [da01237d36c] tmp-vfx-platform-2023: Fix libsndlib picking up system libopus

2022-11-28 Thread Brecht Van Lommel
Commit: da01237d36ca6f46937da900d4901ed91611f314
Author: Brecht Van Lommel
Date:   Mon Nov 28 16:27:54 2022 +0100
Branches: tmp-vfx-platform-2023
https://developer.blender.org/rBda01237d36ca6f46937da900d4901ed91611f314

Fix libsndlib picking up system libopus

Build against our own instead.

===

M   build_files/build_environment/cmake/sndfile.cmake

===

diff --git a/build_files/build_environment/cmake/sndfile.cmake 
b/build_files/build_environment/cmake/sndfile.cmake
index a2ac2a33779..1e4249e7e53 100644
--- a/build_files/build_environment/cmake/sndfile.cmake
+++ b/build_files/build_environment/cmake/sndfile.cmake
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0-or-later
 
 set(SNDFILE_EXTRA_ARGS)
-set(SNDFILE_ENV 
PKG_CONFIG_PATH=${mingw_LIBDIR}/ogg/lib/pkgconfig:${mingw_LIBDIR}/vorbis/lib/pkgconfig:${mingw_LIBDIR}/flac/lib/pkgconfig:${mingw_LIBDIR})
+set(SNDFILE_ENV 
PKG_CONFIG_PATH=${mingw_LIBDIR}/ogg/lib/pkgconfig:${mingw_LIBDIR}/vorbis/lib/pkgconfig:${mingw_LIBDIR}/flac/lib/pkgconfig:${mingw_LIBDIR}/opus/lib/pkgconfig:${mingw_LIBDIR})
 
 if(WIN32)
   set(SNDFILE_ENV set ${SNDFILE_ENV} &&)
@@ -30,6 +30,7 @@ add_dependencies(
   external_sndfile
   external_ogg
   external_vorbis
+  external_opus
 )
 if(UNIX)
   add_dependencies(

___
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] [3b08062b343] tmp-vfx-platform-2023: MaterialX: various changes

2022-11-28 Thread Brecht Van Lommel
Commit: 3b08062b343679cab3a5f72673100e139c17eda0
Author: Brecht Van Lommel
Date:   Thu Nov 24 19:50:00 2022 +0100
Branches: tmp-vfx-platform-2023
https://developer.blender.org/rB3b08062b343679cab3a5f72673100e139c17eda0

MaterialX: various changes

* Install datafiles in shared library folder
* Various fixes to make it work on macOS/Linux
* Disqble MaterialXRender modules
* Use sitecustomize instead of usercustomize mechanism, as the latter
  seems to be disabled by default and site seems more correct anyway.

===

M   build_files/build_environment/cmake/materialx.cmake
M   build_files/cmake/platform/platform_apple.cmake
A   release/scripts/site/sitecustomize.py
D   release/scripts/site/usercustomize.py
M   source/creator/CMakeLists.txt

===

diff --git a/build_files/build_environment/cmake/materialx.cmake 
b/build_files/build_environment/cmake/materialx.cmake
index eb6a22e8ad3..37913c74d6a 100644
--- a/build_files/build_environment/cmake/materialx.cmake
+++ b/build_files/build_environment/cmake/materialx.cmake
@@ -2,6 +2,7 @@
 
 set(MATERIALX_EXTRA_ARGS
   -DMATERIALX_BUILD_PYTHON=ON
+  -DMATERIALX_BUILD_RENDER=OFF
   -DMATERIALX_INSTALL_PYTHON=OFF
   -DMATERIALX_PYTHON_EXECUTABLE=${PYTHON_BINARY}
   -DMATERIALX_PYTHON_VERSION=${PYTHON_SHORT_VERSION}
diff --git a/build_files/cmake/platform/platform_apple.cmake 
b/build_files/cmake/platform/platform_apple.cmake
index 07d7036f809..fca0c3a06c5 100644
--- a/build_files/cmake/platform/platform_apple.cmake
+++ b/build_files/cmake/platform/platform_apple.cmake
@@ -89,6 +89,14 @@ if(WITH_USD)
   add_bundled_libraries(usd/lib)
 endif()
 
+if(WITH_MATERIALX)
+  find_package(MaterialX)
+  set_and_warn_library_found("MaterialX" MaterialX_FOUND WITH_MATERIALX)
+  if(WITH_MATERIALX)
+add_bundled_libraries(materialx/lib)
+  endif()
+endif()
+
 if(WITH_OPENSUBDIV)
   find_package(OpenSubdiv)
   add_bundled_libraries(opensubdiv/lib)
diff --git a/release/scripts/site/sitecustomize.py 
b/release/scripts/site/sitecustomize.py
new file mode 100644
index 000..891930eb132
--- /dev/null
+++ b/release/scripts/site/sitecustomize.py
@@ -0,0 +1,41 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Make shared libraries needed by modules available in standalone Python 
binary.
+
+import sys
+import os
+
+exe_dir, exe_file = os.path.split(sys.executable)
+is_python = exe_file.startswith("python")
+
+# Path to Blender shared libraries.
+shared_lib_dirname = "blender.shared" if sys.platform == "win32" else "lib"
+if is_python:
+shared_lib_dir = os.path.abspath(os.path.join(exe_dir, "..", "..", "..", 
shared_lib_dirname))
+else:
+shared_lib_dir = os.path.abspath(os.path.join(exe_dir, shared_lib_dirname))
+
+if sys.platform == "win32":
+# Directory for extensions to find DLLs.
+if is_python:
+os.add_dll_directory(shared_lib_dir)
+
+# Directory for USD extension to find DLLs.
+import_paths = os.getenv("PXR_USD_WINDOWS_DLL_PATH")
+if import_paths is None:
+os.environ["PXR_USD_WINDOWS_DLL_PATH"] = shared_lib_dir
+
+# OIIO will by default add all paths from the path variable to 
add_dll_directory
+# problem there is that those folders will be searched before ours and 
versions of
+# some dlls may be found that are not blenders and may not even be the 
right version
+# causing compatibility issues.
+os.environ["OIIO_LOAD_DLLS_FROM_PATH"] = "0"
+
+# MaterialX libraries, append if already specified.
+materialx_libs_dir = os.path.abspath(os.path.join(shared_lib_dir, "materialx", 
"libraries"))
+materialx_libs_env = os.getenv("MATERIALX_SEARCH_PATH")
+if materialx_libs_env is None:
+os.environ["MATERIALX_SEARCH_PATH"] = materialx_libs_dir
+elif sys.platform == "win32":
+os.environ["MATERIALX_SEARCH_PATH"] = materialx_libs_dir + ";" + 
materialx_libs_env
+else:
+os.environ["MATERIALX_SEARCH_PATH"] = materialx_libs_dir + ":" + 
materialx_libs_env
diff --git a/release/scripts/site/usercustomize.py 
b/release/scripts/site/usercustomize.py
deleted file mode 100644
index 21f9acc5f05..000
--- a/release/scripts/site/usercustomize.py
+++ /dev/null
@@ -1,25 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-or-later
-# Make shared libraries needed by modules available in standalone Python 
binary.
-
-import sys
-import os
-
-if sys.platform == 'win32':
-exe_dir, exe_file = os.path.split(sys.executable)
-if exe_file.startswith('python'):
-blender_dir = os.path.abspath(os.path.join(exe_dir, '..', '..', 
'..','blender.shared'))
-os.add_dll_directory(blender_dir)
-# OIIO will by default add all paths from the path variable to 
add_dll_directory
-# problem there is that those folders will be searched before ours and 
versions of
-# some dlls may be found that are not blenders and may not even be the 
right version
-# causing 

[Bf-blender-cvs] [8c8abae9710] tmp-vfx-platform-2023: Fix collada patch apply issue on macOS

2022-11-28 Thread Brecht Van Lommel
Commit: 8c8abae97104ebf5e72bbc33fe4c4f8d934e75b4
Author: Brecht Van Lommel
Date:   Mon Nov 28 16:16:44 2022 +0100
Branches: tmp-vfx-platform-2023
https://developer.blender.org/rB8c8abae97104ebf5e72bbc33fe4c4f8d934e75b4

Fix collada patch apply issue on macOS

===

M   build_files/build_environment/cmake/check_software.cmake
M   build_files/build_environment/cmake/opencollada.cmake

===

diff --git a/build_files/build_environment/cmake/check_software.cmake 
b/build_files/build_environment/cmake/check_software.cmake
index 903c2c3022f..34544ca176b 100644
--- a/build_files/build_environment/cmake/check_software.cmake
+++ b/build_files/build_environment/cmake/check_software.cmake
@@ -19,7 +19,9 @@ if(UNIX)
 yasm
   )
 
-  if(NOT APPLE)
+  if(APPLE)
+list(APPEND _required_software dos2unix)
+  else()
 list(APPEND _required_software patchelf)
   endif()
 
@@ -53,7 +55,7 @@ if(UNIX)
   "  apt install autoconf automake bison libtool yasm tcl ninja-build 
meson python3-mako patchelf\n"
   "\n"
   "On macOS (with homebrew):\n"
-  "  brew install autoconf automake bison flex libtool meson ninja 
pkg-config yasm\n"
+  "  brew install autoconf automake bison dos2unix flex libtool meson 
ninja pkg-config yasm\n"
   "\n"
   "Other platforms:\n"
   "  Install equivalent packages.\n")
diff --git a/build_files/build_environment/cmake/opencollada.cmake 
b/build_files/build_environment/cmake/opencollada.cmake
index b1a3028debd..9e403f25181 100644
--- a/build_files/build_environment/cmake/opencollada.cmake
+++ b/build_files/build_environment/cmake/opencollada.cmake
@@ -9,13 +9,17 @@ if(UNIX)
   # as does the OPENCOLLADA package, if this can be corrected upstream that 
would be better.
   # For now use `sed` to force UNIX line endings so the patch applies.
   # Needed as neither ignoring white-space or applying as a binary resolve 
this problem.
+  if(APPLE)
+set(_dos2unix dos2unix)
+  else()
+set(_dos2unix sed -i "s/\\r//")
+  endif()
   set(PATCH_MAYBE_DOS2UNIX_CMD
-sed -i "s/\\r//"
+${_dos2unix}
 ${PATCH_DIR}/opencollada.diff
 ${BUILD_DIR}/opencollada/src/external_opencollada/CMakeLists.txt
 
${BUILD_DIR}/opencollada/src/external_opencollada/Externals/LibXML/CMakeLists.txt
 &&
   )
-
 else()
   set(OPENCOLLADA_EXTRA_ARGS
 -DCMAKE_DEBUG_POSTFIX=_d

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


[Bf-blender-cvs] [b0bf10889be] master: Merge branch 'blender-v3.4-release'

2022-11-28 Thread Richard Antalik
Commit: b0bf10889be974cc44698e9fc7c80fe0f51e3b60
Author: Richard Antalik
Date:   Mon Nov 28 18:26:21 2022 +0100
Branches: master
https://developer.blender.org/rBb0bf10889be974cc44698e9fc7c80fe0f51e3b60

Merge branch 'blender-v3.4-release'

===



===



___
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] [33ce83984df] blender-v3.4-release: Fix T102801: Empty metasequence sliding away while moving

2022-11-28 Thread Richard Antalik
Commit: 33ce83984df27d22101a981a39612e284e1972e1
Author: Richard Antalik
Date:   Mon Nov 28 18:23:29 2022 +0100
Branches: blender-v3.4-release
https://developer.blender.org/rB33ce83984df27d22101a981a39612e284e1972e1

Fix T102801: Empty metasequence sliding away while moving

Meta strip position relies on strips within. When meta strip is empty,
update function, that would normally update it's position returns early
and this causes translaton to behave erratically.

When strip is empty, treat it as normal strip and move its start frame
as with other strip types.

===

M   source/blender/sequencer/intern/strip_transform.c

===

diff --git a/source/blender/sequencer/intern/strip_transform.c 
b/source/blender/sequencer/intern/strip_transform.c
index 14875df9445..7b1ae1dd454 100644
--- a/source/blender/sequencer/intern/strip_transform.c
+++ b/source/blender/sequencer/intern/strip_transform.c
@@ -117,9 +117,10 @@ void SEQ_transform_translate_sequence(Scene *evil_scene, 
Sequence *seq, int delt
 return;
   }
 
-  /* Meta strips requires special handling: their content is to be translated, 
and then frame range
-   * of the meta is to be updated for the updated content. */
-  if (seq->type == SEQ_TYPE_META) {
+  /* Meta strips requires their content is to be translated, and then frame 
range of the meta is
+   * updated based on nested strips. Thiw won't work for empty metas, so they 
can be treated as
+   * normal strip. */
+  if (seq->type == SEQ_TYPE_META && !BLI_listbase_is_empty(&seq->seqbase)) {
 Sequence *seq_child;
 for (seq_child = seq->seqbase.first; seq_child; seq_child = 
seq_child->next) {
   SEQ_transform_translate_sequence(evil_scene, seq_child, delta);

___
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] [2c7b7161f2d] soc-2022-many-lights-sampling: Fix wrong distant light bounding cone angles

2022-11-28 Thread Weizhen Huang
Commit: 2c7b7161f2df0015b1ed63aee693983bf95d953c
Author: Weizhen Huang
Date:   Mon Nov 28 18:13:24 2022 +0100
Branches: soc-2022-many-lights-sampling
https://developer.blender.org/rB2c7b7161f2df0015b1ed63aee693983bf95d953c

Fix wrong distant light bounding cone angles

===

M   intern/cycles/kernel/light/tree.h
M   intern/cycles/scene/light_tree.cpp

===

diff --git a/intern/cycles/kernel/light/tree.h 
b/intern/cycles/kernel/light/tree.h
index 9b4462387c3..9ffb4c22697 100644
--- a/intern/cycles/kernel/light/tree.h
+++ b/intern/cycles/kernel/light/tree.h
@@ -259,8 +259,7 @@ ccl_device void light_tree_emitter_importance(KernelGlobals 
kg,
   }
   if (klight->type == LIGHT_DISTANT) {
 /* Treating it as a disk light 1 unit away */
-cos_theta_u = fast_cosf(theta_o);
-theta_o = 0.0f;
+cos_theta_u = fast_cosf(kemitter->theta_e);
 max_distance = 1.0f / cos_theta_u;
   }
   else {
diff --git a/intern/cycles/scene/light_tree.cpp 
b/intern/cycles/scene/light_tree.cpp
index 90f5ae43260..6db2b29c4fd 100644
--- a/intern/cycles/scene/light_tree.cpp
+++ b/intern/cycles/scene/light_tree.cpp
@@ -173,8 +173,8 @@ LightTreePrimitive::LightTreePrimitive(Scene *scene, int 
prim_id, int object_id)
   strength *= lamp->get_average_radiance() * M_PI_F;
 }
 else if (type == LIGHT_DISTANT) {
-  bcone.theta_o = tanf(0.5f * lamp->get_angle());
-  bcone.theta_e = 0;
+  bcone.theta_o = 0;
+  bcone.theta_e = 0.5f * lamp->get_angle();
 }
 
 if (lamp->get_shader()) {

___
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] [33b3645d975] master: Merge branch 'blender-v3.4-release'

2022-11-28 Thread Bastien Montagne
Commit: 33b3645d9759995ccce1eeff22349124dc72741b
Author: Bastien Montagne
Date:   Mon Nov 28 17:11:46 2022 +0100
Branches: master
https://developer.blender.org/rB33b3645d9759995ccce1eeff22349124dc72741b

Merge branch 'blender-v3.4-release'

===



===



___
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] [9eb1d62ba60] blender-v3.4-release: Fix T102638: GPencil: Modifier added on linked object restore its value on reloading the file

2022-11-28 Thread Bastien Montagne
Commit: 9eb1d62ba60a084b5305c39a007f7b74679401c9
Author: Bastien Montagne
Date:   Mon Nov 28 17:10:02 2022 +0100
Branches: blender-v3.4-release
https://developer.blender.org/rB9eb1d62ba60a084b5305c39a007f7b74679401c9

Fix T102638: GPencil: Modifier added on linked object restore its value on 
reloading the file

One line missing in code handling overrides insertions of gpencil
modifiers...

Fix also suitable for 3.3LTS.

===

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

===

diff --git a/source/blender/makesrna/intern/rna_object.c 
b/source/blender/makesrna/intern/rna_object.c
index fc0631c7043..08500a0b984 100644
--- a/source/blender/makesrna/intern/rna_object.c
+++ b/source/blender/makesrna/intern/rna_object.c
@@ -323,6 +323,7 @@ const EnumPropertyItem rna_enum_object_axis_items[] = {
 #  include "BKE_deform.h"
 #  include "BKE_effect.h"
 #  include "BKE_global.h"
+#  include "BKE_gpencil_modifier.h"
 #  include "BKE_key.h"
 #  include "BKE_material.h"
 #  include "BKE_mesh.h"
@@ -1949,6 +1950,8 @@ bool 
rna_Object_greasepencil_modifiers_override_apply(Main *bmain,
   GpencilModifierData *mod_dst = ED_object_gpencil_modifier_add(
   NULL, bmain, NULL, ob_dst, mod_src->name, mod_src->type);
 
+  BKE_gpencil_modifier_copydata(mod_src, mod_dst);
+
   BLI_remlink(&ob_dst->greasepencil_modifiers, mod_dst);
   /* This handles NULL anchor as expected by adding at head of list. */
   BLI_insertlinkafter(&ob_dst->greasepencil_modifiers, mod_anchor, mod_dst);

___
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] [8dfe5b236e9] blender-v3.3-release: Fix slow continuous depsgraph updates in sculpt paint mode in some cases

2022-11-28 Thread Brecht Van Lommel
Commit: 8dfe5b236e9fc057a372050985c4931a55bbb167
Author: Brecht Van Lommel
Date:   Wed Oct 26 19:27:12 2022 +0200
Branches: blender-v3.3-release
https://developer.blender.org/rB8dfe5b236e9fc057a372050985c4931a55bbb167

Fix slow continuous depsgraph updates in sculpt paint mode in some cases

Updates for cursor could cause the paint data to be continuously refreshed,
which is pretty cheap by itself, but not when it starts tagging the depsgraph.

The paint slot refresh code ideally should not be doing depsgraph tags at all,
but checking if there were changes at least avoids continuous updates.

===

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

===

diff --git a/source/blender/blenkernel/intern/material.c 
b/source/blender/blenkernel/intern/material.c
index df2c48aaac5..c0d57cc20e6 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -1496,58 +1496,65 @@ static ePaintSlotFilter 
material_paint_slot_filter(const struct Object *ob)
 
 void BKE_texpaint_slot_refresh_cache(Scene *scene, Material *ma, const struct 
Object *ob)
 {
-  int count = 0;
-
   if (!ma) {
 return;
   }
 
   const ePaintSlotFilter slot_filter = material_paint_slot_filter(ob);
 
-  /* COW needed when adding texture slot on an object with no materials. */
-  DEG_id_tag_update(&ma->id, ID_RECALC_SHADING | ID_RECALC_COPY_ON_WRITE);
+  const TexPaintSlot *prev_texpaintslot = ma->texpaintslot;
+  const int prev_paint_active_slot = ma->paint_active_slot;
+  const int prev_paint_clone_slot = ma->paint_clone_slot;
+  const int prev_tot_slots = ma->tot_slots;
 
-  if (ma->texpaintslot) {
-MEM_freeN(ma->texpaintslot);
-ma->tot_slots = 0;
-ma->texpaintslot = NULL;
-  }
+  ma->texpaintslot = NULL;
+  ma->tot_slots = 0;
 
   if (scene->toolsettings->imapaint.mode == IMAGEPAINT_MODE_IMAGE) {
 ma->paint_active_slot = 0;
 ma->paint_clone_slot = 0;
-return;
   }
-
-  if (!(ma->nodetree)) {
+  else if (!(ma->nodetree)) {
 ma->paint_active_slot = 0;
 ma->paint_clone_slot = 0;
-return;
   }
+  else {
+int count = count_texture_nodes_recursive(ma->nodetree, slot_filter);
 
-  count = count_texture_nodes_recursive(ma->nodetree, slot_filter);
-
-  if (count == 0) {
-ma->paint_active_slot = 0;
-ma->paint_clone_slot = 0;
-return;
-  }
+if (count == 0) {
+  ma->paint_active_slot = 0;
+  ma->paint_clone_slot = 0;
+}
+else {
+  ma->texpaintslot = MEM_callocN(sizeof(*ma->texpaintslot) * count, 
"texpaint_slots");
 
-  ma->texpaintslot = MEM_callocN(sizeof(*ma->texpaintslot) * count, 
"texpaint_slots");
+  bNode *active_node = nodeGetActivePaintCanvas(ma->nodetree);
 
-  bNode *active_node = nodeGetActivePaintCanvas(ma->nodetree);
+  fill_texpaint_slots_recursive(ma->nodetree, active_node, ob, ma, count, 
slot_filter);
 
-  fill_texpaint_slots_recursive(ma->nodetree, active_node, ob, ma, count, 
slot_filter);
+  ma->tot_slots = count;
 
-  ma->tot_slots = count;
+  if (ma->paint_active_slot >= count) {
+ma->paint_active_slot = count - 1;
+  }
 
-  if (ma->paint_active_slot >= count) {
-ma->paint_active_slot = count - 1;
+  if (ma->paint_clone_slot >= count) {
+ma->paint_clone_slot = count - 1;
+  }
+}
   }
 
-  if (ma->paint_clone_slot >= count) {
-ma->paint_clone_slot = count - 1;
+  /* COW needed when adding texture slot on an object with no materials.
+   * But do it only when slots actually change to avoid continuous depsgrap 
updates. */
+  if (ma->tot_slots != prev_tot_slots || ma->paint_active_slot != 
prev_paint_active_slot ||
+  ma->paint_clone_slot != prev_paint_clone_slot ||
+  (ma->texpaintslot && prev_texpaintslot &&
+   memcmp(ma->texpaintslot, prev_texpaintslot, sizeof(*ma->texpaintslot) * 
ma->tot_slots) !=
+   0)) {
+DEG_id_tag_update(&ma->id, ID_RECALC_SHADING | ID_RECALC_COPY_ON_WRITE);
   }
+
+  MEM_SAFE_FREE(prev_texpaintslot);
 }
 
 void BKE_texpaint_slots_refresh_object(Scene *scene, struct Object *ob)

___
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] [c47b6978e32] master: Animation: Make Bake Animation operator use preview range when enabled

2022-11-28 Thread Colin Basnett
Commit: c47b6978e327c654109f78cea4935a577010bad1
Author: Colin Basnett
Date:   Mon Nov 28 08:04:02 2022 -0800
Branches: master
https://developer.blender.org/rBc47b6978e327c654109f78cea4935a577010bad1

Animation: Make Bake Animation operator use preview range when enabled

This patch makes the Bake Actions operator fills the Start Frame & End From 
with that of the Preview Range if "Use Preview Range" is enabled.

{F13973619}

Reviewed By: sybren

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

===

M   release/scripts/startup/bl_operators/anim.py

===

diff --git a/release/scripts/startup/bl_operators/anim.py 
b/release/scripts/startup/bl_operators/anim.py
index 0f4c6c4b9c3..1c92ee81345 100644
--- a/release/scripts/startup/bl_operators/anim.py
+++ b/release/scripts/startup/bl_operators/anim.py
@@ -282,8 +282,12 @@ class NLA_OT_bake(Operator):
 
 def invoke(self, context, _event):
 scene = context.scene
-self.frame_start = scene.frame_start
-self.frame_end = scene.frame_end
+if scene.use_preview_range:
+self.frame_start = scene.frame_preview_start
+self.frame_end = scene.frame_preview_end
+else:
+self.frame_start = scene.frame_start
+self.frame_end = scene.frame_end
 self.bake_types = {'POSE'} if context.mode == 'POSE' else {'OBJECT'}
 
 wm = context.window_manager

___
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] [24c416c302a] blender-v3.3-release: Fix T101925: sculpt color painting not updating with Cycles viewport render

2022-11-28 Thread Brecht Van Lommel
Commit: 24c416c302ae694bf67cc44c31b73d8521d503ff
Author: Brecht Van Lommel
Date:   Wed Oct 26 18:01:45 2022 +0200
Branches: blender-v3.3-release
https://developer.blender.org/rB24c416c302ae694bf67cc44c31b73d8521d503ff

Fix T101925: sculpt color painting not updating with Cycles viewport render

* External engines do not use the PBVH and need slower depsgraph updates.
* Final depsgraph tag after stroke finishes was missing for sculpt color
  painting, caused missing updates for other viewports as well as any
  modifiers or nodes on other objects using the colors.

===

M   source/blender/blenkernel/BKE_paint.h
M   source/blender/blenkernel/intern/paint.c
M   source/blender/draw/engines/basic/basic_engine.c
M   source/blender/draw/engines/eevee/eevee_materials.c
M   source/blender/draw/engines/overlay/overlay_facing.c
M   source/blender/draw/engines/overlay/overlay_fade.c
M   source/blender/draw/engines/overlay/overlay_mode_transfer.c
M   source/blender/draw/engines/overlay/overlay_sculpt.c
M   source/blender/draw/engines/overlay/overlay_wireframe.c
M   source/blender/draw/engines/workbench/workbench_engine.c
M   source/blender/editors/sculpt_paint/sculpt.c
M   source/blender/editors/sculpt_paint/sculpt_undo.c

===

diff --git a/source/blender/blenkernel/BKE_paint.h 
b/source/blender/blenkernel/BKE_paint.h
index 162459d2005..c1fad8995be 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -732,7 +732,7 @@ void BKE_sculpt_ensure_orig_mesh_data(struct Scene *scene, 
struct Object *object
  * Test if PBVH can be used directly for drawing, which is faster than
  * drawing the mesh and all updates that come with it.
  */
-bool BKE_sculptsession_use_pbvh_draw(const struct Object *ob, const struct 
View3D *v3d);
+bool BKE_sculptsession_use_pbvh_draw(const struct Object *ob, const struct 
RegionView3D *rv3d);
 
 enum {
   SCULPT_MASK_LAYER_CALC_VERT = (1 << 0),
diff --git a/source/blender/blenkernel/intern/paint.c 
b/source/blender/blenkernel/intern/paint.c
index 9b0d15ac702..8e14df0e7d9 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -2313,7 +2313,7 @@ void BKE_sculpt_bvh_update_from_ccg(PBVH *pbvh, SubdivCCG 
*subdiv_ccg)
 subdiv_ccg->grid_hidden);
 }
 
-bool BKE_sculptsession_use_pbvh_draw(const Object *ob, const View3D 
*UNUSED(v3d))
+bool BKE_sculptsession_use_pbvh_draw(const Object *ob, const RegionView3D 
*rv3d)
 {
   SculptSession *ss = ob->sculpt;
   if (ss == NULL || ss->pbvh == NULL || ss->mode_type != OB_MODE_SCULPT) {
@@ -2321,9 +2321,10 @@ bool BKE_sculptsession_use_pbvh_draw(const Object *ob, 
const View3D *UNUSED(v3d)
   }
 
   if (BKE_pbvh_type(ss->pbvh) == PBVH_FACES) {
-/* Regular mesh only draws from PBVH without modifiers and shape keys. */
-
-return !(ss->shapekey_active || ss->deform_modifiers_active);
+/* Regular mesh only draws from PBVH without modifiers and shape keys, or 
for
+ * external engines that do not have access to the PBVH like Eevee does. */
+const bool external_engine = rv3d && rv3d->render_engine != NULL;
+return !(ss->shapekey_active || ss->deform_modifiers_active || 
external_engine);
   }
 
   /* Multires and dyntopo always draw directly from the PBVH. */
diff --git a/source/blender/draw/engines/basic/basic_engine.c 
b/source/blender/draw/engines/basic/basic_engine.c
index 975d9e299bf..5e46b54fc2d 100644
--- a/source/blender/draw/engines/basic/basic_engine.c
+++ b/source/blender/draw/engines/basic/basic_engine.c
@@ -183,7 +183,7 @@ static void basic_cache_populate(void *vedata, Object *ob)
 }
   }
 
-  const bool use_sculpt_pbvh = BKE_sculptsession_use_pbvh_draw(ob, 
draw_ctx->v3d) &&
+  const bool use_sculpt_pbvh = BKE_sculptsession_use_pbvh_draw(ob, 
draw_ctx->rv3d) &&
!DRW_state_is_image_render();
   const bool do_cull = (draw_ctx->v3d &&
 (draw_ctx->v3d->shading.flag & 
V3D_SHADING_BACKFACE_CULLING));
diff --git a/source/blender/draw/engines/eevee/eevee_materials.c 
b/source/blender/draw/engines/eevee/eevee_materials.c
index 50e038dc898..684c6cd394b 100644
--- a/source/blender/draw/engines/eevee/eevee_materials.c
+++ b/source/blender/draw/engines/eevee/eevee_materials.c
@@ -803,7 +803,7 @@ void EEVEE_materials_cache_populate(EEVEE_Data *vedata,
   const DRWContextState *draw_ctx = DRW_context_state_get();
   Scene *scene = draw_ctx->scene;
 
-  bool use_sculpt_pbvh = BKE_sculptsession_use_pbvh_draw(ob, draw_ctx->v3d) &&
+  bool use_sculpt_pbvh = BKE_sculptsession_use_pbvh_draw(ob, draw_ctx->rv3d) &&
  !DRW_state_is_image_render();
 
   /* First get materials for this mesh. */
diff --git a/source/blender/draw/engines/overlay/overlay_facing.c 
b/source/blender/draw/engin

[Bf-blender-cvs] [dd7a10e5a5f] blender-v3.3-release: Fix T102214: inconsistenty between bake and render with invalid material index

2022-11-28 Thread Brecht Van Lommel
Commit: dd7a10e5a5f15fac6d0c06f49dc1f2e59637f7ec
Author: Brecht Van Lommel
Date:   Wed Nov 9 16:59:16 2022 +0100
Branches: blender-v3.3-release
https://developer.blender.org/rBdd7a10e5a5f15fac6d0c06f49dc1f2e59637f7ec

Fix T102214: inconsistenty between bake and render with invalid material index

When the materal slot index on mesh faces exceeds the number of slots, rendering
would use the last material slot while other operations like baking would fall
back to the default material.

Now consistently use the last material slot in such cases, since preserving
backwards compatibility for rendering seems most important. And if there is
one material slot, it's more useful to use that one rather than falling back
to the default material.

===

M   source/blender/blenkernel/intern/material.c
M   source/blender/render/intern/bake.c

===

diff --git a/source/blender/blenkernel/intern/material.c 
b/source/blender/blenkernel/intern/material.c
index f899901b54e..df2c48aaac5 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -652,38 +652,29 @@ Material **BKE_object_material_get_p(Object *ob, short 
act)
 
   /* if object cannot have material, (totcolp == NULL) */
   totcolp = BKE_object_material_len_p(ob);
-  if (totcolp == NULL || ob->totcol == 0) {
+  if (totcolp == NULL || *totcolp == 0) {
 return NULL;
   }
 
-  /* return NULL for invalid 'act', can happen for mesh face indices */
-  if (act > ob->totcol) {
-return NULL;
-  }
-  if (act <= 0) {
-if (act < 0) {
-  CLOG_ERROR(&LOG, "Negative material index!");
-}
-return NULL;
-  }
+  /* Clamp to number of slots if index is out of range, same convention as 
used for rendering. */
+  const int slot_index = clamp_i(act - 1, 0, *totcolp - 1);
 
-  if (ob->matbits && ob->matbits[act - 1]) { /* in object */
-ma_p = &ob->mat[act - 1];
+  /* Fix inconsistency which may happen when library linked data reduces the 
number of
+   * slots but object was not updated. Ideally should be fixed elsewhere. */
+  if (*totcolp < ob->totcol) {
+ob->totcol = *totcolp;
   }
-  else { /* in data */
-
-/* check for inconsistency */
-if (*totcolp < ob->totcol) {
-  ob->totcol = *totcolp;
-}
-if (act > ob->totcol) {
-  act = ob->totcol;
-}
 
+  if (slot_index < ob->totcol && ob->matbits && ob->matbits[slot_index]) {
+/* Use object material slot. */
+ma_p = &ob->mat[slot_index];
+  }
+  else {
+/* Use data material slot. */
 matarar = BKE_object_material_array_p(ob);
 
 if (matarar && *matarar) {
-  ma_p = &(*matarar)[act - 1];
+  ma_p = &(*matarar)[slot_index];
 }
 else {
   ma_p = NULL;
@@ -716,17 +707,17 @@ static ID 
*get_evaluated_object_data_with_materials(Object *ob)
 Material *BKE_object_material_get_eval(Object *ob, short act)
 {
   BLI_assert(DEG_is_evaluated_object(ob));
-  const int slot_index = act - 1;
 
-  if (slot_index < 0) {
-return NULL;
-  }
   ID *data = get_evaluated_object_data_with_materials(ob);
   const short *tot_slots_data_ptr = BKE_id_material_len_p(data);
   const int tot_slots_data = tot_slots_data_ptr ? *tot_slots_data_ptr : 0;
-  if (slot_index >= tot_slots_data) {
+
+  if (tot_slots_data == 0) {
 return NULL;
   }
+
+  /* Clamp to number of slots if index is out of range, same convention as 
used for rendering. */
+  const int slot_index = clamp_i(act - 1, 0, tot_slots_data - 1);
   const int tot_slots_object = ob->totcol;
 
   Material ***materials_data_ptr = BKE_id_material_array_p(data);
diff --git a/source/blender/render/intern/bake.c 
b/source/blender/render/intern/bake.c
index 9ffe2879779..095d03b857f 100644
--- a/source/blender/render/intern/bake.c
+++ b/source/blender/render/intern/bake.c
@@ -740,6 +740,7 @@ void RE_bake_pixels_populate(Mesh *me,
   MLoopTri *looptri = MEM_mallocN(sizeof(*looptri) * tottri, __func__);
 
   BKE_mesh_recalc_looptri(me->mloop, me->mpoly, me->mvert, me->totloop, 
me->totpoly, looptri);
+  const int materials_num = targets->materials_num;
 
   for (int i = 0; i < tottri; i++) {
 const MLoopTri *lt = &looptri[i];
@@ -748,7 +749,11 @@ void RE_bake_pixels_populate(Mesh *me,
 bd.primitive_id = i;
 
 /* Find images matching this material. */
-Image *image = targets->material_to_image[mp->mat_nr];
+const int material_index = (materials_num) ? 
clamp_i(targets->material_to_image[mp->mat_nr],
+ 0,
+ materials_num - 1) :
+ 0;
+Image *image = targets->material_to_image[material_index];
 for (int image_id = 0; image_id < targets->images_num; image_id++) {
   BakeImage *bk_image = &targets->images[image_id];
   if (bk_image->image != image) {

_

[Bf-blender-cvs] [19bb30baf60] master: Fix T102735: Knife tool does not work properly in perspective viewport

2022-11-28 Thread Germano Cavalcante
Commit: 19bb30baf6057d39a45f1e8693c6abcaceca84db
Author: Germano Cavalcante
Date:   Wed Nov 23 23:14:56 2022 -0300
Branches: master
https://developer.blender.org/rB19bb30baf6057d39a45f1e8693c6abcaceca84db

Fix T102735: Knife tool does not work properly in perspective viewport

Use `ED_view3d_win_to_3d` to unproject the first click coords.

This is the same function used in other tools like Draw Curve.

Differential revision: https://developer.blender.org/D16617

===

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

===

diff --git a/source/blender/editors/mesh/editmesh_knife.c 
b/source/blender/editors/mesh/editmesh_knife.c
index 369162e80a3..dbe77805dd8 100644
--- a/source/blender/editors/mesh/editmesh_knife.c
+++ b/source/blender/editors/mesh/editmesh_knife.c
@@ -1897,17 +1897,9 @@ static void knife_start_cut(KnifeTool_OpData *kcd)
   kcd->mdata.is_stored = false;
 
   if (kcd->prev.vert == NULL && kcd->prev.edge == NULL) {
-float origin[3], origin_ofs[3];
 float ofs_local[3];
-
 negate_v3_v3(ofs_local, kcd->vc.rv3d->ofs);
-
-knife_input_ray_segment(kcd, kcd->curr.mval, 1.0f, origin, origin_ofs);
-
-if (!isect_line_plane_v3(
-kcd->prev.cage, origin, origin_ofs, ofs_local, 
kcd->vc.rv3d->viewinv[2])) {
-  zero_v3(kcd->prev.cage);
-}
+ED_view3d_win_to_3d(kcd->vc.v3d, kcd->region, ofs_local, kcd->curr.mval, 
kcd->prev.cage);
 
 copy_v3_v3(kcd->prev.co, kcd->prev.cage); /* TODO: do we need this? */
 copy_v3_v3(kcd->curr.cage, kcd->prev.cage);

___
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] [5758d114c1a] master: Dual Mesh: Avoid transferring position attribute twice

2022-11-28 Thread Hans Goudey
Commit: 5758d114c1a6126bea6e64ccb74b5ea7c33999c1
Author: Hans Goudey
Date:   Sun Nov 27 23:23:19 2022 -0600
Branches: master
https://developer.blender.org/rB5758d114c1a6126bea6e64ccb74b5ea7c33999c1

Dual Mesh: Avoid transferring position attribute twice

The node transferred position once as a generic attribute, and then set
the values again manually. This wastes processing during the attribute
transfer step. On a 1 million face grid, I observed roughly an 8%
improvement, from 231.5 to 217.1 ms average and 225.4 to 209.6 ms min.

===

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

===

diff --git a/source/blender/nodes/geometry/nodes/node_geo_dual_mesh.cc 
b/source/blender/nodes/geometry/nodes/node_geo_dual_mesh.cc
index ed6b1bad7cf..eb8f0b8e0ba 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_dual_mesh.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_dual_mesh.cc
@@ -127,7 +127,6 @@ static void copy_data_based_on_pairs(Span data,
  * closest face.
  */
 static void transfer_attributes(
-const Map &attributes,
 const Span vertex_types,
 const bool keep_boundaries,
 const Span new_to_old_edges_map,
@@ -136,12 +135,14 @@ static void transfer_attributes(
 const AttributeAccessor src_attributes,
 MutableAttributeAccessor dst_attributes)
 {
-  for (Map::Item entry : attributes.items()) {
-const AttributeIDRef attribute_id = entry.key;
-GAttributeReader src_attribute = src_attributes.lookup(attribute_id);
-if (!src_attribute) {
-  continue;
-}
+  /* Retrieve all attributes except for position which is handled manually.
+   * Remove anonymous attributes that don't need to be propagated.*/
+  Set attribute_ids = src_attributes.all_ids();
+  attribute_ids.remove("position");
+  attribute_ids.remove_if([](const AttributeIDRef &id) { return 
!id.should_be_kept(); });
+
+  for (const AttributeIDRef &id : attribute_ids) {
+GAttributeReader src_attribute = src_attributes.lookup(id);
 
 eAttrDomain out_domain;
 if (src_attribute.domain == ATTR_DOMAIN_FACE) {
@@ -157,7 +158,7 @@ static void transfer_attributes(
 const eCustomDataType data_type = bke::cpp_type_to_custom_data_type(
 src_attribute.varray.type());
 GSpanAttributeWriter dst_attribute = 
dst_attributes.lookup_or_add_for_write_only_span(
-attribute_id, out_domain, data_type);
+id, out_domain, data_type);
 if (!dst_attribute) {
   continue;
 }
@@ -605,30 +606,23 @@ static void dissolve_redundant_verts(const Span 
edges,
  *
  * Some special cases are needed for boundaries and non-manifold geometry.
  */
-static void calc_dual_mesh(GeometrySet &geometry_set,
-   const MeshComponent &in_component,
-   const bool keep_boundaries)
+static Mesh *calc_dual_mesh(const Mesh &src_mesh, const bool keep_boundaries)
 {
-  const Mesh &mesh_in = *in_component.get_for_read();
-  const Span src_verts = mesh_in.verts();
-  const Span src_edges = mesh_in.edges();
-  const Span src_polys = mesh_in.polys();
-  const Span src_loops = mesh_in.loops();
-
-  Map attributes;
-  geometry_set.gather_attributes_for_propagation(
-  {GEO_COMPONENT_TYPE_MESH}, GEO_COMPONENT_TYPE_MESH, false, attributes);
-
-  Array vertex_types(mesh_in.totvert);
-  Array edge_types(mesh_in.totedge);
-  calc_boundaries(mesh_in, vertex_types, edge_types);
+  const Span src_verts = src_mesh.verts();
+  const Span src_edges = src_mesh.edges();
+  const Span src_polys = src_mesh.polys();
+  const Span src_loops = src_mesh.loops();
+
+  Array vertex_types(src_mesh.totvert);
+  Array edge_types(src_mesh.totedge);
+  calc_boundaries(src_mesh, vertex_types, edge_types);
   /* Stores the indices of the polygons connected to the vertex. Because the 
polygons are looped
* over in order of their indices, the polygon's indices will be sorted in 
ascending order.
* (This can change once they are sorted using `sort_vertex_polys`). */
   Array> vert_to_poly_map = 
bke::mesh_topology::build_vert_to_poly_map(
   src_polys, src_loops, src_verts.size());
-  Array> vertex_shared_edges(mesh_in.totvert);
-  Array> vertex_corners(mesh_in.totvert);
+  Array> vertex_shared_edges(src_mesh.totvert);
+  Array> vertex_corners(src_mesh.totvert);
   threading::parallel_for(vert_to_poly_map.index_range(), 512, [&](IndexRange 
range) {
 for (const int i : range) {
   if (vertex_types[i] == VertexType::Loose || vertex_types[i] >= 
VertexType::NonManifold ||
@@ -675,8 +669,8 @@ static void calc_dual_mesh(GeometrySet &geometry_set,
 }
   });
 
-  Vector vertex_positions(mesh_in.totpoly);
-  for (const int i : IndexRange(mesh_in.totpoly)) {
+  Vector vertex_positions(src_mesh.totpoly);
+  for (const int i : IndexRange(src_mesh.totpoly)) {
 const MPoly &poly = src_polys[i];
 BKE_mesh_calc_poly_center(

[Bf-blender-cvs] [d96859c5b11] master: Cleanup: Move dual mesh topology map to blenkernel

2022-11-28 Thread Hans Goudey
Commit: d96859c5b11101dce2f2c9b6e69aa677f02a85df
Author: Hans Goudey
Date:   Sun Nov 27 23:03:38 2022 -0600
Branches: master
https://developer.blender.org/rBd96859c5b11101dce2f2c9b6e69aa677f02a85df

Cleanup: Move dual mesh topology map to blenkernel

It's helpful to have these topology maps standardized and organized
a bit better so they can be optimized and considered for future caching
together. Also use a more standard name for the map for that purpose.

===

M   source/blender/blenkernel/BKE_mesh_mapping.h
M   source/blender/blenkernel/intern/mesh_mapping.cc
M   source/blender/nodes/geometry/nodes/node_geo_dual_mesh.cc

===

diff --git a/source/blender/blenkernel/BKE_mesh_mapping.h 
b/source/blender/blenkernel/BKE_mesh_mapping.h
index a0ded44f630..e218ee72694 100644
--- a/source/blender/blenkernel/BKE_mesh_mapping.h
+++ b/source/blender/blenkernel/BKE_mesh_mapping.h
@@ -351,6 +351,7 @@ namespace blender::bke::mesh_topology {
 Array build_loop_to_poly_map(Span polys, int loops_num);
 
 Array> build_vert_to_edge_map(Span edges, int verts_num);
+Array> build_vert_to_poly_map(Span polys, Span 
loops, int verts_num);
 Array> build_vert_to_loop_map(Span loops, int verts_num);
 Array> build_edge_to_loop_map(Span loops, int edges_num);
 Vector> build_edge_to_loop_map_resizable(Span loops, int 
edges_num);
diff --git a/source/blender/blenkernel/intern/mesh_mapping.cc 
b/source/blender/blenkernel/intern/mesh_mapping.cc
index 98fb8a7fb42..cdd7fd4895d 100644
--- a/source/blender/blenkernel/intern/mesh_mapping.cc
+++ b/source/blender/blenkernel/intern/mesh_mapping.cc
@@ -577,6 +577,20 @@ Array> build_vert_to_edge_map(const 
Span edges, const int ver
   return map;
 }
 
+Array> build_vert_to_poly_map(const Span polys,
+  const Span loops,
+  int verts_num)
+{
+  Array> map(verts_num);
+  for (const int64_t i : polys.index_range()) {
+const MPoly &poly = polys[i];
+for (const MLoop &loop : loops.slice(poly.loopstart, poly.totloop)) {
+  map[loop.v].append(int(i));
+}
+  }
+  return map;
+}
+
 Array> build_vert_to_loop_map(const Span loops, const int 
verts_num)
 {
   Array> map(verts_num);
diff --git a/source/blender/nodes/geometry/nodes/node_geo_dual_mesh.cc 
b/source/blender/nodes/geometry/nodes/node_geo_dual_mesh.cc
index 9b1c13bf563..ed6b1bad7cf 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_dual_mesh.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_dual_mesh.cc
@@ -8,6 +8,7 @@
 
 #include "BKE_attribute_math.hh"
 #include "BKE_mesh.h"
+#include "BKE_mesh_mapping.h"
 
 #include "node_geometry_util.hh"
 
@@ -249,23 +250,6 @@ static void calc_boundaries(const Mesh &mesh,
   }
 }
 
-/**
- * Stores the indices of the polygons connected to each vertex.
- */
-static void create_vertex_poly_map(const Mesh &mesh,
-   MutableSpan> 
r_vertex_poly_indices)
-{
-  const Span polys = mesh.polys();
-  const Span loops = mesh.loops();
-  for (const int i : polys.index_range()) {
-const MPoly &poly = polys[i];
-const Span poly_loops = loops.slice(poly.loopstart, poly.totloop);
-for (const MLoop &loop : poly_loops) {
-  r_vertex_poly_indices[loop.v].append(i);
-}
-  }
-}
-
 /**
  * Sorts the polygons connected to the given vertex based on polygon 
adjacency. The ordering is
  * so such that the normals point in the same way as the original mesh. If the 
vertex is a
@@ -538,14 +522,13 @@ static bool vertex_needs_dissolving(const int vertex,
 const int first_poly_index,
 const int second_poly_index,
 const Span vertex_types,
-const Span> 
vertex_poly_indices)
+const Span> vert_to_poly_map)
 {
   /* Order is guaranteed to be the same because 2poly verts that are not on 
the boundary are
* ignored in `sort_vertex_polys`. */
-  return (vertex_types[vertex] != VertexType::Boundary &&
-  vertex_poly_indices[vertex].size() == 2 &&
-  vertex_poly_indices[vertex][0] == first_poly_index &&
-  vertex_poly_indices[vertex][1] == second_poly_index);
+  return (vertex_types[vertex] != VertexType::Boundary && 
vert_to_poly_map[vertex].size() == 2 &&
+  vert_to_poly_map[vertex][0] == first_poly_index &&
+  vert_to_poly_map[vertex][1] == second_poly_index);
 }
 
 /**
@@ -558,7 +541,7 @@ static bool vertex_needs_dissolving(const int vertex,
 static void dissolve_redundant_verts(const Span edges,
  const Span polys,
  const Span loops,
- const Span> 
vertex_poly_indices,
+ const Span> vert_to

[Bf-blender-cvs] [70041ced144] master: Cleanup: Remove unused mesh array variables and arguments

2022-11-28 Thread Hans Goudey
Commit: 70041ced144faaa49daaf0429cf4a177ddc5fd18
Author: Hans Goudey
Date:   Sun Nov 27 22:42:15 2022 -0600
Branches: master
https://developer.blender.org/rB70041ced144faaa49daaf0429cf4a177ddc5fd18

Cleanup: Remove unused mesh array variables and arguments

===

M   source/blender/blenkernel/BKE_multires.h
M   source/blender/blenkernel/intern/multires.cc
M   source/blender/blenkernel/intern/pbvh.c
M   source/blender/io/alembic/intern/abc_customdata.cc
M   source/blender/modifiers/intern/MOD_uvwarp.cc
M   source/blender/render/intern/multires_bake.c

===

diff --git a/source/blender/blenkernel/BKE_multires.h 
b/source/blender/blenkernel/BKE_multires.h
index 53dfaf953ea..13dc32fede5 100644
--- a/source/blender/blenkernel/BKE_multires.h
+++ b/source/blender/blenkernel/BKE_multires.h
@@ -156,15 +156,8 @@ void old_mdisps_bilinear(float out[3], float (*disps)[3], 
int st, float u, float
 /**
  * Find per-corner coordinate with given per-face UV coord.
  */
-int mdisp_rot_face_to_crn(struct MVert *mvert,
-  struct MPoly *mpoly,
-  struct MLoop *mloop,
-  const struct MLoopTri *lt,
-  int face_side,
-  float u,
-  float v,
-  float *x,
-  float *y);
+int mdisp_rot_face_to_crn(
+struct MPoly *mpoly, int face_side, float u, float v, float *x, float *y);
 
 /* Reshaping, define in multires_reshape.c */
 
diff --git a/source/blender/blenkernel/intern/multires.cc 
b/source/blender/blenkernel/intern/multires.cc
index 5ff9602650e..7f9a0d64e4b 100644
--- a/source/blender/blenkernel/intern/multires.cc
+++ b/source/blender/blenkernel/intern/multires.cc
@@ -1522,15 +1522,8 @@ void multiresModifier_ensure_external_read(struct Mesh 
*mesh, const MultiresModi
 
 /* Multires interpolation stuff */
 
-int mdisp_rot_face_to_crn(struct MVert * /*mvert*/,
-  struct MPoly *mpoly,
-  struct MLoop * /*mloop*/,
-  const struct MLoopTri * /*lt*/,
-  const int face_side,
-  const float u,
-  const float v,
-  float *x,
-  float *y)
+int mdisp_rot_face_to_crn(
+MPoly *mpoly, const int face_side, const float u, const float v, float *x, 
float *y)
 {
   const float offset = face_side * 0.5f - 0.5f;
   int S = 0;
diff --git a/source/blender/blenkernel/intern/pbvh.c 
b/source/blender/blenkernel/intern/pbvh.c
index 7cb352ad42a..145ceb143ea 100644
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@ -3765,7 +3765,6 @@ void BKE_pbvh_sync_visibility_from_verts(PBVH *pbvh, Mesh 
*mesh)
 }
 case PBVH_GRIDS: {
   const MPoly *mp = BKE_mesh_polys(mesh);
-  const MLoop *mloop = BKE_mesh_loops(mesh);
   CCGKey key = pbvh->gridkey;
 
   bool *hide_poly = (bool *)CustomData_get_layer_named(
@@ -3773,10 +3772,9 @@ void BKE_pbvh_sync_visibility_from_verts(PBVH *pbvh, 
Mesh *mesh)
 
   bool delete_hide_poly = true;
   for (int face_index = 0; face_index < mesh->totpoly; face_index++, mp++) 
{
-const MLoop *ml = mloop + mp->loopstart;
 bool hidden = false;
 
-for (int loop_index = 0; !hidden && loop_index < mp->totloop; 
loop_index++, ml++) {
+for (int loop_index = 0; !hidden && loop_index < mp->totloop; 
loop_index++) {
   int grid_index = mp->loopstart + loop_index;
 
   if (pbvh->grid_hidden[grid_index] &&
diff --git a/source/blender/io/alembic/intern/abc_customdata.cc 
b/source/blender/io/alembic/intern/abc_customdata.cc
index 3349f9fc30b..2cd14bae527 100644
--- a/source/blender/io/alembic/intern/abc_customdata.cc
+++ b/source/blender/io/alembic/intern/abc_customdata.cc
@@ -173,7 +173,6 @@ static void get_cols(const CDStreamConfig &config,
 {
   const float cscale = 1.0f / 255.0f;
   const MPoly *polys = config.mpoly;
-  const MLoop *mloops = config.mloop;
   const MCol *cfaces = static_cast(cd_data);
 
   buffer.reserve(config.totvert);
@@ -184,11 +183,9 @@ static void get_cols(const CDStreamConfig &config,
   for (int i = 0; i < config.totpoly; i++) {
 const MPoly *p = &polys[i];
 const MCol *cface = &cfaces[p->loopstart + p->totloop];
-const MLoop *mloop = &mloops[p->loopstart + p->totloop];
 
 for (int j = 0; j < p->totloop; j++) {
   cface--;
-  mloop--;
 
   col[0] = cface->a * cscale;
   col[1] = cface->r * cscale;
diff --git a/source/blender/modifiers/intern/MOD_uvwarp.cc 
b/source/blender/modifiers/intern/MOD_uvwarp.cc
index a96b28b4e2e..0954165d656 100644
--- a/source/blender/modifiers/intern/MOD_uvwarp.cc
+++ b/source/blender/mo

[Bf-blender-cvs] [0940719b5ab] master: Line Art: Use local spans for mesh arrays

2022-11-28 Thread Hans Goudey
Commit: 0940719b5ab3a35b6a3bd0d42b30dfe284550b14
Author: Hans Goudey
Date:   Sun Nov 27 22:37:23 2022 -0600
Branches: master
https://developer.blender.org/rB0940719b5ab3a35b6a3bd0d42b30dfe284550b14

Line Art: Use local spans for mesh arrays

Avoid accessing arrays from the mesh for every element and add safety
by using Span instead of raw pointers. Similar to previous commits.

===

M   source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.cc

===

diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.cc 
b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.cc
index 8367950eb72..f9967ff3d02 100644
--- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.cc
+++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.cc
@@ -1476,6 +1476,7 @@ struct EdgeFeatData {
   const int *material_indices;
   blender::Span edges;
   blender::Span loops;
+  blender::Span polys;
   LineartTriangle *tri_array;
   LineartVert *v_array;
   float crease_threshold;
@@ -1641,13 +1642,11 @@ static void 
lineart_identify_mlooptri_feature_edges(void *__restrict userdata,
   }
 
   if (!only_contour) {
-const MPoly *polys = BKE_mesh_polys(me);
-
 if (ld->conf.use_crease) {
   bool do_crease = true;
   if (!ld->conf.force_crease && !e_feat_data->use_auto_smooth &&
-  (polys[mlooptri[f1].poly].flag & ME_SMOOTH) &&
-  (polys[mlooptri[f2].poly].flag & ME_SMOOTH)) {
+  (e_feat_data->polys[mlooptri[f1].poly].flag & ME_SMOOTH) &&
+  (e_feat_data->polys[mlooptri[f2].poly].flag & ME_SMOOTH)) {
 do_crease = false;
   }
   if (do_crease && (dot_v3v3_db(tri1->gn, tri2->gn) < 
e_feat_data->crease_threshold)) {
@@ -1786,6 +1785,8 @@ static void 
lineart_triangle_adjacent_assign(LineartTriangle *tri,
 
 struct TriData {
   LineartObjectInfo *ob_info;
+  blender::Span verts;
+  blender::Span loops;
   const MLoopTri *mlooptri;
   const int *material_indices;
   LineartVert *vert_arr;
@@ -1799,13 +1800,13 @@ static void lineart_load_tri_task(void *__restrict 
userdata,
   const TaskParallelTLS *__restrict /*tls*/)
 {
   TriData *tri_task_data = (TriData *)userdata;
-  Mesh *me = tri_task_data->ob_info->original_me;
   LineartObjectInfo *ob_info = tri_task_data->ob_info;
+  const blender::Span verts = tri_task_data->verts;
+  const blender::Span loops = tri_task_data->loops;
   const MLoopTri *mlooptri = &tri_task_data->mlooptri[i];
   const int *material_indices = tri_task_data->material_indices;
   LineartVert *vert_arr = tri_task_data->vert_arr;
   LineartTriangle *tri = tri_task_data->tri_arr;
-  const MLoop *loops = BKE_mesh_loops(me);
 
   tri = (LineartTriangle *)(((uchar *)tri) + 
tri_task_data->lineart_triangle_size * i);
 
@@ -1838,7 +1839,6 @@ static void lineart_load_tri_task(void *__restrict 
userdata,
 
   double gn[3];
   float no[3];
-  const MVert *verts = BKE_mesh_verts(me);
   normal_tri_v3(no, verts[v1].co, verts[v2].co, verts[v3].co);
   copy_v3db_v3fl(gn, no);
   mul_v3_mat3_m4v3_db(tri->gn, ob_info->normal, gn);
@@ -2044,6 +2044,7 @@ static void 
lineart_geometry_object_load(LineartObjectInfo *ob_info,
   TriData tri_data;
   tri_data.ob_info = ob_info;
   tri_data.mlooptri = mlooptri;
+  tri_data.verts = me->verts();
   tri_data.material_indices = material_indices;
   tri_data.vert_arr = la_v_arr;
   tri_data.tri_arr = la_tri_arr;
@@ -2074,6 +2075,7 @@ static void 
lineart_geometry_object_load(LineartObjectInfo *ob_info,
   edge_feat_data.mlooptri = mlooptri;
   edge_feat_data.material_indices = material_indices;
   edge_feat_data.edges = me->edges();
+  edge_feat_data.polys = me->polys();
   edge_feat_data.loops = me->loops();
   edge_feat_data.edge_nabr = lineart_build_edge_neighbor(me, total_edges);
   edge_feat_data.tri_array = la_tri_arr;

___
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] [7a9fce28c03] master: Cleanup: Pass spans by value in cone mesh primitive

2022-11-28 Thread Hans Goudey
Commit: 7a9fce28c03b09f68dfc2635b0a9aeb4c448b7a9
Author: Hans Goudey
Date:   Sun Nov 27 22:54:23 2022 -0600
Branches: master
https://developer.blender.org/rB7a9fce28c03b09f68dfc2635b0a9aeb4c448b7a9

Cleanup: Pass spans by value in cone mesh primitive

Also use more typical ordering for the arguments.

===

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

===

diff --git 
a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cone.cc 
b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cone.cc
index 586470ff3c7..206be90fcbf 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cone.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cone.cc
@@ -255,7 +255,7 @@ int ConeConfig::calculate_total_corners()
   return corner_total;
 }
 
-static void calculate_cone_verts(const MutableSpan &verts, const 
ConeConfig &config)
+static void calculate_cone_verts(const ConeConfig &config, MutableSpan 
verts)
 {
   Array circle(config.circle_segments);
   const float angle_delta = 2.0f * (M_PI / float(config.circle_segments));
@@ -319,7 +319,7 @@ static void calculate_cone_verts(const MutableSpan 
&verts, const ConeConf
   }
 }
 
-static void calculate_cone_edges(const MutableSpan &edges, const 
ConeConfig &config)
+static void calculate_cone_edges(const ConeConfig &config, MutableSpan 
edges)
 {
   int edge_index = 0;
 
@@ -368,9 +368,9 @@ static void calculate_cone_edges(const MutableSpan 
&edges, const ConeConf
   }
 }
 
-static void calculate_cone_faces(const MutableSpan &loops,
- const MutableSpan &polys,
- const ConeConfig &config)
+static void calculate_cone_faces(const ConeConfig &config,
+ MutableSpan loops,
+ MutableSpan polys)
 {
   int loop_index = 0;
   int poly_index = 0;
@@ -474,12 +474,10 @@ static void calculate_cone_faces(const MutableSpan 
&loops,
   }
 }
 
-static void calculate_selection_outputs(Mesh *mesh,
-const ConeConfig &config,
-ConeAttributeOutputs 
&attribute_outputs)
+static void calculate_selection_outputs(const ConeConfig &config,
+const ConeAttributeOutputs 
&attribute_outputs,
+MutableAttributeAccessor attributes)
 {
-  MutableAttributeAccessor attributes = mesh->attributes_for_write();
-
   /* Populate "Top" selection output. */
   if (attribute_outputs.top_id) {
 const bool face = !config.top_is_point && config.fill_type != 
GEO_NODE_MESH_CIRCLE_FILL_NONE;
@@ -691,11 +689,11 @@ Mesh *create_cylinder_or_cone_mesh(const float radius_top,
   MutableSpan polys = mesh->polys_for_write();
   MutableSpan loops = mesh->loops_for_write();
 
-  calculate_cone_verts(verts, config);
-  calculate_cone_edges(edges, config);
-  calculate_cone_faces(loops, polys, config);
+  calculate_cone_verts(config, verts);
+  calculate_cone_edges(config, edges);
+  calculate_cone_faces(config, loops, polys);
   calculate_cone_uvs(mesh, config);
-  calculate_selection_outputs(mesh, config, attribute_outputs);
+  calculate_selection_outputs(config, attribute_outputs, 
mesh->attributes_for_write());
 
   mesh->loose_edges_tag_none();

___
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] [bcabd04e324] master: Mesh: Avoid retrieving edge and loop arrays repeatedly

2022-11-28 Thread Hans Goudey
Commit: bcabd04e324277b1a709738aace440fb0d5b0c5a
Author: Hans Goudey
Date:   Sun Nov 27 18:46:46 2022 -0600
Branches: master
https://developer.blender.org/rBbcabd04e324277b1a709738aace440fb0d5b0c5a

Mesh: Avoid retrieving edge and loop arrays repeatedly

A utility function retrieved mesh arrays for every element after
05952aa94d33ee which can be easily avoided. This was used when
building the GPU indices for sculpt mode drawing. In my tests this
saves 0.1ms per PBVH node. There may be very slight improvements
in line art and shrinkwrap as well.

===

M   source/blender/blenkernel/BKE_mesh.h
M   source/blender/blenkernel/intern/mesh.cc
M   source/blender/blenkernel/intern/shrinkwrap.cc
M   source/blender/draw/intern/draw_pbvh.cc
M   source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.cc
M   source/blender/gpu/intern/gpu_shader_builder_stubs.cc

===

diff --git a/source/blender/blenkernel/BKE_mesh.h 
b/source/blender/blenkernel/BKE_mesh.h
index 577107149ee..a3f74f0fb7c 100644
--- a/source/blender/blenkernel/BKE_mesh.h
+++ b/source/blender/blenkernel/BKE_mesh.h
@@ -132,7 +132,8 @@ int BKE_mesh_edge_other_vert(const struct MEdge *e, int v);
 /**
  * Sets each output array element to the edge index if it is a real edge, or 
-1.
  */
-void BKE_mesh_looptri_get_real_edges(const struct Mesh *mesh,
+void BKE_mesh_looptri_get_real_edges(const struct MEdge *edges,
+ const struct MLoop *loops,
  const struct MLoopTri *looptri,
  int r_edges[3]);
 
diff --git a/source/blender/blenkernel/intern/mesh.cc 
b/source/blender/blenkernel/intern/mesh.cc
index 02d375bd782..deaa9aec3f7 100644
--- a/source/blender/blenkernel/intern/mesh.cc
+++ b/source/blender/blenkernel/intern/mesh.cc
@@ -1490,13 +1490,13 @@ int BKE_mesh_edge_other_vert(const MEdge *e, int v)
   return -1;
 }
 
-void BKE_mesh_looptri_get_real_edges(const Mesh *mesh, const MLoopTri 
*looptri, int r_edges[3])
+void BKE_mesh_looptri_get_real_edges(const MEdge *edges,
+ const MLoop *loops,
+ const MLoopTri *tri,
+ int r_edges[3])
 {
-  const Span edges = mesh->edges();
-  const Span loops = mesh->loops();
-
   for (int i = 2, i_next = 0; i_next < 3; i = i_next++) {
-const MLoop *l1 = &loops[looptri->tri[i]], *l2 = 
&loops[looptri->tri[i_next]];
+const MLoop *l1 = &loops[tri->tri[i]], *l2 = &loops[tri->tri[i_next]];
 const MEdge *e = &edges[l1->e];
 
 bool is_real = (l1->v == e->v1 && l2->v == e->v2) || (l1->v == e->v2 && 
l2->v == e->v1);
diff --git a/source/blender/blenkernel/intern/shrinkwrap.cc 
b/source/blender/blenkernel/intern/shrinkwrap.cc
index 69a9f6f0fc2..f28748dcbce 100644
--- a/source/blender/blenkernel/intern/shrinkwrap.cc
+++ b/source/blender/blenkernel/intern/shrinkwrap.cc
@@ -239,7 +239,7 @@ static ShrinkwrapBoundaryData 
*shrinkwrap_build_boundary_data(Mesh *mesh)
 
   for (int i = 0; i < totlooptri; i++) {
 int edges[3];
-BKE_mesh_looptri_get_real_edges(mesh, &mlooptri[i], edges);
+BKE_mesh_looptri_get_real_edges(medge, mloop, &mlooptri[i], edges);
 
 for (int j = 0; j < 3; j++) {
   if (edges[j] >= 0 && edge_mode[edges[j]]) {
@@ -1049,7 +1049,7 @@ static void mesh_looptri_target_project(void *userdata,
 const BLI_bitmap *is_boundary = tree->boundary->edge_is_boundary;
 int edges[3];
 
-BKE_mesh_looptri_get_real_edges(tree->mesh, lt, edges);
+BKE_mesh_looptri_get_real_edges(data->edge, data->loop, lt, edges);
 
 for (int i = 0; i < 3; i++) {
   if (edges[i] >= 0 && BLI_BITMAP_TEST(is_boundary, edges[i])) {
diff --git a/source/blender/draw/intern/draw_pbvh.cc 
b/source/blender/draw/intern/draw_pbvh.cc
index 6c504e63511..39d493003c2 100644
--- a/source/blender/draw/intern/draw_pbvh.cc
+++ b/source/blender/draw/intern/draw_pbvh.cc
@@ -24,6 +24,7 @@
 #include "BLI_map.hh"
 #include "BLI_math_color.h"
 #include "BLI_math_vec_types.hh"
+#include "BLI_timeit.hh"
 #include "BLI_utildefines.h"
 #include "BLI_vector.hh"
 
@@ -959,6 +960,8 @@ struct PBVHBatches {
   material_index = mat_index[poly_index];
 }
 
+const blender::Span edges = args->me->edges();
+
 /* Calculate number of edges*/
 int edge_count = 0;
 for (int i = 0; i < args->totprim; i++) {
@@ -969,7 +972,7 @@ struct PBVHBatches {
   }
 
   int r_edges[3];
-  BKE_mesh_looptri_get_real_edges(args->me, lt, r_edges);
+  BKE_mesh_looptri_get_real_edges(edges.data(), args->mloop, lt, r_edges);
 
   if (r_edges[0] != -1) {
 edge_count++;
@@ -994,7 +997,7 @@ struct PBVHBatches {
   }
 
   int r_edges[3];
-  BKE_mesh_looptri_get_real_edges(args->me, lt, r_edges);
+  BKE_mesh_looptri_get_real_edges(edges.data(),

[Bf-blender-cvs] [6e26d0645ef] master: Cleanup: Use spans for voxel remesh mesh data

2022-11-28 Thread Hans Goudey
Commit: 6e26d0645ef63572f0f1875f8097e71373025f50
Author: Hans Goudey
Date:   Sun Nov 27 22:41:28 2022 -0600
Branches: master
https://developer.blender.org/rB6e26d0645ef63572f0f1875f8097e71373025f50

Cleanup: Use spans for voxel remesh mesh data

===

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

===

diff --git a/source/blender/blenkernel/intern/mesh_remesh_voxel.cc 
b/source/blender/blenkernel/intern/mesh_remesh_voxel.cc
index 0887e26148a..86c77327f98 100644
--- a/source/blender/blenkernel/intern/mesh_remesh_voxel.cc
+++ b/source/blender/blenkernel/intern/mesh_remesh_voxel.cc
@@ -288,7 +288,7 @@ void BKE_mesh_remesh_reproject_paint_mask(Mesh *target, 
const Mesh *source)
 {
   BVHTreeFromMesh bvhtree = {nullptr};
   BKE_bvhtree_from_mesh_get(&bvhtree, source, BVHTREE_FROM_VERTS, 2);
-  const MVert *target_verts = (const MVert 
*)CustomData_get_layer(&target->vdata, CD_MVERT);
+  const Span target_verts = target->verts();
   const float *source_mask = (const float 
*)CustomData_get_layer(&source->vdata, CD_PAINT_MASK);
   if (source_mask == nullptr) {
 return;
@@ -305,13 +305,11 @@ void BKE_mesh_remesh_reproject_paint_mask(Mesh *target, 
const Mesh *source)
 
   blender::threading::parallel_for(IndexRange(target->totvert), 4096, 
[&](const IndexRange range) {
 for (const int i : range) {
-  float from_co[3];
   BVHTreeNearest nearest;
   nearest.index = -1;
   nearest.dist_sq = FLT_MAX;
-  copy_v3_v3(from_co, target_verts[i].co);
   BLI_bvhtree_find_nearest(
-  bvhtree.tree, from_co, &nearest, bvhtree.nearest_callback, &bvhtree);
+  bvhtree.tree, target_verts[i].co, &nearest, 
bvhtree.nearest_callback, &bvhtree);
   if (nearest.index != -1) {
 target_mask[i] = source_mask[nearest.index];
   }
@@ -326,9 +324,9 @@ void BKE_remesh_reproject_sculpt_face_sets(Mesh *target, 
const Mesh *source)
   using namespace blender::bke;
   const AttributeAccessor src_attributes = source->attributes();
   MutableAttributeAccessor dst_attributes = target->attributes_for_write();
-  const MPoly *target_polys = (const MPoly 
*)CustomData_get_layer(&target->pdata, CD_MPOLY);
-  const MVert *target_verts = (const MVert 
*)CustomData_get_layer(&target->vdata, CD_MVERT);
-  const MLoop *target_loops = (const MLoop 
*)CustomData_get_layer(&target->ldata, CD_MLOOP);
+  const Span target_verts = target->verts();
+  const Span target_polys = target->polys();
+  const Span target_loops = target->loops();
 
   const VArray src_face_sets = 
src_attributes.lookup(".sculpt_face_set",

ATTR_DOMAIN_FACE);
@@ -354,8 +352,9 @@ void BKE_remesh_reproject_sculpt_face_sets(Mesh *target, 
const Mesh *source)
   BVHTreeNearest nearest;
   nearest.index = -1;
   nearest.dist_sq = FLT_MAX;
-  const MPoly *mpoly = &target_polys[i];
-  BKE_mesh_calc_poly_center(mpoly, &target_loops[mpoly->loopstart], 
target_verts, from_co);
+  const MPoly &poly = target_polys[i];
+  BKE_mesh_calc_poly_center(
+  &poly, &target_loops[poly.loopstart], target_verts.data(), from_co);
   BLI_bvhtree_find_nearest(
   bvhtree.tree, from_co, &nearest, bvhtree.nearest_callback, &bvhtree);
   if (nearest.index != -1) {
@@ -403,7 +402,7 @@ void BKE_remesh_reproject_vertex_paint(Mesh *target, const 
Mesh *source)
 size_t data_size = CustomData_sizeof(layer->type);
 void *target_data = target_cdata->layers[layer_i].data;
 void *source_data = layer->data;
-MVert *target_verts = (MVert *)CustomData_get_layer(&target->vdata, 
CD_MVERT);
+const Span target_verts = target->verts();
 
 if (domain == ATTR_DOMAIN_POINT) {
   blender::threading::parallel_for(

___
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] [baba5d22141] master: Multires: Avoid retriving mesh arrays for every element

2022-11-28 Thread Hans Goudey
Commit: baba5d22141d450bff9f96361998dd463762ca74
Author: Hans Goudey
Date:   Sun Nov 27 22:30:09 2022 -0600
Branches: master
https://developer.blender.org/rBbaba5d22141d450bff9f96361998dd463762ca74

Multires: Avoid retriving mesh arrays for every element

Based on the surrounding code this probably wasn't a
bottleneck, but it's nice to avoid in principle anyway.

===

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

===

diff --git a/source/blender/blenkernel/intern/multires_unsubdivide.c 
b/source/blender/blenkernel/intern/multires_unsubdivide.c
index 353fbec6933..28bd199a967 100644
--- a/source/blender/blenkernel/intern/multires_unsubdivide.c
+++ b/source/blender/blenkernel/intern/multires_unsubdivide.c
@@ -963,11 +963,9 @@ static void 
multires_unsubdivide_prepare_original_bmesh_for_extract(
  * Checks the orientation of the loops to flip the x and y axis when 
extracting the grid if
  * necessary.
  */
-static bool multires_unsubdivide_flip_grid_x_axis(Mesh *mesh, int poly, int 
loop, int v_x)
+static bool multires_unsubdivide_flip_grid_x_axis(
+const MPoly *polys, const MLoop *loops, int poly, int loop, int v_x)
 {
-  const MPoly *polys = BKE_mesh_polys(mesh);
-  const MLoop *loops = BKE_mesh_loops(mesh);
-
   const MPoly *p = &polys[poly];
 
   const MLoop *l_first = &loops[p->loopstart];
@@ -1037,6 +1035,9 @@ static void 
multires_unsubdivide_extract_grids(MultiresUnsubdivideContext *conte
   const int base_l_offset = CustomData_get_n_offset(
   &bm_base_mesh->ldata, CD_PROP_INT32, base_l_layer_index);
 
+  const MPoly *polys = BKE_mesh_polys(base_mesh);
+  const MLoop *loops = BKE_mesh_loops(base_mesh);
+
   /* Main loop for extracting the grids. Iterates over the base mesh vertices. 
*/
   BM_ITER_MESH (v, &iter, bm_base_mesh, BM_VERTS_OF_MESH) {
 
@@ -1074,7 +1075,7 @@ static void 
multires_unsubdivide_extract_grids(MultiresUnsubdivideContext *conte
   /* Check the orientation of the loops in case that is needed to flip 
the x and y axis
* when extracting the grid. */
   const bool flip_grid = multires_unsubdivide_flip_grid_x_axis(
-  base_mesh, base_mesh_face_index, base_mesh_loop_index, 
corner_x_index);
+  polys, loops, base_mesh_face_index, base_mesh_loop_index, 
corner_x_index);
 
   /* Extract the grid for that loop. */
   context->base_mesh_grids[base_mesh_loop_index].grid_index = 
base_mesh_loop_index;

___
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] [653e3e2689a] master: Subdiv: Avoid repeatedly accessing mesh arrays

2022-11-28 Thread Hans Goudey
Commit: 653e3e2689a4b7fee83425b26beb23aefdcc1d6d
Author: Hans Goudey
Date:   Sun Nov 27 20:11:39 2022 -0600
Branches: master
https://developer.blender.org/rB653e3e2689a4b7fee83425b26beb23aefdcc1d6d

Subdiv: Avoid repeatedly accessing mesh arrays

Fix a performance regression from 05952aa94d33ee by storing pointers
to mesh arrays locally in the subdiv foreach context. In a simple test
of a 1 million face grid, this improved performance by 5% (from 0.31
to 0.295 seconds).

===

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

===

diff --git a/source/blender/blenkernel/intern/subdiv_foreach.c 
b/source/blender/blenkernel/intern/subdiv_foreach.c
index faf531b0f5e..e851c969de8 100644
--- a/source/blender/blenkernel/intern/subdiv_foreach.c
+++ b/source/blender/blenkernel/intern/subdiv_foreach.c
@@ -67,6 +67,9 @@ BLI_INLINE int ptex_face_resolution_get(const MPoly *poly, 
int resolution)
 
 typedef struct SubdivForeachTaskContext {
   const Mesh *coarse_mesh;
+  const MEdge *coarse_edges;
+  const MPoly *coarse_polys;
+  const MLoop *coarse_loops;
   const SubdivToMeshSettings *settings;
   /* Callbacks. */
   const SubdivForeachContext *foreach_context;
@@ -158,16 +161,14 @@ static void 
subdiv_foreach_ctx_count(SubdivForeachTaskContext *ctx)
   const int num_inner_vertices_per_noquad_patch = (no_quad_patch_resolution - 
2) *
   (no_quad_patch_resolution - 
2);
   const Mesh *coarse_mesh = ctx->coarse_mesh;
-  const MLoop *coarse_mloop = BKE_mesh_loops(coarse_mesh);
-  const MPoly *coarse_mpoly = BKE_mesh_polys(coarse_mesh);
   ctx->num_subdiv_vertices = coarse_mesh->totvert;
   ctx->num_subdiv_edges = coarse_mesh->totedge * 
(num_subdiv_vertices_per_coarse_edge + 1);
   /* Calculate extra vertices and edges created by non-loose geometry. */
   for (int poly_index = 0; poly_index < coarse_mesh->totpoly; poly_index++) {
-const MPoly *coarse_poly = &coarse_mpoly[poly_index];
+const MPoly *coarse_poly = &ctx->coarse_polys[poly_index];
 const int num_ptex_faces_per_poly = 
num_ptex_faces_per_poly_get(coarse_poly);
 for (int corner = 0; corner < coarse_poly->totloop; corner++) {
-  const MLoop *loop = &coarse_mloop[coarse_poly->loopstart + corner];
+  const MLoop *loop = &ctx->coarse_loops[coarse_poly->loopstart + corner];
   const bool is_edge_used = 
BLI_BITMAP_TEST_BOOL(ctx->coarse_edges_used_map, loop->e);
   /* Edges which aren't counted yet. */
   if (!is_edge_used) {
@@ -225,12 +226,11 @@ static void 
subdiv_foreach_ctx_init_offsets(SubdivForeachTaskContext *ctx)
   ctx->edge_inner_offset = ctx->edge_boundary_offset +
coarse_mesh->totedge * 
num_subdiv_edges_per_coarse_edge;
   /* "Indexed" offsets. */
-  const MPoly *coarse_mpoly = BKE_mesh_polys(coarse_mesh);
   int vertex_offset = 0;
   int edge_offset = 0;
   int polygon_offset = 0;
   for (int poly_index = 0; poly_index < coarse_mesh->totpoly; poly_index++) {
-const MPoly *coarse_poly = &coarse_mpoly[poly_index];
+const MPoly *coarse_poly = &ctx->coarse_polys[poly_index];
 const int num_ptex_faces_per_poly = 
num_ptex_faces_per_poly_get(coarse_poly);
 ctx->subdiv_vertex_offset[poly_index] = vertex_offset;
 ctx->subdiv_edge_offset[poly_index] = edge_offset;
@@ -300,13 +300,10 @@ static void subdiv_foreach_corner_vertices_regular_do(
 bool check_usage)
 {
   const float weights[4][2] = {{0.0f, 0.0f}, {1.0f, 0.0f}, {1.0f, 1.0f}, 
{0.0f, 1.0f}};
-  const Mesh *coarse_mesh = ctx->coarse_mesh;
-  const MLoop *coarse_mloop = BKE_mesh_loops(coarse_mesh);
-  const MPoly *coarse_mpoly = BKE_mesh_polys(coarse_mesh);
-  const int coarse_poly_index = coarse_poly - coarse_mpoly;
+  const int coarse_poly_index = coarse_poly - ctx->coarse_polys;
   const int ptex_face_index = ctx->face_ptex_offset[coarse_poly_index];
   for (int corner = 0; corner < coarse_poly->totloop; corner++) {
-const MLoop *coarse_loop = &coarse_mloop[coarse_poly->loopstart + corner];
+const MLoop *coarse_loop = &ctx->coarse_loops[coarse_poly->loopstart + 
corner];
 if (check_usage &&
 BLI_BITMAP_TEST_AND_SET_ATOMIC(ctx->coarse_vertices_used_map, 
coarse_loop->v)) {
   continue;
@@ -342,13 +339,10 @@ static void subdiv_foreach_corner_vertices_special_do(
 SubdivForeachVertexFromCornerCb vertex_corner,
 bool check_usage)
 {
-  const Mesh *coarse_mesh = ctx->coarse_mesh;
-  const MLoop *coarse_mloop = BKE_mesh_loops(coarse_mesh);
-  const MPoly *coarse_mpoly = BKE_mesh_polys(coarse_mesh);
-  const int coarse_poly_index = coarse_poly - coarse_mpoly;
+  const int coarse_poly_index = coarse_poly - ctx->coarse_polys;
   int ptex_face_index = ctx->face_ptex_offset[coarse_poly_index];
   for (int corner = 0; corner < coarse_poly->totloop; corner++, 
ptex_face_index++) {
-const MLoop *coarse_loop = &co

[Bf-blender-cvs] [ca8fa2f7d61] temp-asset-library-all: Merge branch 'master' into temp-asset-library-all

2022-11-28 Thread Julian Eisel
Commit: ca8fa2f7d61890ec2a7beac144010816e3735cec
Author: Julian Eisel
Date:   Thu Nov 24 16:25:39 2022 +0100
Branches: temp-asset-library-all
https://developer.blender.org/rBca8fa2f7d61890ec2a7beac144010816e3735cec

Merge branch 'master' into temp-asset-library-all

===



===



___
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] [86b9b1df227] temp-asset-library-all: Merge branch 'master' into temp-asset-library-all

2022-11-28 Thread Julian Eisel
Commit: 86b9b1df227639f8d906d49e4896be4862b24256
Author: Julian Eisel
Date:   Mon Nov 28 15:44:59 2022 +0100
Branches: temp-asset-library-all
https://developer.blender.org/rB86b9b1df227639f8d906d49e4896be4862b24256

Merge branch 'master' into temp-asset-library-all

===



===



___
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] [e968b4197b6] blender-v3.3-release: Fix T102257: Crash when making an Object as Effector set to Guide and trying to scrub the timeline

2022-11-28 Thread Germano Cavalcante
Commit: e968b4197b68538b64280178330e552880df19cf
Author: Germano Cavalcante
Date:   Wed Nov 9 12:09:55 2022 -0300
Branches: blender-v3.3-release
https://developer.blender.org/rBe968b4197b68538b64280178330e552880df19cf

Fix T102257: Crash when making an Object as Effector set to Guide and trying to 
scrub the timeline

rB67e23b4b2967 revealed the bug. But the bug already existed before,
it just wasn't triggered.

Apparently the problem happens because the python code generated in
`initGuiding()` cannot be executed twice.

The second time the `initGuiding()` code is executed, the local python
variables are removed to make way for the others, but the reference to
one of the grids in a `Solver` object (name='solver_guiding2') is still
being used somewhere. So an error is raised and a crash is forced.

The solution is to prevent the python code in `initGuiding()` from being
executed twice.

When `FLUID_DOMAIN_ACTIVE_GUIDE` is in `fds->active_fields` this
indicates that the pointer in `mPhiGuideIn` has been set and the guiding
is already computed (does not need to be computed again).

Maniphest Tasks: T102257

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

===

M   intern/mantaflow/intern/MANTA_main.cpp

===

diff --git a/intern/mantaflow/intern/MANTA_main.cpp 
b/intern/mantaflow/intern/MANTA_main.cpp
index fc14c909f4d..56a2e14d5ec 100644
--- a/intern/mantaflow/intern/MANTA_main.cpp
+++ b/intern/mantaflow/intern/MANTA_main.cpp
@@ -58,7 +58,6 @@ MANTA::MANTA(int *res, FluidModifierData *fmd)
   mUsingDiffusion = (fds->flags & FLUID_DOMAIN_USE_DIFFUSION) && mUsingLiquid;
   mUsingViscosity = (fds->flags & FLUID_DOMAIN_USE_VISCOSITY) && mUsingLiquid;
   mUsingMVel = (fds->flags & FLUID_DOMAIN_USE_SPEED_VECTORS) && mUsingLiquid;
-  mUsingGuiding = (fds->flags & FLUID_DOMAIN_USE_GUIDE);
   mUsingDrops = (fds->particle_type & FLUID_DOMAIN_PARTICLE_SPRAY) && 
mUsingLiquid;
   mUsingBubbles = (fds->particle_type & FLUID_DOMAIN_PARTICLE_BUBBLE) && 
mUsingLiquid;
   mUsingFloats = (fds->particle_type & FLUID_DOMAIN_PARTICLE_FOAM) && 
mUsingLiquid;
@@ -68,6 +67,7 @@ MANTA::MANTA(int *res, FluidModifierData *fmd)
   mUsingFire = (fds->active_fields & FLUID_DOMAIN_ACTIVE_FIRE) && mUsingSmoke;
   mUsingColors = (fds->active_fields & FLUID_DOMAIN_ACTIVE_COLORS) && 
mUsingSmoke;
   mUsingObstacle = (fds->active_fields & FLUID_DOMAIN_ACTIVE_OBSTACLE);
+  mUsingGuiding = (fds->active_fields & FLUID_DOMAIN_ACTIVE_GUIDE);
   mUsingInvel = (fds->active_fields & FLUID_DOMAIN_ACTIVE_INVEL);
   mUsingOutflow = (fds->active_fields & FLUID_DOMAIN_ACTIVE_OUTFLOW);

___
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] [2eabe0a320e] blender-v3.3-release: Fix T100969: Memory leak GPU subdivision during rendering.

2022-11-28 Thread Jeroen Bakker
Commit: 2eabe0a320e820081b4dc34a8409ce02c2edec66
Author: Jeroen Bakker
Date:   Fri Nov 11 08:23:16 2022 +0100
Branches: blender-v3.3-release
https://developer.blender.org/rB2eabe0a320e820081b4dc34a8409ce02c2edec66

Fix T100969: Memory leak GPU subdivision during rendering.

The viewport cleans up old subdivision buffers right after drawing.
During rendering this was not done and when rendering many frames
this lead to memory issues.

This patch will also clear up the GPU Subdivision buffers after any
offscreen render or final render. There is already a mutex so this
is safe to be done from a non main thread.

Thanks to @kevindietrich to finding the root cause.

===

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

===

diff --git a/source/blender/draw/intern/draw_manager.c 
b/source/blender/draw/intern/draw_manager.c
index fcada20e5fb..233d93277ae 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -1996,6 +1996,7 @@ void DRW_render_to_image(RenderEngine *engine, struct 
Depsgraph *depsgraph)
   DRW_smoke_exit(DST.vmempool);
 
   drw_manager_exit(&DST);
+  DRW_cache_free_old_subdiv();
 
   /* Reset state after drawing */
   DRW_state_reset();
diff --git a/source/blender/editors/space_view3d/view3d_draw.c 
b/source/blender/editors/space_view3d/view3d_draw.c
index f854b5d18af..7e1bb1489f5 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -1697,6 +1697,7 @@ void ED_view3d_draw_offscreen(Depsgraph *depsgraph,
  do_color_management,
  ofs,
  viewport);
+  DRW_cache_free_old_subdiv();
   GPU_matrix_pop_projection();
   GPU_matrix_pop();

___
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] [3e413327984] blender-v3.3-release: Cycles: enable AMD RDNA3 GPUs and upgrade HIP compiler

2022-11-28 Thread Sayak Biswas
Commit: 3e413327984e9d10613cfdb05e150353f0ed39a0
Author: Sayak Biswas
Date:   Thu Nov 17 16:16:41 2022 +0100
Branches: blender-v3.3-release
https://developer.blender.org/rB3e413327984e9d10613cfdb05e150353f0ed39a0

Cycles: enable AMD RDNA3 GPUs and upgrade HIP compiler

* Enable AMD RDNA3 GPUs
* Fix T100891: performance regression with RDNA2 cards
* Workaround new compiler issue with Vega, by using -O1

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

===

M   CMakeLists.txt
M   build_files/config/pipeline_config.yaml
M   intern/cycles/kernel/CMakeLists.txt

===

diff --git a/CMakeLists.txt b/CMakeLists.txt
index f36d16a6ec9..939aea906bc 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -447,7 +447,7 @@ endif()
 if(NOT APPLE)
   option(WITH_CYCLES_DEVICE_HIP"Enable Cycles AMD HIP support" ON)
   option(WITH_CYCLES_HIP_BINARIES  "Build Cycles AMD HIP binaries" OFF)
-  set(CYCLES_HIP_BINARIES_ARCH gfx900 gfx906 gfx90c gfx902 gfx1010 gfx1011 
gfx1012 gfx1030 gfx1031 gfx1032 gfx1034 gfx1035 CACHE STRING "AMD HIP 
architectures to build binaries for")
+  set(CYCLES_HIP_BINARIES_ARCH gfx900 gfx906 gfx90c gfx902 gfx1010 gfx1011 
gfx1012 gfx1030 gfx1031 gfx1032 gfx1034 gfx1035 gfx1100 gfx1101 gfx1102 CACHE 
STRING "AMD HIP architectures to build binaries for")
   mark_as_advanced(WITH_CYCLES_DEVICE_HIP)
   mark_as_advanced(CYCLES_HIP_BINARIES_ARCH)
 endif()
diff --git a/build_files/config/pipeline_config.yaml 
b/build_files/config/pipeline_config.yaml
index aedaf35629b..e0c55725dd0 100644
--- a/build_files/config/pipeline_config.yaml
+++ b/build_files/config/pipeline_config.yaml
@@ -55,7 +55,7 @@ buildbot:
 cuda11:
 version: '11.4.1'
 hip:
-version: '5.2.21440'
+version: '5.3.22480'
 optix:
 version: '7.3.0'
 cmake:
diff --git a/intern/cycles/kernel/CMakeLists.txt 
b/intern/cycles/kernel/CMakeLists.txt
index 7c31b21797f..617ee113880 100644
--- a/intern/cycles/kernel/CMakeLists.txt
+++ b/intern/cycles/kernel/CMakeLists.txt
@@ -563,13 +563,22 @@ if(WITH_CYCLES_HIP_BINARIES AND WITH_CYCLES_DEVICE_HIP)
 if(WIN32)
   set(hip_command ${CMAKE_COMMAND})
   set(hip_flags
--E env "HIP_PATH=${HIP_ROOT_DIR}" "PATH=${HIP_PERL_DIR}"
+-E env "HIP_PATH=${HIP_ROOT_DIR}"
 ${HIP_HIPCC_EXECUTABLE}.bat)
 else()
   set(hip_command ${HIP_HIPCC_EXECUTABLE})
   set(hip_flags)
 endif()
 
+# There's a bug in the compiler causing some scenes to fail to render on 
Vega cards
+# A workaround currently is to set -O1 opt level during kernel compilation 
for these
+# cards Remove this when a newer compiler is available with fixes.
+if(WIN32 AND (${arch} MATCHES "gfx90[a-z0-9]+"))
+  set(hip_opt_flags "-O1")
+else()
+  set(hip_opt_flags)
+endif()
+
 set(hip_flags
   ${hip_flags}
   --amdgpu-target=${arch}
@@ -586,6 +595,7 @@ if(WITH_CYCLES_HIP_BINARIES AND WITH_CYCLES_DEVICE_HIP)
   -Wno-unused-value
   --hipcc-func-supp
   -ffast-math
+  ${hip_opt_flags}
   -o ${CMAKE_CURRENT_BINARY_DIR}/${hip_file})
 
 if(WITH_NANOVDB)

___
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] [4d58a1c657d] blender-v3.3-release: Fix Grease Pencil materials added by Python missing

2022-11-28 Thread Philipp Oeser
Commit: 4d58a1c657db7acc585d1782d66ff983ef5ce90a
Author: Philipp Oeser
Date:   Fri Nov 18 10:25:17 2022 +0100
Branches: blender-v3.3-release
https://developer.blender.org/rB4d58a1c657db7acc585d1782d66ff983ef5ce90a

Fix Grease Pencil materials added by Python missing

These materials were missing from the "Change Active Material" menu.

Caused by rBe3faef686d38.

Error was getting the preview [which wasnt there yet]
These only appeared once the material tab in the Properties Editor was
used (since this ensured a valid preview icon).

Above commit changed behavior for RNA icon getter (this does not create
data anymore), so ensure the preview by hand here.

Similar to rB182edd4c35c2.

Fixes T102566.

Maniphest Tasks: T102566

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

===

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

===

diff --git a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py 
b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
index 44d82be8ab0..ad307f8100d 100644
--- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
+++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
@@ -296,6 +296,7 @@ class GPENCIL_MT_material_active(Menu):
 
 for slot in ob.material_slots:
 mat = slot.material
+mat.id_data.preview_ensure()
 if mat and mat.id_data and mat.id_data.preview:
 icon = mat.id_data.preview.icon_id
 layout.operator("gpencil.material_set", text=mat.name, 
icon_value=icon).slot = mat.name

___
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] [6008c678593] blender-v3.3-release: Fix T100530: Drawing arifacts Volume/AMD.

2022-11-28 Thread Jeroen Bakker
Commit: 6008c6785939826a19aac0d048f0af1d7dd279de
Author: Jeroen Bakker
Date:   Wed Nov 16 12:53:10 2022 +0100
Branches: blender-v3.3-release
https://developer.blender.org/rB6008c6785939826a19aac0d048f0af1d7dd279de

Fix T100530: Drawing arifacts Volume/AMD.

Missing initialization of global shader variable.
Most drivers initialize these by them selves, but not all of them.

===

M   source/blender/draw/engines/eevee/shaders/volumetric_frag.glsl

===

diff --git a/source/blender/draw/engines/eevee/shaders/volumetric_frag.glsl 
b/source/blender/draw/engines/eevee/shaders/volumetric_frag.glsl
index c6de723ac25..05e4d6c7f05 100644
--- a/source/blender/draw/engines/eevee/shaders/volumetric_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/volumetric_frag.glsl
@@ -20,7 +20,7 @@ layout(location = 1) out vec4 volumeExtinction;
 layout(location = 2) out vec4 volumeEmissive;
 layout(location = 3) out vec4 volumePhase;
 
-int attr_id;
+int attr_id = 0;
 
 #ifndef CLEAR
 GlobalData init_globals(void)

___
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] [4a7ace4a783] blender-v3.3-release: win-launcher: linger when launched from steam

2022-11-28 Thread Ray Molenkamp
Commit: 4a7ace4a783f71d0f5ebc6c152fb503039290e7d
Author: Ray Molenkamp
Date:   Thu Nov 17 07:29:09 2022 -0700
Branches: blender-v3.3-release
https://developer.blender.org/rB4a7ace4a783f71d0f5ebc6c152fb503039290e7d

win-launcher: linger when launched from steam

The launcher is designed to exit as soon as possible
so there's no useless processes idling. Now when steam
launches blender with the launcher, this breaks the
time tracking steam has as the thing it just started
exits within milliseconds.

There already is some code in the launcher that makes
the launcher linger to support background mode. This
patch extends this a bit to also wait if the parent
process is steam.exe

Reviewed by: brecht lichtwerk dingto
Differential Revision: https://developer.blender.org/D16527

===

M   source/creator/blender_launcher_win32.c

===

diff --git a/source/creator/blender_launcher_win32.c 
b/source/creator/blender_launcher_win32.c
index 242105e5e05..993efafb53d 100644
--- a/source/creator/blender_launcher_win32.c
+++ b/source/creator/blender_launcher_win32.c
@@ -4,6 +4,54 @@
 #include 
 
 #include 
+#include 
+
+BOOL LaunchedFromSteam()
+{
+  HANDLE hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
+  BOOL isSteam = FALSE;
+  if (!hSnapShot)
+return (FALSE);
+
+  PROCESSENTRY32 process_entry;
+  process_entry.dwSize = sizeof(PROCESSENTRY32);
+
+  if (!Process32First(hSnapShot, &process_entry)) {
+CloseHandle(hSnapShot);
+return (FALSE);
+  }
+
+  /* First find our parent process ID. */
+  DWORD our_pid = GetCurrentProcessId();
+  DWORD parent_pid = -1;
+
+  do {
+if (process_entry.th32ProcessID == our_pid) {
+  parent_pid = process_entry.th32ParentProcessID;
+  break;
+}
+  } while (Process32Next(hSnapShot, &process_entry));
+
+  if (parent_pid == -1 || !Process32First(hSnapShot, &process_entry)) {
+CloseHandle(hSnapShot);
+return (FALSE);
+  }
+  /* Then do another loop to find the process name of the parent.
+   * this is done in 2 loops, since the order of the processes is
+   * unknown and we may already have passed the parent process by
+   * the time we figure out its pid in the first loop. */
+  do {
+if (process_entry.th32ProcessID == parent_pid) {
+  if (_wcsicmp(process_entry.szExeFile, L"steam.exe") == 0) {
+isSteam = TRUE;
+  }
+  break;
+}
+  } while (Process32Next(hSnapShot, &process_entry));
+
+  CloseHandle(hSnapShot);
+  return isSteam;
+}
 
 int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR 
pCmdLine, int nCmdShow)
 {
@@ -68,9 +116,9 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE 
hPrevInstance, PWSTR pCmdLine
   DWORD returnValue = success ? 0 : -1;
 
   if (success) {
-/* If blender-launcher is called with background command line flag,
+/* If blender-launcher is called with background command line flag or 
launched from steam,
  * wait for the blender process to exit and return its return value. */
-BOOL background = FALSE;
+BOOL background = LaunchedFromSteam();
 int argc = 0;
 LPWSTR *argv = CommandLineToArgvW(pCmdLine, &argc);
 for (int i = 0; i < argc; i++) {

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


[Bf-blender-cvs] [f0cd1fed189] blender-v3.3-release: Fix T102537: Curve subdivide mishandles single point curves

2022-11-28 Thread Hans Goudey
Commit: f0cd1fed189b5747268bfce8daad13093dbcabb1
Author: Hans Goudey
Date:   Tue Nov 15 18:52:02 2022 -0600
Branches: blender-v3.3-release
https://developer.blender.org/rBf0cd1fed189b5747268bfce8daad13093dbcabb1

Fix T102537: Curve subdivide mishandles single point curves

Also, single point cyclic Catmull Rom curves aren't evaluated properly.
Cyclic is meant to make no difference in that case. Now they correctly
evaluate to a single point.

===

M   source/blender/blenkernel/intern/curve_catmull_rom.cc
M   source/blender/geometry/intern/subdivide_curves.cc

===

diff --git a/source/blender/blenkernel/intern/curve_catmull_rom.cc 
b/source/blender/blenkernel/intern/curve_catmull_rom.cc
index 952d59edcf9..f26ae1f723f 100644
--- a/source/blender/blenkernel/intern/curve_catmull_rom.cc
+++ b/source/blender/blenkernel/intern/curve_catmull_rom.cc
@@ -12,8 +12,12 @@ namespace blender::bke::curves::catmull_rom {
 int calculate_evaluated_num(const int points_num, const bool cyclic, const int 
resolution)
 {
   const int eval_num = resolution * segments_num(points_num, cyclic);
+  if (cyclic) {
+/* Make sure there is a single evaluated point for the single-point curve 
case. */
+return std::max(eval_num, 1);
+  }
   /* If the curve isn't cyclic, one last point is added to the final point. */
-  return cyclic ? eval_num : eval_num + 1;
+  return eval_num + 1;
 }
 
 /* Adapted from Cycles #catmull_rom_basis_eval function. */
diff --git a/source/blender/geometry/intern/subdivide_curves.cc 
b/source/blender/geometry/intern/subdivide_curves.cc
index 8057f029e73..f2c54d4fa59 100644
--- a/source/blender/geometry/intern/subdivide_curves.cc
+++ b/source/blender/geometry/intern/subdivide_curves.cc
@@ -37,16 +37,21 @@ static void calculate_result_offsets(const 
bke::CurvesGeometry &src_curves,
   const IndexRange src_segments = curve_dst_offsets(src_points, curve_i);
 
   MutableSpan point_offsets = dst_point_offsets.slice(src_segments);
-
   MutableSpan point_counts = point_offsets.drop_back(1);
-  cuts.materialize_compressed(src_points, point_counts);
-  for (int &count : point_counts) {
-/* Make sure the number of cuts is greater than zero and add one for 
the existing point. */
-count = std::max(count, 0) + 1;
+
+  if (src_points.size() == 1) {
+point_counts.first() = 1;
   }
-  if (!cyclic[curve_i]) {
-/* The last point only has a segment to be subdivided if the curve 
isn't cyclic. */
-point_counts.last() = 1;
+  else {
+cuts.materialize_compressed(src_points, point_counts);
+for (int &count : point_counts) {
+  /* Make sure there at least one cut, and add one for the existing 
point. */
+  count = std::max(count, 0) + 1;
+}
+if (!cyclic[curve_i]) {
+  /* The last point only has a segment to be subdivided if the curve 
isn't cyclic. */
+  point_counts.last() = 1;
+}
   }
 
   bke::curves::accumulate_counts_to_offsets(point_offsets);

___
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] [5a03d212a9a] blender-v3.3-release: Fix T100926: Show UV outline in texture paint mode

2022-11-28 Thread Chris Blackbourn
Commit: 5a03d212a9ac25b44c299f05baf1b0f54d34c733
Author: Chris Blackbourn
Date:   Wed Nov 16 11:13:45 2022 +1300
Branches: blender-v3.3-release
https://developer.blender.org/rB5a03d212a9ac25b44c299f05baf1b0f54d34c733

Fix T100926: Show UV outline in texture paint mode

After rB716ea1547989 the UV overlay is no longer displayed in
the UV Editor. It only appears for the Image Editor.

So restore the previous behavior, displaying the "UV shadow"
overlay in the UV editor as well.

Reviewed By: Jeroen Bakker, Germano Cavalcante

Maniphest Tasks: T92614, T100926

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

===

M   source/blender/draw/engines/overlay/overlay_edit_uv.c

===

diff --git a/source/blender/draw/engines/overlay/overlay_edit_uv.c 
b/source/blender/draw/engines/overlay/overlay_edit_uv.c
index adbe5e7155e..2513e923c12 100644
--- a/source/blender/draw/engines/overlay/overlay_edit_uv.c
+++ b/source/blender/draw/engines/overlay/overlay_edit_uv.c
@@ -137,6 +137,8 @@ void OVERLAY_edit_uv_init(OVERLAY_Data *vedata)
  ((is_paint_mode && do_tex_paint_shadows &&
((draw_ctx->object_mode &
  (OB_MODE_TEXTURE_PAINT | 
OB_MODE_EDIT)) != 0)) ||
+  (is_uv_editor && do_tex_paint_shadows &&
+   ((draw_ctx->object_mode & 
(OB_MODE_TEXTURE_PAINT)) != 0)) ||
   (is_view_mode && do_tex_paint_shadows &&
((draw_ctx->object_mode & 
(OB_MODE_TEXTURE_PAINT)) != 0)) ||
   (do_uv_overlay && (show_modified_uvs)));

___
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] [981245fc6fc] blender-v3.3-release: Fix T102421: Image.save() not respecting set image.file_format

2022-11-28 Thread Brecht Van Lommel
Commit: 981245fc6fc29538e625edf429f926f7a182ddb7
Author: Brecht Van Lommel
Date:   Mon Nov 14 17:09:13 2022 +0100
Branches: blender-v3.3-release
https://developer.blender.org/rB981245fc6fc29538e625edf429f926f7a182ddb7

Fix T102421: Image.save() not respecting set image.file_format

The default file type for new ImBuf is already PNG, no need to override it
again in the save method.

===

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

===

diff --git a/source/blender/blenkernel/intern/image_save.cc 
b/source/blender/blenkernel/intern/image_save.cc
index ce77564ecaf..aae9576121a 100644
--- a/source/blender/blenkernel/intern/image_save.cc
+++ b/source/blender/blenkernel/intern/image_save.cc
@@ -117,16 +117,10 @@ bool BKE_image_save_options_init(ImageSaveOptions *opts,
   }
 }
 else {
-  if (ima->source == IMA_SRC_GENERATED) {
-opts->im_format.imtype = R_IMF_IMTYPE_PNG;
-opts->im_format.compress = ibuf->foptions.quality;
-opts->im_format.planes = ibuf->planes;
-if (!IMB_colormanagement_space_name_is_data(ima_colorspace)) {
-  ima_colorspace = 
IMB_colormanagement_role_colorspace_name_get(COLOR_ROLE_DEFAULT_BYTE);
-}
-  }
-  else {
-BKE_image_format_from_imbuf(&opts->im_format, ibuf);
+  BKE_image_format_from_imbuf(&opts->im_format, ibuf);
+  if (ima->source == IMA_SRC_GENERATED &&
+  !IMB_colormanagement_space_name_is_data(ima_colorspace)) {
+ima_colorspace = 
IMB_colormanagement_role_colorspace_name_get(COLOR_ROLE_DEFAULT_BYTE);
   }
 
   /* use the multiview image settings as the default */

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


[Bf-blender-cvs] [e257e2e0759] blender-v3.3-release: Fix: Link drag search crash with incorrect socket name in switch node

2022-11-28 Thread Martijn Versteegh
Commit: e257e2e0759294c915db26db94f7af6cce2a903e
Author: Martijn Versteegh
Date:   Tue Nov 15 21:47:57 2022 +0100
Branches: blender-v3.3-release
https://developer.blender.org/rBe257e2e0759294c915db26db94f7af6cce2a903e

Fix: Link drag search crash with incorrect socket name in switch node

When dragging out a boolean noodle, releasing and choosing
'switch > Switch' from the search popup, the code would mistakenly
search for 'Start' instead of 'Switch'.

Also the function called was not exactly the right one, leading to the
node being marked as invalid.

Reviewed By: Jacques Lucke

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

===

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

===

diff --git a/source/blender/nodes/geometry/nodes/node_geo_switch.cc 
b/source/blender/nodes/geometry/nodes/node_geo_switch.cc
index ddc87e3dac4..11e7f40c1c5 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_switch.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_switch.cc
@@ -123,7 +123,7 @@ static void 
node_gather_link_searches(GatherLinkSearchOpParams ¶ms)
 if (params.other_socket().type == SOCK_BOOLEAN) {
   params.add_item(IFACE_("Switch"), [](LinkSearchOpParams ¶ms) {
 bNode &node = params.add_node("GeometryNodeSwitch");
-params.connect_available_socket(node, "Start");
+params.update_and_connect_available_socket(node, "Switch");
   });
 }
 params.add_item(IFACE_("False"), [](LinkSearchOpParams ¶ms) {

___
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] [92680674d0b] blender-v3.3-release: Fix T102187: Add knife tool in mesh panel

2022-11-28 Thread Pratik Borhade
Commit: 92680674d0b78f477ec8dd68589289e45870791b
Author: Pratik Borhade
Date:   Sun Nov 13 22:48:24 2022 +0530
Branches: blender-v3.3-release
https://developer.blender.org/rB92680674d0b78f477ec8dd68589289e45870791b

Fix T102187: Add knife tool in mesh panel

Add knife tool option in mesh panel

Reviewer: campbellbarton, JulienKaspar

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

===

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

===

diff --git a/release/scripts/startup/bl_ui/space_view3d.py 
b/release/scripts/startup/bl_ui/space_view3d.py
index e0970a9708e..1a55a5f2535 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -3841,6 +3841,7 @@ class VIEW3D_MT_edit_mesh(Menu):
 
 layout.operator("mesh.bisect")
 layout.operator("mesh.knife_project")
+layout.operator("mesh.knife_tool")
 
 if with_bullet:
 layout.operator("mesh.convex_hull")

___
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] [c024d6f47db] blender-v3.3-release: Fix T95335 Bevel operator Loop Slide overshoot.

2022-11-28 Thread Howard Trickey
Commit: c024d6f47dbd14da2397fa3818d0ea4e8c6a5329
Author: Howard Trickey
Date:   Sun Nov 13 14:09:27 2022 -0500
Branches: blender-v3.3-release
https://developer.blender.org/rBc024d6f47dbd14da2397fa3818d0ea4e8c6a5329

Fix T95335 Bevel operator Loop Slide overshoot.

If the edge you are going to slide along is very close to in line
with the adjacent beveled edge, then there will be sharp overshoots.
There is an epsilon comparison to just abandon loop slide if this
situation is happening. That epsilon used to be 0.25 radians, but
bug T86768 complained that that value was too high, so it was changed
to .0001 radians (5 millidegrees). Now this current bug shows that
that was too aggressively small, so this change ups it by a factor
of 10, to .001 radians (5 centidegrees). All previous bug reports
remained fixed.

===

M   source/blender/bmesh/tools/bmesh_bevel.c

===

diff --git a/source/blender/bmesh/tools/bmesh_bevel.c 
b/source/blender/bmesh/tools/bmesh_bevel.c
index aa2c93f7c5a..20ea8a4db08 100644
--- a/source/blender/bmesh/tools/bmesh_bevel.c
+++ b/source/blender/bmesh/tools/bmesh_bevel.c
@@ -1502,8 +1502,11 @@ static void offset_meet(BevelParams *bp,
 }
 
 /* This was changed from 0.25f to fix bug T86768.
- * Original bug T44961 remains fixed with this value. */
-#define BEVEL_GOOD_ANGLE 0.0001f
+ * Original bug T44961 remains fixed with this value.
+ * Update: changed again from 0.0001f to fix bug T95335.
+ * Original two bugs remained fixed.
+ */
+#define BEVEL_GOOD_ANGLE 0.001f
 
 /**
  * Calculate the meeting point between e1 and e2 (one of which should have 
zero offsets),

___
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] [198fd56a5e6] blender-v3.3-release: Fix T100883: crash with particle instancing and clumping

2022-11-28 Thread Brecht Van Lommel
Commit: 198fd56a5e689eb668ccae106262c08badf23d9a
Author: Brecht Van Lommel
Date:   Wed Nov 9 20:30:41 2022 +0100
Branches: blender-v3.3-release
https://developer.blender.org/rB198fd56a5e689eb668ccae106262c08badf23d9a

Fix T100883: crash with particle instancing and clumping

Properly initialize clump curve mapping tables for duplis and other cases
where this was missed by making a generic init/free function instead of
duplicating the same logic in multiple places. Also fold lattice deform
init into this.

===

M   source/blender/blenkernel/BKE_particle.h
M   source/blender/blenkernel/intern/fluid.c
M   source/blender/blenkernel/intern/object_dupli.cc
M   source/blender/blenkernel/intern/particle.c
M   source/blender/blenkernel/intern/particle_system.c
M   source/blender/draw/intern/draw_cache_impl_particles.c
M   source/blender/io/alembic/exporter/abc_writer_points.cc
M   source/blender/modifiers/intern/MOD_explode.c
M   source/blender/modifiers/intern/MOD_particleinstance.c
M   source/blender/render/intern/texture_pointdensity.c

===

diff --git a/source/blender/blenkernel/BKE_particle.h 
b/source/blender/blenkernel/BKE_particle.h
index 5f8b2fafdd3..cc75a47f098 100644
--- a/source/blender/blenkernel/BKE_particle.h
+++ b/source/blender/blenkernel/BKE_particle.h
@@ -291,7 +291,11 @@ void psys_set_current_num(struct Object *ob, int index);
 /* UNUSED */
 // struct Object *psys_find_object(struct Scene *scene, struct ParticleSystem 
*psys);
 
-struct LatticeDeformData *psys_create_lattice_deform_data(struct 
ParticleSimulationData *sim);
+/**
+ * Initialize/free data for particle simulation evaluation.
+ */
+void psys_sim_data_init(struct ParticleSimulationData *sim);
+void psys_sim_data_free(struct ParticleSimulationData *sim);
 
 /**
  * For a given evaluated particle system get its original.
@@ -416,7 +420,7 @@ void psys_get_particle_on_path(struct 
ParticleSimulationData *sim,
struct ParticleKey *state,
bool vel);
 /**
- * Gets particle's state at a time.
+ * Gets particle's state at a time. Must call psys_sim_data_init before this.
  * \return true if particle exists and can be seen and false if not.
  */
 bool psys_get_particle_state(struct ParticleSimulationData *sim,
diff --git a/source/blender/blenkernel/intern/fluid.c 
b/source/blender/blenkernel/intern/fluid.c
index 0fc09803088..d45aa480ec8 100644
--- a/source/blender/blenkernel/intern/fluid.c
+++ b/source/blender/blenkernel/intern/fluid.c
@@ -1541,18 +1541,8 @@ static void emit_from_particles(Object *flow_ob,
 sim.scene = scene;
 sim.ob = flow_ob;
 sim.psys = psys;
-sim.psys->lattice_deform_data = psys_create_lattice_deform_data(&sim);
 
-/* prepare curvemapping tables */
-if ((psys->part->child_flag & PART_CHILD_USE_CLUMP_CURVE) && 
psys->part->clumpcurve) {
-  BKE_curvemapping_changed_all(psys->part->clumpcurve);
-}
-if ((psys->part->child_flag & PART_CHILD_USE_ROUGH_CURVE) && 
psys->part->roughcurve) {
-  BKE_curvemapping_changed_all(psys->part->roughcurve);
-}
-if ((psys->part->child_flag & PART_CHILD_USE_TWIST_CURVE) && 
psys->part->twistcurve) {
-  BKE_curvemapping_changed_all(psys->part->twistcurve);
-}
+psys_sim_data_init(&sim);
 
 /* initialize particle cache */
 if (psys->part->type == PART_HAIR) {
@@ -1693,6 +1683,8 @@ static void emit_from_particles(Object *flow_ob,
 if (particle_vel) {
   MEM_freeN(particle_vel);
 }
+
+psys_sim_data_free(&sim);
   }
 }
 
diff --git a/source/blender/blenkernel/intern/object_dupli.cc 
b/source/blender/blenkernel/intern/object_dupli.cc
index 407a2c8955c..7954dc1340a 100644
--- a/source/blender/blenkernel/intern/object_dupli.cc
+++ b/source/blender/blenkernel/intern/object_dupli.cc
@@ -1292,7 +1292,7 @@ static void make_duplis_particle_system(const 
DupliContext *ctx, ParticleSystem
 
 RNG *rng = BLI_rng_new_srandom(31415926u + (unsigned int)psys->seed);
 
-psys->lattice_deform_data = psys_create_lattice_deform_data(&sim);
+psys_sim_data_init(&sim);
 
 /* Gather list of objects or single object. */
 int totcollection = 0;
@@ -1514,17 +1514,13 @@ static void make_duplis_particle_system(const 
DupliContext *ctx, ParticleSystem
 }
 
 BLI_rng_free(rng);
+psys_sim_data_free(&sim);
   }
 
   /* Clean up. */
   if (oblist) {
 MEM_freeN(oblist);
   }
-
-  if (psys->lattice_deform_data) {
-BKE_lattice_deform_data_destroy(psys->lattice_deform_data);
-psys->lattice_deform_data = nullptr;
-  }
 }
 
 static void make_duplis_particles(const DupliContext *ctx)
diff --git a/source/blender/blenkernel/intern/particle.c 
b/source/blender/blenkernel/intern/particle.c
index c5344997733..4d9187d7911 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blend

[Bf-blender-cvs] [331de028ef7] blender-v3.3-release: Fix T101220: UV proportional editing not working correctly with UV Sync Selection

2022-11-28 Thread Germano Cavalcante
Commit: 331de028ef7dcebb63dd09345b311942d6e22f62
Author: Germano Cavalcante
Date:   Tue Sep 20 17:29:33 2022 -0300
Branches: blender-v3.3-release
https://developer.blender.org/rB331de028ef7dcebb63dd09345b311942d6e22f62

Fix T101220: UV proportional editing not working correctly with UV Sync 
Selection

Regression introduced in rb2ba1cf4b40fc.

The `MLOOPUV_VERTSEL` flag only indicates UV selection without sync.

===

M   source/blender/editors/transform/transform_convert_mesh_uv.c

===

diff --git a/source/blender/editors/transform/transform_convert_mesh_uv.c 
b/source/blender/editors/transform/transform_convert_mesh_uv.c
index d95bc7b976f..bcd4c2a2b29 100644
--- a/source/blender/editors/transform/transform_convert_mesh_uv.c
+++ b/source/blender/editors/transform/transform_convert_mesh_uv.c
@@ -74,8 +74,12 @@ static void UVsToTransData(const float aspect[2],
 /**
  * \param dists: Store the closest connected distance to selected vertices.
  */
-static void uv_set_connectivity_distance(BMesh *bm, float *dists, const float 
aspect[2])
+static void uv_set_connectivity_distance(const ToolSettings *ts,
+ BMesh *bm,
+ float *dists,
+ const float aspect[2])
 {
+#define TMP_LOOP_SELECT_TAG BM_ELEM_TAG_ALT
   /* Mostly copied from #transform_convert_mesh_connectivity_distance. */
   BLI_LINKSTACK_DECLARE(queue, BMLoop *);
 
@@ -103,13 +107,15 @@ static void uv_set_connectivity_distance(BMesh *bm, float 
*dists, const float as
   float dist;
   MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
 
-  bool uv_vert_sel = luv->flag & MLOOPUV_VERTSEL;
+  bool uv_vert_sel = uvedit_uv_select_test_ex(ts, l, cd_loop_uv_offset);
 
   if (uv_vert_sel) {
 BLI_LINKSTACK_PUSH(queue, l);
+BM_elem_flag_enable(l, TMP_LOOP_SELECT_TAG);
 dist = 0.0f;
   }
   else {
+BM_elem_flag_disable(l, TMP_LOOP_SELECT_TAG);
 dist = FLT_MAX;
   }
 
@@ -164,7 +170,7 @@ static void uv_set_connectivity_distance(BMesh *bm, float 
*dists, const float as
 
 bool other_vert_sel, connected_vert_sel;
 
-other_vert_sel = luv_other->flag & MLOOPUV_VERTSEL;
+other_vert_sel = BM_elem_flag_test_bool(l_other, TMP_LOOP_SELECT_TAG);
 
 BM_ITER_ELEM (l_connected, &l_connected_iter, l_other->v, 
BM_LOOPS_OF_VERT) {
   if (l_connected == l_other) {
@@ -176,7 +182,7 @@ static void uv_set_connectivity_distance(BMesh *bm, float 
*dists, const float as
   }
 
   MLoopUV *luv_connected = BM_ELEM_CD_GET_VOID_P(l_connected, 
cd_loop_uv_offset);
-  connected_vert_sel = luv_connected->flag & MLOOPUV_VERTSEL;
+  connected_vert_sel = BM_elem_flag_test_bool(l_connected, 
TMP_LOOP_SELECT_TAG);
 
   /* Check if this loop is connected in UV space.
* If the uv loops share the same selection state (if not, they are 
not connected as
@@ -232,6 +238,7 @@ static void uv_set_connectivity_distance(BMesh *bm, float 
*dists, const float as
   BLI_LINKSTACK_FREE(queue_next);
 
   MEM_freeN(dists_prev);
+#undef TMP_LOOP_SELECT_TAG
 }
 
 static void createTransUVs(bContext *C, TransInfo *t)
@@ -339,7 +346,7 @@ static void createTransUVs(bContext *C, TransInfo *t)
 if (is_prop_connected) {
   prop_dists = MEM_callocN(em->bm->totloop * sizeof(float), 
"TransObPropDists(UV Editing)");
 
-  uv_set_connectivity_distance(em->bm, prop_dists, t->aspect);
+  uv_set_connectivity_distance(t->settings, em->bm, prop_dists, t->aspect);
 }
 
 BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_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] [d0e9a8c46ab] blender-v3.3-release: Fix T101533: Wrong DoF when a non-camera object is the active camera

2022-11-28 Thread Miguel Pozo
Commit: d0e9a8c46aba056144b1bfe8ddd55cc1d6ccc56e
Author: Miguel Pozo
Date:   Mon Nov 7 15:30:15 2022 +0100
Branches: blender-v3.3-release
https://developer.blender.org/rBd0e9a8c46aba056144b1bfe8ddd55cc1d6ccc56e

Fix T101533: Wrong DoF when a non-camera object is the active camera

Make sure non-camera data is not casted to a Camera pointer.

Solution suggested by Damien Picard (@pioverfour).

===

M   source/blender/draw/engines/eevee/eevee_depth_of_field.c
M   source/blender/draw/engines/gpencil/gpencil_engine.c
M   source/blender/draw/engines/workbench/workbench_effect_dof.c

===

diff --git a/source/blender/draw/engines/eevee/eevee_depth_of_field.c 
b/source/blender/draw/engines/eevee/eevee_depth_of_field.c
index 0d14a0c5f61..caa63b9c54c 100644
--- a/source/blender/draw/engines/eevee/eevee_depth_of_field.c
+++ b/source/blender/draw/engines/eevee/eevee_depth_of_field.c
@@ -189,7 +189,7 @@ int EEVEE_depth_of_field_init(EEVEE_ViewLayerData 
*UNUSED(sldata),
   const DRWContextState *draw_ctx = DRW_context_state_get();
   const Scene *scene_eval = DEG_get_evaluated_scene(draw_ctx->depsgraph);
 
-  Camera *cam = (camera != NULL) ? camera->data : NULL;
+  Camera *cam = (camera != NULL && camera->type == OB_CAMERA) ? camera->data : 
NULL;
 
   if (cam && (cam->dof.flag & CAM_DOF_ENABLED)) {
 RegionView3D *rv3d = draw_ctx->rv3d;
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c 
b/source/blender/draw/engines/gpencil/gpencil_engine.c
index 4f520e61936..bb0dd45f320 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.c
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.c
@@ -289,7 +289,7 @@ void GPENCIL_cache_init(void *ved)
 DRW_shgroup_call_procedural_triangles(grp, NULL, 1);
   }
 
-  Camera *cam = (pd->camera != NULL) ? pd->camera->data : NULL;
+  Camera *cam = (pd->camera != NULL && pd->camera->type == OB_CAMERA) ? 
pd->camera->data : NULL;
 
   /* Pseudo DOF setup. */
   if (cam && (cam->dof.flag & CAM_DOF_ENABLED)) {
diff --git a/source/blender/draw/engines/workbench/workbench_effect_dof.c 
b/source/blender/draw/engines/workbench/workbench_effect_dof.c
index 58d49cf226e..a7247f4e9a6 100644
--- a/source/blender/draw/engines/workbench/workbench_effect_dof.c
+++ b/source/blender/draw/engines/workbench/workbench_effect_dof.c
@@ -128,7 +128,7 @@ void workbench_dof_engine_init(WORKBENCH_Data *vedata)
 camera = wpd->cam_original_ob;
   }
 
-  Camera *cam = camera != NULL ? camera->data : NULL;
+  Camera *cam = camera != NULL && camera->type == OB_CAMERA ? camera->data : 
NULL;
   if ((wpd->shading.flag & V3D_SHADING_DEPTH_OF_FIELD) == 0 || (cam == NULL) ||
   ((cam->dof.flag & CAM_DOF_ENABLED) == 0)) {
 wpd->dof_enabled = 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] [4f22e6178e6] blender-v3.3-release: Fix T101270: Object Info > Random not unique for nested instances and curves

2022-11-28 Thread Brecht Van Lommel
Commit: 4f22e6178e62eee448b597cc14ee8b8fa2a63612
Author: Brecht Van Lommel
Date:   Fri Nov 11 12:54:01 2022 +0100
Branches: blender-v3.3-release
https://developer.blender.org/rB4f22e6178e62eee448b597cc14ee8b8fa2a63612

Fix T101270: Object Info > Random not unique for nested instances and curves

This random number is intended to be unique for every instance, however for
some cases with more than one level of nesting this was failing. This also
affected curves after they were refactored to use geometry sets.

For simple cases the random number is the same as before, however for more
complex nesting it will be different than before, changing the render result.

===

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

===

diff --git a/source/blender/blenkernel/intern/object_dupli.cc 
b/source/blender/blenkernel/intern/object_dupli.cc
index 7954dc1340a..44e08a9a62b 100644
--- a/source/blender/blenkernel/intern/object_dupli.cc
+++ b/source/blender/blenkernel/intern/object_dupli.cc
@@ -72,6 +72,9 @@ struct DupliContext {
   Object *obedit;
 
   Scene *scene;
+  /** Root parent object at the scene level. */
+  Object *root_object;
+  /** Immediate parent object in the context. */
   Object *object;
   float space_mat[4][4];
 
@@ -112,6 +115,7 @@ static void init_context(DupliContext *r_ctx,
   r_ctx->scene = scene;
   r_ctx->collection = nullptr;
 
+  r_ctx->root_object = ob;
   r_ctx->object = ob;
   r_ctx->obedit = OBEDIT_FROM_OBACT(ob);
   r_ctx->instance_stack = &instance_stack;
@@ -206,8 +210,9 @@ static DupliObject *make_dupli(const DupliContext *ctx,
 dob->no_draw = true;
   }
 
-  /* Random number.
-   * The logic here is designed to match Cycles. */
+  /* Random number per instance.
+   * The root object in the scene, persistent ID up to the instance object, 
and the instance object
+   * name together result in a unique random number. */
   dob->random_id = BLI_hash_string(dob->ob->id.name + 2);
 
   if (dob->persistent_id[0] != INT_MAX) {
@@ -219,8 +224,8 @@ static DupliObject *make_dupli(const DupliContext *ctx,
 dob->random_id = BLI_hash_int_2d(dob->random_id, 0);
   }
 
-  if (ctx->object != ob) {
-dob->random_id ^= BLI_hash_int(BLI_hash_string(ctx->object->id.name + 2));
+  if (ctx->root_object != ob) {
+dob->random_id ^= BLI_hash_int(BLI_hash_string(ctx->root_object->id.name + 
2));
   }
 
   return dob;

___
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] [29bc410c8a6] blender-v3.3-release: Fix T89399: Mouse wrapping causes erratic movement

2022-11-28 Thread Germano Cavalcante
Commit: 29bc410c8a67fcdc65827e30741eec1c8463df06
Author: Germano Cavalcante
Date:   Thu Aug 18 09:32:49 2022 -0300
Branches: blender-v3.3-release
https://developer.blender.org/rB29bc410c8a67fcdc65827e30741eec1c8463df06

Fix T89399: Mouse wrapping causes erratic movement

As mentioned in T89399, "the source of this bug is that cursor wrap
moves the cursor, but when it later checks the mouse position it hasn't
yet been updated, so it re-wraps".

As far as I could see, this happens for two reasons:
1. During the first warp, there are already other mousemove events in the queue 
with an outdated position.
2. Sometimes Windows occasionally and inexplicably ignores `SetCursorPos()` or 
`SendInput()` events. (See [1])

The solution consists in checking if the cursor is inside the bounds right 
after wrapping.
If it's not inside, it indicates that the wrapping either didn't work or the 
event is out of date.
In these cases do not change the "accum" values.

1. 
https://github.com/libsdl-org/SDL/blob/f317d619ccd22e60cebf1b09d716d3985359c981/src/video/windows/SDL_windowsmouse.c#L255)

Maniphest Tasks: T89399

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

===

M   intern/ghost/intern/GHOST_SystemWin32.cpp

===

diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp 
b/intern/ghost/intern/GHOST_SystemWin32.cpp
index 0d4016253fb..82eef4a2854 100644
--- a/intern/ghost/intern/GHOST_SystemWin32.cpp
+++ b/intern/ghost/intern/GHOST_SystemWin32.cpp
@@ -1122,6 +1122,12 @@ GHOST_EventCursor 
*GHOST_SystemWin32::processCursorEvent(GHOST_WindowWin32 *wind
   system->getCursorPosition(x_screen, y_screen);
 
   if (window->getCursorGrabModeIsWarp()) {
+/* WORKAROUND:
+ * Sometimes Windows ignores `SetCursorPos()` or `SendInput()` calls or 
the mouse event is
+ * outdate. Identify these cases by checking if the cursor is not yet 
within bounds. */
+static bool is_warping_x = false;
+static bool is_warping_y = false;
+
 int32_t x_new = x_screen;
 int32_t y_new = y_screen;
 int32_t x_accum, y_accum;
@@ -1138,29 +1144,41 @@ GHOST_EventCursor 
*GHOST_SystemWin32::processCursorEvent(GHOST_WindowWin32 *wind
 
 window->getCursorGrabAccum(x_accum, y_accum);
 if (x_new != x_screen || y_new != y_screen) {
+  system->setCursorPosition(x_new, y_new); /* wrap */
+
+  /* Do not update the accum values if we are an outdated or failed 
pos-warp event. */
+  if (!is_warping_x) {
+is_warping_x = x_new != x_screen;
+if (is_warping_x) {
+  x_accum += (x_screen - x_new);
+}
+  }
+
+  if (!is_warping_y) {
+is_warping_y = y_new != y_screen;
+if (is_warping_y) {
+  y_accum += (y_screen - y_new);
+}
+  }
+  window->setCursorGrabAccum(x_accum, y_accum);
+
   /* When wrapping we don't need to add an event because the 
setCursorPosition call will cause
* a new event after. */
-  system->setCursorPosition(x_new, y_new); /* wrap */
-  window->setCursorGrabAccum(x_accum + (x_screen - x_new), y_accum + 
(y_screen - y_new));
-}
-else {
-  return new GHOST_EventCursor(system->getMilliSeconds(),
-   GHOST_kEventCursorMove,
-   window,
-   x_screen + x_accum,
-   y_screen + y_accum,
-   GHOST_TABLET_DATA_NONE);
+  return NULL;
 }
+
+is_warping_x = false;
+is_warping_y = false;
+x_screen += x_accum;
+y_screen += y_accum;
   }
-  else {
-return new GHOST_EventCursor(system->getMilliSeconds(),
- GHOST_kEventCursorMove,
- window,
- x_screen,
- y_screen,
- GHOST_TABLET_DATA_NONE);
-  }
-  return NULL;
+
+  return new GHOST_EventCursor(system->getMilliSeconds(),
+   GHOST_kEventCursorMove,
+   window,
+   x_screen,
+   y_screen,
+   GHOST_TABLET_DATA_NONE);
 }
 
 void GHOST_SystemWin32::processWheelEvent(GHOST_WindowWin32 *window, WPARAM 
wParam, LPARAM lParam)

___
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] [be34354500f] blender-v3.3-release: audaspace: Fix build error with MSVC 17.4+

2022-11-28 Thread Ray Molenkamp
Commit: be34354500fdc2f5be52a3046d7e77a07114042d
Author: Ray Molenkamp
Date:   Wed Nov 9 14:39:15 2022 -0700
Branches: blender-v3.3-release
https://developer.blender.org/rBbe34354500fdc2f5be52a3046d7e77a07114042d

audaspace: Fix build error with MSVC 17.4+

`DeviceManager.h` uses `std::string` without explicitly including
the `` header. While older MSVC implicitly included this
header somewhere, the headers for 17.4+ do not leading to a build
error.

===

M   extern/audaspace/include/devices/DeviceManager.h

===

diff --git a/extern/audaspace/include/devices/DeviceManager.h 
b/extern/audaspace/include/devices/DeviceManager.h
index 27a546630e8..fa84025478f 100644
--- a/extern/audaspace/include/devices/DeviceManager.h
+++ b/extern/audaspace/include/devices/DeviceManager.h
@@ -27,6 +27,7 @@
 #include 
 #include 
 #include 
+#include 
 
 AUD_NAMESPACE_BEGIN

___
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] [036c60a27d8] blender-v3.3-release: Fix: Spline Parameter node produces NaN when curve is a single point

2022-11-28 Thread Jacques Lucke
Commit: 036c60a27d8d2d66d9cf81c131c6c94548ba51c6
Author: Jacques Lucke
Date:   Thu Sep 29 13:32:03 2022 +0200
Branches: blender-v3.3-release
https://developer.blender.org/rB036c60a27d8d2d66d9cf81c131c6c94548ba51c6

Fix: Spline Parameter node produces NaN when curve is a single point

Issue found in file from T101256.

===

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

===

diff --git 
a/source/blender/nodes/geometry/nodes/node_geo_curve_spline_parameter.cc 
b/source/blender/nodes/geometry/nodes/node_geo_curve_spline_parameter.cc
index 5901d310df4..03f5e428fb3 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_curve_spline_parameter.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_curve_spline_parameter.cc
@@ -126,6 +126,10 @@ static VArray 
construct_curve_parameter_varray(const bke::CurvesGeometry
 value *= factor;
   }
 }
+else if (curve_lengths.size() == 1) {
+  /* The curve is a single point. */
+  curve_lengths[0] = 0.0f;
+}
 else {
   /* It is arbitrary what to do in those rare cases when all the 
points are
* in the same position. In this case we are just arbitrarily giving 
a valid

___
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] [7a21a49ac53] blender-v3.3-release: Fix T102312: anchored brush texture overlay draws in wrong place

2022-11-28 Thread Philipp Oeser
Commit: 7a21a49ac531b4181e1ed8c24d409f4296b1f5f6
Author: Philipp Oeser
Date:   Tue Nov 8 12:27:17 2022 +0100
Branches: blender-v3.3-release
https://developer.blender.org/rB7a21a49ac531b4181e1ed8c24d409f4296b1f5f6

Fix T102312: anchored brush texture overlay draws in wrong place

Rotation and scale was done around the wrong center (always around mouse
position) in paint_draw_tex_overlay [on the other hand,
paint_draw_cursor_overlay already got the center right].

Now make the center dependent on UnifiedPaintSettings "draw_anchored".

Maniphest Tasks: T102312

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

===

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

===

diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c 
b/source/blender/editors/sculpt_paint/paint_cursor.c
index c5ebcf870a3..312914ce1ee 100644
--- a/source/blender/editors/sculpt_paint/paint_cursor.c
+++ b/source/blender/editors/sculpt_paint/paint_cursor.c
@@ -563,31 +563,36 @@ static bool paint_draw_tex_overlay(UnifiedPaintSettings 
*ups,
 if (mtex->brush_map_mode == MTEX_MAP_MODE_VIEW) {
   GPU_matrix_push();
 
+  float center[2] = {
+  ups->draw_anchored ? ups->anchored_initial_mouse[0] : x,
+  ups->draw_anchored ? ups->anchored_initial_mouse[1] : y,
+  };
+
   /* Brush rotation. */
-  GPU_matrix_translate_2f(x, y);
+  GPU_matrix_translate_2fv(center);
   GPU_matrix_rotate_2d(-RAD2DEGF(primary ? ups->brush_rotation : 
ups->brush_rotation_sec));
-  GPU_matrix_translate_2f(-x, -y);
+  GPU_matrix_translate_2f(-center[0], -center[1]);
 
   /* Scale based on tablet pressure. */
   if (primary && ups->stroke_active && BKE_brush_use_size_pressure(brush)) 
{
 const float scale = ups->size_pressure_value;
-GPU_matrix_translate_2f(x, y);
+GPU_matrix_translate_2fv(center);
 GPU_matrix_scale_2f(scale, scale);
-GPU_matrix_translate_2f(-x, -y);
+GPU_matrix_translate_2f(-center[0], -center[1]);
   }
 
   if (ups->draw_anchored) {
-quad.xmin = ups->anchored_initial_mouse[0] - ups->anchored_size;
-quad.ymin = ups->anchored_initial_mouse[1] - ups->anchored_size;
-quad.xmax = ups->anchored_initial_mouse[0] + ups->anchored_size;
-quad.ymax = ups->anchored_initial_mouse[1] + ups->anchored_size;
+quad.xmin = center[0] - ups->anchored_size;
+quad.ymin = center[1] - ups->anchored_size;
+quad.xmax = center[0] + ups->anchored_size;
+quad.ymax = center[1] + ups->anchored_size;
   }
   else {
 const int radius = BKE_brush_size_get(vc->scene, brush) * zoom;
-quad.xmin = x - radius;
-quad.ymin = y - radius;
-quad.xmax = x + radius;
-quad.ymax = y + radius;
+quad.xmin = center[0] - radius;
+quad.ymin = center[1] - radius;
+quad.xmax = center[0] + radius;
+quad.ymax = center[1] + radius;
   }
 }
 else if (mtex->brush_map_mode == MTEX_MAP_MODE_TILED) {

___
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] [af7dd995880] blender-v3.3-release: Fix T102018: find HIP library also in system library paths on Linux

2022-11-28 Thread Brecht Van Lommel
Commit: af7dd995880dcc88f9e590e12cda20b385471910
Author: Brecht Van Lommel
Date:   Tue Nov 1 15:34:12 2022 +0100
Branches: blender-v3.3-release
https://developer.blender.org/rBaf7dd995880dcc88f9e590e12cda20b385471910

Fix T102018: find HIP library also in system library paths on Linux

Previously it would use a hardcoded location where the AMD driver installs it,
but Linux distributions may use other locations. Now look for both cases.

===

M   extern/hipew/src/hipew.c

===

diff --git a/extern/hipew/src/hipew.c b/extern/hipew/src/hipew.c
index ecf952e266f..7cafe7727f5 100644
--- a/extern/hipew/src/hipew.c
+++ b/extern/hipew/src/hipew.c
@@ -253,7 +253,7 @@ static int hipewHipInit(void) {
   /* Default installation path. */
   const char *hip_paths[] = {"", NULL};
 #else
-  const char *hip_paths[] = {"/opt/rocm/hip/lib/libamdhip64.so", NULL};
+  const char *hip_paths[] = {"libamdhip64.so", 
"/opt/rocm/hip/lib/libamdhip64.so", NULL};
 #endif
   static int initialized = 0;
   static int result = 0;

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


[Bf-blender-cvs] [9676cb6d8df] blender-v3.3-release: Fix T102092: GPencil Sculpt Grab crash using Shift key

2022-11-28 Thread Antonio Vazquez
Commit: 9676cb6d8dfc6b6ac6c51fd2b5f6cf82d9d42d1b
Author: Antonio Vazquez
Date:   Thu Oct 27 16:46:51 2022 +0200
Branches: blender-v3.3-release
https://developer.blender.org/rB9676cb6d8dfc6b6ac6c51fd2b5f6cf82d9d42d1b

Fix T102092: GPencil Sculpt Grab crash using Shift key

There was a problem with the hash table that was 
not created as expected.

Also fixed an unreported memory leak in Grab tool not
related to this crash but detected during debug.

===

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

===

diff --git a/source/blender/editors/gpencil/gpencil_sculpt_paint.c 
b/source/blender/editors/gpencil/gpencil_sculpt_paint.c
index 424544c8085..f47ec78ce33 100644
--- a/source/blender/editors/gpencil/gpencil_sculpt_paint.c
+++ b/source/blender/editors/gpencil/gpencil_sculpt_paint.c
@@ -1202,6 +1202,9 @@ static bool gpencil_sculpt_brush_init(bContext *C, 
wmOperator *op)
 gso->automasking_strokes = BLI_ghash_ptr_new(__func__);
   }
   else {
+if (gso->automasking_strokes != NULL) {
+  BLI_ghash_free(gso->automasking_strokes, NULL, NULL);
+}
 gso->automasking_strokes = NULL;
   }
   /* save mask */
@@ -1292,6 +1295,10 @@ static void gpencil_sculpt_brush_exit(bContext *C, 
wmOperator *op)
 }
 
 default:
+  if (gso->stroke_customdata != NULL) {
+BLI_ghash_free(gso->stroke_customdata, NULL, NULL);
+gso->stroke_customdata = NULL;
+  }
   break;
   }
 
@@ -2075,6 +2082,20 @@ static void gpencil_sculpt_brush_apply_event(bContext 
*C, wmOperator *op, const
 if (gso->brush == NULL) {
   gso->brush = gso->brush_prev;
 }
+Brush *brush = gso->brush;
+if (brush->gpencil_settings->sculpt_mode_flag &
+(GP_SCULPT_FLAGMODE_AUTOMASK_STROKE | 
GP_SCULPT_FLAGMODE_AUTOMASK_LAYER |
+ GP_SCULPT_FLAGMODE_AUTOMASK_MATERIAL)) {
+  if (gso->automasking_strokes == NULL) {
+gso->automasking_strokes = BLI_ghash_ptr_new(__func__);
+  }
+}
+else {
+  if (gso->automasking_strokes != NULL) {
+BLI_ghash_free(gso->automasking_strokes, NULL, NULL);
+  }
+  gso->automasking_strokes = NULL;
+}
   }
   else {
 if (gso->brush_prev != NULL) {

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


[Bf-blender-cvs] [1fd35126c42] blender-v3.3-release: Fix File Browser Move Bookmark malfunction if no item is selected

2022-11-28 Thread Philipp Oeser
Commit: 1fd35126c42656e1792080534107679476c3d106
Author: Philipp Oeser
Date:   Fri Nov 4 10:28:20 2022 +0100
Branches: blender-v3.3-release
https://developer.blender.org/rB1fd35126c42656e1792080534107679476c3d106

Fix File Browser Move Bookmark malfunction if no item is selected

The operator was acting on non selected items (wasnt checking SpaceFile
bookmarknr for being -1) which could end up removing items even.

Now sanatize this by introducing proper poll (which returns false if
nothing is selected).

Fixes T102014.

Maniphest Tasks: T102014

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

===

M   source/blender/editors/space_file/file_ops.c

===

diff --git a/source/blender/editors/space_file/file_ops.c 
b/source/blender/editors/space_file/file_ops.c
index 59d9a15fbab..54cd281da5b 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -1316,6 +1316,18 @@ static int bookmark_move_exec(bContext *C, wmOperator 
*op)
   return OPERATOR_FINISHED;
 }
 
+static bool file_bookmark_move_poll(bContext *C)
+{
+  SpaceFile *sfile = CTX_wm_space_file(C);
+
+  /* Bookmarks are for file browsing only (not asset browsing). */
+  if (!ED_operator_file_browsing_active(C)) {
+return false;
+  }
+
+  return sfile->bookmarknr != -1;
+}
+
 void FILE_OT_bookmark_move(wmOperatorType *ot)
 {
   static const EnumPropertyItem slot_move[] = {
@@ -1332,8 +1344,7 @@ void FILE_OT_bookmark_move(wmOperatorType *ot)
 
   /* api callbacks */
   ot->exec = bookmark_move_exec;
-  /* Bookmarks are for file browsing only (not asset browsing). */
-  ot->poll = ED_operator_file_browsing_active;
+  ot->poll = file_bookmark_move_poll;
 
   /* flags */
   ot->flag = OPTYPE_REGISTER; /* No undo! */

___
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] [19a13a8b8b8] blender-v3.3-release: Fix T85870: ColorRamp Keyframes crash Blender

2022-11-28 Thread Julian Eisel
Commit: 19a13a8b8b80a458322e7895672658f453e72c4f
Author: Julian Eisel
Date:   Tue Nov 8 12:14:31 2022 +0100
Branches: blender-v3.3-release
https://developer.blender.org/rB19a13a8b8b80a458322e7895672658f453e72c4f

Fix T85870: ColorRamp Keyframes crash Blender

The color-band needs to do some special, rather awkward updating of the
UI state when certain values are changed. As @lichtwerk noted in the
report, this was done to the wrong buttons. Now lookup the proper
buttons, and don't assume that `uiItemR()` only adds a single button
(which often isn't the case).

===

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

===

diff --git a/source/blender/editors/interface/interface_templates.c 
b/source/blender/editors/interface/interface_templates.c
index f051e9004ca..89713a7eabd 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -3673,13 +3673,9 @@ static void colorband_buttons_layout(uiLayout *layout,
 
   row = uiLayoutRow(split, false);
   uiItemR(row, &ptr, "position", 0, IFACE_("Pos"), ICON_NONE);
-  bt = block->buttons.last;
-  UI_but_func_set(bt, colorband_update_cb, bt, coba);
 
   row = uiLayoutRow(layout, false);
   uiItemR(row, &ptr, "color", 0, "", ICON_NONE);
-  bt = block->buttons.last;
-  UI_but_funcN_set(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
 }
 else {
   split = uiLayoutSplit(layout, 0.5f, false);
@@ -3704,13 +3700,28 @@ static void colorband_buttons_layout(uiLayout *layout,
 
   row = uiLayoutRow(subsplit, false);
   uiItemR(row, &ptr, "position", UI_ITEM_R_SLIDER, IFACE_("Pos"), 
ICON_NONE);
-  bt = block->buttons.last;
-  UI_but_func_set(bt, colorband_update_cb, bt, coba);
 
   row = uiLayoutRow(split, false);
   uiItemR(row, &ptr, "color", 0, "", ICON_NONE);
-  bt = block->buttons.last;
-  UI_but_funcN_set(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
+}
+
+/* Some special (rather awkward) treatment to update UI state on certain 
property changes. */
+LISTBASE_FOREACH_BACKWARD (uiBut *, but, &block->buttons) {
+  if (but->rnapoin.data != ptr.data) {
+continue;
+  }
+  if (!but->rnaprop) {
+continue;
+  }
+
+  const char *prop_identifier = RNA_property_identifier(but->rnaprop);
+  if (STREQ(prop_identifier, "position")) {
+UI_but_func_set(but, colorband_update_cb, but, coba);
+  }
+
+  if (STREQ(prop_identifier, "color")) {
+UI_but_funcN_set(but, rna_update_cb, MEM_dupallocN(cb), NULL);
+  }
 }
   }
 }

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


[Bf-blender-cvs] [6810deb5215] blender-v3.3-release: Fix T101062: sculpt curves crash using a paintcurve brush

2022-11-28 Thread Philipp Oeser
Commit: 6810deb5215df3ee7d92d7972988092f1aab5eae
Author: Philipp Oeser
Date:   Thu Sep 29 12:57:48 2022 +0200
Branches: blender-v3.3-release
https://developer.blender.org/rB6810deb5215df3ee7d92d7972988092f1aab5eae

Fix T101062: sculpt curves crash using a paintcurve brush

For one, paintcurves were not considered in curves sculpt mode at all
(so you couldnt draw them). This is now enabled.

And the second issue was that since curves sculpt mode uses the reguar
paint_stroke_modal() [which handles paintcurves], this was actually
excuted, freeing the PaintStroke from SculptCurvesBrushStrokeData (but
not the CurvesSculptStrokeOperation) and immediately return
OPERATOR_FINISHED from modal (resulting in a double MEM_delete of
SculptCurvesBrushStrokeData -- in both invoke and modal).

There might be better ways to handle the memory free, for now the double
freeing is prevented by setting the operator customdata to NULL (and
check for that later).

Maniphest Tasks: T101062

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

===

M   source/blender/editors/sculpt_paint/curves_sculpt_ops.cc
M   source/blender/editors/sculpt_paint/paint_curve.c

===

diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc 
b/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc
index 4ae4149a2a0..7a61a9229e6 100644
--- a/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc
+++ b/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc
@@ -220,8 +220,10 @@ static int sculpt_curves_stroke_invoke(bContext *C, 
wmOperator *op, const wmEven
 
   int return_value = op->type->modal(C, op, event);
   if (return_value == OPERATOR_FINISHED) {
-paint_stroke_free(C, op, op_data->stroke);
-MEM_delete(op_data);
+if (op->customdata != nullptr) {
+  paint_stroke_free(C, op, op_data->stroke);
+  MEM_delete(op_data);
+}
 return OPERATOR_FINISHED;
   }
 
@@ -236,16 +238,19 @@ static int sculpt_curves_stroke_modal(bContext *C, 
wmOperator *op, const wmEvent
   int return_value = paint_stroke_modal(C, op, event, &op_data->stroke);
   if (ELEM(return_value, OPERATOR_FINISHED, OPERATOR_CANCELLED)) {
 MEM_delete(op_data);
+op->customdata = nullptr;
   }
   return return_value;
 }
 
 static void sculpt_curves_stroke_cancel(bContext *C, wmOperator *op)
 {
-  SculptCurvesBrushStrokeData *op_data = 
static_cast(
-  op->customdata);
-  paint_stroke_cancel(C, op, op_data->stroke);
-  MEM_delete(op_data);
+  if (op->customdata != nullptr) {
+SculptCurvesBrushStrokeData *op_data = 
static_cast(
+op->customdata);
+paint_stroke_cancel(C, op, op_data->stroke);
+MEM_delete(op_data);
+  }
 }
 
 static void SCULPT_CURVES_OT_brush_stroke(struct wmOperatorType *ot)
diff --git a/source/blender/editors/sculpt_paint/paint_curve.c 
b/source/blender/editors/sculpt_paint/paint_curve.c
index 22d6626ab16..26f76d46f85 100644
--- a/source/blender/editors/sculpt_paint/paint_curve.c
+++ b/source/blender/editors/sculpt_paint/paint_curve.c
@@ -44,7 +44,7 @@ bool paint_curve_poll(bContext *C)
   RegionView3D *rv3d = CTX_wm_region_view3d(C);
   SpaceImage *sima;
 
-  if (rv3d && !(ob && ((ob->mode & OB_MODE_ALL_PAINT) != 0))) {
+  if (rv3d && !(ob && ((ob->mode & (OB_MODE_ALL_PAINT | 
OB_MODE_SCULPT_CURVES)) != 0))) {
 return false;
   }
 
@@ -676,6 +676,9 @@ static int paintcurve_draw_exec(bContext *C, wmOperator 
*UNUSED(op))
 case PAINT_MODE_SCULPT:
   name = "SCULPT_OT_brush_stroke";
   break;
+case PAINT_MODE_SCULPT_CURVES:
+  name = "SCULPT_CURVES_OT_brush_stroke";
+  break;
 default:
   return OPERATOR_PASS_THROUGH;
   }

___
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] [ee8d32b1d97] blender-v3.3-release: Fix T101669: Cycles artifacts in bump map baking

2022-11-28 Thread Brecht Van Lommel
Commit: ee8d32b1d9714159060d17aa3f6089b981b064ad
Author: Brecht Van Lommel
Date:   Wed Nov 9 19:35:54 2022 +0100
Branches: blender-v3.3-release
https://developer.blender.org/rBee8d32b1d9714159060d17aa3f6089b981b064ad

Fix T101669: Cycles artifacts in bump map baking

After barycentric convention changes, the differentials used for bump mapping
were wrong leading to artifacts with long thin triangles.

===

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

===

diff --git a/intern/cycles/kernel/integrator/init_from_bake.h 
b/intern/cycles/kernel/integrator/init_from_bake.h
index c77fc2540c1..7995f5ebf49 100644
--- a/intern/cycles/kernel/integrator/init_from_bake.h
+++ b/intern/cycles/kernel/integrator/init_from_bake.h
@@ -160,6 +160,13 @@ ccl_device bool integrator_init_from_bake(KernelGlobals kg,
   u = v;
   v = 1.0f - tmp - v;
 
+  const float tmpdx = dudx;
+  const float tmpdy = dudy;
+  dudx = dvdx;
+  dudy = dvdy;
+  dvdx = -tmpdx - dvdx;
+  dvdy = -tmpdy - dvdy;
+
   /* Position and normal on triangle. */
   const int object = kernel_data.bake.object_index;
   float3 P, Ng;

___
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] [7151bb54a4f] soc-2022-many-lights-sampling: Refactor: move visibility test outside of spread angle function

2022-11-28 Thread Weizhen Huang
Commit: 7151bb54a4f629c6354fac07df2471c4db9e3847
Author: Weizhen Huang
Date:   Mon Nov 28 14:06:05 2022 +0100
Branches: soc-2022-many-lights-sampling
https://developer.blender.org/rB7151bb54a4f629c6354fac07df2471c4db9e3847

Refactor: move visibility test outside of spread angle function

===

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

===

diff --git a/intern/cycles/kernel/light/tree.h 
b/intern/cycles/kernel/light/tree.h
index 48225d45554..9b4462387c3 100644
--- a/intern/cycles/kernel/light/tree.h
+++ b/intern/cycles/kernel/light/tree.h
@@ -17,9 +17,7 @@ CCL_NAMESPACE_BEGIN
 ccl_device float light_tree_cos_bounding_box_angle(const float3 bbox_min,
const float3 bbox_max,
const float3 P,
-   const float3 N,
-   const float3 
point_to_centroid,
-   ccl_private bool 
&bbox_is_visible)
+   const float3 
point_to_centroid)
 {
   float cos_theta_u = 1.0f;
   /* Iterate through all 8 possible points of the bounding box. */
@@ -31,9 +29,6 @@ ccl_device float light_tree_cos_bounding_box_angle(const 
float3 bbox_min,
 /* Caculate the bounding box angle. */
 float3 point_to_corner = normalize(corner - P);
 cos_theta_u = fminf(cos_theta_u, dot(point_to_centroid, point_to_corner));
-
-/* Figure out whether or not the bounding box is in front or behind the 
shading point. */
-bbox_is_visible |= dot(point_to_corner, N) > 0;
   }
   return cos_theta_u;
 }
@@ -386,18 +381,6 @@ ccl_device void light_tree_node_importance(KernelGlobals 
kg,
 
   const float3 centroid = 0.5f * (bbox_min + bbox_max);
 
-  point_to_centroid = normalize_len(centroid - P, &distance);
-  bool bbox_is_visible = has_transmission;
-  cos_theta_u = light_tree_cos_bounding_box_angle(
-  bbox_min, bbox_max, P, N_or_D, point_to_centroid, bbox_is_visible);
-
-  /* If the node is guaranteed to be behind the surface we're sampling, 
and the surface is
-   * opaque, then we can give the node an importance of 0 as it 
contributes nothing to the
-   * surface. */
-  if (!bbox_is_visible) {
-return;
-  }
-
   if (in_volume_segment) {
 const float3 D = N_or_D;
 const float3 closest_point = P + dot(centroid - P, D) * D;
@@ -406,7 +389,23 @@ ccl_device void light_tree_node_importance(KernelGlobals 
kg,
 float3 P_v;
 point_to_centroid = -compute_v(centroid, P, D, bcone_axis, t, P_v);
 cos_theta_u = light_tree_cos_bounding_box_angle(
-bbox_min, bbox_max, P_v, D, point_to_centroid, bbox_is_visible);
+bbox_min, bbox_max, P_v, point_to_centroid);
+  }
+  else {
+const float3 N = N_or_D;
+const float3 bbox_extent = bbox_max - centroid;
+const bool bbox_is_visible = has_transmission |
+ (dot(N, centroid - P) + dot(fabs(N), 
fabs(bbox_extent)) > 0);
+
+/* If the node is guaranteed to be behind the surface we're sampling, 
and the surface is
+ * opaque, then we can give the node an importance of 0 as it 
contributes nothing to the
+ * surface. */
+if (!bbox_is_visible) {
+  return;
+}
+
+point_to_centroid = normalize_len(centroid - P, &distance);
+cos_theta_u = light_tree_cos_bounding_box_angle(bbox_min, bbox_max, P, 
point_to_centroid);
   }
   /* clamp distance to half the radius of the cluster when splitting is 
disabled */
   distance = fmaxf(0.5f * len(centroid - bbox_max), distance);

___
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] [1ce158c8297] soc-2022-many-lights-sampling: Cleanup: remove unused variable

2022-11-28 Thread Weizhen Huang
Commit: 1ce158c829756806a64ec829f272908d5342c454
Author: Weizhen Huang
Date:   Mon Nov 28 13:50:53 2022 +0100
Branches: soc-2022-many-lights-sampling
https://developer.blender.org/rB1ce158c829756806a64ec829f272908d5342c454

Cleanup: remove unused variable

===

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

===

diff --git a/intern/cycles/kernel/light/tree.h 
b/intern/cycles/kernel/light/tree.h
index 17c1df99b34..48225d45554 100644
--- a/intern/cycles/kernel/light/tree.h
+++ b/intern/cycles/kernel/light/tree.h
@@ -327,7 +327,6 @@ ccl_device void light_tree_emitter_importance(KernelGlobals 
kg,
 min_distance = len(centroid - closest_point);
 max_distance = min_distance;
 float3 P_v;
-float t_v;
 point_to_centroid = -compute_v(centroid, P, D, bcone_axis, t, P_v);
   }
 
@@ -405,7 +404,6 @@ ccl_device void light_tree_node_importance(KernelGlobals kg,
 /* minimal distance of the ray to the cluster */
 distance = len(centroid - closest_point);
 float3 P_v;
-float t_v;
 point_to_centroid = -compute_v(centroid, P, D, bcone_axis, t, P_v);
 cos_theta_u = light_tree_cos_bounding_box_angle(
 bbox_min, bbox_max, P_v, D, point_to_centroid, bbox_is_visible);

___
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


  1   2   >