[Bf-blender-cvs] [86464cfcef2] master: Fix error converting UV's to MLoopUV

2023-01-10 Thread Campbell Barton
Commit: 86464cfcef2c982ae532b47553207be13f3d3815
Author: Campbell Barton
Date:   Wed Jan 11 13:57:51 2023 +1100
Branches: master
https://developer.blender.org/rB86464cfcef2c982ae532b47553207be13f3d3815

Fix error converting UV's to MLoopUV

Logic to skip UV layers that are part of the MLoopUV treated all
loop-layers as UV's, causing duplicate and invalid names to be added
to be added to 'uv_sublayers_to_skip', this asserted in debug mode
when saving the `ellie_animation.blend` demo blend file.

===

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

===

diff --git a/source/blender/blenkernel/intern/mesh_legacy_convert.cc 
b/source/blender/blenkernel/intern/mesh_legacy_convert.cc
index 2fea74176f9..07fe17794ff 100644
--- a/source/blender/blenkernel/intern/mesh_legacy_convert.cc
+++ b/source/blender/blenkernel/intern/mesh_legacy_convert.cc
@@ -1532,13 +1532,16 @@ void BKE_mesh_legacy_convert_uvs_to_struct(
   char edge_name[MAX_CUSTOMDATA_LAYER_NAME];
   char pin_name[MAX_CUSTOMDATA_LAYER_NAME];
   for (const CustomDataLayer  : loop_layers_to_write) {
-
uv_sublayers_to_skip.add_multiple_new({BKE_uv_map_vert_select_name_get(layer.name,
 vert_name),
-   
BKE_uv_map_edge_select_name_get(layer.name, edge_name),
-   BKE_uv_map_pin_name_get(layer.name, 
pin_name)});
+if (layer.type == CD_PROP_FLOAT2) {
+  uv_sublayers_to_skip.add_multiple_new(
+  {BKE_uv_map_vert_select_name_get(layer.name, vert_name),
+   BKE_uv_map_edge_select_name_get(layer.name, edge_name),
+   BKE_uv_map_pin_name_get(layer.name, pin_name)});
+}
   }
 
   for (const CustomDataLayer  : loop_layers_to_write) {
-if (uv_sublayers_to_skip.contains_as(layer.name)) {
+if (layer.name[0] && uv_sublayers_to_skip.contains_as(layer.name)) {
   continue;
 }
 if (layer.type != CD_PROP_FLOAT2) {

___
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] [28d38e876ff] master: Cleanup: rename face_corners to loop for internal layer operations

2023-01-10 Thread Campbell Barton
Commit: 28d38e876fff564be10b341a5d0f81c13d24f7ed
Author: Campbell Barton
Date:   Wed Jan 11 13:53:22 2023 +1100
Branches: master
https://developer.blender.org/rB28d38e876fff564be10b341a5d0f81c13d24f7ed

Cleanup: rename face_corners to loop for internal layer operations

Follows naming used elsewhere.

===

M   source/blender/blenkernel/BKE_mesh_legacy_convert.h
M   source/blender/blenkernel/intern/mesh_legacy_convert.cc

===

diff --git a/source/blender/blenkernel/BKE_mesh_legacy_convert.h 
b/source/blender/blenkernel/BKE_mesh_legacy_convert.h
index d6689da7d86..5b72d85a433 100644
--- a/source/blender/blenkernel/BKE_mesh_legacy_convert.h
+++ b/source/blender/blenkernel/BKE_mesh_legacy_convert.h
@@ -26,9 +26,10 @@ struct MFace;
 
 #ifdef __cplusplus
 
-void BKE_mesh_legacy_convert_uvs_to_struct(Mesh *mesh,
-   blender::ResourceScope 
_mloopuv_for_convert,
-   blender::Vector _to_write);
+void BKE_mesh_legacy_convert_uvs_to_struct(
+Mesh *mesh,
+blender::ResourceScope _mloopuv_for_convert,
+blender::Vector _layers_to_write);
 void BKE_mesh_legacy_convert_uvs_to_generic(Mesh *mesh);
 
 /**
diff --git a/source/blender/blenkernel/intern/mesh_legacy_convert.cc 
b/source/blender/blenkernel/intern/mesh_legacy_convert.cc
index 1ad70792a22..2fea74176f9 100644
--- a/source/blender/blenkernel/intern/mesh_legacy_convert.cc
+++ b/source/blender/blenkernel/intern/mesh_legacy_convert.cc
@@ -1519,7 +1519,7 @@ void 
BKE_mesh_legacy_convert_mpoly_to_material_indices(Mesh *mesh)
 void BKE_mesh_legacy_convert_uvs_to_struct(
 Mesh *mesh,
 blender::ResourceScope _mloopuv_for_convert,
-blender::Vector _corner_layers_to_write)
+blender::Vector _layers_to_write)
 {
   using namespace blender;
   using namespace blender::bke;
@@ -1531,13 +1531,13 @@ void BKE_mesh_legacy_convert_uvs_to_struct(
   char vert_name[MAX_CUSTOMDATA_LAYER_NAME];
   char edge_name[MAX_CUSTOMDATA_LAYER_NAME];
   char pin_name[MAX_CUSTOMDATA_LAYER_NAME];
-  for (const CustomDataLayer  : face_corner_layers_to_write) {
+  for (const CustomDataLayer  : loop_layers_to_write) {
 
uv_sublayers_to_skip.add_multiple_new({BKE_uv_map_vert_select_name_get(layer.name,
 vert_name),

BKE_uv_map_edge_select_name_get(layer.name, edge_name),
BKE_uv_map_pin_name_get(layer.name, 
pin_name)});
   }
 
-  for (const CustomDataLayer  : face_corner_layers_to_write) {
+  for (const CustomDataLayer  : loop_layers_to_write) {
 if (uv_sublayers_to_skip.contains_as(layer.name)) {
   continue;
 }
@@ -1571,7 +1571,7 @@ void BKE_mesh_legacy_convert_uvs_to_struct(
 new_layer_to_write.append(mloopuv_layer);
   }
 
-  face_corner_layers_to_write = new_layer_to_write;
+  loop_layers_to_write = new_layer_to_write;
   mesh->ldata.totlayer = new_layer_to_write.size();
   mesh->ldata.maxlayer = mesh->ldata.totlayer;
 }

___
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] [bd7a1d5de60] master: Docs: improve doc-string for UI_BUT_HAS_SEP_CHAR & UI_SEP_CHAR

2023-01-10 Thread Campbell Barton
Commit: bd7a1d5de60956e726f73e9a2fcf44547b2211ca
Author: Campbell Barton
Date:   Wed Jan 11 13:39:13 2023 +1100
Branches: master
https://developer.blender.org/rBbd7a1d5de60956e726f73e9a2fcf44547b2211ca

Docs: improve doc-string for UI_BUT_HAS_SEP_CHAR & UI_SEP_CHAR

===

M   source/blender/editors/include/UI_interface.h

===

diff --git a/source/blender/editors/include/UI_interface.h 
b/source/blender/editors/include/UI_interface.h
index 415356d1d71..cd729a330ca 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -79,7 +79,11 @@ typedef struct uiViewItemHandle uiViewItemHandle;
 
 /* Defines */
 
-/* char for splitting strings, aligning shortcuts in menus, users never see */
+/**
+ * Character used for splitting labels (right align text after this character).
+ * Users should never see this character.
+ * Only applied when #UI_BUT_HAS_SEP_CHAR flag is enabled, see it's doc-string 
for details.
+ */
 #define UI_SEP_CHAR '|'
 #define UI_SEP_CHAR_S "|"
 
@@ -220,7 +224,12 @@ enum {
   /** Use for popups to start editing the button on initialization. */
   UI_BUT_ACTIVATE_ON_INIT = 1 << 26,
 
-  /** #uiBut.str contains #UI_SEP_CHAR, used for key shortcuts */
+  /**
+   * #uiBut.str contains #UI_SEP_CHAR, used to show key-shortcuts right 
aligned.
+   *
+   * Since a label may contain #UI_SEP_CHAR, it's important to split on the 
last occurrence
+   * (meaning the right aligned text can't contain this character).
+   */
   UI_BUT_HAS_SEP_CHAR = 1 << 27,
   /** Don't run updates while dragging (needed in rare cases). */
   UI_BUT_UPDATE_DELAY = 1 << 28,

___
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] [32812c2cc2a] master: Cleanup: Remove redundant mesh data mask handling

2023-01-10 Thread Hans Goudey
Commit: 32812c2cc2a70bee018d205586e70154faeccbf7
Author: Hans Goudey
Date:   Tue Jan 10 20:07:47 2023 -0500
Branches: master
https://developer.blender.org/rB32812c2cc2a70bee018d205586e70154faeccbf7

Cleanup: Remove redundant mesh data mask handling

Byte colors are generic attributes and are therefore included in
CD_MASK_PROP_ALL. Also clarify the use of vertex groups.
They always have to be propagated since they're displayed in
the spreadsheet, etc.

===

M   source/blender/blenkernel/intern/mesh.cc
M   source/blender/blenkernel/intern/object_update.cc

===

diff --git a/source/blender/blenkernel/intern/mesh.cc 
b/source/blender/blenkernel/intern/mesh.cc
index f67cf7e0646..47832e669ed 100644
--- a/source/blender/blenkernel/intern/mesh.cc
+++ b/source/blender/blenkernel/intern/mesh.cc
@@ -517,8 +517,7 @@ static int customdata_compare(
 {
   CustomDataLayer *l1, *l2;
   int layer_count1 = 0, layer_count2 = 0, j;
-  const uint64_t cd_mask_non_generic = CD_MASK_MEDGE | CD_MASK_MPOLY | 
CD_MASK_PROP_BYTE_COLOR |
-   CD_MASK_MDEFORMVERT;
+  const uint64_t cd_mask_non_generic = CD_MASK_MEDGE | CD_MASK_MPOLY | 
CD_MASK_MDEFORMVERT;
   const uint64_t cd_mask_all_attr = CD_MASK_PROP_ALL | cd_mask_non_generic;
   const Span loops_1 = m1->loops();
   const Span loops_2 = m2->loops();
diff --git a/source/blender/blenkernel/intern/object_update.cc 
b/source/blender/blenkernel/intern/object_update.cc
index a7da1bfb5d2..5abd5188d1e 100644
--- a/source/blender/blenkernel/intern/object_update.cc
+++ b/source/blender/blenkernel/intern/object_update.cc
@@ -141,9 +141,9 @@ void BKE_object_handle_data_update(Depsgraph *depsgraph, 
Scene *scene, Object *o
   CustomData_MeshMasks cddata_masks = scene->customdata_mask;
   CustomData_MeshMasks_update(_masks, _MASK_BAREMESH);
   /* Custom attributes should not be removed automatically. They might be 
used by the render
-   * engine or scripts. They can still be removed explicitly using 
geometry nodes.
-   * Crease can be used in generic situations with geometry nodes as well. 
*/
-  cddata_masks.vmask |= CD_MASK_PROP_ALL | CD_MASK_CREASE;
+   * engine or scripts. They can still be removed explicitly using 
geometry nodes. Crease and
+   * vertex groups can be used in arbitrary situations with geometry nodes 
as well. */
+  cddata_masks.vmask |= CD_MASK_PROP_ALL | CD_MASK_CREASE | 
CD_MASK_MDEFORMVERT;
   cddata_masks.emask |= CD_MASK_PROP_ALL | CD_MASK_CREASE;
   cddata_masks.fmask |= CD_MASK_PROP_ALL;
   cddata_masks.pmask |= CD_MASK_PROP_ALL;
@@ -154,12 +154,10 @@ void BKE_object_handle_data_update(Depsgraph *depsgraph, 
Scene *scene, Object *o
 #ifdef WITH_FREESTYLE
   cddata_masks.emask |= CD_MASK_FREESTYLE_EDGE;
   cddata_masks.pmask |= CD_MASK_FREESTYLE_FACE;
-  cddata_masks.vmask |= CD_MASK_MDEFORMVERT;
 #endif
   if (DEG_get_mode(depsgraph) == DAG_EVAL_RENDER) {
 /* Always compute UVs, vertex colors as orcos for render. */
-cddata_masks.lmask |= CD_MASK_PROP_FLOAT2 | CD_MASK_PROP_BYTE_COLOR;
-cddata_masks.vmask |= CD_MASK_ORCO | CD_MASK_PROP_COLOR;
+cddata_masks.vmask |= CD_MASK_ORCO;
   }
   makeDerivedMesh(depsgraph, scene, ob, _masks); /* was 
CD_MASK_BAREMESH */
   break;

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


[Bf-blender-cvs] [12a26b8fe39] master: Cleanup: format

2023-01-10 Thread Campbell Barton
Commit: 12a26b8fe392d8801794e9873f47bcecdb624328
Author: Campbell Barton
Date:   Wed Jan 11 13:03:49 2023 +1100
Branches: master
https://developer.blender.org/rB12a26b8fe392d8801794e9873f47bcecdb624328

Cleanup: format

===

M   release/scripts/startup/bl_ui/space_view3d.py
M   source/blender/editors/space_node/add_menu_assets.cc
M   
source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
M   source/blender/io/usd/intern/usd_writer_mesh.cc

===

diff --git a/release/scripts/startup/bl_ui/space_view3d.py 
b/release/scripts/startup/bl_ui/space_view3d.py
index 0af3325ae2c..bb11ed80ac2 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -2702,10 +2702,9 @@ class VIEW3D_MT_object_context_menu(Menu):
 if obj.type == 'GPENCIL':
 layout.operator_menu_enum("gpencil.convert", "type", 
text="Convert To")
 
-if (
-obj.type in {'MESH', 'CURVE', 'CURVES', 'SURFACE', 
'GPENCIL', 'LATTICE', 'ARMATURE', 'META', 'FONT', 'POINTCLOUD'} or
-(obj.type == 'EMPTY' and obj.instance_collection is not 
None)
-):
+if (obj.type in {
+'MESH', 'CURVE', 'CURVES', 'SURFACE', 'GPENCIL', 'LATTICE', 
'ARMATURE', 'META', 'FONT', 'POINTCLOUD',
+} or (obj.type == 'EMPTY' and obj.instance_collection is not 
None)):
 layout.operator_context = 'INVOKE_REGION_WIN'
 layout.operator_menu_enum("object.origin_set", text="Set 
Origin", property="type")
 layout.operator_context = 'INVOKE_DEFAULT'
diff --git a/source/blender/editors/space_node/add_menu_assets.cc 
b/source/blender/editors/space_node/add_menu_assets.cc
index fc250b63ffe..912493c3e7e 100644
--- a/source/blender/editors/space_node/add_menu_assets.cc
+++ b/source/blender/editors/space_node/add_menu_assets.cc
@@ -87,7 +87,8 @@ static AssetItemTree build_catalog_tree(const bContext , 
const bNodeTree *node
   ED_assetlist_storage_fetch(_library_ref, );
   ED_assetlist_ensure_previews_job(_library_ref, );
 
-  asset_system::AssetLibrary *all_library = 
ED_assetlist_library_get_once_available(all_library_ref);
+  asset_system::AssetLibrary *all_library = 
ED_assetlist_library_get_once_available(
+  all_library_ref);
   if (!all_library) {
 return {};
   }
diff --git 
a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp 
b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
index a04e9584005..40f49b458f4 100644
--- 
a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
+++ 
b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
@@ -44,8 +44,8 @@
 #include "BLI_ghash.h"
 #include "BLI_listbase.h"
 #include "BLI_math_color.h"
-#include "BLI_math_vector_types.hh"
 #include "BLI_math_vector.h"
+#include "BLI_math_vector_types.hh"
 #include "BLI_utildefines.h"
 
 #include "DEG_depsgraph.h"
diff --git a/source/blender/io/usd/intern/usd_writer_mesh.cc 
b/source/blender/io/usd/intern/usd_writer_mesh.cc
index 237e1414eaf..45fa0d48d80 100644
--- a/source/blender/io/usd/intern/usd_writer_mesh.cc
+++ b/source/blender/io/usd/intern/usd_writer_mesh.cc
@@ -9,8 +9,8 @@
 #include 
 
 #include "BLI_assert.h"
-#include "BLI_math_vector_types.hh"
 #include "BLI_math_vector.h"
+#include "BLI_math_vector_types.hh"
 
 #include "BKE_attribute.h"
 #include "BKE_attribute.hh"

___
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] [494c3ba063d] master: Cleanup: quiet warning mixing enum/int & replace NULL with nullptr

2023-01-10 Thread Campbell Barton
Commit: 494c3ba063d89781b085291ccebb5741bdb90ab7
Author: Campbell Barton
Date:   Wed Jan 11 13:03:51 2023 +1100
Branches: master
https://developer.blender.org/rB494c3ba063d89781b085291ccebb5741bdb90ab7

Cleanup: quiet warning mixing enum/int & replace NULL with nullptr

===

M   source/blender/editors/space_file/filesel.cc
M   source/blender/makesrna/intern/rna_gpencil_modifier.c

===

diff --git a/source/blender/editors/space_file/filesel.cc 
b/source/blender/editors/space_file/filesel.cc
index 32181a9f5f6..446e5434edf 100644
--- a/source/blender/editors/space_file/filesel.cc
+++ b/source/blender/editors/space_file/filesel.cc
@@ -94,7 +94,7 @@ static void fileselect_initialize_params_common(SpaceFile 
*sfile, FileSelectPara
 static void fileselect_ensure_updated_asset_params(SpaceFile *sfile)
 {
   BLI_assert(sfile->browse_mode == FILE_BROWSE_MODE_ASSETS);
-  BLI_assert(sfile->op == NULL);
+  BLI_assert(sfile->op == nullptr);
 
   FileAssetSelectParams *asset_params = sfile->asset_params;
 
@@ -158,11 +158,11 @@ static FileSelectParams 
*fileselect_ensure_updated_file_params(SpaceFile *sfile)
   /* set the parameters from the operator, if it exists */
   if (op) {
 PropertyRNA *prop;
-const bool is_files = (RNA_struct_find_property(op->ptr, "files") != NULL);
-const bool is_filepath = (RNA_struct_find_property(op->ptr, "filepath") != 
NULL);
-const bool is_filename = (RNA_struct_find_property(op->ptr, "filename") != 
NULL);
-const bool is_directory = (RNA_struct_find_property(op->ptr, "directory") 
!= NULL);
-const bool is_relative_path = (RNA_struct_find_property(op->ptr, 
"relative_path") != NULL);
+const bool is_files = (RNA_struct_find_property(op->ptr, "files") != 
nullptr);
+const bool is_filepath = (RNA_struct_find_property(op->ptr, "filepath") != 
nullptr);
+const bool is_filename = (RNA_struct_find_property(op->ptr, "filename") != 
nullptr);
+const bool is_directory = (RNA_struct_find_property(op->ptr, "directory") 
!= nullptr);
+const bool is_relative_path = (RNA_struct_find_property(op->ptr, 
"relative_path") != nullptr);
 
 BLI_strncpy_utf8(
 params->title, WM_operatortype_name(op->type, op->ptr), 
sizeof(params->title));
@@ -208,68 +208,69 @@ static FileSelectParams 
*fileselect_ensure_updated_file_params(SpaceFile *sfile)
   params->flag |= FILE_DIRSEL_ONLY;
 }
 if ((prop = RNA_struct_find_property(op->ptr, "check_existing"))) {
-  params->flag |= RNA_property_boolean_get(op->ptr, prop) ? 
FILE_CHECK_EXISTING : 0;
+  params->flag |= RNA_property_boolean_get(op->ptr, prop) ? 
int(FILE_CHECK_EXISTING) : 0;
 }
 if ((prop = RNA_struct_find_property(op->ptr, "hide_props_region"))) {
-  params->flag |= RNA_property_boolean_get(op->ptr, prop) ? 
FILE_HIDE_TOOL_PROPS : 0;
+  params->flag |= RNA_property_boolean_get(op->ptr, prop) ? 
int(FILE_HIDE_TOOL_PROPS) : 0;
 }
 
 params->filter = 0;
 if ((prop = RNA_struct_find_property(op->ptr, "filter_blender"))) {
-  params->filter |= RNA_property_boolean_get(op->ptr, prop) ? 
FILE_TYPE_BLENDER : 0;
+  params->filter |= RNA_property_boolean_get(op->ptr, prop) ? 
int(FILE_TYPE_BLENDER) : 0;
 }
 if ((prop = RNA_struct_find_property(op->ptr, "filter_blenlib"))) {
-  params->filter |= RNA_property_boolean_get(op->ptr, prop) ? 
FILE_TYPE_BLENDERLIB : 0;
+  params->filter |= RNA_property_boolean_get(op->ptr, prop) ? 
int(FILE_TYPE_BLENDERLIB) : 0;
 }
 if ((prop = RNA_struct_find_property(op->ptr, "filter_backup"))) {
-  params->filter |= RNA_property_boolean_get(op->ptr, prop) ? 
FILE_TYPE_BLENDER_BACKUP : 0;
+  params->filter |= RNA_property_boolean_get(op->ptr, prop) ? 
int(FILE_TYPE_BLENDER_BACKUP) :
+  0;
 }
 if ((prop = RNA_struct_find_property(op->ptr, "filter_image"))) {
-  params->filter |= RNA_property_boolean_get(op->ptr, prop) ? 
FILE_TYPE_IMAGE : 0;
+  params->filter |= RNA_property_boolean_get(op->ptr, prop) ? 
int(FILE_TYPE_IMAGE) : 0;
 }
 if ((prop = RNA_struct_find_property(op->ptr, "filter_movie"))) {
-  params->filter |= RNA_property_boolean_get(op->ptr, prop) ? 
FILE_TYPE_MOVIE : 0;
+  params->filter |= RNA_property_boolean_get(op->ptr, prop) ? 
int(FILE_TYPE_MOVIE) : 0;
 }
 if ((prop = RNA_struct_find_property(op->ptr, "filter_python"))) {
-  params->filter |= RNA_property_boolean_get(op->ptr, prop) ? 
FILE_TYPE_PYSCRIPT : 0;
+  params->filter |= RNA_property_boolean_get(op->ptr, prop) ? 
int(FILE_TYPE_PYSCRIPT) : 0;
 }
 if ((prop = RNA_struct_find_property(op->ptr, "filter_font"))) {
-  params->filter |= RNA_property_boolean_get(op->ptr, prop) ? 
FILE_TYPE_FTFONT : 0;
+  params->filter |= RNA_property_boolean_get(op->ptr, prop) ? 

[Bf-blender-cvs] [8367f2bffc5] master: Cleanup: function style casts for C++

2023-01-10 Thread Campbell Barton
Commit: 8367f2bffc58a8f591ed2e6d67f6dd625dc5041c
Author: Campbell Barton
Date:   Wed Jan 11 13:03:53 2023 +1100
Branches: master
https://developer.blender.org/rB8367f2bffc58a8f591ed2e6d67f6dd625dc5041c

Cleanup: function style casts for C++

===

M   source/blender/blenkernel/intern/customdata.cc
M   source/blender/blenkernel/intern/modifier.cc
M   source/blender/blenkernel/intern/particle.cc
M   source/blender/blenlib/intern/math_boolean.cc
M   
source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_stretch_angle.cc
M   source/blender/editors/mesh/editmesh_select.cc
M   source/blender/editors/mesh/editmesh_undo.cc
M   source/blender/editors/render/render_shading.cc
M   source/blender/editors/space_file/filesel.cc
M   source/blender/render/intern/multires_bake.cc

===

diff --git a/source/blender/blenkernel/intern/customdata.cc 
b/source/blender/blenkernel/intern/customdata.cc
index 433c4355d97..1d970d35148 100644
--- a/source/blender/blenkernel/intern/customdata.cc
+++ b/source/blender/blenkernel/intern/customdata.cc
@@ -5249,7 +5249,7 @@ void CustomData_debug_info_from_layers(const CustomData 
*data, const char *inden
   const char *name = CustomData_layertype_name(type);
   const int size = CustomData_sizeof(type);
   const void *pt = CustomData_get_layer(data, type);
-  const int pt_size = pt ? (int)(MEM_allocN_len(pt) / size) : 0;
+  const int pt_size = pt ? int(MEM_allocN_len(pt) / size) : 0;
   const char *structname;
   int structnum;
   CustomData_file_write_info(type, , );
diff --git a/source/blender/blenkernel/intern/modifier.cc 
b/source/blender/blenkernel/intern/modifier.cc
index 50c9c13a9ac..508c1fe2331 100644
--- a/source/blender/blenkernel/intern/modifier.cc
+++ b/source/blender/blenkernel/intern/modifier.cc
@@ -349,7 +349,7 @@ void BKE_modifier_copydata_generic(const ModifierData 
*md_src,
   const size_t data_size = sizeof(ModifierData);
   const char *md_src_data = ((const char *)md_src) + data_size;
   char *md_dst_data = ((char *)md_dst) + data_size;
-  BLI_assert(data_size <= (size_t)mti->structSize);
+  BLI_assert(data_size <= size_t(mti->structSize));
   memcpy(md_dst_data, md_src_data, size_t(mti->structSize) - data_size);
 
   /* Runtime fields are never to be preserved. */
diff --git a/source/blender/blenkernel/intern/particle.cc 
b/source/blender/blenkernel/intern/particle.cc
index 5e3b393ce6b..484cb343a97 100644
--- a/source/blender/blenkernel/intern/particle.cc
+++ b/source/blender/blenkernel/intern/particle.cc
@@ -521,8 +521,8 @@ void BKE_particle_init_rng(void)
   RNG *rng = BLI_rng_new_srandom(5831); /* arbitrary */
   for (int i = 0; i < PSYS_FRAND_COUNT; i++) {
 PSYS_FRAND_BASE[i] = BLI_rng_get_float(rng);
-PSYS_FRAND_SEED_OFFSET[i] = (uint)BLI_rng_get_int(rng);
-PSYS_FRAND_SEED_MULTIPLIER[i] = (uint)BLI_rng_get_int(rng);
+PSYS_FRAND_SEED_OFFSET[i] = uint(BLI_rng_get_int(rng));
+PSYS_FRAND_SEED_MULTIPLIER[i] = uint(BLI_rng_get_int(rng));
   }
   BLI_rng_free(rng);
 }
diff --git a/source/blender/blenlib/intern/math_boolean.cc 
b/source/blender/blenlib/intern/math_boolean.cc
index 977b4ca5365..689c23ce092 100644
--- a/source/blender/blenlib/intern/math_boolean.cc
+++ b/source/blender/blenlib/intern/math_boolean.cc
@@ -201,7 +201,7 @@ static RobustInitCaller init_caller;
   y = bvirt - b
 
 #define Fast_Two_Diff(a, b, x, y) \
-  x = (double)(a - b); \
+  x = double(a - b); \
   Fast_Two_Diff_Tail(a, b, x, y)
 
 #define Two_Sum_Tail(a, b, x, y) \
@@ -253,7 +253,7 @@ static RobustInitCaller init_caller;
   y = (alo * blo) - err3
 
 #define Two_Product_2Presplit(a, ahi, alo, b, bhi, blo, x, y) \
-  x = (double)(a * b); \
+  x = double(a * b); \
   err1 = x - (ahi * bhi); \
   err2 = err1 - (alo * bhi); \
   err3 = err2 - (ahi * blo); \
diff --git 
a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_stretch_angle.cc
 
b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_stretch_angle.cc
index a7b0331769c..b295a314883 100644
--- 
a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_stretch_angle.cc
+++ 
b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_stretch_angle.cc
@@ -70,7 +70,7 @@ static void edituv_get_edituv_stretch_angle(float auv[2][2],
 #if 0 /* here for reference, this is done in shader now. */
   float uvang = angle_normalized_v2v2(auv0, auv1);
   float ang = angle_normalized_v3v3(av0, av1);
-  float stretch = fabsf(uvang - ang) / (float)M_PI;
+  float stretch = fabsf(uvang - ang) / float(M_PI);
   return 1.0f - pow2f(1.0f - stretch);
 #endif
 }
diff --git a/source/blender/editors/mesh/editmesh_select.cc 
b/source/blender/editors/mesh/editmesh_select.cc
index 6955db63fe8..b911da376b4 100644
--- a/source/blender/editors/mesh/editmesh_select.cc
+++ 

[Bf-blender-cvs] [9f283bee7ec] master: BLI_string_ref: avoid passing null to strncmp (quiet ASAN warning)

2023-01-10 Thread Campbell Barton
Commit: 9f283bee7ecfedabc7a6b46fb9f2cece6b3e31ec
Author: Campbell Barton
Date:   Wed Jan 11 13:03:48 2023 +1100
Branches: master
https://developer.blender.org/rB9f283bee7ecfedabc7a6b46fb9f2cece6b3e31ec

BLI_string_ref: avoid passing null to strncmp (quiet ASAN warning)

The existing logic to avoid passing null only worked when both
strings were null.

===

M   source/blender/blenlib/BLI_string_ref.hh

===

diff --git a/source/blender/blenlib/BLI_string_ref.hh 
b/source/blender/blenlib/BLI_string_ref.hh
index 14dee54d730..6ad4d6fd3af 100644
--- a/source/blender/blenlib/BLI_string_ref.hh
+++ b/source/blender/blenlib/BLI_string_ref.hh
@@ -608,9 +608,14 @@ constexpr bool operator==(StringRef a, StringRef b)
 return false;
   }
   if (a.data() == b.data()) {
-/* This also avoids passing null to the call below, which would results in 
an ASAN warning. */
+/* This also avoids passing null to the call below when both are null,
+ * which would results in an ASAN warning. */
 return true;
   }
+  if (!a.data() || !b.data()) {
+/* Account for a single value being null, resulting in an ASAN warning. */
+return false;
+  }
   return STREQLEN(a.data(), b.data(), size_t(a.size()));
 }

___
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] [bd9602036a1] master: Fix pose-slide failing with array custom properties

2023-01-10 Thread Campbell Barton
Commit: bd9602036a182df778228a838c67feaf3e9299c4
Author: Campbell Barton
Date:   Wed Jan 11 13:03:46 2023 +1100
Branches: master
https://developer.blender.org/rBbd9602036a182df778228a838c67feaf3e9299c4

Fix pose-slide failing with array custom properties

Pose slide would attempt to use non-array functions to get/set RNA
array properties. Asserting in debug mode.

===

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

===

diff --git a/source/blender/editors/armature/pose_slide.c 
b/source/blender/editors/armature/pose_slide.c
index e2610628f97..86675a1bef2 100644
--- a/source/blender/editors/armature/pose_slide.c
+++ b/source/blender/editors/armature/pose_slide.c
@@ -521,24 +521,75 @@ static void pose_slide_apply_props(tPoseSlideOp *pso,
 switch (RNA_property_type(prop)) {
   /* Continuous values that can be smoothly interpolated. */
   case PROP_FLOAT: {
-float tval = RNA_property_float_get(, prop);
+const bool is_array = RNA_property_array_check(prop);
+float tval;
+if (is_array) {
+  if (UNLIKELY((uint)fcu->array_index >= 
RNA_property_array_length(, prop))) {
+break; /* Out of range, skip. */
+  }
+  tval = RNA_property_float_get_index(, prop, 
fcu->array_index);
+}
+else {
+  tval = RNA_property_float_get(, prop);
+}
+
 pose_slide_apply_val(pso, fcu, pfl->ob, );
-RNA_property_float_set(, prop, tval);
+
+if (is_array) {
+  RNA_property_float_set_index(, prop, fcu->array_index, tval);
+}
+else {
+  RNA_property_float_set(, prop, tval);
+}
 break;
   }
   case PROP_INT: {
-float tval = (float)RNA_property_int_get(, prop);
+const bool is_array = RNA_property_array_check(prop);
+float tval;
+if (is_array) {
+  if (UNLIKELY((uint)fcu->array_index >= 
RNA_property_array_length(, prop))) {
+break; /* Out of range, skip. */
+  }
+  tval = RNA_property_int_get_index(, prop, fcu->array_index);
+}
+else {
+  tval = RNA_property_int_get(, prop);
+}
+
 pose_slide_apply_val(pso, fcu, pfl->ob, );
-RNA_property_int_set(, prop, (int)tval);
+
+if (is_array) {
+  RNA_property_int_set_index(, prop, fcu->array_index, tval);
+}
+else {
+  RNA_property_int_set(, prop, tval);
+}
 break;
   }
 
   /* Values which can only take discrete values. */
   case PROP_BOOLEAN: {
-float tval = (float)RNA_property_boolean_get(, prop);
+const bool is_array = RNA_property_array_check(prop);
+float tval;
+if (is_array) {
+  if (UNLIKELY((uint)fcu->array_index >= 
RNA_property_array_length(, prop))) {
+break; /* Out of range, skip. */
+  }
+  tval = RNA_property_boolean_get_index(, prop, 
fcu->array_index);
+}
+else {
+  tval = RNA_property_boolean_get(, prop);
+}
+
 pose_slide_apply_val(pso, fcu, pfl->ob, );
-RNA_property_boolean_set(
-, prop, (int)tval); /* XXX: do we need threshold clamping 
here? */
+
+/* XXX: do we need threshold clamping here? */
+if (is_array) {
+  RNA_property_boolean_set_index(, prop, fcu->array_index, 
tval);
+}
+else {
+  RNA_property_boolean_set(, prop, tval);
+}
 break;
   }
   case PROP_ENUM: {

___
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] [50d6af1e0e8] master: Fix invalid string comparison

2023-01-10 Thread Campbell Barton
Commit: 50d6af1e0e8f98a2dd0ba6245026c18da7b3cedb
Author: Campbell Barton
Date:   Wed Jan 11 13:03:44 2023 +1100
Branches: master
https://developer.blender.org/rB50d6af1e0e8f98a2dd0ba6245026c18da7b3cedb

Fix invalid string comparison

Error from recent addition: 250eda36b8f91a2f89b202d5eb79108260e1b1e3.
Compare the enum value instead.

===

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

===

diff --git a/source/blender/makesrna/intern/rna_gpencil_modifier.c 
b/source/blender/makesrna/intern/rna_gpencil_modifier.c
index 46d8b7f8f3c..bfb13f26136 100644
--- a/source/blender/makesrna/intern/rna_gpencil_modifier.c
+++ b/source/blender/makesrna/intern/rna_gpencil_modifier.c
@@ -959,7 +959,7 @@ const EnumPropertyItem 
*gpencil_build_time_mode_filter(bContext *UNUSED(C),
 
   for (const EnumPropertyItem *item = gpencil_build_time_mode_items; 
item->identifier != NULL;
item++) {
-if (is_concurrent && item->identifier == "DRAWSPEED") {
+if (is_concurrent && (item->value == GP_BUILD_TIMEMODE_DRAWSPEED)) {
   continue;
 }
 RNA_enum_item_add(_list, , item);

___
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] [ea2db47a0bb] temp-nodes-group-declarations: Use null for root tree for node tree change propagation

2023-01-10 Thread Hans Goudey
Commit: ea2db47a0bbd07fa24e2b06307123bb4dc2c71ce
Author: Hans Goudey
Date:   Tue Jan 10 16:49:57 2023 -0500
Branches: temp-nodes-group-declarations
https://developer.blender.org/rBea2db47a0bbd07fa24e2b06307123bb4dc2c71ce

Use null for root tree for node tree change propagation

===

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

===

diff --git a/source/blender/editors/space_node/node_group.cc 
b/source/blender/editors/space_node/node_group.cc
index 62e642c5f43..ca0361e82dc 100644
--- a/source/blender/editors/space_node/node_group.cc
+++ b/source/blender/editors/space_node/node_group.cc
@@ -1010,7 +1010,7 @@ static void node_group_make_insert_selected(const 
bContext ,
 info.link->fromsock = node_group_find_output_socket(gnode, 
info.interface_socket->identifier);
   }
 
-  ED_node_tree_propagate_change(, bmain, );
+  ED_node_tree_propagate_change(, bmain, nullptr);
 }
 
 static bNode *node_group_make_from_nodes(const bContext ,

___
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] [eaa17cfae25] temp-nodes-group-declarations: Merge branch 'master' into temp-nodes-group-declarations

2023-01-10 Thread Hans Goudey
Commit: eaa17cfae25d5e77b81c44940788623cfb38c5e5
Author: Hans Goudey
Date:   Tue Jan 10 16:41:44 2023 -0500
Branches: temp-nodes-group-declarations
https://developer.blender.org/rBeaa17cfae25d5e77b81c44940788623cfb38c5e5

Merge branch 'master' into temp-nodes-group-declarations

===



===



___
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] [79e600f75e0] refactor-mesh-sharp-face-generic: Cleanup: Rename functions

2023-01-10 Thread Hans Goudey
Commit: 79e600f75e06971682c5e7bd7444a07d3718e7c0
Author: Hans Goudey
Date:   Tue Jan 10 16:35:15 2023 -0500
Branches: refactor-mesh-sharp-face-generic
https://developer.blender.org/rB79e600f75e06971682c5e7bd7444a07d3718e7c0

Cleanup: Rename functions

===

M   source/blender/blenkernel/BKE_mesh_legacy_convert.h
M   source/blender/blenkernel/intern/mesh.cc
M   source/blender/blenkernel/intern/mesh_legacy_convert.cc
M   source/blender/blenloader/intern/versioning_400.cc

===

diff --git a/source/blender/blenkernel/BKE_mesh_legacy_convert.h 
b/source/blender/blenkernel/BKE_mesh_legacy_convert.h
index d0747a07efe..a92d69d4be6 100644
--- a/source/blender/blenkernel/BKE_mesh_legacy_convert.h
+++ b/source/blender/blenkernel/BKE_mesh_legacy_convert.h
@@ -95,8 +95,8 @@ void BKE_mesh_legacy_convert_loose_edges_to_flag(struct Mesh 
*mesh);
 void BKE_mesh_legacy_attribute_flags_to_strings(struct Mesh *mesh);
 void BKE_mesh_legacy_attribute_strings_to_flags(struct Mesh *mesh);
 
-void BKE_mesh_sharp_faces_to_flags(struct Mesh *mesh);
-void BKE_mesh_sharp_faces_from_flags(struct Mesh *mesh);
+void BKE_mesh_legacy_sharp_faces_to_flags(struct Mesh *mesh);
+void BKE_mesh_legacy_sharp_faces_from_flags(struct Mesh *mesh);
 
 void BKE_mesh_legacy_sharp_edges_to_flags(struct Mesh *mesh);
 void BKE_mesh_legacy_sharp_edges_from_flags(struct Mesh *mesh);
diff --git a/source/blender/blenkernel/intern/mesh.cc 
b/source/blender/blenkernel/intern/mesh.cc
index b0fbfbf1a5e..c1f9bba7659 100644
--- a/source/blender/blenkernel/intern/mesh.cc
+++ b/source/blender/blenkernel/intern/mesh.cc
@@ -269,7 +269,7 @@ static void mesh_blend_write(BlendWriter *writer, ID *id, 
const void *id_address
   BKE_mesh_legacy_convert_hide_layers_to_flags(mesh);
   BKE_mesh_legacy_convert_selection_layers_to_flags(mesh);
   BKE_mesh_legacy_convert_material_indices_to_mpoly(mesh);
-  BKE_mesh_sharp_faces_to_flags(mesh);
+  BKE_mesh_legacy_sharp_faces_to_flags(mesh);
   BKE_mesh_legacy_bevel_weight_from_layers(mesh);
   BKE_mesh_legacy_face_set_from_generic(mesh, poly_layers);
   BKE_mesh_legacy_edge_crease_from_layers(mesh);
diff --git a/source/blender/blenkernel/intern/mesh_legacy_convert.cc 
b/source/blender/blenkernel/intern/mesh_legacy_convert.cc
index f17a02b92ab..0bc28698aee 100644
--- a/source/blender/blenkernel/intern/mesh_legacy_convert.cc
+++ b/source/blender/blenkernel/intern/mesh_legacy_convert.cc
@@ -1225,7 +1225,7 @@ void BKE_mesh_tessface_ensure(struct Mesh *mesh)
 /** \name Sharp Edge Conversion
  * \{ */
 
-void BKE_mesh_sharp_faces_to_flags(Mesh *mesh)
+void BKE_mesh_legacy_sharp_faces_to_flags(Mesh *mesh)
 {
   using namespace blender;
   MutableSpan polys = mesh->polys_for_write();
@@ -1244,7 +1244,7 @@ void BKE_mesh_sharp_faces_to_flags(Mesh *mesh)
   }
 }
 
-void BKE_mesh_sharp_faces_from_flags(Mesh *mesh)
+void BKE_mesh_legacy_sharp_faces_from_flags(Mesh *mesh)
 {
   using namespace blender;
   using namespace blender::bke;
diff --git a/source/blender/blenloader/intern/versioning_400.cc 
b/source/blender/blenloader/intern/versioning_400.cc
index 93d66c6f4e2..da3a0018d24 100644
--- a/source/blender/blenloader/intern/versioning_400.cc
+++ b/source/blender/blenloader/intern/versioning_400.cc
@@ -31,7 +31,7 @@ static void 
version_mesh_legacy_to_struct_of_array_format(Mesh )
   BKE_mesh_legacy_convert_flags_to_hide_layers();
   BKE_mesh_legacy_convert_uvs_to_generic();
   BKE_mesh_legacy_convert_mpoly_to_material_indices();
-  BKE_mesh_sharp_faces_from_flags();
+  BKE_mesh_legacy_sharp_faces_from_flags();
   BKE_mesh_legacy_bevel_weight_to_layers();
   BKE_mesh_legacy_sharp_edges_from_flags();
   BKE_mesh_legacy_face_set_to_generic();

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


[Bf-blender-cvs] [6b32a9a956d] refactor-mesh-sharp-face-generic: Cleanup: Rearrange arguments

2023-01-10 Thread Hans Goudey
Commit: 6b32a9a956d5e0f9e64d65be834f45220839fb56
Author: Hans Goudey
Date:   Tue Jan 10 16:38:41 2023 -0500
Branches: refactor-mesh-sharp-face-generic
https://developer.blender.org/rB6b32a9a956d5e0f9e64d65be834f45220839fb56

Cleanup: Rearrange arguments

===

M   source/blender/blenkernel/BKE_mesh_mapping.h
M   source/blender/blenkernel/intern/mesh_legacy_convert.cc
M   source/blender/blenkernel/intern/mesh_mapping.cc
M   source/blender/editors/mesh/mesh_data.cc
M   source/blender/io/wavefront_obj/exporter/obj_export_mesh.cc
M   source/blender/makesrna/intern/rna_mesh_api.c

===

diff --git a/source/blender/blenkernel/BKE_mesh_mapping.h 
b/source/blender/blenkernel/BKE_mesh_mapping.h
index 6e415e03f95..c8561372e30 100644
--- a/source/blender/blenkernel/BKE_mesh_mapping.h
+++ b/source/blender/blenkernel/BKE_mesh_mapping.h
@@ -319,11 +319,11 @@ bool BKE_mesh_calc_islands_loop_poly_uvmap(float 
(*vert_positions)[3],
 int *BKE_mesh_calc_smoothgroups(const struct MEdge *medge,
 int totedge,
 const struct MPoly *mpoly,
-const bool *sharp_faces,
 int totpoly,
 const struct MLoop *mloop,
 int totloop,
 const bool *sharp_edges,
+const bool *sharp_faces,
 int *r_totgroup,
 bool use_bitflags);
 
diff --git a/source/blender/blenkernel/intern/mesh_legacy_convert.cc 
b/source/blender/blenkernel/intern/mesh_legacy_convert.cc
index 0bc28698aee..7083c9880de 100644
--- a/source/blender/blenkernel/intern/mesh_legacy_convert.cc
+++ b/source/blender/blenkernel/intern/mesh_legacy_convert.cc
@@ -450,7 +450,7 @@ static void convert_mfaces_to_mpolys(ID *id,
   }
   bool *sharp_faces = static_cast(
   CustomData_get_layer_named(pdata, CD_PROP_BOOL, "sharp_face"));
-  if (sharp_faces == nullptr) {
+  if (!sharp_faces) {
 sharp_faces = static_cast(CustomData_add_layer_named(
 pdata, CD_PROP_BOOL, CD_SET_DEFAULT, nullptr, totpoly, "sharp_face"));
   }
diff --git a/source/blender/blenkernel/intern/mesh_mapping.cc 
b/source/blender/blenkernel/intern/mesh_mapping.cc
index 4460465a50b..76534a9de2b 100644
--- a/source/blender/blenkernel/intern/mesh_mapping.cc
+++ b/source/blender/blenkernel/intern/mesh_mapping.cc
@@ -871,11 +871,11 @@ static bool poly_is_island_boundary_smooth_cb(const int 
poly_index,
 int *BKE_mesh_calc_smoothgroups(const MEdge *medge,
 const int totedge,
 const MPoly *mpoly,
-const bool *sharp_faces,
 const int totpoly,
 const MLoop *mloop,
 const int totloop,
 const bool *sharp_edges,
+const bool *sharp_faces,
 int *r_totgroup,
 const bool use_bitflags)
 {
diff --git a/source/blender/editors/mesh/mesh_data.cc 
b/source/blender/editors/mesh/mesh_data.cc
index 835fa5f6c1e..e2cb1286356 100644
--- a/source/blender/editors/mesh/mesh_data.cc
+++ b/source/blender/editors/mesh/mesh_data.cc
@@ -868,13 +868,14 @@ static int 
mesh_customdata_custom_splitnormals_add_exec(bContext *C, wmOperator
   bke::MutableAttributeAccessor attributes = me->attributes_for_write();
   bke::SpanAttributeWriter sharp_edges = 
attributes.lookup_or_add_for_write_span(
   "sharp_edge", ATTR_DOMAIN_EDGE);
+  const bool *sharp_faces = static_cast(
+  CustomData_get_layer_named(>pdata, CD_PROP_BOOL, "sharp_face"));
   BKE_edges_sharp_from_angle_set(me->totedge,
  loops.data(),
  loops.size(),
  polys.data(),
  BKE_mesh_poly_normals_ensure(me),
- static_cast(CustomData_get_layer_named(
- >pdata, CD_PROP_BOOL, 
"sharp_face")),
+ sharp_faces,
  polys.size(),
  me->smoothresh,
  sharp_edges.span.data());
@@ -1542,13 +1543,14 @@ void ED_mesh_split_faces(Mesh *mesh)
   const float split_angle = (mesh->flag & ME_AUTOSMOOTH) != 0 ? 
mesh->smoothresh : float(M_PI);
 
   Array sharp_edges(mesh->totedge, false);
+  const bool *sharp_faces_ptr = static_cast(
+  CustomData_get_layer_named(>pdata, CD_PROP_BOOL, "sharp_face"));
   BKE_edges_sharp_from_angle_set(mesh->totedge,
   

[Bf-blender-cvs] [b9e67ee1d6f] refactor-mesh-sharp-face-generic: Cleanup: Rearrange arguments

2023-01-10 Thread Hans Goudey
Commit: b9e67ee1d6ffac24dcb1a3091fb45c092ec18775
Author: Hans Goudey
Date:   Tue Jan 10 16:34:49 2023 -0500
Branches: refactor-mesh-sharp-face-generic
https://developer.blender.org/rBb9e67ee1d6ffac24dcb1a3091fb45c092ec18775

Cleanup: Rearrange arguments

===

M   source/blender/blenkernel/BKE_mesh.h
M   source/blender/blenkernel/intern/data_transfer.cc
M   source/blender/blenkernel/intern/key.cc
M   source/blender/blenkernel/intern/mesh.cc
M   source/blender/blenkernel/intern/mesh_mirror.cc
M   source/blender/blenkernel/intern/mesh_normals.cc
M   source/blender/blenkernel/intern/mesh_remap.cc
M   source/blender/draw/intern/draw_cache_extract_mesh_render_data.cc
M   source/blender/modifiers/intern/MOD_normal_edit.cc
M   source/blender/modifiers/intern/MOD_weighted_normal.cc

===

diff --git a/source/blender/blenkernel/BKE_mesh.h 
b/source/blender/blenkernel/BKE_mesh.h
index f705248e52e..d96db499892 100644
--- a/source/blender/blenkernel/BKE_mesh.h
+++ b/source/blender/blenkernel/BKE_mesh.h
@@ -609,11 +609,11 @@ void BKE_mesh_normals_loop_split(const float 
(*vert_positions)[3],
  int numLoops,
  const struct MPoly *mpolys,
  const float (*poly_normals)[3],
- const bool *sharp_faces,
  int numPolys,
  bool use_split_normals,
  float split_angle,
  const bool *sharp_edges,
+ const bool *sharp_faces,
  const int *loop_to_poly_map,
  MLoopNorSpaceArray *r_lnors_spacearr,
  short (*clnors_data)[2]);
diff --git a/source/blender/blenkernel/intern/data_transfer.cc 
b/source/blender/blenkernel/intern/data_transfer.cc
index 17da2eb8596..f6f405f7be7 100644
--- a/source/blender/blenkernel/intern/data_transfer.cc
+++ b/source/blender/blenkernel/intern/data_transfer.cc
@@ -290,6 +290,8 @@ static void data_transfer_dtdata_type_preprocess(Mesh 
*me_src,
 if (dirty_nors_dst || do_loop_nors_dst) {
   const bool *sharp_edges = static_cast(
   CustomData_get_layer_named(_dst->edata, CD_PROP_BOOL, 
"sharp_edge"));
+  const bool *sharp_faces = static_cast(
+  CustomData_get_layer_named(_dst->pdata, CD_PROP_BOOL, 
"sharp_face"));
   BKE_mesh_normals_loop_split(positions_dst,
   BKE_mesh_vertex_normals_ensure(me_dst),
   num_verts_dst,
@@ -300,12 +302,11 @@ static void data_transfer_dtdata_type_preprocess(Mesh 
*me_src,
   num_loops_dst,
   polys_dst,
   BKE_mesh_poly_normals_ensure(me_dst),
-  static_cast(CustomData_get_layer_named(
-  _dst->pdata, CD_PROP_BOOL, 
"sharp_face")),
   num_polys_dst,
   use_split_nors_dst,
   split_angle_dst,
   sharp_edges,
+  sharp_faces,
   nullptr,
   nullptr,
   custom_nors_dst);
diff --git a/source/blender/blenkernel/intern/key.cc 
b/source/blender/blenkernel/intern/key.cc
index fdea39fef67..3f17416e1e6 100644
--- a/source/blender/blenkernel/intern/key.cc
+++ b/source/blender/blenkernel/intern/key.cc
@@ -2276,6 +2276,8 @@ void BKE_keyblock_mesh_calc_normals(const KeyBlock *kb,
 CustomData_get_layer(>ldata, CD_CUSTOMLOOPNORMAL)); /* May be 
nullptr. */
 const bool *sharp_edges = static_cast(
 CustomData_get_layer_named(>edata, CD_PROP_BOOL, "sharp_edge"));
+const bool *sharp_faces = static_cast(
+CustomData_get_layer_named(>pdata, CD_PROP_BOOL, "sharp_face"));
 BKE_mesh_normals_loop_split(positions,
 vert_normals,
 mesh->totvert,
@@ -2286,12 +2288,11 @@ void BKE_keyblock_mesh_calc_normals(const KeyBlock *kb,
 mesh->totloop,
 polys,
 poly_normals,
-static_cast(CustomData_get_layer_named(
->pdata, CD_PROP_BOOL, "sharp_face")),
 mesh->totpoly,
 (mesh->flag & ME_AUTOSMOOTH) != 0,
 mesh->smoothresh,
 sharp_edges,
+sharp_faces,
  

[Bf-blender-cvs] [3a9ea48b7d9] refactor-mesh-sharp-face-generic: Merge branch 'master' into refactor-mesh-sharp-face-generic

2023-01-10 Thread Hans Goudey
Commit: 3a9ea48b7d9c7807738f8c4d7301640a6dd447c0
Author: Hans Goudey
Date:   Tue Jan 10 16:30:22 2023 -0500
Branches: refactor-mesh-sharp-face-generic
https://developer.blender.org/rB3a9ea48b7d9c7807738f8c4d7301640a6dd447c0

Merge branch 'master' into refactor-mesh-sharp-face-generic

===



===

diff --cc release/scripts/startup/bl_ui/properties_data_mesh.py
index 7cca560cfce,61027f68f19..bb1ce7f3ea3
--- a/release/scripts/startup/bl_ui/properties_data_mesh.py
+++ b/release/scripts/startup/bl_ui/properties_data_mesh.py
@@@ -605,9 -605,8 +605,8 @@@ class DATA_PT_mesh_attributes(MeshButto
  colliding_names = []
  for collection in (
  # Built-in names.
- {"position": None, "normal": None, "crease": None},
 -{"shade_smooth": None, "normal": None, "crease": None},
++{"normal": None, "crease": None},
  mesh.attributes,
- mesh.uv_layers,
  None if ob is None else ob.vertex_groups,
  ):
  if collection is None:
diff --cc source/blender/blenkernel/BKE_mesh.h
index 0727cb71b85,4d81507ef1c..f705248e52e
--- a/source/blender/blenkernel/BKE_mesh.h
+++ b/source/blender/blenkernel/BKE_mesh.h
@@@ -475,18 -471,15 +471,18 @@@ void BKE_mesh_ensure_normals_for_displa
   *
   * Used when defining an empty custom loop normals data layer,
   * to keep same shading as with auto-smooth!
 + *
 + * \param sharp_faces: Optional array used to mark specific faces as sharp.
   */
- void BKE_edges_sharp_from_angle_set(struct MEdge *medges,
- int numEdges,
+ void BKE_edges_sharp_from_angle_set(int numEdges,
  const struct MLoop *mloops,
  int numLoops,
  const struct MPoly *mpolys,
  const float (*poly_normals)[3],
 +const bool *sharp_faces,
  int numPolys,
- float split_angle);
+ float split_angle,
+ bool *sharp_edges);
  
  /**
   * References a contiguous loop-fan with normal offset vars.
@@@ -599,9 -592,10 +595,11 @@@ void BKE_lnor_space_custom_normal_to_da
   * (splitting edges).
   *
   * \param loop_to_poly_map: Optional pre-created map from loops to their 
polygon.
 + * \param sharp_faces: Optional array used to mark specific faces as sharp.
+  * \param sharp_edges: Optional array of sharp edge tags, used to split the 
evaluated normals on
+  * each side of the edge.
   */
- void BKE_mesh_normals_loop_split(const struct MVert *mverts,
+ void BKE_mesh_normals_loop_split(const float (*vert_positions)[3],
   const float (*vert_normals)[3],
   int numVerts,
   const struct MEdge *medges,
@@@ -629,10 -623,10 +628,11 @@@ void BKE_mesh_normals_loop_custom_set(c
int numLoops,
const struct MPoly *mpolys,
const float (*poly_normals)[3],
 +  const bool *sharp_faces,
int numPolys,
+   bool *sharp_edges,
short (*r_clnors_data)[2]);
- void BKE_mesh_normals_loop_custom_from_verts_set(const struct MVert *mverts,
+ void BKE_mesh_normals_loop_custom_from_verts_set(const float 
(*vert_positions)[3],
   const float 
(*vert_normals)[3],
   float 
(*r_custom_vert_normals)[3],
   int numVerts,
@@@ -642,8 -636,8 +642,9 @@@
   int numLoops,
   const struct MPoly *mpolys,
   const float 
(*poly_normals)[3],
 + const bool *sharp_faces,
   int numPolys,
+  bool *sharp_edges,
   short (*r_clnors_data)[2]);
  
  /**
diff --cc source/blender/blenkernel/BKE_mesh_legacy_convert.h
index 6e7a5833281,d6689da7d86..d0747a07efe
--- a/source/blender/blenkernel/BKE_mesh_legacy_convert.h
+++ b/source/blender/blenkernel/BKE_mesh_legacy_convert.h
@@@ -91,6 -95,16 +95,19 @@@ void BKE_mesh_legacy_convert_loose_edge
  void BKE_mesh_legacy_attribute_flags_to_strings(struct Mesh *mesh);
  void 

[Bf-blender-cvs] [dd9e1eded0d] master: Mesh: Move sharp edge flag to generic attribute

2023-01-10 Thread Hans Goudey
Commit: dd9e1eded0d48e19a500233b20e8c5f18ed12a09
Author: Hans Goudey
Date:   Tue Jan 10 16:12:14 2023 -0500
Branches: master
https://developer.blender.org/rBdd9e1eded0d48e19a500233b20e8c5f18ed12a09

Mesh: Move sharp edge flag to generic attribute

Move the `ME_SHARP` flag for mesh edges to a generic boolean
attribute. This will help allow changing mesh edges to just a pair
of integers, giving performance improvements. In the future it could
also give benefits for normal calculation, which could more easily
check if all or no edges are marked sharp, which is helpful considering
the plans in T93551.

The attribute is generally only allocated when it's necessary. When
leaving edit mode, it will only be created if an edge is marked sharp.
The data can be edited with geometry nodes just like a regular edge
domain boolean attribute.

The attribute is named `sharp_edge`, aiming to reflect the similar
`select_edge` naming and to allow a future `sharp_face` name in
a separate commit.

Ref T95966

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

===

M   source/blender/blenkernel/BKE_mesh.h
M   source/blender/blenkernel/BKE_mesh_legacy_convert.h
M   source/blender/blenkernel/BKE_mesh_mapping.h
M   source/blender/blenkernel/intern/curve_to_mesh_convert.cc
M   source/blender/blenkernel/intern/customdata.cc
M   source/blender/blenkernel/intern/data_transfer.cc
M   source/blender/blenkernel/intern/geometry_component_mesh.cc
M   source/blender/blenkernel/intern/key.cc
M   source/blender/blenkernel/intern/mesh.cc
M   source/blender/blenkernel/intern/mesh_legacy_convert.cc
M   source/blender/blenkernel/intern/mesh_mapping.cc
M   source/blender/blenkernel/intern/mesh_mirror.cc
M   source/blender/blenkernel/intern/mesh_normals.cc
M   source/blender/blenkernel/intern/mesh_remap.cc
M   source/blender/blenkernel/intern/subsurf_ccg.c
M   source/blender/blenloader/intern/versioning_400.cc
M   source/blender/bmesh/intern/bmesh_construct.c
M   source/blender/bmesh/intern/bmesh_mesh_convert.cc
M   source/blender/draw/intern/draw_cache_extract_mesh_render_data.cc
M   source/blender/editors/mesh/mesh_data.cc
M   source/blender/editors/sculpt_paint/sculpt_face_set.cc
M   source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.cc
M   source/blender/io/wavefront_obj/exporter/obj_export_mesh.cc
M   source/blender/makesdna/DNA_meshdata_types.h
M   source/blender/makesrna/intern/rna_mesh.c
M   source/blender/makesrna/intern/rna_mesh_api.c
M   source/blender/modifiers/intern/MOD_normal_edit.cc
M   source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
M   source/blender/modifiers/intern/MOD_weighted_normal.cc

===

diff --git a/source/blender/blenkernel/BKE_mesh.h 
b/source/blender/blenkernel/BKE_mesh.h
index 5190d09ccf8..4d81507ef1c 100644
--- a/source/blender/blenkernel/BKE_mesh.h
+++ b/source/blender/blenkernel/BKE_mesh.h
@@ -472,14 +472,14 @@ void BKE_mesh_ensure_normals_for_display(struct Mesh 
*mesh);
  * Used when defining an empty custom loop normals data layer,
  * to keep same shading as with auto-smooth!
  */
-void BKE_edges_sharp_from_angle_set(struct MEdge *medges,
-int numEdges,
+void BKE_edges_sharp_from_angle_set(int numEdges,
 const struct MLoop *mloops,
 int numLoops,
 const struct MPoly *mpolys,
 const float (*poly_normals)[3],
 int numPolys,
-float split_angle);
+float split_angle,
+bool *sharp_edges);
 
 /**
  * References a contiguous loop-fan with normal offset vars.
@@ -592,6 +592,8 @@ void BKE_lnor_space_custom_normal_to_data(const 
MLoopNorSpace *lnor_space,
  * (splitting edges).
  *
  * \param loop_to_poly_map: Optional pre-created map from loops to their 
polygon.
+ * \param sharp_edges: Optional array of sharp edge tags, used to split the 
evaluated normals on
+ * each side of the edge.
  */
 void BKE_mesh_normals_loop_split(const float (*vert_positions)[3],
  const float (*vert_normals)[3],
@@ -606,6 +608,7 @@ void BKE_mesh_normals_loop_split(const float 
(*vert_positions)[3],
  int numPolys,
  bool use_split_normals,
  float split_angle,
+ const bool *sharp_edges,
  const int *loop_to_poly_map,
  MLoopNorSpaceArray *r_lnors_spacearr,
  short (*clnors_data)[2]);
@@ -613,7 +616,7 @@ 

[Bf-blender-cvs] [30c90f0ad01] master: Cleanup: Replace "UV's" with "UVs"

2023-01-10 Thread Damien Picard
Commit: 30c90f0ad015ae23eb37780f64429ba9e406eafe
Author: Damien Picard
Date:   Tue Jan 10 14:49:51 2023 -0500
Branches: master
https://developer.blender.org/rB30c90f0ad015ae23eb37780f64429ba9e406eafe

Cleanup: Replace "UV's" with "UVs"

An apostrophe should not be used because it is not a mark of plural,
even for initialisms. This involves mostly comments, but a few UI
messages are affected as well.

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

===

M   doc/python_api/examples/bpy.types.Mesh.py
M   release/scripts/modules/bpy_extras/object_utils.py
M   release/scripts/startup/bl_operators/add_mesh_torus.py
M   release/scripts/startup/bl_operators/uvcalc_lightmap.py
M   source/blender/blenkernel/BKE_mesh.h
M   source/blender/blenkernel/BKE_pbvh_pixels.hh
M   source/blender/blenkernel/intern/mesh.cc
M   source/blender/blenkernel/intern/mesh_legacy_convert.cc
M   source/blender/blenkernel/intern/mesh_mapping.cc
M   source/blender/blenkernel/intern/mesh_merge_customdata.cc
M   source/blender/blenlib/BLI_uvproject.h
M   source/blender/blenloader/intern/versioning_280.c
M   source/blender/blenloader/intern/versioning_defaults.cc
M   source/blender/bmesh/bmesh.h
M   source/blender/bmesh/intern/bmesh_interp.c
M   source/blender/bmesh/intern/bmesh_opdefines.c
M   source/blender/bmesh/intern/bmesh_operators.h
M   source/blender/bmesh/intern/bmesh_walkers_impl.c
M   source/blender/bmesh/operators/bmo_inset.c
M   source/blender/bmesh/tools/bmesh_bevel.c
M   source/blender/bmesh/tools/bmesh_boolean.cc
M   source/blender/bmesh/tools/bmesh_intersect.c
M   source/blender/bmesh/tools/bmesh_path_region_uv.c
M   source/blender/draw/engines/overlay/overlay_edit_uv.cc
M   source/blender/draw/intern/draw_cache_impl_mesh.cc
M   source/blender/draw/intern/draw_manager.c
M   
source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_stretch_angle.cc
M   source/blender/editors/include/ED_mesh.h
M   source/blender/editors/mesh/editmesh_tools.c
M   source/blender/editors/object/object_add.cc
M   source/blender/editors/object/object_modifier.cc
M   source/blender/editors/sculpt_paint/paint_image_proj.cc
M   source/blender/editors/sculpt_paint/sculpt_uv.c
M   source/blender/editors/transform/transform_convert.c
M   source/blender/editors/uvedit/uvedit_intern.h
M   source/blender/editors/uvedit/uvedit_ops.c
M   source/blender/editors/uvedit/uvedit_rip.c
M   source/blender/editors/uvedit/uvedit_select.c
M   source/blender/editors/uvedit/uvedit_smart_stitch.c
M   source/blender/editors/uvedit/uvedit_unwrap_ops.c
M   source/blender/makesdna/DNA_meshdata_types.h
M   source/blender/makesdna/DNA_scene_types.h
M   source/blender/makesrna/intern/rna_modifier.c
M   source/blender/makesrna/intern/rna_scene.c
M   source/blender/modifiers/intern/MOD_dynamicpaint.c
M   source/blender/windowmanager/intern/wm_event_system.cc

===

diff --git a/doc/python_api/examples/bpy.types.Mesh.py 
b/doc/python_api/examples/bpy.types.Mesh.py
index 68cc42ec6bf..8872201e123 100644
--- a/doc/python_api/examples/bpy.types.Mesh.py
+++ b/doc/python_api/examples/bpy.types.Mesh.py
@@ -13,16 +13,16 @@ Blender stores 4 main arrays to define mesh geometry.
 - :class:`Mesh.polygons`: (reference a range of loops)
 
 
-Each polygon reference a slice in the loop array, this way, polygons do not 
store vertices or corner data such as UV's directly,
+Each polygon references a slice in the loop array, this way, polygons do not 
store vertices or corner data such as UVs directly,
 only a reference to loops that the polygon uses.
 
 :class:`Mesh.loops`, :class:`Mesh.uv_layers` :class:`Mesh.vertex_colors` are 
all aligned so the same polygon loop
-indices can be used to find the UV's and vertex colors as with as the vertices.
+indices can be used to find the UVs and vertex colors as with as the vertices.
 
 To compare mesh API options see: :ref:`NGons and Tessellation Faces 
`
 
 
-This example script prints the vertices and UV's for each polygon, assumes the 
active object is a mesh with UVs.
+This example script prints the vertices and UVs for each polygon, assumes the 
active object is a mesh with UVs.
 """
 
 import bpy
diff --git a/release/scripts/modules/bpy_extras/object_utils.py 
b/release/scripts/modules/bpy_extras/object_utils.py
index 5275a83e062..efbd635955c 100644
--- a/release/scripts/modules/bpy_extras/object_utils.py
+++ b/release/scripts/modules/bpy_extras/object_utils.py
@@ -127,7 +127,7 @@ def object_data_add(context, obdata, operator=None, 
name=None):
 layer.update()  # apply location
 # layer.objects.active = obj_new
 
-# Match up UV layers, this is needed so adding an object with UV's
+# Match up UV 

[Bf-blender-cvs] [4bac85f0775] refactor-mesh-corners-generic: Merge branch 'master' into refactor-mesh-corners-generic

2023-01-10 Thread Hans Goudey
Commit: 4bac85f0775a5cc4e2c73fa3d8563f2573790fbb
Author: Hans Goudey
Date:   Tue Jan 10 14:35:15 2023 -0500
Branches: refactor-mesh-corners-generic
https://developer.blender.org/rB4bac85f0775a5cc4e2c73fa3d8563f2573790fbb

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

===



===

diff --cc source/blender/blenkernel/BKE_mesh.h
index 76b86e13e4b,ffca4cff347..c3ff1a14972
--- a/source/blender/blenkernel/BKE_mesh.h
+++ b/source/blender/blenkernel/BKE_mesh.h
@@@ -34,8 -34,8 +34,7 @@@ struct MDeformVert
  struct MDisps;
  struct MEdge;
  struct MFace;
 -struct MLoop;
  struct MLoopTri;
- struct MLoopUV;
  struct MPoly;
  struct Main;
  struct MemArena;
@@@ -694,12 -689,11 +693,11 @@@ void BKE_mesh_calc_poly_center(const st
 float r_cent[3]);
  /* NOTE: passing poly-normal is only a speedup so we can skip calculating it. 
*/
  float BKE_mesh_calc_poly_area(const struct MPoly *mpoly,
 -  const struct MLoop *loopstart,
 +  const int *poly_verts,
const float (*vert_positions)[3]);
  float BKE_mesh_calc_area(const struct Mesh *me);
- float BKE_mesh_calc_poly_uv_area(const struct MPoly *mpoly, const struct 
MLoopUV *uv_array);
  void BKE_mesh_calc_poly_angles(const struct MPoly *mpoly,
 -   const struct MLoop *loopstart,
 +   const int *poly_verts,
 const float (*vert_positions)[3],
 float angles[]);
  
diff --cc source/blender/blenkernel/BKE_mesh_mapping.h
index 2e5ae6d36b8,36ac0708629..ae99915a965
--- a/source/blender/blenkernel/BKE_mesh_mapping.h
+++ b/source/blender/blenkernel/BKE_mesh_mapping.h
@@@ -15,8 -15,8 +15,7 @@@ extern "C" 
  #endif
  
  struct MEdge;
 -struct MLoop;
  struct MLoopTri;
- struct MLoopUV;
  struct MPoly;
  
  /* UvVertMap */
@@@ -103,8 -103,8 +102,8 @@@ typedef struct MeshElemMap 
  UvVertMap *BKE_mesh_uv_vert_map_create(const struct MPoly *mpoly,
 const bool *hide_poly,
 const bool *select_poly,
 -   const struct MLoop *mloop,
 +   const int *corner_verts,
-const struct MLoopUV *mloopuv,
+const float (*mloopuv)[2],
 unsigned int totpoly,
 unsigned int totvert,
 const float limit[2],
@@@ -305,10 -303,9 +304,10 @@@ bool BKE_mesh_calc_islands_loop_poly_uv
 int totedge,
 struct MPoly *polys,
 int totpoly,
 -   struct MLoop *loops,
 +   const int *corner_verts,
 +   const int *corner_edges,
 int totloop,
-const struct MLoopUV *luvs,
+const float (*luvs)[2],
 MeshIslandStore *r_island_store);
  
  /**
diff --cc source/blender/blenkernel/BKE_mesh_tangent.h
index 49e22cd55b6,b30ce13da8d..1b767278d12
--- a/source/blender/blenkernel/BKE_mesh_tangent.h
+++ b/source/blender/blenkernel/BKE_mesh_tangent.h
@@@ -19,10 -19,10 +19,10 @@@ struct ReportList
   */
  void BKE_mesh_calc_loop_tangent_single_ex(const float (*vert_positions)[3],
int numVerts,
 -  const struct MLoop *mloops,
 +  const int *corner_verts,
float (*r_looptangent)[4],
const float (*loop_normals)[3],
-   const struct MLoopUV *loopuv,
+   const float (*loopuv)[2],
int numLoops,
const struct MPoly *mpolys,
int numPolys,
diff --cc source/blender/blenkernel/intern/customdata.cc
index 748f5fd95a3,8444598d7d8..63e600c4224
--- a/source/blender/blenkernel/intern/customdata.cc
+++ b/source/blender/blenkernel/intern/customdata.cc
@@@ -2128,8 -2050,8 +2050,7 @@@ const CustomData_MeshMasks CD_MASK_MES
  /* pmask */
  (CD_MASK_MPOLY | CD_MASK_FACEMAP | CD_MASK_FREESTYLE_FACE | 
CD_MASK_PROP_ALL),
  /* lmask */
- (CD_MASK_MDISPS | CD_MASK_MLOOPUV | CD_MASK_CUSTOMLOOPNORMAL | 

[Bf-blender-cvs] [5bc71f22a24] master: Snap Gizmo: remove unused "snap_elements"

2023-01-10 Thread Germano Cavalcante
Commit: 5bc71f22a24a48780fe335c557f2f9bbc690eb85
Author: Germano Cavalcante
Date:   Tue Jan 10 15:56:17 2023 -0300
Branches: master
https://developer.blender.org/rB5bc71f22a24a48780fe335c557f2f9bbc690eb85

Snap Gizmo: remove unused "snap_elements"

This property was intended to keep the snap elements synchronized with the 
scene.

But another solution exists.

And this property is not even working correctly.

===

M   source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.c

===

diff --git a/source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.c 
b/source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.c
index c5a542c0bf3..5cac8b93b88 100644
--- a/source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.c
+++ b/source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.c
@@ -41,17 +41,6 @@ typedef struct SnapGizmo3D {
   V3DSnapCursorState *snap_state;
 } SnapGizmo3D;
 
-static void snap_gizmo_snap_elements_update(SnapGizmo3D *snap_gizmo)
-{
-  wmGizmoProperty *gz_prop_snap;
-  gz_prop_snap = WM_gizmo_target_property_find(_gizmo->gizmo, 
"snap_elements");
-
-  if (gz_prop_snap->prop) {
-V3DSnapCursorState *snap_state = snap_gizmo->snap_state;
-snap_state->snap_elem_force |= RNA_property_enum_get(_prop_snap->ptr, 
gz_prop_snap->prop);
-  }
-}
-
 /*  */
 /** \name ED_gizmo_library specific API
  * \{ */
@@ -262,9 +251,6 @@ static int snap_gizmo_test_select(bContext *C, wmGizmo *gz, 
const int mval[2])
 {
   SnapGizmo3D *snap_gizmo = (SnapGizmo3D *)gz;
 
-  /* Snap Elements can change while the gizmo is active. Need to be updated 
somewhere. */
-  snap_gizmo_snap_elements_update(snap_gizmo);
-
   /* Snap values are updated too late at the cursor. Be sure to update ahead 
of time. */
   int x, y;
   {
@@ -404,9 +390,6 @@ static void GIZMO_GT_snap_3d(wmGizmoType *gzt)
 INT_MAX);
   RNA_def_property_int_array_funcs_runtime(
   prop, gizmo_snap_rna_snap_elem_index_get_fn, NULL, NULL);
-
-  /* Read/Write. */
-  WM_gizmotype_target_property_def(gzt, "snap_elements", PROP_ENUM, 1);
 }
 
 void ED_gizmotypes_snap_3d(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] [3a81f0a978b] refactor-mesh-corners-generic: Merge branch 'refactor-mesh-position-generic' into refactor-mesh-corners-generic

2023-01-10 Thread Hans Goudey
Commit: 3a81f0a978bf517ba56dd32f9a9c7f1413f05ce4
Author: Hans Goudey
Date:   Tue Jan 10 13:30:48 2023 -0500
Branches: refactor-mesh-corners-generic
https://developer.blender.org/rB3a81f0a978bf517ba56dd32f9a9c7f1413f05ce4

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

===



===

diff --cc source/blender/blenkernel/BKE_bvhutils.h
index a22c9fd976a,67b282ff2ad..d74af8effb3
--- a/source/blender/blenkernel/BKE_bvhutils.h
+++ b/source/blender/blenkernel/BKE_bvhutils.h
@@@ -180,8 -180,8 +180,8 @@@ BVHTree *bvhtree_from_editmesh_looptri_
   * Builds a BVH-tree where nodes are the looptri faces of the given mesh.
   */
  BVHTree *bvhtree_from_mesh_looptri_ex(struct BVHTreeFromMesh *data,
-   const float (*positions)[3],
+   const float (*vert_positions)[3],
 -  const struct MLoop *mloop,
 +  const int *corner_verts,
const struct MLoopTri *looptri,
int looptri_num,
const blender::BitVector<> ,
diff --cc source/blender/blenkernel/BKE_mesh_remap.h
index c62fa959893,7508821860c..f8768b19d57
--- a/source/blender/blenkernel/BKE_mesh_remap.h
+++ b/source/blender/blenkernel/BKE_mesh_remap.h
@@@ -221,8 -220,8 +221,8 @@@ void BKE_mesh_remap_calc_polys_from_mes
   float max_dist,
   float ray_radius,
   const struct Mesh *mesh_dst,
-  const float (*positions_dst)[3],
+  const float (*vert_positions_dst)[3],
 - const struct MLoop *loops_dst,
 + const int *corner_verts,
   const struct MPoly *polys_dst,
   int numpolys_dst,
   struct Mesh *me_src,
diff --cc source/blender/blenkernel/BKE_volume_to_mesh.hh
index 29a38d1934f,15e405a103d..33ff97b0fe9
--- a/source/blender/blenkernel/BKE_volume_to_mesh.hh
+++ b/source/blender/blenkernel/BKE_volume_to_mesh.hh
@@@ -62,9 -62,9 +62,9 @@@ void fill_mesh_from_openvdb_data(const 
   int vert_offset,
   int poly_offset,
   int loop_offset,
-  MutableSpan positions,
+  MutableSpan vert_positions,
   MutableSpan polys,
 - MutableSpan loops);
 + MutableSpan corner_verts);
  
  #endif
  
diff --cc source/blender/blenkernel/intern/bvhutils.cc
index 15378b2aca3,fc1072d4cb8..e06dfa3b57c
--- a/source/blender/blenkernel/intern/bvhutils.cc
+++ b/source/blender/blenkernel/intern/bvhutils.cc
@@@ -1105,8 -1105,8 +1105,8 @@@ BVHTree *bvhtree_from_editmesh_looptri
  }
  
  BVHTree *bvhtree_from_mesh_looptri_ex(BVHTreeFromMesh *data,
-   const float (*positions)[3],
+   const float (*vert_positions)[3],
 -  const struct MLoop *mloop,
 +  const int *corner_verts,
const struct MLoopTri *looptri,
const int looptri_num,
const BitVector<> _mask,
@@@ -1118,8 -1118,8 +1118,8 @@@
BVHTree *tree = bvhtree_from_mesh_looptri_create_tree(epsilon,
  tree_type,
  axis,
- positions,
+ vert_positions,
 -mloop,
 +corner_verts,
  looptri,
  looptri_num,
  looptri_mask,
@@@ -1130,7 -1130,7 +1130,7 @@@
if (data) {
  /* Setup BVHTreeFromMesh */
  bvhtree_from_mesh_setup_data(
- tree, BVHTREE_FROM_LOOPTRI, positions, nullptr, nullptr, 
corner_verts, looptri, data);
 -tree, BVHTREE_FROM_LOOPTRI, vert_positions, nullptr, nullptr, mloop, 
looptri, data);
++tree, BVHTREE_FROM_LOOPTRI, vert_positions, nullptr, nullptr, 
corner_verts, looptri, data);
}
  
return tree;

[Bf-blender-cvs] [d397ecae325] master: Geometry Nodes: Add a selection input to the store named attribute node

2023-01-10 Thread Charlie Jolly
Commit: d397ecae3255a150954bee32249fd7d58a39d903
Author: Charlie Jolly
Date:   Sat Jan 7 14:32:49 2023 +
Branches: master
https://developer.blender.org/rBd397ecae3255a150954bee32249fd7d58a39d903

Geometry Nodes: Add a selection input to the store named attribute node

This patch is a response to T101313.

Adds a selection to the Store Named Attribute node.

If the attribute does not exist unselected parts
are filled with zero values. Otherwise, only the
selected parts are filled.

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

===

M   source/blender/blenkernel/BKE_geometry_fields.hh
M   source/blender/blenkernel/intern/geometry_fields.cc
M   source/blender/nodes/geometry/nodes/node_geo_store_named_attribute.cc

===

diff --git a/source/blender/blenkernel/BKE_geometry_fields.hh 
b/source/blender/blenkernel/BKE_geometry_fields.hh
index 085bade618c..5f5333beb63 100644
--- a/source/blender/blenkernel/BKE_geometry_fields.hh
+++ b/source/blender/blenkernel/BKE_geometry_fields.hh
@@ -315,6 +315,12 @@ bool try_capture_field_on_geometry(GeometryComponent 
,
const eAttrDomain domain,
const fn::GField );
 
+bool try_capture_field_on_geometry(GeometryComponent ,
+   const AttributeIDRef _id,
+   const eAttrDomain domain,
+   const fn::Field ,
+   const fn::GField );
+
 /**
  * Try to find the geometry domain that the field should be evaluated on. If 
it is not obvious
  * which domain is correct, none is returned.
diff --git a/source/blender/blenkernel/intern/geometry_fields.cc 
b/source/blender/blenkernel/intern/geometry_fields.cc
index 9c691cb5870..f4f4d0d8719 100644
--- a/source/blender/blenkernel/intern/geometry_fields.cc
+++ b/source/blender/blenkernel/intern/geometry_fields.cc
@@ -1,5 +1,7 @@
 /* SPDX-License-Identifier: GPL-2.0-or-later */
 
+#include "BLI_array_utils.hh"
+
 #include "BKE_attribute.hh"
 #include "BKE_curves.hh"
 #include "BKE_geometry_fields.hh"
@@ -408,6 +410,7 @@ bool NormalFieldInput::is_equal_to(const fn::FieldNode 
) const
 bool try_capture_field_on_geometry(GeometryComponent ,
const AttributeIDRef _id,
const eAttrDomain domain,
+   const fn::Field ,
const fn::GField )
 {
   MutableAttributeAccessor attributes = *component.attributes_for_write();
@@ -423,19 +426,44 @@ bool try_capture_field_on_geometry(GeometryComponent 
,
   const IndexMask mask{IndexMask(domain_size)};
   const bke::AttributeValidator validator = 
attributes.lookup_validator(attribute_id);
 
+  const std::optional meta_data = 
attributes.lookup_meta_data(attribute_id);
+  const bool attribute_exists = meta_data && meta_data->domain == domain &&
+meta_data->data_type == data_type;
+
+  /*  We are writing to an attribute that exists already with the correct 
domain and type. */
+  if (attribute_exists) {
+if (GSpanAttributeWriter dst_attribute = 
attributes.lookup_for_write_span(attribute_id)) {
+  bke::GeometryFieldContext field_context{component, domain};
+  const IndexMask mask{IndexMask(domain_size)};
+
+  fn::FieldEvaluator evaluator{field_context, };
+  evaluator.add(validator.validate_field_if_necessary(field));
+  evaluator.set_selection(selection);
+  evaluator.evaluate();
+
+  const IndexMask selection = evaluator.get_evaluated_selection_as_mask();
+
+  array_utils::copy(evaluator.get_evaluated(0), selection, 
dst_attribute.span);
+
+  dst_attribute.finish();
+  return true;
+}
+  }
+
   /* Could avoid allocating a new buffer if:
-   * - We are writing to an attribute that exists already with the correct 
domain and type.
* - The field does not depend on that attribute (we can't easily check for 
that yet). */
-  void *buffer = MEM_mallocN(type.size() * domain_size, __func__);
-
+  void *buffer = MEM_mallocN_aligned(type.size() * domain_size, 
type.alignment(), __func__);
+  if (selection.node().depends_on_input() || 
!fn::evaluate_constant_field(selection)) {
+/* If every element might not be selected, the buffer must be initialized. 
*/
+type.value_initialize_n(buffer, domain_size);
+  }
   fn::FieldEvaluator evaluator{field_context, };
   evaluator.add_with_destination(validator.validate_field_if_necessary(field),
  GMutableSpan{type, buffer, domain_size});
+  evaluator.set_selection(selection);
   evaluator.evaluate();
 
-  const std::optional meta_data = 
attributes.lookup_meta_data(attribute_id);
-
-  if (meta_data && meta_data->domain == domain && meta_data->data_type == 
data_type) {
+  if 

[Bf-blender-cvs] [01f509232bb] refactor-mesh-sharp-edge-generic: Merge branch 'master' into refactor-mesh-sharp-edge-generic

2023-01-10 Thread Hans Goudey
Commit: 01f509232bbc6fff39f0c1de45b79b9efa3fab47
Author: Hans Goudey
Date:   Tue Jan 10 13:05:56 2023 -0500
Branches: refactor-mesh-sharp-edge-generic
https://developer.blender.org/rB01f509232bbc6fff39f0c1de45b79b9efa3fab47

Merge branch 'master' into refactor-mesh-sharp-edge-generic

===



===

diff --cc source/blender/blenkernel/BKE_mesh.h
index 998fca10f80,ffca4cff347..1cf86e87493
--- a/source/blender/blenkernel/BKE_mesh.h
+++ b/source/blender/blenkernel/BKE_mesh.h
@@@ -596,10 -592,8 +592,10 @@@ void BKE_lnor_space_custom_normal_to_da
   * (splitting edges).
   *
   * \param loop_to_poly_map: Optional pre-created map from loops to their 
polygon.
 + * \param sharp_edges: Optional array of sharp edge tags, used to split the 
evaluated normals on
 + * each side of the edge.
   */
- void BKE_mesh_normals_loop_split(const struct MVert *mverts,
+ void BKE_mesh_normals_loop_split(const float (*vert_positions)[3],
   const float (*vert_normals)[3],
   int numVerts,
   const struct MEdge *medges,
@@@ -617,10 -610,10 +613,10 @@@
   MLoopNorSpaceArray *r_lnors_spacearr,
   short (*clnors_data)[2]);
  
- void BKE_mesh_normals_loop_custom_set(const struct MVert *mverts,
+ void BKE_mesh_normals_loop_custom_set(const float (*vert_positions)[3],
const float (*vert_normals)[3],
int numVerts,
 -  struct MEdge *medges,
 +  const struct MEdge *medges,
int numEdges,
const struct MLoop *mloops,
float (*r_custom_loop_normals)[3],
@@@ -628,9 -621,8 +624,9 @@@
const struct MPoly *mpolys,
const float (*poly_normals)[3],
int numPolys,
 +  bool *sharp_edges,
short (*r_clnors_data)[2]);
- void BKE_mesh_normals_loop_custom_from_verts_set(const struct MVert *mverts,
+ void BKE_mesh_normals_loop_custom_from_verts_set(const float 
(*vert_positions)[3],
   const float 
(*vert_normals)[3],
   float 
(*r_custom_vert_normals)[3],
   int numVerts,
diff --cc source/blender/blenkernel/BKE_mesh_legacy_convert.h
index 3fa45959d2c,3b1b94e516a..3a755599da0
--- a/source/blender/blenkernel/BKE_mesh_legacy_convert.h
+++ b/source/blender/blenkernel/BKE_mesh_legacy_convert.h
@@@ -88,9 -95,13 +95,16 @@@ void BKE_mesh_legacy_convert_loose_edge
  void BKE_mesh_legacy_attribute_flags_to_strings(struct Mesh *mesh);
  void BKE_mesh_legacy_attribute_strings_to_flags(struct Mesh *mesh);
  
 +void BKE_mesh_sharp_edges_to_flags(struct Mesh *mesh);
 +void BKE_mesh_sharp_edges_from_flags(struct Mesh *mesh);
 +
+ struct MVert *BKE_mesh_legacy_convert_positions_to_verts(
+ Mesh *mesh,
+ blender::ResourceScope _arrays_for_convert,
+ blender::Vector _layers_to_write);
+ 
+ void BKE_mesh_legacy_convert_verts_to_positions(Mesh *mesh);
+ 
  #endif
  
  /**
diff --cc source/blender/blenkernel/intern/curve_to_mesh_convert.cc
index 12da300598b,305a245a036..2a97e98a9fb
--- a/source/blender/blenkernel/intern/curve_to_mesh_convert.cc
+++ b/source/blender/blenkernel/intern/curve_to_mesh_convert.cc
@@@ -713,34 -688,26 +710,34 @@@ Mesh *curve_to_mesh_sweep(const CurvesG
  tangents.slice(info.main_points),
  normals.slice(info.main_points),
  radii.is_empty() ? radii : 
radii.slice(info.main_points),
- verts.slice(info.vert_range));
+ positions.slice(info.vert_range));
});
  
 -  if (profile.curve_type_counts()[CURVE_TYPE_BEZIER] > 0) {
 -const VArray curve_types = profile.curve_types();
 -const VArraySpan handle_types_left{profile.handle_types_left()};
 -const VArraySpan handle_types_right{profile.handle_types_right()};
 +  MutableAttributeAccessor mesh_attributes = mesh->attributes_for_write();
  
 +  SpanAttributeWriter sharp_edges;
 +  write_sharp_bezier_edges(curves_info, offsets, mesh_attributes, 
sharp_edges);
 +  if (fill_caps) {
 +if (!sharp_edges) {
 +  sharp_edges = 
mesh_attributes.lookup_or_add_for_write_span("sharp_edge",
 +   
ATTR_DOMAIN_EDGE);
 +}
  foreach_curve_combination(curves_info, offsets, [&](const CombinationInfo 
) {
 -  if 

[Bf-blender-cvs] [b061ace7485] tmp-workbench-rewrite2: Add explicit initializations to all classes/structs

2023-01-10 Thread Miguel Pozo
Commit: b061ace74851116b2ecc5d8b21a03a9430247c92
Author: Miguel Pozo
Date:   Tue Jan 10 17:36:32 2023 +0100
Branches: tmp-workbench-rewrite2
https://developer.blender.org/rBb061ace74851116b2ecc5d8b21a03a9430247c92

Add explicit initializations to all classes/structs

===

M   source/blender/draw/engines/workbench/workbench_private.hh

===

diff --git a/source/blender/draw/engines/workbench/workbench_private.hh 
b/source/blender/draw/engines/workbench/workbench_private.hh
index e1549884027..ee63f2c2010 100644
--- a/source/blender/draw/engines/workbench/workbench_private.hh
+++ b/source/blender/draw/engines/workbench/workbench_private.hh
@@ -39,9 +39,9 @@ class ShaderCache {
 };
 
 struct Material {
-  float3 base_color;
+  float3 base_color = float3(0);
   /* Packed data into a int. Decoded in the shader. */
-  uint packed_data;
+  uint packed_data = 0;
 
   Material();
   Material(float3 color);
@@ -60,38 +60,38 @@ void get_material_image(Object *ob,
 eGPUSamplerState _state);
 
 struct SceneState {
-  Scene *scene;
+  Scene *scene = nullptr;
 
-  Object *camera_object;
-  Camera *camera;
-  float4x4 view_projection_matrix;
-  int2 resolution;
+  Object *camera_object = nullptr;
+  Camera *camera = nullptr;
+  float4x4 view_projection_matrix = float4x4::identity();
+  int2 resolution = int2(0);
 
-  eContextObjectMode object_mode;
+  eContextObjectMode object_mode = CTX_MODE_OBJECT;
 
-  View3DShading shading;
+  View3DShading shading = {};
   eLightingType lighting_type = eLightingType::STUDIO;
-  bool xray_mode;
+  bool xray_mode = false;
 
-  DRWState cull_state;
+  DRWState cull_state = DRW_STATE_NO_DRAW;
   Vector clip_planes = {};
 
-  float4 background_color;
+  float4 background_color = float4(0);
 
-  bool draw_cavity;
-  bool draw_curvature;
-  bool draw_shadows;
-  bool draw_outline;
-  bool draw_dof;
-  bool draw_aa;
+  bool draw_cavity = false;
+  bool draw_curvature = false;
+  bool draw_shadows = false;
+  bool draw_outline = false;
+  bool draw_dof = false;
+  bool draw_aa = false;
 
-  bool draw_object_id;
-  bool draw_transparent_depth;
+  bool draw_object_id = false;
+  bool draw_transparent_depth = false;
 
-  int sample;
-  int samples_len;
-  bool reset_taa_next_sample;
-  bool render_finished;
+  int sample = 0;
+  int samples_len = 0;
+  bool reset_taa_next_sample = false;
+  bool render_finished = false;
 
   /* Used when material_type == eMaterialType::SINGLE */
   Material material_override = Material(float3(1.0f));
@@ -102,13 +102,13 @@ struct SceneState {
 };
 
 struct ObjectState {
-  eV3DShadingColorType color_type;
-  bool sculpt_pbvh;
-  bool texture_paint_mode;
-  ::Image *image_paint_override;
-  eGPUSamplerState override_sampler_state;
-  bool draw_shadow;
-  bool use_per_material_batches;
+  eV3DShadingColorType color_type = V3D_SHADING_SINGLE_COLOR;
+  bool sculpt_pbvh = false;
+  bool texture_paint_mode = false;
+  ::Image *image_paint_override = nullptr;
+  eGPUSamplerState override_sampler_state = GPU_SAMPLER_DEFAULT;
+  bool draw_shadow = false;
+  bool use_per_material_batches = false;
 
   ObjectState(const SceneState _state, Object *ob);
 };
@@ -119,12 +119,12 @@ class CavityEffect {
* workbench_composite_info.hh (cavity_samples) */
   static const int max_samples_ = 512;
 
-  UniformArrayBuffer samples_buf;
+  UniformArrayBuffer samples_buf = {};
 
-  int sample_;
-  int sample_count_;
-  bool curvature_enabled_;
-  bool cavity_enabled_;
+  int sample_ = 0;
+  int sample_count_ = 0;
+  bool curvature_enabled_ = false;
+  bool cavity_enabled_ = false;
 
  public:
   void init(const SceneState _state, struct SceneResources );
@@ -137,9 +137,9 @@ class CavityEffect {
 struct SceneResources {
   static const int jitter_tx_size = 64;
 
-  ShaderCache shader_cache;
+  ShaderCache shader_cache = {};
 
-  StringRefNull current_matcap;
+  StringRefNull current_matcap = {};
   Texture matcap_tx = "matcap_tx";
 
   TextureFromPool color_tx = "wb_color_tx";
@@ -148,12 +148,12 @@ struct SceneResources {
   TextureFromPool depth_in_front_tx = "wb_depth_in_front_tx";
 
   StorageVectorBuffer material_buf = {"material_buf"};
-  UniformBuffer world_buf;
+  UniformBuffer world_buf = {};
   UniformArrayBuffer clip_planes_buf;
 
   Texture jitter_tx = "wb_jitter_tx";
 
-  CavityEffect cavity;
+  CavityEffect cavity = {};
 
   void init(const SceneState _state);
   void load_jitter_tx(int total_samples);
@@ -163,11 +163,11 @@ class MeshPass : public PassMain {
  private:
   using TextureSubPassKey = std::pair;
 
-  Map texture_subpass_map_;
+  Map texture_subpass_map_ = {};
 
-  PassMain::Sub *passes_[geometry_type_len][shader_type_len];
+  PassMain::Sub *passes_[geometry_type_len][shader_type_len] = {{nullptr}};
 
-  bool is_empty_;
+  bool is_empty_ = false;
 
  public:
   MeshPass(const char *name);
@@ -193,7 +193,7 @@ 

[Bf-blender-cvs] [f1a90deb13f] tmp-workbench-rewrite2: Remove UNUSED macros (Needed after D16828)

2023-01-10 Thread Miguel Pozo
Commit: f1a90deb13fe57a8617f3fa034fa87abfb31e8d8
Author: Miguel Pozo
Date:   Tue Jan 10 17:08:27 2023 +0100
Branches: tmp-workbench-rewrite2
https://developer.blender.org/rBf1a90deb13fe57a8617f3fa034fa87abfb31e8d8

Remove UNUSED macros (Needed after D16828)

===

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

===

diff --git a/source/blender/draw/engines/workbench/workbench_effect_dof.cc 
b/source/blender/draw/engines/workbench/workbench_effect_dof.cc
index e68a64bf69d..582adeb4ed9 100644
--- a/source/blender/draw/engines/workbench/workbench_effect_dof.cc
+++ b/source/blender/draw/engines/workbench/workbench_effect_dof.cc
@@ -237,7 +237,7 @@ void DofPass::draw(Manager , View , 
SceneResources , int2
   };
   CallbackData callback_data = {manager, view, down2_ps_};
 
-  auto downsample_level = [](void *callback_data, int UNUSED(level)) {
+  auto downsample_level = [](void *callback_data, int /*level*/) {
 CallbackData *cd = static_cast(callback_data);
 cd->manager.submit(cd->pass, cd->view);
   };
diff --git a/source/blender/draw/engines/workbench/workbench_engine.cc 
b/source/blender/draw/engines/workbench/workbench_engine.cc
index ce0e0f9347d..b63f63f7109 100644
--- a/source/blender/draw/engines/workbench/workbench_engine.cc
+++ b/source/blender/draw/engines/workbench/workbench_engine.cc
@@ -644,8 +644,8 @@ static void workbench_render_to_image(void *vedata,
 workbench_cache_init(vedata);
 auto workbench_render_cache = [](void *vedata,
  struct Object *ob,
- struct RenderEngine *UNUSED(engine),
- struct Depsgraph *UNUSED(depsgraph)) {
+ struct RenderEngine * /*engine*/,
+ struct Depsgraph * /*depsgraph*/) {
   workbench_cache_populate(vedata, ob);
 };
 DRW_render_object_iter(vedata, engine, depsgraph, workbench_render_cache);

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

2023-01-10 Thread Miguel Pozo
Commit: 47a629b972f78e3008bed6680c170922fdbef12b
Author: Miguel Pozo
Date:   Tue Jan 10 16:02:00 2023 +0100
Branches: tmp-workbench-rewrite2
https://developer.blender.org/rB47a629b972f78e3008bed6680c170922fdbef12b

Merge branch 'master' into tmp-workbench-rewrite2

===



===

diff --cc source/blender/gpu/intern/gpu_texture_private.hh
index 20543391691,344ec911adc..1b3c04a78f9
--- a/source/blender/gpu/intern/gpu_texture_private.hh
+++ b/source/blender/gpu/intern/gpu_texture_private.hh
@@@ -41,10 -41,10 +41,10 @@@ typedef enum eGPUTextureType 
GPU_TEXTURE_CUBE_ARRAY = (GPU_TEXTURE_CUBE | GPU_TEXTURE_ARRAY),
  } eGPUTextureType;
  
 -ENUM_OPERATORS(eGPUTextureType, GPU_TEXTURE_CUBE_ARRAY)
 +ENUM_OPERATORS(eGPUTextureType, GPU_TEXTURE_BUFFER)
  
  /* Format types for samplers within the shader.
-  * This covers the sampler format type permutations within GLSL/MSL.*/
+  * This covers the sampler format type permutations within GLSL/MSL. */
  typedef enum eGPUSamplerFormat {
GPU_SAMPLER_TYPE_FLOAT = 0,
GPU_SAMPLER_TYPE_INT = 1,
diff --cc source/blender/makesdna/DNA_userdef_types.h
index 6654961f740,4c9568d9228..09f03706c00
--- a/source/blender/makesdna/DNA_userdef_types.h
+++ b/source/blender/makesdna/DNA_userdef_types.h
@@@ -652,9 -652,6 +652,8 @@@ typedef struct UserDef_Experimental 
char use_override_templates;
char enable_eevee_next;
char use_sculpt_texture_paint;
-   char use_realtime_compositor;
 +  char enable_workbench_next;
-   char _pad[6];
++  char _pad[7];
/** `makesdna` does not allow empty structs. */
  } UserDef_Experimental;

___
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] [8a3a1a0c144] master: Fix T103781: assert when connecting viewer node on mesh without faces

2023-01-10 Thread Jacques Lucke
Commit: 8a3a1a0c14468fd397548378ce4499e566b274a3
Author: Jacques Lucke
Date:   Tue Jan 10 17:13:12 2023 +0100
Branches: master
https://developer.blender.org/rB8a3a1a0c14468fd397548378ce4499e566b274a3

Fix T103781: assert when connecting viewer node on mesh without faces

`Span.data()` does not have to be `nullptr` when the size is zero.
This happens e.g. when slicing a span to a size of zero.

===

M   source/blender/blenlib/BLI_generic_array.hh

===

diff --git a/source/blender/blenlib/BLI_generic_array.hh 
b/source/blender/blenlib/BLI_generic_array.hh
index 03dc8814309..c46dbe0c907 100644
--- a/source/blender/blenlib/BLI_generic_array.hh
+++ b/source/blender/blenlib/BLI_generic_array.hh
@@ -89,11 +89,8 @@ class GArray {
*/
   GArray(const GSpan span, Allocator allocator = {}) : GArray(span.type(), 
span.size(), allocator)
   {
-if (span.data() != nullptr) {
-  BLI_assert(span.size() != 0);
-  /* Use copy assign rather than construct since the memory is already 
initialized. */
-  type_->copy_assign_n(span.data(), data_, size_);
-}
+/* Use copy assign rather than construct since the memory is already 
initialized. */
+type_->copy_assign_n(span.data(), data_, size_);
   }
 
   /**

___
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] [db688b62f9e] master: Fix T103764: Grease Pencil modes other than Draw use a wrong radial

2023-01-10 Thread Antonio Vazquez
Commit: db688b62f9e2d5a73d7bfaaac7cb0f5b2e8c1d6b
Author: Antonio Vazquez
Date:   Tue Jan 10 17:00:43 2023 +0100
Branches: master
https://developer.blender.org/rBdb688b62f9e2d5a73d7bfaaac7cb0f5b2e8c1d6b

Fix T103764: Grease Pencil modes other than Draw use a wrong radial

It was introduced in commit https://developer.blender.org/rB0fb12a9c2ebc

The problem was that the tool uses the same values for all modes,
but the new calculation must be only for Draw mode.

Now the mode is checked.

===

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

===

diff --git a/source/blender/editors/gpencil/gpencil_utils.c 
b/source/blender/editors/gpencil/gpencil_utils.c
index 1f80cd06af2..a7895b94600 100644
--- a/source/blender/editors/gpencil/gpencil_utils.c
+++ b/source/blender/editors/gpencil/gpencil_utils.c
@@ -1786,7 +1786,8 @@ float ED_gpencil_radial_control_scale(struct bContext *C,
   const int mval[2])
 {
   float scale_fac = 1.0f;
-  if ((brush && brush->gpencil_settings) && (brush->gpencil_tool == 
GPAINT_TOOL_DRAW)) {
+  if ((brush && brush->gpencil_settings) && (brush->ob_mode == 
OB_MODE_PAINT_GPENCIL) &&
+  (brush->gpencil_tool == GPAINT_TOOL_DRAW)) {
 float cursor_radius = ED_gpencil_cursor_radius(C, mval[0], mval[1]);
 scale_fac = max_ff(cursor_radius, 1.0f) / max_ff(initial_value, 1.0f);
   }

___
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] [e63671c21d7] blender-projects-basics: Support & use new asset library path query from master

2023-01-10 Thread Julian Eisel
Commit: e63671c21d7b07dfb0966ba710aac9b6d7e9306c
Author: Julian Eisel
Date:   Tue Jan 10 16:45:39 2023 +0100
Branches: blender-projects-basics
https://developer.blender.org/rBe63671c21d7b07dfb0966ba710aac9b6d7e9306c

Support & use new asset library path query from master

===

M   source/blender/asset_system/intern/asset_library_service.cc
M   source/blender/editors/asset/intern/asset_list.cc
M   source/blender/editors/space_file/filesel.cc

===

diff --git a/source/blender/asset_system/intern/asset_library_service.cc 
b/source/blender/asset_system/intern/asset_library_service.cc
index acfb49770cd..f2e0250dde6 100644
--- a/source/blender/asset_system/intern/asset_library_service.cc
+++ b/source/blender/asset_system/intern/asset_library_service.cc
@@ -4,9 +4,14 @@
  * \ingroup asset_system
  */
 
+#include 
+#include 
+
 #include "BKE_asset_library_custom.h"
 #include "BKE_blender.h"
+#include "BKE_blender_project.h"
 
+#include "BLI_path_util.h"
 #include "BLI_string_ref.hh"
 
 #include "DNA_asset_types.h"
@@ -188,16 +193,49 @@ std::string 
AssetLibraryService::root_path_from_library_ref(
 return "";
   }
 
-  BLI_assert(library_reference.type == ASSET_LIBRARY_CUSTOM);
   BLI_assert(library_reference.custom_library_index >= 0);
 
-  bUserAssetLibrary *user_library = 
BKE_preferences_asset_library_find_from_index(
-  , library_reference.custom_library_index);
-  if (!user_library || !user_library->path[0]) {
-return "";
+  switch (library_reference.type) {
+case ASSET_LIBRARY_CUSTOM_FROM_PREFERENCES: {
+  CustomAssetLibraryDefinition *user_library = 
BKE_asset_library_custom_find_from_index(
+  _libraries, library_reference.custom_library_index);
+  if (user_library && user_library->path[0]) {
+return user_library->path;
+  }
+  break;
+}
+case ASSET_LIBRARY_CUSTOM_FROM_PROJECT: {
+  BlenderProject *project = BKE_project_active_get();
+  if (!project) {
+return "";
+  }
+
+  ListBase *project_libraries = 
BKE_project_custom_asset_libraries_get(project);
+  CustomAssetLibraryDefinition *project_library_ = 
BKE_asset_library_custom_find_from_index(
+  project_libraries, library_reference.custom_library_index);
+  if (!project_library_) {
+return "";
+  }
+
+  /* Project asset libraries typically use relative paths (relative to 
project root directory).
+   */
+  if (BLI_path_is_rel(project_library_->path)) {
+const char *project_root_path = BKE_project_root_path_get(project);
+char path[1024]; /* FILE_MAX */
+BLI_path_join(path, sizeof(path), project_root_path, 
project_library_->path);
+return path;
+  }
+  else {
+return project_library_->path;
+  }
+  break;
+}
+default:
+  BLI_assert_unreachable();
+  break;
   }
 
-  return user_library->path;
+  return "";
 }
 
 void AssetLibraryService::allocate_service_instance()
diff --git a/source/blender/editors/asset/intern/asset_list.cc 
b/source/blender/editors/asset/intern/asset_list.cc
index b23223ed02b..a6089cf8ae6 100644
--- a/source/blender/editors/asset/intern/asset_list.cc
+++ b/source/blender/editors/asset/intern/asset_list.cc
@@ -153,16 +153,6 @@ void AssetList::setup()
   filelist_setindexer(files, use_asset_indexer ? _indexer_asset : 
_indexer_noop);
 
   char path[FILE_MAXDIR] = "";
-#if 0
-   /* Project asset libraries typically use relative paths (relative to 
project root directory).
-   */
-  if ((library_ref_.type == ASSET_LIBRARY_CUSTOM_FROM_PROJECT) &&
-  BLI_path_is_rel(custom_library->path)) {
-BlenderProject *project = CTX_wm_project();
-const char *project_root_path = BKE_project_root_path_get(project);
-BLI_path_join(path, sizeof(path), project_root_path, custom_library->path);
-  }
-#endif
   if (!asset_lib_path.empty()) {
 BLI_strncpy(path, asset_lib_path.c_str(), sizeof(path));
   }
diff --git a/source/blender/editors/space_file/filesel.cc 
b/source/blender/editors/space_file/filesel.cc
index 3654979d661..da76ba81da9 100644
--- a/source/blender/editors/space_file/filesel.cc
+++ b/source/blender/editors/space_file/filesel.cc
@@ -23,6 +23,8 @@
 #  include 
 #endif
 
+#include "AS_asset_library.hh"
+
 #include "DNA_screen_types.h"
 #include "DNA_space_types.h"
 #include "DNA_userdef_types.h"
@@ -412,45 +414,26 @@ static void 
fileselect_refresh_asset_params(FileAssetSelectParams *asset_params)
 {
   AssetLibraryReference *library = _params->asset_library_ref;
   FileSelectParams *base_params = _params->base_params;
-  CustomAssetLibraryDefinition *custom_library =
-  ED_asset_library_find_custom_library_from_reference(library);
 
   /* Ensure valid asset library, or fall-back to local one. */
-  if (!custom_library) {
+  if (!ED_asset_library_find_custom_library_from_reference(library)) {

[Bf-blender-cvs] [3ff321bc982] blender-projects-basics: Merge branch 'master' into blender-projects-basics

2023-01-10 Thread Julian Eisel
Commit: 3ff321bc98233163b0b3e53107683b030a2ef936
Author: Julian Eisel
Date:   Tue Jan 10 16:37:29 2023 +0100
Branches: blender-projects-basics
https://developer.blender.org/rB3ff321bc98233163b0b3e53107683b030a2ef936

Merge branch 'master' into blender-projects-basics

===



===



___
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] [9b8c2f91f60] master: Cleanup: Compile `filesel.c` in C++

2023-01-10 Thread Julian Eisel
Commit: 9b8c2f91f6065593aeed36067ce74fe5991233fb
Author: Julian Eisel
Date:   Tue Jan 10 16:33:00 2023 +0100
Branches: master
https://developer.blender.org/rB9b8c2f91f6065593aeed36067ce74fe5991233fb

Cleanup: Compile `filesel.c` in C++

This is a mere "get this to compile in C++", didn't do changes like
using `MEM_cnew()` instead of `MEM_calloc()`.

Needed for the blender-project-basics branch, so I don't have to write C
wrappers for a single call from this file.

===

M   source/blender/editors/space_file/CMakeLists.txt
R097source/blender/editors/space_file/filesel.c 
source/blender/editors/space_file/filesel.cc

===

diff --git a/source/blender/editors/space_file/CMakeLists.txt 
b/source/blender/editors/space_file/CMakeLists.txt
index ede48060126..2c3b775f796 100644
--- a/source/blender/editors/space_file/CMakeLists.txt
+++ b/source/blender/editors/space_file/CMakeLists.txt
@@ -32,7 +32,7 @@ set(SRC
   file_panels.c
   file_utils.c
   filelist.cc
-  filesel.c
+  filesel.cc
   folder_history.cc
   fsmenu.c
   space_file.c
diff --git a/source/blender/editors/space_file/filesel.c 
b/source/blender/editors/space_file/filesel.cc
similarity index 97%
rename from source/blender/editors/space_file/filesel.c
rename to source/blender/editors/space_file/filesel.cc
index 0b0ab2b0d66..32181a9f5f6 100644
--- a/source/blender/editors/space_file/filesel.c
+++ b/source/blender/editors/space_file/filesel.cc
@@ -5,9 +5,9 @@
  * \ingroup spfile
  */
 
-#include 
-#include 
-#include 
+#include 
+#include 
+#include 
 
 #include 
 #include 
@@ -99,8 +99,8 @@ static void fileselect_ensure_updated_asset_params(SpaceFile 
*sfile)
   FileAssetSelectParams *asset_params = sfile->asset_params;
 
   if (!asset_params) {
-asset_params = sfile->asset_params = MEM_callocN(sizeof(*asset_params),
- "FileAssetSelectParams");
+asset_params = sfile->asset_params = static_cast(
+MEM_callocN(sizeof(*asset_params), "FileAssetSelectParams"));
 asset_params->base_params.details_flags = 
U_default.file_space_data.details_flags;
 asset_params->asset_library_ref.type = ASSET_LIBRARY_LOCAL;
 asset_params->asset_library_ref.custom_library_index = -1;
@@ -139,7 +139,8 @@ static FileSelectParams 
*fileselect_ensure_updated_file_params(SpaceFile *sfile)
 
   /* create new parameters if necessary */
   if (!sfile->params) {
-sfile->params = MEM_callocN(sizeof(FileSelectParams), "fileselparams");
+sfile->params = static_cast(
+MEM_callocN(sizeof(FileSelectParams), "fileselparams"));
 /* set path to most recently opened .blend */
 BLI_split_dirfile(blendfile_path,
   sfile->params->dir,
@@ -534,7 +535,7 @@ void ED_fileselect_activate_by_id(SpaceFile *sfile, ID 
*asset_id, const bool def
 
 static void on_reload_select_by_relpath(SpaceFile *sfile, onReloadFnData 
custom_data)
 {
-  const char *relative_path = custom_data;
+  const char *relative_path = static_cast(custom_data);
   ED_fileselect_activate_by_relpath(sfile, relative_path);
 }
 
@@ -879,7 +880,9 @@ FileAttributeColumnType 
file_attribute_column_type_find_isect(const View2D *v2d,
 /* Column header drawing doesn't use left tile border, so subtract it. */
 rel_x = mx - (tile_x - layout->tile_border_x);
 
-for (FileAttributeColumnType column = 0; column < ATTRIBUTE_COLUMN_MAX; 
column++) {
+for (FileAttributeColumnType column = FileAttributeColumnType(0);
+ column < ATTRIBUTE_COLUMN_MAX;
+ column = FileAttributeColumnType(int(column) + 1)) {
   if (!file_attribute_column_type_enabled(params, column)) {
 continue;
   }
@@ -940,8 +943,10 @@ static void file_attribute_columns_widths(const 
FileSelectParams *params, FileLa
   /* Name column uses remaining width */
   else {
 int remwidth = layout->tile_w;
-for (FileAttributeColumnType column_type = ATTRIBUTE_COLUMN_MAX - 1; 
column_type >= 0;
- column_type--) {
+for (FileAttributeColumnType column_type =
+ FileAttributeColumnType(int(ATTRIBUTE_COLUMN_MAX) - 1);
+ column_type >= 0;
+ column_type = FileAttributeColumnType(int(column_type) - 1)) {
   if ((column_type == COLUMN_NAME) ||
   !file_attribute_column_type_enabled(params, column_type)) {
 continue;
@@ -978,7 +983,8 @@ void ED_fileselect_init_layout(struct SpaceFile *sfile, 
ARegion *region)
   int textheight;
 
   if (sfile->layout == NULL) {
-sfile->layout = MEM_callocN(sizeof(struct FileLayout), "file_layout");
+sfile->layout = static_cast(
+MEM_callocN(sizeof(struct FileLayout), "file_layout"));
 sfile->layout->dirty = true;
   }
   else if (sfile->layout->dirty == false) {
@@ -1084,7 +1090,7 @@ void ED_file_change_dir_ex(bContext *C, ScrArea *area)
   if (UNLIKELY(area->spacetype != SPACE_FILE)) {

[Bf-blender-cvs] [df5ebd348b6] master: Fix T103556: Cycles viewport unexpected pixel changes when hovering over UI

2023-01-10 Thread Brecht Van Lommel
Commit: df5ebd348b66c16084c47543f95a15fc53da5a0f
Author: Brecht Van Lommel
Date:   Tue Jan 10 16:31:21 2023 +0100
Branches: master
https://developer.blender.org/rBdf5ebd348b66c16084c47543f95a15fc53da5a0f

Fix T103556: Cycles viewport unexpected pixel changes when hovering over UI

With the GPU API the sampler can not be set after texture binding, which caused
a delay of the actual change. Now do both in a single call for correctness and
performance.

===

M   intern/cycles/blender/display_driver.cpp

===

diff --git a/intern/cycles/blender/display_driver.cpp 
b/intern/cycles/blender/display_driver.cpp
index 58f179d1824..8df0061d8ca 100644
--- a/intern/cycles/blender/display_driver.cpp
+++ b/intern/cycles/blender/display_driver.cpp
@@ -721,8 +721,6 @@ static void draw_tile(const float2 ,
 return;
   }
 
-  GPU_texture_bind(texture.gpu_texture, 0);
-
   /* Trick to keep sharp rendering without jagged edges on all GPUs.
*
* The idea here is to enforce driver to use linear interpolation when the 
image is not zoomed
@@ -735,14 +733,14 @@ static void draw_tile(const float2 ,
   const float zoomed_height = draw_tile.params.size.y * zoom.y;
   if (texture.width != draw_tile.params.size.x || texture.height != 
draw_tile.params.size.y) {
 /* Resolution divider is different from 1, force nearest interpolation. */
-GPU_texture_filter_mode(texture.gpu_texture, false);
+GPU_texture_bind_ex(texture.gpu_texture, GPU_SAMPLER_DEFAULT, 0, false);
   }
   else if (zoomed_width - draw_tile.params.size.x > 0.5f ||
zoomed_height - draw_tile.params.size.y > 0.5f) {
-GPU_texture_filter_mode(texture.gpu_texture, false);
+GPU_texture_bind_ex(texture.gpu_texture, GPU_SAMPLER_DEFAULT, 0, false);
   }
   else {
-GPU_texture_filter_mode(texture.gpu_texture, true);
+GPU_texture_bind_ex(texture.gpu_texture, GPU_SAMPLER_FILTER, 0, false);
   }
 
   /* Draw at the parameters for which the texture has been updated for. This 
allows to always draw

___
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] [f0eba2fe6c2] blender-projects-basics: Merge branch 'master' into blender-projects-basics

2023-01-10 Thread Julian Eisel
Commit: f0eba2fe6c2a7d2d0d44b27c595b14b43956d26e
Author: Julian Eisel
Date:   Tue Jan 10 15:54:27 2023 +0100
Branches: blender-projects-basics
https://developer.blender.org/rBf0eba2fe6c2a7d2d0d44b27c595b14b43956d26e

Merge branch 'master' into blender-projects-basics

===



===

diff --cc source/blender/asset_system/intern/asset_library_service.cc
index 41d44867d7e,af48a173bc0..acfb49770cd
--- a/source/blender/asset_system/intern/asset_library_service.cc
+++ b/source/blender/asset_system/intern/asset_library_service.cc
@@@ -56,26 -57,31 +57,32 @@@ void AssetLibraryService::destroy(
  AssetLibrary *AssetLibraryService::get_asset_library(
  const Main *bmain, const AssetLibraryReference _reference)
  {
-   if (library_reference.type == ASSET_LIBRARY_LOCAL) {
- /* For the "Current File" library  we get the asset library root path 
based on main. */
- std::string root_path = bmain ? 
AS_asset_library_find_suitable_root_path_from_main(bmain) : "";
- 
- if (root_path.empty()) {
-   /* File wasn't saved yet. */
-   return get_asset_library_current_file();
+   const eAssetLibraryType type = eAssetLibraryType(library_reference.type);
+ 
+   switch (type) {
+ case ASSET_LIBRARY_LOCAL: {
+   /* For the "Current File" library  we get the asset library root path 
based on main. */
+   std::string root_path = bmain ? 
AS_asset_library_find_suitable_root_path_from_main(bmain) :
+   "";
+ 
+   if (root_path.empty()) {
+ /* File wasn't saved yet. */
+ return get_asset_library_current_file();
+   }
+   return get_asset_library_on_disk(root_path);
  }
- 
- return get_asset_library_on_disk(root_path);
-   }
-   if (library_reference.type == ASSET_LIBRARY_CUSTOM_FROM_PREFERENCES) {
- CustomAssetLibraryDefinition *user_library = 
BKE_asset_library_custom_find_from_index(
- _libraries, library_reference.custom_library_index);
- 
- if (user_library) {
-   return get_asset_library_on_disk(user_library->path);
+ case ASSET_LIBRARY_ALL:
+   return get_asset_library_all(bmain);
 -case ASSET_LIBRARY_CUSTOM: {
++case ASSET_LIBRARY_CUSTOM_FROM_PREFERENCES: {
+   std::string root_path = root_path_from_library_ref(library_reference);
+ 
+   if (!root_path.empty()) {
+ return get_asset_library_on_disk(root_path);
+   }
+   break;
  }
}
 +  /* TODO project libraries */
  
return nullptr;
  }
diff --cc source/blender/editors/asset/ED_asset_library.h
index c5f526e18d5,c4baadc23c8..4746e0bb3e7
--- a/source/blender/editors/asset/ED_asset_library.h
+++ b/source/blender/editors/asset/ED_asset_library.h
@@@ -29,13 -29,14 +29,16 @@@ AssetLibraryReference ED_asset_library_
   * Since this is meant for UI display, skips non-displayable libraries, that 
is, libraries with an
   * empty name or path.
   *
-  * \param include_local_library: Whether to include the "Current File" 
library or not.
+  * \param include_generated: Whether to include libraries that are generated 
and thus cannot be
+  *   written to. Setting this to false means only 
custom libraries will be
+  *   included, since they are stored on disk with a 
single root directory,
+  *   thus have a well defined location that can be 
written to.
   */
  const struct EnumPropertyItem *ED_asset_library_reference_to_rna_enum_itemf(
- bool include_local_library);
+ bool include_generated);
  
 +struct CustomAssetLibraryDefinition 
*ED_asset_library_find_custom_library_from_reference(
 +const AssetLibraryReference *library_ref);
  #ifdef __cplusplus
  }
  #endif
diff --cc source/blender/editors/asset/intern/asset_library_reference_enum.cc
index 7d75dc83854,d20f3205a77..0bbc2b81038
--- a/source/blender/editors/asset/intern/asset_library_reference_enum.cc
+++ b/source/blender/editors/asset/intern/asset_library_reference_enum.cc
@@@ -44,10 -44,10 +44,10 @@@ AssetLibraryReference ED_asset_library_
AssetLibraryReference library;
  
/* Simple case: Predefined repository, just set the value. */
 -  if (value < ASSET_LIBRARY_CUSTOM) {
 +  if (value < ASSET_LIBRARY_CUSTOM_FROM_PREFERENCES) {
  library.type = value;
  library.custom_library_index = -1;
- BLI_assert(ELEM(value, ASSET_LIBRARY_LOCAL));
+ BLI_assert(ELEM(value, ASSET_LIBRARY_ALL, ASSET_LIBRARY_LOCAL));
  return library;
}
  
@@@ -74,35 -70,7 +74,34 @@@
return library;
  }
  
 +static void add_custom_asset_library_enum_items(
 +const ListBase * /*CustomAssetLibraryDefinition*/ libraries,
 +const eAssetLibraryType library_type,
 +EnumPropertyItem **items,
 +int *totitem)
 +{
 +  int i;
 +  LISTBASE_FOREACH_INDEX (CustomAssetLibraryDefinition *, custom_library, 
libraries, i) {
 +/* Note that the path 

[Bf-blender-cvs] [3a98dc68120] master: Fix crash when dragging video into VSE timeline

2023-01-10 Thread Richard Antalik
Commit: 3a98dc681206bd37917d76f35bcb9b846bad09e9
Author: Richard Antalik
Date:   Tue Jan 10 16:12:13 2023 +0100
Branches: master
https://developer.blender.org/rB3a98dc681206bd37917d76f35bcb9b846bad09e9

Fix crash when dragging video into VSE timeline

Caused by NULL dereference in strip overlap handling (expand to fit),
because `time_dependent_strips` strip collection is not created.

Check if strip collection is provided in `query_right_side_strips()`.

===

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 58f41d7e180..1edc4b85f96 100644
--- a/source/blender/sequencer/intern/strip_transform.c
+++ b/source/blender/sequencer/intern/strip_transform.c
@@ -309,7 +309,7 @@ static SeqCollection *query_right_side_strips(const Scene 
*scene,
 
   SeqCollection *collection = SEQ_collection_create(__func__);
   LISTBASE_FOREACH (Sequence *, seq, seqbase) {
-if (SEQ_collection_has_strip(seq, time_dependent_strips)) {
+if (time_dependent_strips != NULL && SEQ_collection_has_strip(seq, 
time_dependent_strips)) {
   continue;
 }
 if (SEQ_collection_has_strip(seq, transformed_strips)) {

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

2023-01-10 Thread Antonio Vazquez
Commit: 92cd94a437538dc55246b5b2f036abcb72af6c03
Author: Antonio Vazquez
Date:   Tue Jan 10 16:17:14 2023 +0100
Branches: gpencil-new-data-proposal
https://developer.blender.org/rB92cd94a437538dc55246b5b2f036abcb72af6c03

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

===



===



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


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

2023-01-10 Thread Antonio Vazquez
Commit: c68a31702a9f934bf88a09b00fabc254c1f70e20
Author: Antonio Vazquez
Date:   Tue Jan 10 16:14:52 2023 +0100
Branches: asset-lite-greasepencil
https://developer.blender.org/rBc68a31702a9f934bf88a09b00fabc254c1f70e20

Merge branch 'master' into asset-lite-greasepencil

===



===



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


[Bf-blender-cvs] [09a5443f201] master: GPencil: Fix unreported wrong fill vertex color in Outline

2023-01-10 Thread Antonio Vazquez
Commit: 09a5443f201e4a612e9fb31ce252d3c31370bf91
Author: Antonio Vazquez
Date:   Tue Jan 10 16:13:37 2023 +0100
Branches: master
https://developer.blender.org/rB09a5443f201e4a612e9fb31ce252d3c31370bf91

GPencil: Fix unreported wrong fill vertex color in Outline

The Fill vertex color was assigned to the wrong stroke. It needs to be
set in the perimeter stroke, not in the original one.

===

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

===

diff --git a/source/blender/editors/gpencil/gpencil_paint.c 
b/source/blender/editors/gpencil/gpencil_paint.c
index 547bda6a1e3..5814248f24c 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -963,7 +963,7 @@ static bGPDstroke *gpencil_stroke_to_outline(tGPsdata *p, 
bGPDstroke *gps)
   /* Set pressure constant. */
   gps_perimeter->thickness = max_ii((int)outline_thickness, 1);
   /* Apply Fill Vertex Color data. */
-  ED_gpencil_fill_vertex_color_set(p->scene->toolsettings, brush, gps);
+  ED_gpencil_fill_vertex_color_set(p->scene->toolsettings, brush, 
gps_perimeter);
 
   bGPDspoint *pt;
   for (int i = 0; i < gps_perimeter->totpoints; 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] [0b013d8873a] tmp-workbench-rewrite2: Code standards

2023-01-10 Thread Miguel Pozo
Commit: 0b013d8873a369daec86dcdb25a5f2c2a7575c73
Author: Miguel Pozo
Date:   Tue Jan 10 13:46:50 2023 +0100
Branches: tmp-workbench-rewrite2
https://developer.blender.org/rB0b013d8873a369daec86dcdb25a5f2c2a7575c73

Code standards

===

M   source/blender/draw/engines/workbench/workbench_private.hh

===

diff --git a/source/blender/draw/engines/workbench/workbench_private.hh 
b/source/blender/draw/engines/workbench/workbench_private.hh
index dd1d6b17daa..e1549884027 100644
--- a/source/blender/draw/engines/workbench/workbench_private.hh
+++ b/source/blender/draw/engines/workbench/workbench_private.hh
@@ -16,12 +16,6 @@ namespace blender::workbench {
 using namespace draw;
 
 class ShaderCache {
- private:
-  /* TODO(fclem): We might want to change to a Map since most shader will 
never be compiled. */
-  GPUShader 
*prepass_shader_cache_[pipeline_type_len][geometry_type_len][shader_type_len]
-  [lighting_type_len][2] = {nullptr};
-  GPUShader *resolve_shader_cache_[pipeline_type_len][lighting_type_len][2][2] 
= nullptr;
-
  public:
   ~ShaderCache();
 
@@ -35,6 +29,13 @@ class ShaderCache {
 eLightingType lighting_type,
 bool cavity = false,
 bool curvature = false);
+
+ private:
+  /* TODO(fclem): We might want to change to a Map since most shader will 
never be compiled. */
+  GPUShader 
*prepass_shader_cache_[pipeline_type_len][geometry_type_len][shader_type_len]
+  [lighting_type_len][2 /*clip*/] = 
{nullptr};
+  GPUShader *resolve_shader_cache_[pipeline_type_len][lighting_type_len][2 
/*cavity*/]
+  [2 /*curvature*/] = nullptr;
 };
 
 struct Material {
@@ -47,9 +48,9 @@ struct Material {
   Material(::Object , bool random = false);
   Material(::Material );
 
-  bool is_transparent();
-
   static uint32_t pack_data(float metallic, float roughness, float alpha);
+
+  bool is_transparent();
 };
 
 void get_material_image(Object *ob,
@@ -114,24 +115,28 @@ struct ObjectState {
 
 class CavityEffect {
  private:
-  int sample_;
-  int sample_count_;
-  bool curvature_enabled_;
-  bool cavity_enabled_;
-
   /* This value must be kept in sync with the one declared at
* workbench_composite_info.hh (cavity_samples) */
   static const int max_samples_ = 512;
+
   UniformArrayBuffer samples_buf;
 
-  void load_samples_buf(int ssao_samples);
+  int sample_;
+  int sample_count_;
+  bool curvature_enabled_;
+  bool cavity_enabled_;
 
  public:
   void init(const SceneState _state, struct SceneResources );
   void setup_resolve_pass(PassSimple , struct SceneResources );
+
+ private:
+  void load_samples_buf(int ssao_samples);
 };
 
 struct SceneResources {
+  static const int jitter_tx_size = 64;
+
   ShaderCache shader_cache;
 
   StringRefNull current_matcap;
@@ -146,28 +151,28 @@ struct SceneResources {
   UniformBuffer world_buf;
   UniformArrayBuffer clip_planes_buf;
 
-  static const int jitter_tx_size = 64;
   Texture jitter_tx = "wb_jitter_tx";
-  void load_jitter_tx(int total_samples);
 
   CavityEffect cavity;
 
   void init(const SceneState _state);
+  void load_jitter_tx(int total_samples);
 };
 
 class MeshPass : public PassMain {
  private:
-  PassMain::Sub *passes_[geometry_type_len][shader_type_len];
-
   using TextureSubPassKey = std::pair;
+
   Map texture_subpass_map_;
 
+  PassMain::Sub *passes_[geometry_type_len][shader_type_len];
+
   bool is_empty_;
 
  public:
   MeshPass(const char *name);
 
-  /* Move to draw::Pass */
+  /* TODO: Move to draw::Pass */
   bool is_empty() const;
 
   void init_pass(SceneResources , DRWState state, int clip_planes);
@@ -244,10 +249,8 @@ class TransparentDepthPass {
 };
 
 class ShadowPass {
-
-  bool enabled_;
-
-  enum PassType { Pass, Fail, ForcedFail, Length };
+ private:
+  enum PassType { PASS = 0, FAIL, FORCED_FAIL, MAX };
 
   class ShadowView : public View {
 bool force_fail_method_;
@@ -270,6 +273,8 @@ class ShadowPass {
 virtual VisibilityBuf _visibility_buffer();
   } view_ = {};
 
+  bool enabled_;
+
   UniformBuffer pass_data_;
 
   /* Draws are added to both passes and the visibily compute shader selects 
one of them */
@@ -279,9 +284,11 @@ class ShadowPass {
   /* In some cases, we know beforehand that we need to use the fail technique 
*/
   PassMain forced_fail_ps_ = {"Shadow.ForcedFail"};
 
-  PassMain::Sub *passes_[PassType::Length][2][2] = {{{nullptr}}};
+  /* [PassType][Is Manifold][Is Cap] */
+  PassMain::Sub *passes_[PassType::MAX][2][2] = {{{nullptr}}};
   PassMain::Sub *_pass_ptr(PassType type, bool manifold, bool cap = false);
 
+  /* [Is Pass Technique][Is Manifold][Is Cap] */
   GPUShader *shaders_[2][2][2] = {{{nullptr}}};
   GPUShader *get_shader(bool depth_pass, bool 

[Bf-blender-cvs] [128d4104bfe] tmp-workbench-rewrite2: Remove blender:: namespace

2023-01-10 Thread Miguel Pozo
Commit: 128d4104bfe459dcd279cce975c3c934775c4eaa
Author: Miguel Pozo
Date:   Mon Jan 9 18:13:39 2023 +0100
Branches: tmp-workbench-rewrite2
https://developer.blender.org/rB128d4104bfe459dcd279cce975c3c934775c4eaa

Remove blender:: namespace

===

M   source/blender/draw/engines/workbench/workbench_effect_antialiasing.cc
M   source/blender/draw/engines/workbench/workbench_shadow.cc

===

diff --git 
a/source/blender/draw/engines/workbench/workbench_effect_antialiasing.cc 
b/source/blender/draw/engines/workbench/workbench_effect_antialiasing.cc
index 94d15e7ff0f..91040390876 100644
--- a/source/blender/draw/engines/workbench/workbench_effect_antialiasing.cc
+++ b/source/blender/draw/engines/workbench/workbench_effect_antialiasing.cc
@@ -8,9 +8,9 @@
 namespace blender::workbench {
 
 class TaaSamples {
-  void init_samples(blender::Array , const int size)
+  void init_samples(Array , const int size)
   {
-samples = blender::Array(size);
+samples = Array(size);
 BLI_jitter_init((float(*)[2])samples.begin(), size);
 
 /* Find closest element to center */
@@ -58,11 +58,11 @@ class TaaSamples {
   }
 
  public:
-  blender::Array x5;
-  blender::Array x8;
-  blender::Array x11;
-  blender::Array x16;
-  blender::Array x32;
+  Array x5;
+  Array x8;
+  Array x11;
+  Array x16;
+  Array x32;
 
   TaaSamples()
   {
diff --git a/source/blender/draw/engines/workbench/workbench_shadow.cc 
b/source/blender/draw/engines/workbench/workbench_shadow.cc
index 85f12d9e71e..10a7ca19277 100644
--- a/source/blender/draw/engines/workbench/workbench_shadow.cc
+++ b/source/blender/draw/engines/workbench/workbench_shadow.cc
@@ -99,8 +99,8 @@ void ShadowPass::ShadowView::setup(View , float3 
light_direction, bool forc
   float4 frustum_planes[6];
   DRW_culling_frustum_planes_get(nullptr, (float(*)[4])frustum_planes);
 
-  blender::Vector faces_result = {};
-  blender::Vector corners_result = {};
+  Vector faces_result = {};
+  Vector corners_result = {};
 
   /* "Unlit" frustum faces are left "as-is" */
 
@@ -214,15 +214,15 @@ void 
ShadowPass::ShadowView::compute_visibility(ObjectBoundsBuf ,
   words_len = ceil_to_multiple_u(max_ii(1, words_len), 4);
   uint32_t data = 0xu;
 
-  if (current_pass_type_ == ShadowPass::Pass) {
+  if (current_pass_type_ == ShadowPass::PASS) {
 /* TODO(fclem): Resize to nearest pow2 to reduce fragmentation. */
 pass_visibility_buf_.resize(words_len);
 GPU_storagebuf_clear(pass_visibility_buf_, GPU_R32UI, GPU_DATA_UINT, 
);
 fail_visibility_buf_.resize(words_len);
 GPU_storagebuf_clear(fail_visibility_buf_, GPU_R32UI, GPU_DATA_UINT, 
);
   }
-  else if (current_pass_type_ == ShadowPass::Fail) {
-/* Already computed in the ShadowPass::Pass */
+  else if (current_pass_type_ == ShadowPass::FAIL) {
+/* Already computed in the ShadowPass::PASS */
 GPU_debug_group_end();
 return;
   }
@@ -239,8 +239,8 @@ void 
ShadowPass::ShadowView::compute_visibility(ObjectBoundsBuf ,
 static GPUShader *static_pass_type_shader = 
GPU_shader_create_from_info_name(
 "workbench_next_shadow_visibility_compute_static_pass_type");
 
-GPUShader *shader = current_pass_type_ == ShadowPass::ForcedFail ? 
static_pass_type_shader :
-   
dynamic_pass_type_shader;
+GPUShader *shader = current_pass_type_ == ShadowPass::FORCED_FAIL ? 
static_pass_type_shader :
+
dynamic_pass_type_shader;
 GPU_shader_bind(shader);
 GPU_shader_uniform_1i(shader, "resource_len", resource_len);
 GPU_shader_uniform_1i(shader, "view_len", view_len_);
@@ -250,7 +250,7 @@ void 
ShadowPass::ShadowView::compute_visibility(ObjectBoundsBuf ,
 GPU_uniformbuf_bind(extruded_frustum_,
 GPU_shader_get_uniform_block(shader, 
"extruded_frustum"));
 GPU_storagebuf_bind(bounds, GPU_shader_get_ssbo(shader, "bounds_buf"));
-if (current_pass_type_ == ShadowPass::ForcedFail) {
+if (current_pass_type_ == ShadowPass::FORCED_FAIL) {
   GPU_storagebuf_bind(visibility_buf_, GPU_shader_get_ssbo(shader, 
"visibility_buf"));
 }
 else {
@@ -270,11 +270,11 @@ void 
ShadowPass::ShadowView::compute_visibility(ObjectBoundsBuf ,
 VisibilityBuf ::ShadowView::get_visibility_buffer()
 {
   switch (current_pass_type_) {
-case ShadowPass::Pass:
+case ShadowPass::PASS:
   return pass_visibility_buf_;
-case ShadowPass::Fail:
+case ShadowPass::FAIL:
   return fail_visibility_buf_;
-case ShadowPass::ForcedFail:
+case ShadowPass::FORCED_FAIL:
   return visibility_buf_;
 default:
   BLI_assert_unreachable();
@@ -369,13 +369,13 @@ void ShadowPass::sync()
 
   /* Stencil Shadow passes. */
   for (bool manifold : {false, true}) {
-PassMain::Sub * = 

[Bf-blender-cvs] [ee51f6b3e9f] tmp-workbench-rewrite2: Use functional type casting

2023-01-10 Thread Miguel Pozo
Commit: ee51f6b3e9f2eb0caaecabb7cd4939c8163471cc
Author: Miguel Pozo
Date:   Mon Jan 9 18:25:16 2023 +0100
Branches: tmp-workbench-rewrite2
https://developer.blender.org/rBee51f6b3e9f2eb0caaecabb7cd4939c8163471cc

Use functional type  casting

===

M   source/blender/draw/engines/workbench/workbench_effect_cavity.cc
M   source/blender/draw/engines/workbench/workbench_effect_dof.cc

===

diff --git a/source/blender/draw/engines/workbench/workbench_effect_cavity.cc 
b/source/blender/draw/engines/workbench/workbench_effect_cavity.cc
index 31a419f733e..30363b19681 100644
--- a/source/blender/draw/engines/workbench/workbench_effect_cavity.cc
+++ b/source/blender/draw/engines/workbench/workbench_effect_cavity.cc
@@ -64,7 +64,7 @@ void CavityEffect::load_samples_buf(int ssao_samples)
 double dphi;
 BLI_hammersley_1d(i, );
 
-float phi = (float)dphi * 2.0f * M_PI + it_add;
+float phi = float(dphi) * 2.0f * M_PI + it_add;
 samples_buf[i].x = math::cos(phi);
 samples_buf[i].y = math::sin(phi);
 /* This deliberately distribute more samples
diff --git a/source/blender/draw/engines/workbench/workbench_effect_dof.cc 
b/source/blender/draw/engines/workbench/workbench_effect_dof.cc
index 0f80713fba9..e68a64bf69d 100644
--- a/source/blender/draw/engines/workbench/workbench_effect_dof.cc
+++ b/source/blender/draw/engines/workbench/workbench_effect_dof.cc
@@ -108,7 +108,7 @@ void DofPass::init(const SceneState _state)
 resolve_sh_ = 
GPU_shader_create_from_info_name("workbench_effect_dof_resolve");
   }
 
-  offset_ = scene_state.sample / (float)scene_state.samples_len;
+  offset_ = scene_state.sample / float(scene_state.samples_len);
 
   int2 half_res = scene_state.resolution / 2;
   half_res = {max_ii(half_res.x, 1), max_ii(half_res.y, 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] [8cbbfa8c293] tmp-workbench-rewrite2: Fix MSL compilation

2023-01-10 Thread Miguel Pozo
Commit: 8cbbfa8c293ce077d916e3c53da31618a490e960
Author: Miguel Pozo
Date:   Mon Jan 9 18:25:29 2023 +0100
Branches: tmp-workbench-rewrite2
https://developer.blender.org/rB8cbbfa8c293ce077d916e3c53da31618a490e960

Fix MSL compilation

===

M   
source/blender/draw/engines/workbench/shaders/workbench_next_composite_frag.glsl

===

diff --git 
a/source/blender/draw/engines/workbench/shaders/workbench_next_composite_frag.glsl
 
b/source/blender/draw/engines/workbench/shaders/workbench_next_composite_frag.glsl
index a66af6008d9..7a5b66d0879 100644
--- 
a/source/blender/draw/engines/workbench/shaders/workbench_next_composite_frag.glsl
+++ 
b/source/blender/draw/engines/workbench/shaders/workbench_next_composite_frag.glsl
@@ -72,10 +72,10 @@ void main()
   color = mix(color, world_data.object_outline_color, outline_opacity);
 #endif
 
-  if (color != world_data.background_color) {
-fragColor = color;
+  if (all(equal(color, world_data.background_color))) {
+discard;
   }
   else {
-discard;
+fragColor = color;
   }
 }

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


[Bf-blender-cvs] [f8eb85d9108] tmp-workbench-rewrite2: Split render output writing into their own functions

2023-01-10 Thread Miguel Pozo
Commit: f8eb85d91085f2ac2bf115916487843ca3d18f78
Author: Miguel Pozo
Date:   Mon Jan 9 17:32:29 2023 +0100
Branches: tmp-workbench-rewrite2
https://developer.blender.org/rBf8eb85d91085f2ac2bf115916487843ca3d18f78

Split render output writing into their own functions

===

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

===

diff --git a/source/blender/draw/engines/workbench/workbench_engine.cc 
b/source/blender/draw/engines/workbench/workbench_engine.cc
index c4115d996b4..ce0e0f9347d 100644
--- a/source/blender/draw/engines/workbench/workbench_engine.cc
+++ b/source/blender/draw/engines/workbench/workbench_engine.cc
@@ -521,6 +521,75 @@ static bool workbench_render_framebuffers_init(void)
 #  define GPU_FINISH_DELIMITER()
 #endif
 
+static void write_render_color_output(struct RenderLayer *layer,
+  const char *viewname,
+  GPUFrameBuffer *fb,
+  const struct rcti *rect)
+{
+  RenderPass *rp = RE_pass_find_by_name(layer, RE_PASSNAME_COMBINED, viewname);
+  if (rp) {
+GPU_framebuffer_bind(fb);
+GPU_framebuffer_read_color(fb,
+   rect->xmin,
+   rect->ymin,
+   BLI_rcti_size_x(rect),
+   BLI_rcti_size_y(rect),
+   4,
+   0,
+   GPU_DATA_FLOAT,
+   rp->rect);
+  }
+}
+
+static void write_render_z_output(struct RenderLayer *layer,
+  const char *viewname,
+  GPUFrameBuffer *fb,
+  const struct rcti *rect,
+  float4x4 winmat)
+{
+  RenderPass *rp = RE_pass_find_by_name(layer, RE_PASSNAME_Z, viewname);
+  if (rp) {
+GPU_framebuffer_bind(fb);
+GPU_framebuffer_read_depth(fb,
+   rect->xmin,
+   rect->ymin,
+   BLI_rcti_size_x(rect),
+   BLI_rcti_size_y(rect),
+   GPU_DATA_FLOAT,
+   rp->rect);
+
+int pix_num = BLI_rcti_size_x(rect) * BLI_rcti_size_y(rect);
+
+/* Convert ogl depth [0..1] to view Z [near..far] */
+if (DRW_view_is_persp_get(nullptr)) {
+  for (float  : MutableSpan(rp->rect, pix_num)) {
+if (z == 1.0f) {
+  z = 1e10f; /* Background */
+}
+else {
+  z = z * 2.0f - 1.0f;
+  z = winmat[3][2] / (z + winmat[2][2]);
+}
+  }
+}
+else {
+  /* Keep in mind, near and far distance are negatives. */
+  float near = DRW_view_near_distance_get(nullptr);
+  float far = DRW_view_far_distance_get(nullptr);
+  float range = fabsf(far - near);
+
+  for (float  : MutableSpan(rp->rect, pix_num)) {
+if (z == 1.0f) {
+  z = 1e10f; /* Background */
+}
+else {
+  z = z * range - near;
+}
+  }
+}
+  }
+}
+
 static void workbench_render_to_image(void *vedata,
   struct RenderEngine *engine,
   struct RenderLayer *layer,
@@ -597,66 +666,8 @@ static void workbench_render_to_image(void *vedata,
   } while (ved->instance->scene_state.sample + 1 < 
ved->instance->scene_state.samples_len);
 
   const char *viewname = RE_GetActiveRenderView(engine->re);
-  /* Write render output. */
-  {
-RenderPass *rp = RE_pass_find_by_name(layer, RE_PASSNAME_COMBINED, 
viewname);
-if (rp) {
-  GPU_framebuffer_bind(dfbl->default_fb);
-  GPU_framebuffer_read_color(dfbl->default_fb,
- rect->xmin,
- rect->ymin,
- BLI_rcti_size_x(rect),
- BLI_rcti_size_y(rect),
- 4,
- 0,
- GPU_DATA_FLOAT,
- rp->rect);
-}
-  }
-  /* Write render Z output */
-  {
-RenderPass *rp = RE_pass_find_by_name(layer, RE_PASSNAME_Z, viewname);
-if (rp) {
-  GPU_framebuffer_bind(dfbl->default_fb);
-  GPU_framebuffer_read_depth(dfbl->default_fb,
- rect->xmin,
- rect->ymin,
- BLI_rcti_size_x(rect),
- BLI_rcti_size_y(rect),
- GPU_DATA_FLOAT,
- rp->rect);
-
-  int pix_num = BLI_rcti_size_x(rect) * BLI_rcti_size_y(rect);
-
-  /* Convert ogl depth [0..1] to view Z [near..far] */
-  if 

[Bf-blender-cvs] [b87ae86e3cc] tmp-workbench-rewrite2: Class separators

2023-01-10 Thread Miguel Pozo
Commit: b87ae86e3cc588206dd00e04c18504b850b0e3cd
Author: Miguel Pozo
Date:   Mon Jan 9 17:39:16 2023 +0100
Branches: tmp-workbench-rewrite2
https://developer.blender.org/rBb87ae86e3cc588206dd00e04c18504b850b0e3cd

Class separators

===

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

===

diff --git a/source/blender/draw/engines/workbench/workbench_mesh_passes.cc 
b/source/blender/draw/engines/workbench/workbench_mesh_passes.cc
index 84c7c58f12f..d47a806b694 100644
--- a/source/blender/draw/engines/workbench/workbench_mesh_passes.cc
+++ b/source/blender/draw/engines/workbench/workbench_mesh_passes.cc
@@ -4,6 +4,10 @@
 
 namespace blender::workbench {
 
+/*  */
+/** \name MeshPass
+ * \{ */
+
 MeshPass::MeshPass(const char *name) : PassMain(name){};
 
 /* Move to draw::Pass */
@@ -99,6 +103,12 @@ void MeshPass::draw(ObjectRef ,

   handle);
 }
 
+/** \} */
+
+/*  */
+/** \name OpaquePass
+ * \{ */
+
 void OpaquePass::sync(const SceneState _state, SceneResources )
 {
   DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | 
DRW_STATE_DEPTH_LESS_EQUAL |
@@ -226,6 +236,12 @@ bool OpaquePass::is_empty() const
   return gbuffer_ps_.is_empty() && gbuffer_in_front_ps_.is_empty();
 }
 
+/** \} */
+
+/*  */
+/** \name TransparentPass
+ * \{ */
+
 void TransparentPass::sync(const SceneState _state, SceneResources 
)
 {
   DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL | 
DRW_STATE_BLEND_OIT |
@@ -297,6 +313,12 @@ bool TransparentPass::is_empty() const
   return accumulation_ps_.is_empty() && accumulation_in_front_ps_.is_empty();
 }
 
+/** \} */
+
+/*  */
+/** \name TransparentDepthPass
+ * \{ */
+
 void TransparentDepthPass::sync(const SceneState _state, SceneResources 
)
 {
   DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | 
DRW_STATE_DEPTH_LESS_EQUAL |
@@ -370,4 +392,6 @@ bool TransparentDepthPass::is_empty() const
   return main_ps_.is_empty() && in_front_ps_.is_empty();
 }
 
+/** \} */
+
 }  // namespace blender::workbench

___
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] [8f165c390d9] tmp-workbench-rewrite2: Fix Clang compilation

2023-01-10 Thread Miguel Pozo
Commit: 8f165c390d968068f9a257955e89ebd7b7c8d535
Author: Miguel Pozo
Date:   Mon Jan 9 17:43:29 2023 +0100
Branches: tmp-workbench-rewrite2
https://developer.blender.org/rB8f165c390d968068f9a257955e89ebd7b7c8d535

Fix Clang compilation

===

M   source/blender/draw/engines/workbench/workbench_private.hh

===

diff --git a/source/blender/draw/engines/workbench/workbench_private.hh 
b/source/blender/draw/engines/workbench/workbench_private.hh
index a413dc17ec5..dd1d6b17daa 100644
--- a/source/blender/draw/engines/workbench/workbench_private.hh
+++ b/source/blender/draw/engines/workbench/workbench_private.hh
@@ -9,7 +9,7 @@
 #include "workbench_enums.hh"
 #include "workbench_shader_shared.h"
 
-extern DrawEngineType draw_engine_workbench_next;
+extern "C" DrawEngineType draw_engine_workbench_next;
 
 namespace blender::workbench {

___
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] [5627c8acea5] tmp-workbench-rewrite2: Replace sinf/cosf with math::sin/cos

2023-01-10 Thread Miguel Pozo
Commit: 5627c8acea58e316164e39ddc883ffe8236e7599
Author: Miguel Pozo
Date:   Mon Jan 9 17:14:37 2023 +0100
Branches: tmp-workbench-rewrite2
https://developer.blender.org/rB5627c8acea58e316164e39ddc883ffe8236e7599

Replace sinf/cosf with math::sin/cos

===

M   source/blender/draw/engines/workbench/workbench_effect_antialiasing.cc
M   source/blender/draw/engines/workbench/workbench_effect_cavity.cc
M   source/blender/draw/engines/workbench/workbench_effect_dof.cc
M   source/blender/draw/engines/workbench/workbench_resources.cc

===

diff --git 
a/source/blender/draw/engines/workbench/workbench_effect_antialiasing.cc 
b/source/blender/draw/engines/workbench/workbench_effect_antialiasing.cc
index 313aad6244e..94d15e7ff0f 100644
--- a/source/blender/draw/engines/workbench/workbench_effect_antialiasing.cc
+++ b/source/blender/draw/engines/workbench/workbench_effect_antialiasing.cc
@@ -82,7 +82,8 @@ static float filter_blackman_harris(float x, const float 
width)
 return 0.0f;
   }
   x = 2.0f * M_PI * clamp_f((x / width + 0.5f), 0.0f, 1.0f);
-  return 0.35875f - 0.48829f * cosf(x) + 0.14128f * cosf(2.0f * x) - 0.01168f 
* cosf(3.0f * x);
+  return 0.35875f - 0.48829f * math::cos(x) + 0.14128f * math::cos(2.0f * x) -
+ 0.01168f * math::cos(3.0f * x);
 }
 
 /* Compute weights for the 3x3 neighborhood using a 1.5px filter. */
diff --git a/source/blender/draw/engines/workbench/workbench_effect_cavity.cc 
b/source/blender/draw/engines/workbench/workbench_effect_cavity.cc
index a87c0fa2ba1..31a419f733e 100644
--- a/source/blender/draw/engines/workbench/workbench_effect_cavity.cc
+++ b/source/blender/draw/engines/workbench/workbench_effect_cavity.cc
@@ -65,8 +65,8 @@ void CavityEffect::load_samples_buf(int ssao_samples)
 BLI_hammersley_1d(i, );
 
 float phi = (float)dphi * 2.0f * M_PI + it_add;
-samples_buf[i].x = cosf(phi);
-samples_buf[i].y = sinf(phi);
+samples_buf[i].x = math::cos(phi);
+samples_buf[i].y = math::sin(phi);
 /* This deliberately distribute more samples
  * at the center of the disk (and thus the shadow). */
 samples_buf[i].z = r;
diff --git a/source/blender/draw/engines/workbench/workbench_effect_dof.cc 
b/source/blender/draw/engines/workbench/workbench_effect_dof.cc
index 11d5cd33f4c..0f80713fba9 100644
--- a/source/blender/draw/engines/workbench/workbench_effect_dof.cc
+++ b/source/blender/draw/engines/workbench/workbench_effect_dof.cc
@@ -75,13 +75,13 @@ void DofPass::setup_samples()
 /* Bokeh shape parameterization. */
 if (blades_ > 1.0f) {
   float denom = T - (2.0 * M_PI / blades_) * floorf((blades_ * T + 
M_PI) / (2.0 * M_PI));
-  r *= cosf(M_PI / blades_) / cosf(denom);
+  r *= math::cos(M_PI / blades_) / math::cos(denom);
 }
 
 T += rotation_;
 
-sample->x = r * cosf(T) * ratio_;
-sample->y = r * sinf(T);
+sample->x = r * math::cos(T) * ratio_;
+sample->y = r * math::sin(T);
 sample->w = 0;
 sample++;
   }
diff --git a/source/blender/draw/engines/workbench/workbench_resources.cc 
b/source/blender/draw/engines/workbench/workbench_resources.cc
index 556df6a5366..84d624d22d5 100644
--- a/source/blender/draw/engines/workbench/workbench_resources.cc
+++ b/source/blender/draw/engines/workbench/workbench_resources.cc
@@ -78,8 +78,8 @@ void SceneResources::load_jitter_tx(int total_samples)
   for (int i = 0; i < texel_count; i++) {
 float phi = blue_noise[i][0] * 2.0f * M_PI;
 /* This rotate the sample per pixels */
-jitter[i].x = cosf(phi);
-jitter[i].y = sinf(phi);
+jitter[i].x = math::cos(phi);
+jitter[i].y = math::sin(phi);
 /* This offset the sample along its direction axis (reduce banding) */
 float bn = blue_noise[i][1] - 0.5f;
 bn = clamp_f(bn, -0.499f, 0.499f); /* fix fireflies */

___
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] [b17578a943d] tmp-workbench-rewrite2: Use std::swap

2023-01-10 Thread Miguel Pozo
Commit: b17578a943da17a510fedc023b2c9c58b2d88da4
Author: Miguel Pozo
Date:   Mon Jan 9 18:17:32 2023 +0100
Branches: tmp-workbench-rewrite2
https://developer.blender.org/rBb17578a943da17a510fedc023b2c9c58b2d88da4

Use std::swap

===

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

===

diff --git 
a/source/blender/draw/engines/workbench/workbench_effect_antialiasing.cc 
b/source/blender/draw/engines/workbench/workbench_effect_antialiasing.cc
index 91040390876..39b46c7ac1e 100644
--- a/source/blender/draw/engines/workbench/workbench_effect_antialiasing.cc
+++ b/source/blender/draw/engines/workbench/workbench_effect_antialiasing.cc
@@ -39,7 +39,7 @@ class TaaSamples {
 
 /* Swap center sample to the start of the array */
 if (closest_index != 0) {
-  swap_v2_v2(samples[0], samples[closest_index]);
+  std::swap(samples[0], samples[closest_index]);
 }
 
 /* Sort list based on farthest distance with previous. */
@@ -53,7 +53,7 @@ class TaaSamples {
   index = j;
 }
   }
-  swap_v2_v2(samples[i + 1], samples[index]);
+  std::swap(samples[i + 1], samples[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] [ed69fbadf73] tmp-workbench-rewrite2: Move get_dummy_gpu_materials to Instance

2023-01-10 Thread Miguel Pozo
Commit: ed69fbadf73dd091143b5c2bc42f25c448c61e2e
Author: Miguel Pozo
Date:   Mon Jan 9 17:25:11 2023 +0100
Branches: tmp-workbench-rewrite2
https://developer.blender.org/rBed69fbadf73dd091143b5c2bc42f25c448c61e2e

Move get_dummy_gpu_materials to Instance

===

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

===

diff --git a/source/blender/draw/engines/workbench/workbench_engine.cc 
b/source/blender/draw/engines/workbench/workbench_engine.cc
index e10bcf872ae..c4115d996b4 100644
--- a/source/blender/draw/engines/workbench/workbench_engine.cc
+++ b/source/blender/draw/engines/workbench/workbench_engine.cc
@@ -19,8 +19,6 @@ namespace blender::workbench {
 
 using namespace draw;
 
-GPUMaterial **get_dummy_gpu_materials(int material_count);
-
 class Instance {
  public:
   SceneState scene_state;
@@ -36,6 +34,17 @@ class Instance {
   DofPass dof_ps;
   AntiAliasingPass anti_aliasing_ps;
 
+  /* An array of nullptr GPUMaterial pointers so we can call 
DRW_cache_object_surface_material_get.
+   * They never get actually used. */
+  Vector dummy_gpu_materials = {1, nullptr, {}};
+  GPUMaterial **get_dummy_gpu_materials(int material_count)
+  {
+if (material_count > dummy_gpu_materials.size()) {
+  dummy_gpu_materials.resize(material_count, nullptr);
+}
+return dummy_gpu_materials.begin();
+  };
+
   void init(Object *camera_ob = nullptr)
   {
 scene_state.init(camera_ob);
@@ -365,18 +374,6 @@ class Instance {
   }
 };
 
-/* This returns an array of nullptr GPUMaterial pointers so we can call
- * DRW_cache_object_surface_material_get. They never get actually used.
- */
-GPUMaterial **get_dummy_gpu_materials(int material_count)
-{
-  static Vector dummy_gpu_materials(1, nullptr, {});
-  if (material_count > dummy_gpu_materials.size()) {
-dummy_gpu_materials.resize(material_count, nullptr);
-  }
-  return dummy_gpu_materials.begin();
-};
-
 }  // namespace blender::workbench
 
 /*  */

___
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] [8213d1735dd] tmp-workbench-rewrite2: Fix comments style

2023-01-10 Thread Miguel Pozo
Commit: 8213d1735dd805467f5b78d871427228e3d488f1
Author: Miguel Pozo
Date:   Mon Jan 9 17:09:32 2023 +0100
Branches: tmp-workbench-rewrite2
https://developer.blender.org/rB8213d1735dd805467f5b78d871427228e3d488f1

Fix comments style

===

M   
source/blender/draw/engines/workbench/shaders/infos/workbench_composite_info.hh
M   source/blender/draw/engines/workbench/workbench_effect_antialiasing.cc
M   source/blender/draw/engines/workbench/workbench_effect_dof.cc
M   source/blender/draw/engines/workbench/workbench_private.hh
M   source/blender/draw/engines/workbench/workbench_shadow.cc

===

diff --git 
a/source/blender/draw/engines/workbench/shaders/infos/workbench_composite_info.hh
 
b/source/blender/draw/engines/workbench/shaders/infos/workbench_composite_info.hh
index bd813a36c6e..c437605574d 100644
--- 
a/source/blender/draw/engines/workbench/shaders/infos/workbench_composite_info.hh
+++ 
b/source/blender/draw/engines/workbench/shaders/infos/workbench_composite_info.hh
@@ -58,7 +58,7 @@ GPU_SHADER_CREATE_INFO(workbench_next_composite)
 .fragment_source("workbench_next_composite_frag.glsl")
 .additional_info("draw_fullscreen", "draw_view");
 
-// Lighting
+/* Lighting */
 
 
GPU_SHADER_CREATE_INFO(workbench_next_resolve_opaque_studio).define("WORKBENCH_LIGHTING_STUDIO");
 
@@ -68,7 +68,7 @@ GPU_SHADER_CREATE_INFO(workbench_next_resolve_opaque_matcap)
 
 
GPU_SHADER_CREATE_INFO(workbench_next_resolve_opaque_flat).define("WORKBENCH_LIGHTING_FLAT");
 
-// Effects
+/* Effects */
 
 GPU_SHADER_CREATE_INFO(workbench_next_resolve_curvature)
 .define("WORKBENCH_CURVATURE")
@@ -78,9 +78,9 @@ GPU_SHADER_CREATE_INFO(workbench_next_resolve_cavity)
 .define("WORKBENCH_CAVITY")
 .sampler(8, ImageType::FLOAT_2D, "jitter_tx") /* TODO(Miguel Pozo): 
GPU_SAMPLER_REPEAT is set
  in CavityEffect, it 
doesn't work here ? */
-.uniform_buf(5, "float4", "cavity_samples[512]");
+.uniform_buf(5, "vec4", "cavity_samples[512]");
 
-// Variations
+/* Variations */
 
 #define WORKBENCH_FINAL_VARIATION(name, ...) \
   
GPU_SHADER_CREATE_INFO(name).additional_info(__VA_ARGS__).do_static_compilation(true);
diff --git 
a/source/blender/draw/engines/workbench/workbench_effect_antialiasing.cc 
b/source/blender/draw/engines/workbench/workbench_effect_antialiasing.cc
index 17e1acb15e4..313aad6244e 100644
--- a/source/blender/draw/engines/workbench/workbench_effect_antialiasing.cc
+++ b/source/blender/draw/engines/workbench/workbench_effect_antialiasing.cc
@@ -13,7 +13,7 @@ class TaaSamples {
 samples = blender::Array(size);
 BLI_jitter_init((float(*)[2])samples.begin(), size);
 
-/* find closest element to center */
+/* Find closest element to center */
 int closest_index = 0;
 float closest_squared_distance = 1.0f;
 
@@ -29,7 +29,7 @@ class TaaSamples {
 float2 closest_sample = samples[closest_index];
 
 for (float2  : samples) {
-  /* move jitter samples so that closest sample is in center */
+  /* Move jitter samples so that closest sample is in center */
   sample -= closest_sample;
   /* Avoid samples outside range (wrap around). */
   sample = {fmodf(sample.x + 0.5f, 1.0f), fmodf(sample.y + 0.5f, 1.0f)};
@@ -37,7 +37,7 @@ class TaaSamples {
   sample = (sample * 2.0f) - 1.0f;
 }
 
-/* swap center sample to the start of the array */
+/* Swap center sample to the start of the array */
 if (closest_index != 0) {
   swap_v2_v2(samples[0], samples[closest_index]);
 }
@@ -96,7 +96,7 @@ static void setup_taa_weights(const float2 offset, float 
r_weights[9], float _
 for (int y = -1; y <= 1; y++, i++) {
   float2 sample_co = float2(x, y) - offset;
   float r = len_v2(sample_co);
-  /* fclem: is radial distance ok here? */
+  /* fclem: Is radial distance ok here? */
   float weight = filter_blackman_harris(r, filter_width);
   r_weight_sum += weight;
   r_weights[i] = weight;
@@ -215,7 +215,7 @@ void AntiAliasingPass::setup_view(View , int2 
resolution)
   /* TODO(Miguel Pozo): New API equivalent? */
   const DRWView *default_view = DRW_view_default_get();
   float4x4 winmat, viewmat, persmat;
-  /* construct new matrices from transform delta */
+  /* Construct new matrices from transform delta */
   DRW_view_winmat_get(default_view, winmat.ptr(), false);
   DRW_view_viewmat_get(default_view, viewmat.ptr(), false);
   DRW_view_persmat_get(default_view, persmat.ptr(), false);
diff --git a/source/blender/draw/engines/workbench/workbench_effect_dof.cc 
b/source/blender/draw/engines/workbench/workbench_effect_dof.cc
index 25b0c6de74e..11d5cd33f4c 100644
--- a/source/blender/draw/engines/workbench/workbench_effect_dof.cc
+++ b/source/blender/draw/engines/workbench/workbench_effect_dof.cc
@@ -128,7 +128,7 @@ void 

[Bf-blender-cvs] [9594be5eef5] tmp-workbench-rewrite2: Remove commented-out code

2023-01-10 Thread Miguel Pozo
Commit: 9594be5eef59e75854ebecd58b20c0f00c15ad8e
Author: Miguel Pozo
Date:   Mon Jan 9 17:11:23 2023 +0100
Branches: tmp-workbench-rewrite2
https://developer.blender.org/rB9594be5eef59e75854ebecd58b20c0f00c15ad8e

Remove commented-out code

===

M   
source/blender/draw/engines/workbench/shaders/infos/workbench_shadow_info.hh
M   
source/blender/draw/engines/workbench/shaders/workbench_next_composite_frag.glsl
M   source/blender/draw/engines/workbench/workbench_engine.cc

===

diff --git 
a/source/blender/draw/engines/workbench/shaders/infos/workbench_shadow_info.hh 
b/source/blender/draw/engines/workbench/shaders/infos/workbench_shadow_info.hh
index 7ebebdf8c2b..a81c1b5712e 100644
--- 
a/source/blender/draw/engines/workbench/shaders/infos/workbench_shadow_info.hh
+++ 
b/source/blender/draw/engines/workbench/shaders/infos/workbench_shadow_info.hh
@@ -32,7 +32,6 @@ GPU_SHADER_CREATE_INFO(workbench_next_shadow_common)
 .vertex_out(workbench_shadow_iface)
 .define("WORKBENCH_NEXT")
 .uniform_buf(1, "ShadowPassData", "pass_data")
-//.push_constant(Type::VEC3, "lightDirection")
 .define("lightDirection", "vData[0].light_direction_os")
 .typedef_source("workbench_shader_shared.h")
 .additional_info("draw_view")
diff --git 
a/source/blender/draw/engines/workbench/shaders/workbench_next_composite_frag.glsl
 
b/source/blender/draw/engines/workbench/shaders/workbench_next_composite_frag.glsl
index 5331ad5f7ae..a66af6008d9 100644
--- 
a/source/blender/draw/engines/workbench/shaders/workbench_next_composite_frag.glsl
+++ 
b/source/blender/draw/engines/workbench/shaders/workbench_next_composite_frag.glsl
@@ -41,20 +41,16 @@ void main()
 
 #  ifdef WORKBENCH_CAVITY
 cavity_compute(uv, depth_tx, normal_tx, cavity, edges);
-// color.rgb = vec3(cavity, edges, 0);
 #  endif
 
 #  ifdef WORKBENCH_CURVATURE
 curvature_compute(uv, object_id_tx, normal_tx, curvature);
-// color.rgb = vec3(curvature);
 #  endif
 
 float final_cavity_factor = clamp(
 (1.0 - cavity) * (1.0 + edges) * (1.0 + curvature), 0.0, 4.0);
 
 color.rgb *= final_cavity_factor;
-// color.rgb *= vec3(0, 1, 0);
-
 #endif
 
 bool shadow = texture(stencil_tx, uv).r != 0;
diff --git a/source/blender/draw/engines/workbench/workbench_engine.cc 
b/source/blender/draw/engines/workbench/workbench_engine.cc
index fff98692220..e10bcf872ae 100644
--- a/source/blender/draw/engines/workbench/workbench_engine.cc
+++ b/source/blender/draw/engines/workbench/workbench_engine.cc
@@ -319,7 +319,6 @@ class Instance {
   resources.object_id_tx.clear(uint4(0));
 }
 
-// resources.depth_tx.acquire(resolution, GPU_DEPTH24_STENCIL8);
 Framebuffer fb = Framebuffer("Workbench.Clear");
 fb.ensure(GPU_ATTACHMENT_TEXTURE(resources.depth_tx));
 fb.bind();
@@ -353,7 +352,6 @@ class Instance {
 
 resources.color_tx.release();
 resources.object_id_tx.release();
-// resources.depth_tx.release();
 resources.depth_in_front_tx.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] [fdb4abc36da] tmp-workbench-rewrite2: Fix workbench_next_merge depth

2023-01-10 Thread Miguel Pozo
Commit: fdb4abc36dadf57d22711af572a61818a5b960dd
Author: Miguel Pozo
Date:   Mon Jan 9 17:10:12 2023 +0100
Branches: tmp-workbench-rewrite2
https://developer.blender.org/rBfdb4abc36dadf57d22711af572a61818a5b960dd

Fix workbench_next_merge depth

===

M   
source/blender/draw/engines/workbench/shaders/infos/workbench_merge_infront_info.hh

===

diff --git 
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
index 56ad367451d..fdf8fb61d9c 100644
--- 
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
@@ -14,4 +14,5 @@ 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")
+.depth_write(DepthWrite::ANY)
 .do_static_compilation(true);

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


[Bf-blender-cvs] [4aec99931b8] tmp-workbench-rewrite2: Clarify TODO comments

2023-01-10 Thread Miguel Pozo
Commit: 4aec99931b878473ab0a20545d9045adc16660ac
Author: Miguel Pozo
Date:   Mon Jan 9 16:36:06 2023 +0100
Branches: tmp-workbench-rewrite2
https://developer.blender.org/rB4aec99931b878473ab0a20545d9045adc16660ac

Clarify TODO comments

===

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

===

diff --git 
a/source/blender/draw/engines/workbench/workbench_effect_antialiasing.cc 
b/source/blender/draw/engines/workbench/workbench_effect_antialiasing.cc
index de0277e4320..17e1acb15e4 100644
--- a/source/blender/draw/engines/workbench/workbench_effect_antialiasing.cc
+++ b/source/blender/draw/engines/workbench/workbench_effect_antialiasing.cc
@@ -234,7 +234,9 @@ void AntiAliasingPass::draw(Manager ,
 GPUTexture *color_tx)
 {
   if (!enabled_) {
-/* TODO(Miguel Pozo): Should render to the input color_tx and depth_tx in 
the first place */
+/* TODO(Miguel Pozo): Should render to the input color_tx and depth_tx in 
the first place.
+ * This requires the use of TextureRefs with stencil_view() support,
+ * but whether TextureRef will stay is still TBD. */
 GPU_texture_copy(color_tx, resources.color_tx);
 GPU_texture_copy(depth_tx, resources.depth_tx);
 return;
@@ -263,7 +265,10 @@ void AntiAliasingPass::draw(Manager ,
 if (sample0_depth_tx_.is_valid()) {
   GPU_texture_copy(sample0_depth_tx_, resources.depth_tx);
 }
-/* TODO(Miguel Pozo): Should render to the input depth_tx in the first 
place */
+/* TODO(Miguel Pozo): Should render to the input depth_tx in the first 
place
+ * This requires the use of TextureRef with stencil_view() support,
+ * but whether TextureRef will stay is still TBD. */
+
 /* Copy back the saved depth buffer for correct overlays. */
 GPU_texture_copy(depth_tx, resources.depth_tx);
   }

___
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] [35e54b52e6e] master: Assets: "All" asset library

2023-01-10 Thread Julian Eisel
Commit: 35e54b52e6ecbb0465f1a28e0915769160b7bf86
Author: Julian Eisel
Date:   Tue Jan 10 15:27:28 2023 +0100
Branches: master
https://developer.blender.org/rB35e54b52e6ecbb0465f1a28e0915769160b7bf86

Assets: "All" asset library

Adds a new built-in asset library that contains all other asset
libraries visible in the asset library selector menu. This also means
all their asset catalogs will be displayed as a single merged tree. The
asset catalogs are not editable, since this would require support for
writing multiple catalog definition files, which isn't there yet.

Often it's not relevant where an asset comes from. Users just want to be
able to get an asset quickly, comparable to how people use a search
engine to browse images or the web itself, instead of first going to a
dedicated platform. They don't want to bother with first choosing where
they want the result to come from.
This especially is needed for the Asset Shelf (T102879) that is being
developed for the brush assets project (T101895). With this, users will
have access to all their brushes efficiently from the 3D view, without
much browsing.

Did an informal review of the asset system bits with Sybren.

===

M   source/blender/asset_system/AS_asset_catalog.hh
M   source/blender/asset_system/AS_asset_library.hh
M   source/blender/asset_system/intern/asset_catalog.cc
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
M   source/blender/editors/asset/ED_asset_catalog.h
M   source/blender/editors/asset/ED_asset_catalog.hh
M   source/blender/editors/asset/ED_asset_library.h
M   source/blender/editors/asset/ED_asset_list.hh
M   source/blender/editors/asset/intern/asset_catalog.cc
M   source/blender/editors/asset/intern/asset_library_reference_enum.cc
M   source/blender/editors/asset/intern/asset_list.cc
M   source/blender/editors/asset/intern/asset_ops.cc
M   source/blender/editors/space_file/asset_catalog_tree_view.cc
M   source/blender/editors/space_file/filelist.cc
M   source/blender/editors/space_file/filesel.c
M   source/blender/makesdna/DNA_asset_defaults.h
M   source/blender/makesdna/DNA_asset_types.h
M   source/blender/makesdna/DNA_space_types.h

===

diff --git a/source/blender/asset_system/AS_asset_catalog.hh 
b/source/blender/asset_system/AS_asset_catalog.hh
index 87b9425c8c6..8f818c6a768 100644
--- a/source/blender/asset_system/AS_asset_catalog.hh
+++ b/source/blender/asset_system/AS_asset_catalog.hh
@@ -45,11 +45,17 @@ class AssetCatalogService {
   Vector> undo_snapshots_;
   Vector> redo_snapshots_;
 
+  const bool is_read_only_ = false;
+
  public:
   static const CatalogFilePath DEFAULT_CATALOG_FILENAME;
 
+  struct read_only_tag {
+  };
+
  public:
   AssetCatalogService();
+  explicit AssetCatalogService(read_only_tag);
   explicit AssetCatalogService(const CatalogFilePath _library_root);
 
   /**
@@ -62,11 +68,24 @@ class AssetCatalogService {
   void tag_has_unsaved_changes(AssetCatalog *edited_catalog);
   bool has_unsaved_changes() const;
 
+  /**
+   * Check if this is a read-only service meaning the user shouldn't be able 
to do edits. This is
+   * not enforced by internal catalog code, the catalog service user is 
responsible for it. For
+   * example the UI should disallow edits.
+   */
+  bool is_read_only() const;
+
   /** Load asset catalog definitions from the files found in the asset 
library. */
   void load_from_disk();
   /** Load asset catalog definitions from the given file or directory. */
   void load_from_disk(const CatalogFilePath _or_directory_path);
 
+  /**
+   * Duplicate the catalogs from \a other_service into this one. Does not 
rebuild the tree, this
+   * needs to be done by the caller (call #rebuild_tree()!).
+   */
+  void add_from_existing(const AssetCatalogService _service);
+
   /**
* Write the catalog definitions to disk.
*
@@ -105,6 +124,15 @@ class AssetCatalogService {
*/
   void reload_catalogs();
 
+  /**
+   * Make sure the tree is updated to the latest collection of catalogs stored 
in this service.
+   * Does not depend on a CDF file being available so this can be called on a 
service that stores
+   * catalogs that are not stored in a CDF.
+   * Most API functions that modify catalog data will trigger this, unless 
otherwise specified (for
+   * batch operations).
+   */
+  void rebuild_tree();
+
   /** Return catalog with the given ID. Return nullptr if not found. */
   AssetCatalog *find_catalog(CatalogID catalog_id) const;
 
@@ -222,7 +250,6 @@ class AssetCatalogService {
   const CatalogFilePath _file_path);
 
   std::unique_ptr read_into_tree();
-  void rebuild_tree();
 
   /**
* For every catalog, ensure that its parent path 

[Bf-blender-cvs] [66af16571df] master: Refactor: Use new "All" asset library to extend node menus with assets

2023-01-10 Thread Julian Eisel
Commit: 66af16571dfe3cb314a59edfee3469a557821e47
Author: Julian Eisel
Date:   Tue Jan 10 15:37:31 2023 +0100
Branches: master
https://developer.blender.org/rB66af16571dfe3cb314a59edfee3469a557821e47

Refactor: Use new "All" asset library to extend node menus with assets

Updates the add and search menu of the node editor to use the new "All"
asset library introduced in the previous commit. This simplifies code by
removing redundant logic to merge contents of multiple asset libraries.

===

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

===

diff --git a/source/blender/editors/space_node/add_menu_assets.cc 
b/source/blender/editors/space_node/add_menu_assets.cc
index bb5f33f8cf0..fc250b63ffe 100644
--- a/source/blender/editors/space_node/add_menu_assets.cc
+++ b/source/blender/editors/space_node/add_menu_assets.cc
@@ -49,13 +49,6 @@ struct LibraryAsset {
   AssetHandle handle;
 };
 
-struct LibraryCatalog {
-  asset_system::AssetLibrary *library;
-  /* Catalog pointers are not save to store. Use the catalog ID instead and 
lookup the catalog when
-   * needed. */
-  const asset_system::CatalogID catalog_id;
-};
-
 struct AssetItemTree {
   asset_system::AssetCatalogTree catalogs;
   MultiValueMap assets_per_path;
@@ -63,14 +56,18 @@ struct AssetItemTree {
   full_catalog_per_tree_item;
 };
 
+static AssetLibraryReference all_library_reference()
+{
+  AssetLibraryReference all_library_ref{};
+  all_library_ref.custom_library_index = -1;
+  all_library_ref.type = ASSET_LIBRARY_ALL;
+  return all_library_ref;
+}
+
 static bool all_loading_finished()
 {
-  for (const AssetLibraryReference  : 
asset_system::all_valid_asset_library_refs()) {
-if (!ED_assetlist_is_loaded()) {
-  return false;
-}
-  }
-  return true;
+  AssetLibraryReference all_library_ref = all_library_reference();
+  return ED_assetlist_is_loaded(_library_ref);
 }
 
 static AssetItemTree build_catalog_tree(const bContext , const bNodeTree 
*node_tree)
@@ -78,68 +75,52 @@ static AssetItemTree build_catalog_tree(const bContext , 
const bNodeTree *node
   if (!node_tree) {
 return {};
   }
-  const Main  = *CTX_data_main();
-  const Vector all_libraries = 
asset_system::all_valid_asset_library_refs();
-
-  /* Merge catalogs from all libraries to deduplicate menu items. Also store 
the catalog and
-   * library for each asset ID in order to use them later when retrieving 
assets and removing
-   * empty catalogs.  */
-  Map id_to_catalog_map;
-  asset_system::AssetCatalogTree catalogs_from_all_libraries;
-  for (const AssetLibraryReference _ref : all_libraries) {
-if (asset_system::AssetLibrary *library = AS_asset_library_load(, 
library_ref)) {
-  if (asset_system::AssetCatalogTree *tree = 
library->catalog_service->get_catalog_tree()) {
-tree->foreach_item([&](asset_system::AssetCatalogTreeItem ) {
-  const asset_system::CatalogID  = item.get_catalog_id();
-  asset_system::AssetCatalog *catalog = 
library->catalog_service->find_catalog(id);
-  catalogs_from_all_libraries.insert_item(*catalog);
-  id_to_catalog_map.add(item.get_catalog_id(), LibraryCatalog{library, 
id});
-});
-  }
-}
-  }
 
   /* Find all the matching node group assets for every catalog path. */
   MultiValueMap assets_per_path;
-  for (const AssetLibraryReference _ref : all_libraries) {
-AssetFilterSettings type_filter{};
-type_filter.id_types = FILTER_ID_NT;
-
-ED_assetlist_storage_fetch(_ref, );
-ED_assetlist_ensure_previews_job(_ref, );
-ED_assetlist_iterate(library_ref, [&](AssetHandle asset) {
-  if (!ED_asset_filter_matches_asset(_filter, )) {
-return true;
-  }
-  const AssetMetaData _data = *ED_asset_handle_get_metadata();
-  const IDProperty *tree_type = BKE_asset_metadata_idprop_find(_data, 
"type");
-  if (tree_type == nullptr || IDP_Int(tree_type) != node_tree->type) {
-return true;
-  }
-  if (BLI_uuid_is_nil(meta_data.catalog_id)) {
-return true;
-  }
-  const LibraryCatalog *library_catalog = 
id_to_catalog_map.lookup_ptr(meta_data.catalog_id);
-  if (library_catalog == nullptr) {
-return true;
-  }
-  const asset_system::AssetCatalog *catalog =
-  
library_catalog->library->catalog_service->find_catalog(library_catalog->catalog_id);
-  assets_per_path.add(catalog->path, LibraryAsset{library_ref, asset});
-  return true;
-});
+
+  AssetFilterSettings type_filter{};
+  type_filter.id_types = FILTER_ID_NT;
+
+  const AssetLibraryReference all_library_ref = all_library_reference();
+
+  ED_assetlist_storage_fetch(_library_ref, );
+  ED_assetlist_ensure_previews_job(_library_ref, );
+
+  asset_system::AssetLibrary *all_library = 

[Bf-blender-cvs] [250eda36b8f] master: GPencil: Build modifier add "natural drawing" time

2023-01-10 Thread Marc Chehab
Commit: 250eda36b8f91a2f89b202d5eb79108260e1b1e3
Author: Marc Chehab
Date:   Tue Jan 10 15:37:02 2023 +0100
Branches: master
https://developer.blender.org/rB250eda36b8f91a2f89b202d5eb79108260e1b1e3

GPencil: Build modifier add "natural drawing" time

This patch uses the recorded drawing speed to rebuild the strokes. This results 
in a way more
natural feel of the animation.

Here's a short summary of existing data used:

- gps->points->time: This is a timestamp in seconds of when the point was 
created
  since the creation of the stroke. It's quite often 0 (I added a sanitization 
routine).
- gpf->inittime: This is a timestamp in seconds when a stroke was drawn measured
  since some unknown point in time. I only ever use the difference between two 
strokes,
  so the absolute value is not relevant.

Reviewed By: frogstomp, antoniov, mendio

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

===

M   source/blender/blenloader/intern/versioning_300.cc
M   source/blender/editors/include/ED_gpencil.h
M   source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c
M   source/blender/makesdna/DNA_gpencil_modifier_defaults.h
M   source/blender/makesdna/DNA_gpencil_modifier_types.h
M   source/blender/makesrna/intern/rna_gpencil_modifier.c

===

diff --git a/source/blender/blenloader/intern/versioning_300.cc 
b/source/blender/blenloader/intern/versioning_300.cc
index 38ecfaf41ea..6b4f374bf0e 100644
--- a/source/blender/blenloader/intern/versioning_300.cc
+++ b/source/blender/blenloader/intern/versioning_300.cc
@@ -3842,6 +3842,20 @@ void blo_do_versions_300(FileData *fd, Library * 
/*lib*/, Main *bmain)
 LISTBASE_FOREACH (Light *, light, >lights) {
   light->radius = light->area_size;
 }
+/* Grease Pencil Build modifier: Set default value for new natural 
drawspeed factor and maximum
+ * gap. */
+if (!DNA_struct_elem_find(fd->filesdna, "BuildGpencilModifierData", 
"float", "speed_fac") ||
+!DNA_struct_elem_find(fd->filesdna, "BuildGpencilModifierData", 
"float", "speed_maxgap")) {
+  LISTBASE_FOREACH (Object *, ob, >objects) {
+LISTBASE_FOREACH (GpencilModifierData *, md, 
>greasepencil_modifiers) {
+  if (md->type == eGpencilModifierType_Build) {
+BuildGpencilModifierData *mmd = (BuildGpencilModifierData *)md;
+mmd->speed_fac = 1.2f;
+mmd->speed_maxgap = 0.5f;
+  }
+}
+  }
+}
   }
 
   /**
diff --git a/source/blender/editors/include/ED_gpencil.h 
b/source/blender/editors/include/ED_gpencil.h
index 9dd2ba5d1d3..c95e58f9559 100644
--- a/source/blender/editors/include/ED_gpencil.h
+++ b/source/blender/editors/include/ED_gpencil.h
@@ -83,7 +83,7 @@ typedef struct tGPspoint {
   float pressure;
   /** Pressure of tablet at this point for alpha factor. */
   float strength;
-  /** Time relative to stroke start (used when converting to path). */
+  /** Time relative to stroke start (used when converting to path & in build 
modifier). */
   float time;
   /** Factor of uv along the stroke. */
   float uv_fac;
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c 
b/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c
index 49ac3275c82..e4320a7b5a8 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c
@@ -47,6 +47,13 @@
 #include "MOD_gpencil_modifiertypes.h"
 #include "MOD_gpencil_ui_common.h"
 
+/* Two hard-coded values for GP_BUILD_MODE_ADDITIVE with 
GP_BUILD_TIMEMODE_DRAWSPEED. */
+
+/* The minimum time gap we should worry about points with no time. */
+#define GP_BUILD_CORRECTGAP 0.001
+/* The time for geometric strokes */
+#define GP_BUILD_TIME_GEOSTROKES 1.0
+
 static void initData(GpencilModifierData *md)
 {
   BuildGpencilModifierData *gpmd = (BuildGpencilModifierData *)md;
@@ -252,53 +259,55 @@ static int cmp_stroke_build_details(const void *ps1, 
const void *ps2)
   return p1->distance > p2->distance ? 1 : (p1->distance == p2->distance ? 0 : 
-1);
 }
 
-/* Sequential and additive - Show strokes one after the other. */
+/* Sequential - Show strokes one after the other (includes additive mode). */
 static void build_sequential(Object *ob,
  BuildGpencilModifierData *mmd,
+ Depsgraph *depsgraph,
  bGPdata *gpd,
  bGPDframe *gpf,
- const int target_def_nr,
+ int target_def_nr,
  float fac,
- bool additive)
+ const float *ctime)
 {
+  /* Total number of strokes in this run. */
   size_t tot_strokes = BLI_listbase_count(>strokes);
-  size_t start_stroke;
+  /* First stroke to build. */
+  size_t 

[Bf-blender-cvs] [fddb76e9af8] master: Fix: new Grease Pencil layer not selected when added from the viewport

2023-01-10 Thread Amelie Fondevilla
Commit: fddb76e9af8de34852cb9906abd1de43ad9f24d3
Author: Amelie Fondevilla
Date:   Tue Jan 10 14:18:09 2023 +0100
Branches: master
https://developer.blender.org/rBfddb76e9af8de34852cb9906abd1de43ad9f24d3

Fix: new Grease Pencil layer not selected when added from the viewport

When adding a new layer from the viewport, the newly created layer
is set as active, which is visible in the properties panel,
but the selection in the dopesheet was not updated accordingly,
due to a missing notifier which is added in this patch.

===

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

===

diff --git a/source/blender/editors/gpencil/gpencil_data.c 
b/source/blender/editors/gpencil/gpencil_data.c
index 4f61016215a..c876832bc0c 100644
--- a/source/blender/editors/gpencil/gpencil_data.c
+++ b/source/blender/editors/gpencil/gpencil_data.c
@@ -247,6 +247,7 @@ static int gpencil_layer_add_exec(bContext *C, wmOperator 
*op)
   ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | 
ID_RECALC_COPY_ON_WRITE);
   }
   WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
+  WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_SELECTED, NULL);
 
   return OPERATOR_FINISHED;
 }

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


[Bf-blender-cvs] [59eec2f67da] temp-asset-library-all: Cleanups after informal review with Sybren

2023-01-10 Thread Julian Eisel
Commit: 59eec2f67da3ed18768a6742b2a0c67c8cb778c9
Author: Julian Eisel
Date:   Tue Jan 10 15:12:12 2023 +0100
Branches: temp-asset-library-all
https://developer.blender.org/rB59eec2f67da3ed18768a6742b2a0c67c8cb778c9

Cleanups after informal review with Sybren

===

M   source/blender/asset_system/AS_asset_library.hh
M   source/blender/asset_system/intern/asset_library.cc
M   source/blender/asset_system/intern/asset_library_service.cc
M   source/blender/editors/asset/ED_asset_catalog.hh
M   source/blender/editors/asset/ED_asset_list.hh
M   source/blender/editors/asset/intern/asset_list.cc
M   source/blender/editors/space_node/add_menu_assets.cc

===

diff --git a/source/blender/asset_system/AS_asset_library.hh 
b/source/blender/asset_system/AS_asset_library.hh
index 14d356c703e..b3b7d421724 100644
--- a/source/blender/asset_system/AS_asset_library.hh
+++ b/source/blender/asset_system/AS_asset_library.hh
@@ -56,7 +56,7 @@ class AssetLibrary {
*/
   std::unique_ptr asset_storage_;
 
-  std::function on_refresh_;
+  std::function on_refresh_;
 
   bCallbackFuncStore on_save_callback_store_{};
 
diff --git a/source/blender/asset_system/intern/asset_library.cc 
b/source/blender/asset_system/intern/asset_library.cc
index 61d45bd4569..2379e738e37 100644
--- a/source/blender/asset_system/intern/asset_library.cc
+++ b/source/blender/asset_system/intern/asset_library.cc
@@ -160,7 +160,7 @@ void AssetLibrary::load_catalogs()
 void AssetLibrary::refresh()
 {
   if (on_refresh_) {
-on_refresh_();
+on_refresh_(*this);
   }
 }
 
diff --git a/source/blender/asset_system/intern/asset_library_service.cc 
b/source/blender/asset_system/intern/asset_library_service.cc
index 1c212cb1136..af48a173bc0 100644
--- a/source/blender/asset_system/intern/asset_library_service.cc
+++ b/source/blender/asset_system/intern/asset_library_service.cc
@@ -79,7 +79,8 @@ AssetLibrary *AssetLibraryService::get_asset_library(
   if (!root_path.empty()) {
 return get_asset_library_on_disk(root_path);
   }
-} break;
+  break;
+}
   }
 
   return nullptr;
@@ -107,7 +108,7 @@ AssetLibrary 
*AssetLibraryService::get_asset_library_on_disk(StringRefNull root_
   lib->on_blend_save_handler_register();
   lib->load_catalogs();
   /* Reload catalogs on refresh. */
-  lib->on_refresh_ = [lib]() { lib->catalog_service->reload_catalogs(); };
+  lib->on_refresh_ = [](AssetLibrary ) { 
self.catalog_service->reload_catalogs(); };
 
   on_disk_libraries_.add_new(normalized_root_path, std::move(lib_uptr));
   CLOG_INFO(, 2, "get \"%s\" (loaded)", normalized_root_path.c_str());
@@ -130,6 +131,23 @@ AssetLibrary 
*AssetLibraryService::get_asset_library_current_file()
   return lib;
 }
 
+static void rebuild_all_library(AssetLibrary _library, const bool 
reload_catalogs)
+{
+  /* Start with empty catalog storage. */
+  all_library.catalog_service = std::make_unique(
+  AssetCatalogService::read_only_tag());
+
+  AssetLibrary::foreach_loaded(
+  [&](AssetLibrary ) {
+if (reload_catalogs) {
+  nested.catalog_service->reload_catalogs();
+}
+
all_library.catalog_service->add_from_existing(*nested.catalog_service);
+  },
+  false);
+  all_library.catalog_service->rebuild_tree();
+}
+
 AssetLibrary *AssetLibraryService::get_asset_library_all(const Main *bmain)
 {
   /* (Re-)load all other asset libraries. */
@@ -152,29 +170,14 @@ AssetLibrary 
*AssetLibraryService::get_asset_library_all(const Main *bmain)
   CLOG_INFO(, 2, "get all lib (loaded)");
   all_library_ = std::make_unique();
 
-  AssetLibrary _library = *all_library_;
-  auto build_catalogs_fn = [_library](const bool is_first_load) {
-/* Start with empty catalog storage. */
-all_library.catalog_service = std::make_unique(
-AssetCatalogService::read_only_tag());
-
-/* (Re-)load catalogs on refresh, and merge them into the all library. */
-AssetLibrary::foreach_loaded(
-[&](AssetLibrary ) {
-  /* On first load the catalogs were read just above, no need to 
reload. */
-  if (!is_first_load) {
-nested.catalog_service->reload_catalogs();
-  }
-  
all_library.catalog_service->add_from_existing(*nested.catalog_service);
-},
-false);
-all_library.catalog_service->rebuild_tree();
-  };
+  /* Don't reload catalogs on this initial read, they've just been loaded 
above. */
+  rebuild_all_library(*all_library_, /*reload_catlogs=*/false);
 
-  build_catalogs_fn(true);
-  all_library.on_refresh_ = [build_catalogs_fn]() { build_catalogs_fn(false); 
};
+  all_library_->on_refresh_ = [](AssetLibrary _library) {
+rebuild_all_library(all_library, /*reload_catalogs=*/true);
+  };
 
-  return _library;
+  return all_library_.get();
 }
 
 std::string AssetLibraryService::root_path_from_library_ref(

[Bf-blender-cvs] [597aecc0164] master: MacOS: Update Min Requirement to 10.15.

2023-01-10 Thread Jeroen Bakker
Commit: 597aecc01644f0063fa4545dabadc5f73387e3d3
Author: Jeroen Bakker
Date:   Tue Jan 10 15:01:02 2023 +0100
Branches: master
https://developer.blender.org/rB597aecc01644f0063fa4545dabadc5f73387e3d3

MacOS: Update Min Requirement to 10.15.

A few weeks ago we enabled the Metal back-end for the viewport.
Due to metal, master is only able to build on MacOS 10.15 and above.
The previous minimum requirement is MacOS 10.13.

It was already planned to bump to a higher version for Blender 3.6. After
a short discussion via bf-committers it was decided that it is fine to bump it 
for
3.5 release.

This patch cleans up the CMake files and update the minimum requirement.

With this patch the next deprecations will be listsed.
- `NSOpenGLView`, `NSOpenGLContext` is deprecated. (replaced by metal)
- `NSStringPboardType` is replaced by `NSPasteboardTypeString`
- `NSTIFFPboardType` is replaced by `NSPasteboardTypeTIFF`
- `NSFilenamesPboardType` should be replaved by multiple pasteboard items with 
`NSPasteboardTypeFileURL` instead.
- `NSUserNotification` should be replaced with UserNotifications.frameworks API

Deprecations will be handled in separate tasks and commits. OpenGL won't be
fixed at this moment, as it will be phased out in the future. 
NSStringPboardType, NSTiffPboardType & NSFilenamesPboardType
 will be provided in a single patch. NSUserNotification will also be provided in
its own patch.

Reviewed By: brecht, sergey

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

===

M   CMakeLists.txt
M   build_files/cmake/platform/platform_apple_xcode.cmake

===

diff --git a/CMakeLists.txt b/CMakeLists.txt
index c957ce37df5..9dfb962a57e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -605,10 +605,6 @@ else()
   set(WITH_METAL_BACKEND OFF)
 endif()
 
-if(WITH_METAL_BACKEND)
-  set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "Minimum OS X 
deployment version" FORCE)
-endif()
-
 if(WIN32)
   getDefaultWindowsPrefixBase(CMAKE_GENERIC_PROGRAM_FILES)
   set(CPACK_INSTALL_PREFIX ${CMAKE_GENERIC_PROGRAM_FILES}/${})
diff --git a/build_files/cmake/platform/platform_apple_xcode.cmake 
b/build_files/cmake/platform/platform_apple_xcode.cmake
index 06890f1cee1..d5579357ce4 100644
--- a/build_files/cmake/platform/platform_apple_xcode.cmake
+++ b/build_files/cmake/platform/platform_apple_xcode.cmake
@@ -155,8 +155,8 @@ if("${CMAKE_OSX_ARCHITECTURES}" STREQUAL "arm64")
   # M1 chips run Big Sur onwards.
   set(OSX_MIN_DEPLOYMENT_TARGET 11.00)
 else()
-  # 10.13 is our min. target, if you use higher sdk, weak linking happens
-  set(OSX_MIN_DEPLOYMENT_TARGET 10.13)
+  # 10.15 is our min. target, if you use higher sdk, weak linking happens
+  set(OSX_MIN_DEPLOYMENT_TARGET 10.15)
 endif()
 
 set(CMAKE_OSX_DEPLOYMENT_TARGET "${OSX_MIN_DEPLOYMENT_TARGET}" CACHE STRING "" 
FORCE)

___
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] [387fc9b40b4] master: MacOS: Silence OpenGL deprecation warnings.

2023-01-10 Thread Jeroen Bakker
Commit: 387fc9b40b41ff6e0039332052dedeeda0962b5b
Author: Jeroen Bakker
Date:   Tue Jan 10 14:57:23 2023 +0100
Branches: master
https://developer.blender.org/rB387fc9b40b41ff6e0039332052dedeeda0962b5b

MacOS: Silence OpenGL deprecation warnings.

OpenGL is deprecated by Apple and triggers a warning when used. The goal
is that OpenGL is replaced by Metal backend, but we are not there yet.

To improve tracability of new warnings we hide deprecation warnings
when the GHOST_ContextCGL.h file is included.

NOTE: This change silences other deprecation warnings as well.

===

M   intern/ghost/intern/GHOST_SystemCocoa.mm
M   intern/ghost/intern/GHOST_WindowCocoa.mm
M   source/blender/gpu/metal/mtl_context.hh

===

diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm 
b/intern/ghost/intern/GHOST_SystemCocoa.mm
index b8463286eab..f8e86e1a720 100644
--- a/intern/ghost/intern/GHOST_SystemCocoa.mm
+++ b/intern/ghost/intern/GHOST_SystemCocoa.mm
@@ -16,6 +16,12 @@
 #include "GHOST_WindowCocoa.h"
 #include "GHOST_WindowManager.h"
 
+/* Don't generate OpenGL deprecation warning. This is a known thing, and is 
not something easily
+ * solvable in a short term. */
+#ifdef __clang__
+#  pragma clang diagnostic ignored "-Wdeprecated-declarations"
+#endif
+
 #include "GHOST_ContextCGL.h"
 
 #ifdef WITH_VULKAN_BACKEND
diff --git a/intern/ghost/intern/GHOST_WindowCocoa.mm 
b/intern/ghost/intern/GHOST_WindowCocoa.mm
index 8748bbaeb35..849e59cd809 100644
--- a/intern/ghost/intern/GHOST_WindowCocoa.mm
+++ b/intern/ghost/intern/GHOST_WindowCocoa.mm
@@ -6,6 +6,12 @@
 #include "GHOST_Debug.h"
 #include "GHOST_SystemCocoa.h"
 
+/* Don't generate OpenGL deprecation warning. This is a known thing, and is 
not something easily
+ * solvable in a short term. */
+#ifdef __clang__
+#  pragma clang diagnostic ignored "-Wdeprecated-declarations"
+#endif
+
 #include "GHOST_ContextCGL.h"
 
 #ifdef WITH_VULKAN_BACKEND
diff --git a/source/blender/gpu/metal/mtl_context.hh 
b/source/blender/gpu/metal/mtl_context.hh
index e2789dbf9a7..ce2fd357ca9 100644
--- a/source/blender/gpu/metal/mtl_context.hh
+++ b/source/blender/gpu/metal/mtl_context.hh
@@ -12,6 +12,12 @@
 #include "GPU_common_types.h"
 #include "GPU_context.h"
 
+/* Don't generate OpenGL deprecation warning. This is a known thing, and is 
not something easily
+ * solvable in a short term. */
+#ifdef __clang__
+#  pragma clang diagnostic ignored "-Wdeprecated-declarations"
+#endif
+
 #include "intern/GHOST_Context.h"
 #include "intern/GHOST_ContextCGL.h"
 #include "intern/GHOST_Window.h"

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


[Bf-blender-cvs] [54bd4f31371] temp-T101739-fix-seam-bleeding-non-manifold: Performance improvement: only evaluate pixels that are near non-manifold areas.

2023-01-10 Thread Jeroen Bakker
Commit: 54bd4f3137126cc61f166e19f3d2d0f46e617b5f
Author: Jeroen Bakker
Date:   Tue Jan 10 14:14:24 2023 +0100
Branches: temp-T101739-fix-seam-bleeding-non-manifold
https://developer.blender.org/rB54bd4f3137126cc61f166e19f3d2d0f46e617b5f

Performance improvement: only evaluate pixels that are near non-manifold areas.

===

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

===

diff --git a/source/blender/blenkernel/intern/pbvh_pixels_copy.cc 
b/source/blender/blenkernel/intern/pbvh_pixels_copy.cc
index dc66405adda..30da7c64cca 100644
--- a/source/blender/blenkernel/intern/pbvh_pixels_copy.cc
+++ b/source/blender/blenkernel/intern/pbvh_pixels_copy.cc
@@ -205,6 +205,7 @@ struct Rows {
   Brush,
   /** This pixel will be copid from another pixel to solve non-manifold 
edge bleeding. */
   CopyFromClosestEdge,
+  Selected,
 };
 
 struct Elem {
@@ -260,14 +261,12 @@ struct Rows {
   }
 }
 
-void determine_copy_pixels(const NonManifoldTileEdges _edges,
-   int search_margin,
-   const int2 tile_resolution)
+void mark_for_evaluation(const Rows , const NonManifoldTileEdges 
_edges)
 {
   for (const Edge _edge : tile_edges) {
 rcti edge_bounds = get_bounds(tile_edge);
-add_margin(edge_bounds, search_margin);
-clamp(edge_bounds, tile_resolution);
+add_margin(edge_bounds, rows.margin);
+clamp(edge_bounds, rows.resolution);
 
 if (edge_bounds.ymax < row_number) {
   continue;
@@ -282,24 +281,22 @@ struct Rows {
 case PixelType::Brush: {
   break;
 }
-case PixelType::Undecided:
 case PixelType::CopyFromClosestEdge: {
+  BLI_assert_unreachable();
+  break;
+}
+case PixelType::Selected: {
+  break;
+}
+case PixelType::Undecided: {
   const float2 point(pixel.copy_command.destination);
   float2 closest_edge_point;
   closest_to_line_v2(closest_edge_point, point, tile_edge.v1.co, 
tile_edge.v2.co);
   float distance_to_edge = 
blender::math::distance_squared(closest_edge_point, point);
-  if (distance_to_edge > pixel.distance) {
+  if (distance_to_edge > rows.margin) {
 break;
   }
-
-  // TODO:
-  //  Find upto 2 valid pixels to copy from.
-  //  Determine the mix factor between the two pixels
-  //  Store result in the pixel.command.
-
-  pixel.distance = distance_to_edge;
-  pixel.type = PixelType::CopyFromClosestEdge;
-
+  pixel.type = PixelType::Selected;
   break;
 }
   }
@@ -307,12 +304,50 @@ struct Rows {
   }
 }
 
-void solution2(Rows , int margin)
+int2 find_second_source(Rows , int2 destination, int2 first_source)
+{
+  rcti search_bounds;
+  BLI_rcti_init(_bounds,
+max_ii(destination.x - 1, 0),
+min_ii(destination.x + 1, rows.resolution.x - 1),
+max_ii(destination.y - 1, 0),
+min_ii(destination.y + 1, rows.resolution.y - 1));
+  /* Initialize to the first source, so when no other source could be 
found it will use the
+   * first_source. */
+  int2 found_source = first_source;
+  float found_distance = std::numeric_limits().max();
+  for (int sy : IndexRange(search_bounds.ymin, 
BLI_rcti_size_y(_bounds))) {
+for (int sx : IndexRange(search_bounds.xmin, 
BLI_rcti_size_x(_bounds))) {
+  int2 source(sx, sy);
+  /* Skip first source as it should be the closest and already 
selected. */
+  if (source == first_source) {
+continue;
+  }
+  if (rows.rows[sy].pixels[sx].type != PixelType::Brush) {
+continue;
+  }
+
+  float new_distance = blender::math::distance(destination, source);
+  if (new_distance < found_distance) {
+found_distance = new_distance;
+found_source = source;
+  }
+}
+  }
+  return found_source;
+}
+
+float determine_mix_factor(int2 destination, int2 source_1, int2 source_2)
+{
+  return dist_to_line_segment_v2(float2(destination), float2(source_1), 
float2(source_2));
+}
+
+void find_copy_source(Rows , int margin)
 {
   for (int x : pixels.index_range()) {
 Elem  = pixels[x];
-/* Skip pixels that already used directly via a brush. */
-if (elem.type == PixelType::Brush) {
+/* Skip pixels that are not selected for evaluation. */
+if (elem.type != PixelType::Selected) {
   continue;
 }
 
@@ -345,9 

[Bf-blender-cvs] [bf70ba2efc4] temp-T101739-fix-seam-bleeding-non-manifold: Use correct bounds.

2023-01-10 Thread Jeroen Bakker
Commit: bf70ba2efc4bb5b8f50297bc21263f7e223a3d65
Author: Jeroen Bakker
Date:   Tue Jan 10 10:47:40 2023 +0100
Branches: temp-T101739-fix-seam-bleeding-non-manifold
https://developer.blender.org/rBbf70ba2efc4bb5b8f50297bc21263f7e223a3d65

Use correct bounds.

===

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

===

diff --git a/source/blender/blenkernel/intern/pbvh_pixels_copy.cc 
b/source/blender/blenkernel/intern/pbvh_pixels_copy.cc
index c4ea851ad9a..dfe716ffc6a 100644
--- a/source/blender/blenkernel/intern/pbvh_pixels_copy.cc
+++ b/source/blender/blenkernel/intern/pbvh_pixels_copy.cc
@@ -4,7 +4,7 @@
 #include "BLI_array.hh"
 #include "BLI_bit_vector.hh"
 #include "BLI_math.h"
-#include "BLI_math_vector_types.hh"
+#include "BLI_math_vector.hh"
 #include "BLI_vector.hh"
 
 #include "IMB_imbuf.h"
@@ -34,6 +34,49 @@ template struct Edge {
   Vertex v2;
 };
 
+rcti get_bounds(const Edge _edge)
+{
+  rcti bounds;
+  BLI_rcti_init_minmax();
+  BLI_rcti_do_minmax_v(, int2(tile_edge.v1.co));
+  BLI_rcti_do_minmax_v(, int2(tile_edge.v2.co));
+  return bounds;
+}
+
+void add_margin(rcti , int margin)
+{
+  bounds.xmin -= margin;
+  bounds.xmax += margin;
+  bounds.ymin -= margin;
+  bounds.ymax += margin;
+}
+
+void clamp(rcti , int2 resolution)
+{
+  rcti clamping_bounds;
+  int2 xy;
+  BLI_rcti_init(_bounds, 0, resolution.x - 1, 0, resolution.y - 1);
+  BLI_rcti_clamp(, _bounds, xy);
+}
+
+const Vertex convert_coord_space(const 
Vertex _vertex,
+   const 
image::ImageTileWrapper image_tile,
+   const int2 tile_resolution)
+{
+  return Vertex{(uv_vertex.co - 
float2(image_tile.get_tile_offset())) *
+  float2(tile_resolution)};
+}
+
+const Edge convert_coord_space(const Edge 
_edge,
+ const image::ImageTileWrapper 
image_tile,
+ const int2 tile_resolution)
+{
+  return Edge{
+  convert_coord_space(uv_edge.v1, image_tile, tile_resolution),
+  convert_coord_space(uv_edge.v2, image_tile, tile_resolution),
+  };
+}
+
 class NonManifoldTileEdges : public Vector> {};
 
 class NonManifoldUVEdges : public Vector> {
@@ -50,18 +93,24 @@ class NonManifoldUVEdges : public 
Vector> {
 }
 Edge edge;
 edge.v1.co = find_uv_vert(mesh_primitive, mesh_edge.vert1).uv;
-edge.v2.co = find_uv_vert(mesh_primitive, mesh_edge.vert1).uv;
+edge.v2.co = find_uv_vert(mesh_primitive, mesh_edge.vert2).uv;
 append(edge);
   }
 }
   }
 
   NonManifoldTileEdges extract_tile_edges(const image::ImageTileWrapper 
image_tile,
-  const int2 tile_resolution)
+  const int2 tile_resolution) const
   {
 NonManifoldTileEdges result;
-// TODO add edges that intersects with the given tile.
-// Convert the space from uv to tile.
+// TODO: Only add edges that intersects with the given tile.
+// TODO: Clamp edges to tile bounds.
+
+for (const Edge _edge : *this) {
+  const Edge tile_edge = convert_coord_space(
+  uv_edge, image_tile, tile_resolution);
+  result.append(tile_edge);
+}
 return result;
   }
 
@@ -148,73 +197,150 @@ class PixelNodesTileData : public 
Vector>
  * encode pixels.
  */
 
-struct Row {
-  enum class PixelType {
-Undecided,
-/** This pixel is directly affected by a brush and doesn't need to be 
solved. */
-Brush,
-/** This pixel will be copid from another pixel to solve non-manifold edge 
bleeding. */
-CopyFromClosestEdge,
-  };
-
-  struct Elem {
-PixelType type = PixelType::Undecided;
-/**
- * Distance to the closest edge that can be sourced to fix an edge bleed.
- * A distance of 0.0 means that the pixel is being drawn on directly and
- * doesn't need to be checked.
- */
-float distance = 0.0f;
-PixelCopyCommand copy_command;
-
-Elem() = default;
+struct Rows {
+
+  struct Row {
+enum class PixelType {
+  Undecided,
+  /** This pixel is directly affected by a brush and doesn't need to be 
solved. */
+  Brush,
+  /** This pixel will be copid from another pixel to solve non-manifold 
edge bleeding. */
+  CopyFromClosestEdge,
+};
+
+struct Elem {
+  PixelType type = PixelType::Undecided;
+  /**
+   * Distance to the closest edge that can be sourced to fix an edge bleed.
+   * A distance of 0.0 means that the pixel is being drawn on directly and
+   * doesn't need to be checked.
+   */
+  float distance = std::numeric_limits::max();
+  PixelCopyCommand copy_command;
+
+  Elem() = default;
+
+  Elem(int2 co)
+  {
+copy_command.destination = co;
+

[Bf-blender-cvs] [48f6d0b1177] temp-T101739-fix-seam-bleeding-non-manifold: Merge branch 'master' into temp-T101739-fix-seam-bleeding-non-manifold

2023-01-10 Thread Jeroen Bakker
Commit: 48f6d0b117718462061bb83ea86b44d6b91f2e01
Author: Jeroen Bakker
Date:   Mon Jan 9 12:26:50 2023 +0100
Branches: temp-T101739-fix-seam-bleeding-non-manifold
https://developer.blender.org/rB48f6d0b117718462061bb83ea86b44d6b91f2e01

Merge branch 'master' into temp-T101739-fix-seam-bleeding-non-manifold

===



===

diff --cc source/blender/blenkernel/BKE_pbvh_pixels.hh
index 2d7d3df4ac3,55ecf65bcac..d3ff0a25dd0
--- a/source/blender/blenkernel/BKE_pbvh_pixels.hh
+++ b/source/blender/blenkernel/BKE_pbvh_pixels.hh
@@@ -3,10 -3,8 +3,10 @@@
  
  #pragma once
  
 +#include 
 +
  #include "BLI_math.h"
- #include "BLI_math_vec_types.hh"
+ #include "BLI_math_vector_types.hh"
  #include "BLI_rect.h"
  #include "BLI_vector.hh"
  
diff --cc source/blender/blenkernel/intern/pbvh_pixels_copy.cc
index 7a7446ac237,000..c4ea851ad9a
mode 100644,00..100644
--- a/source/blender/blenkernel/intern/pbvh_pixels_copy.cc
+++ b/source/blender/blenkernel/intern/pbvh_pixels_copy.cc
@@@ -1,289 -1,0 +1,289 @@@
 +/* SPDX-License-Identifier: GPL-2.0-or-later
 + * Copyright 2022 Blender Foundation. All rights reserved. */
 +
 +#include "BLI_array.hh"
 +#include "BLI_bit_vector.hh"
 +#include "BLI_math.h"
- #include "BLI_math_vec_types.hh"
++#include "BLI_math_vector_types.hh"
 +#include "BLI_vector.hh"
 +
 +#include "IMB_imbuf.h"
 +#include "IMB_imbuf_types.h"
 +
 +#include "BKE_image_wrappers.hh"
 +#include "BKE_pbvh.h"
 +#include "BKE_pbvh_pixels.hh"
 +
 +#include "pbvh_intern.h"
 +#include "pbvh_pixels_copy.hh"
 +#include "pbvh_uv_islands.hh"
 +
 +namespace blender::bke::pbvh::pixels {
 +
 +enum class CoordSpace {
 +  UV,
 +  Tile,
 +};
 +
 +template struct Vertex {
 +  float2 co;
 +};
 +
 +template struct Edge {
 +  Vertex v1;
 +  Vertex v2;
 +};
 +
 +class NonManifoldTileEdges : public Vector> {};
 +
 +class NonManifoldUVEdges : public Vector> {
 + public:
 +  NonManifoldUVEdges(const uv_islands::MeshData _data)
 +  {
 +reserve(count_non_manifold_edges(mesh_data));
 +
 +for (const uv_islands::MeshPrimitive _primitive : 
mesh_data.primitives) {
 +  for (int i = 0; i < 3; i++) {
 +const uv_islands::MeshEdge _edge = *mesh_primitive.edges[i];
 +if (is_manifold(mesh_edge)) {
 +  continue;
 +}
 +Edge edge;
 +edge.v1.co = find_uv_vert(mesh_primitive, mesh_edge.vert1).uv;
 +edge.v2.co = find_uv_vert(mesh_primitive, mesh_edge.vert1).uv;
 +append(edge);
 +  }
 +}
 +  }
 +
 +  NonManifoldTileEdges extract_tile_edges(const image::ImageTileWrapper 
image_tile,
 +  const int2 tile_resolution)
 +  {
 +NonManifoldTileEdges result;
 +// TODO add edges that intersects with the given tile.
 +// Convert the space from uv to tile.
 +return result;
 +  }
 +
 + private:
 +  static int64_t count_non_manifold_edges(const uv_islands::MeshData 
_data)
 +  {
 +int64_t result = 0;
 +for (const uv_islands::MeshPrimitive _primitive : 
mesh_data.primitives) {
 +  for (int i = 0; i < 3; i++) {
 +const uv_islands::MeshEdge _edge = *mesh_primitive.edges[i];
 +if (is_manifold(mesh_edge)) {
 +  continue;
 +}
 +result += 1;
 +  }
 +}
 +return result;
 +  }
 +
 +  static const uv_islands::MeshUVVert _uv_vert(
 +  const uv_islands::MeshPrimitive _primitive, const 
uv_islands::MeshVertex *mesh_vertex)
 +  {
 +for (const uv_islands::MeshUVVert _vertex : mesh_primitive.vertices) {
 +  if (uv_vertex.vertex == mesh_vertex) {
 +return uv_vertex;
 +  }
 +}
 +// TODO: Use cleaner interface.
 +BLI_assert_unreachable();
 +static uv_islands::MeshUVVert dummy;
 +return dummy;
 +  }
 +  static bool is_manifold(const uv_islands::MeshEdge mesh_edge)
 +  {
 +return mesh_edge.primitives.size() == 2;
 +  }
 +};
 +
 +class PixelNodesTileData : public 
Vector> {
 + public:
 +  PixelNodesTileData(PBVH , const image::ImageTileWrapper _tile)
 +  {
 +reserve(count_nodes(pbvh, image_tile));
 +
 +for (PBVHNode  : MutableSpan(pbvh.nodes, pbvh.totnode)) {
 +  if (should_add_node(node, image_tile)) {
 +NodeData _data = *static_cast(node.pixels.node_data);
 +UDIMTilePixels _pixels = *node_data.find_tile_data(image_tile);
 +append(tile_pixels);
 +  }
 +}
 +  }
 +
 + private:
 +  static bool should_add_node(PBVHNode , const image::ImageTileWrapper 
_tile)
 +  {
 +if ((node.flag & PBVH_Leaf) == 0) {
 +  return false;
 +}
 +if (node.pixels.node_data == nullptr) {
 +  return false;
 +}
 +NodeData _data = *static_cast(node.pixels.node_data);
 +if (node_data.find_tile_data(image_tile) == nullptr) {
 +  return false;
 +}
 +return true;
 +  }
 +
 +  static int64_t count_nodes(PBVH , const image::ImageTileWrapper 
_tile)
 +  {
 +

[Bf-blender-cvs] [18fc174ec9f] temp-T101739-fix-seam-bleeding-non-manifold: Packing copy commands inot copy groups.

2023-01-10 Thread Jeroen Bakker
Commit: 18fc174ec9f8cd5624df72a283547689857410ef
Author: Jeroen Bakker
Date:   Tue Jan 10 12:17:56 2023 +0100
Branches: temp-T101739-fix-seam-bleeding-non-manifold
https://developer.blender.org/rB18fc174ec9f8cd5624df72a283547689857410ef

Packing copy commands inot copy groups.

===

M   source/blender/blenkernel/BKE_pbvh_pixels.hh
M   source/blender/blenkernel/intern/pbvh_pixels_copy.cc

===

diff --git a/source/blender/blenkernel/BKE_pbvh_pixels.hh 
b/source/blender/blenkernel/BKE_pbvh_pixels.hh
index d3ff0a25dd0..d7ce30280b2 100644
--- a/source/blender/blenkernel/BKE_pbvh_pixels.hh
+++ b/source/blender/blenkernel/BKE_pbvh_pixels.hh
@@ -265,7 +265,6 @@ template struct 
ImageBufferAccessor {
 };
 
 struct PixelCopyItem {
-  uint8_t delta_destination_x;
   char2 delta_source_1;
   char2 delta_source_2;
   uint8_t mix_factor;
@@ -273,6 +272,7 @@ struct PixelCopyItem {
 
 struct PixelCopyGroup {
   int2 destination;
+  int2 source;
   Vector items;
 };
 
@@ -290,8 +290,8 @@ struct PixelCopyCommand {
   PixelCopyCommand() = default;
   PixelCopyCommand(const PixelCopyGroup )
   : destination(group.destination),
-source_1(group.destination),
-source_2(group.destination),
+source_1(group.source),
+source_2(group.source),
 mix_factor(0.0f)
   {
   }
@@ -307,9 +307,9 @@ struct PixelCopyCommand {
 
   void apply(const PixelCopyItem )
   {
-destination.x += int(item.delta_destination_x);
+destination.x += 1;
 source_1 += int2(item.delta_source_1);
-source_2 += int2(item.delta_source_2);
+source_2 = source_1 + int2(item.delta_source_2);
 mix_factor = float(item.mix_factor) / 255.0f;
   }
 };
diff --git a/source/blender/blenkernel/intern/pbvh_pixels_copy.cc 
b/source/blender/blenkernel/intern/pbvh_pixels_copy.cc
index dfe716ffc6a..c8eca17606a 100644
--- a/source/blender/blenkernel/intern/pbvh_pixels_copy.cc
+++ b/source/blender/blenkernel/intern/pbvh_pixels_copy.cc
@@ -198,7 +198,6 @@ class PixelNodesTileData : public 
Vector>
  */
 
 struct Rows {
-
   struct Row {
 enum class PixelType {
   Undecided,
@@ -308,6 +307,98 @@ struct Rows {
   }
 }
 
+void solution2(Rows )
+{
+  for (int x : pixels.index_range()) {
+Elem  = pixels[x];
+/* Skip pixels that already used directly via a brush. */
+if (elem.type == PixelType::Brush) {
+  continue;
+}
+
+rcti bounds;
+BLI_rcti_init(, x, x, row_number, row_number);
+add_margin(bounds, 8);
+clamp(bounds, rows.resolution);
+
+float found_distance = std::numeric_limits().max();
+int2 found_source(0);
+
+for (int sy : IndexRange(bounds.ymin, BLI_rcti_size_y())) {
+  Row  = rows.rows[sy];
+  for (int sx : IndexRange(bounds.xmin, BLI_rcti_size_x())) {
+Elem  = row.pixels[sx];
+if (source.type != PixelType::Brush) {
+  continue;
+}
+float new_distance = blender::math::distance(float2(sx, sy), 
float2(x, row_number));
+if (found_distance > new_distance) {
+  found_source = int2(sx, sy);
+  found_distance = new_distance;
+}
+  }
+}
+
+if (found_distance == std::numeric_limits().max()) {
+  continue;
+}
+elem.type = PixelType::CopyFromClosestEdge;
+elem.distance = found_distance;
+elem.copy_command.source_1 = found_source;
+// TODO: find second source by looking at neighbouring pixels of 
source_1.
+elem.copy_command.source_2 = found_source;
+elem.copy_command.mix_factor = 0.0f;
+  }
+}
+
+static bool can_be_extended_with(const PixelCopyGroup , const 
PixelCopyCommand )
+{
+  PixelCopyCommand last_command = last_copy_command(group);
+  /* Can only extend when pushing the next pixel. */
+  if (last_command.destination.x != command.destination.x - 1 ||
+  last_command.destination.y != command.destination.y) {
+return false;
+  }
+  /* Can only extend when */
+  int2 delta_source_1 = last_command.source_1 - command.source_1;
+  if (max_ii(UNPACK2(blender::math::abs(delta_source_1))) > 127) {
+return false;
+  }
+  return true;
+}
+
+static void extend_with(PixelCopyGroup , const PixelCopyCommand 
)
+{
+  PixelCopyCommand last_command = last_copy_command(group);
+  PixelCopyItem new_item = {char2(command.source_1 - 
last_command.source_1),
+char2(command.source_2 - command.source_1),
+uint8_t(command.mix_factor * 255)};
+  group.items.append(new_item);
+}
+
+static PixelCopyCommand last_copy_command(const PixelCopyGroup )
+{
+  PixelCopyCommand last_command(group);
+  for (const 

[Bf-blender-cvs] [1bcac42f5e0] temp-T101739-fix-seam-bleeding-non-manifold: Merge branch 'master' into temp-T101739-fix-seam-bleeding-non-manifold

2023-01-10 Thread Jeroen Bakker
Commit: 1bcac42f5e033d3fb18be9563f2a67c09d2638f8
Author: Jeroen Bakker
Date:   Tue Jan 10 14:19:53 2023 +0100
Branches: temp-T101739-fix-seam-bleeding-non-manifold
https://developer.blender.org/rB1bcac42f5e033d3fb18be9563f2a67c09d2638f8

Merge branch 'master' into temp-T101739-fix-seam-bleeding-non-manifold

===



===



___
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] [a017d653a9c] temp-T101739-fix-seam-bleeding-non-manifold: Extract non manifold edges.

2023-01-10 Thread Jeroen Bakker
Commit: a017d653a9c3d16034801c3ad8a878a1fa4ab8b7
Author: Jeroen Bakker
Date:   Fri Jan 6 10:52:52 2023 +0100
Branches: temp-T101739-fix-seam-bleeding-non-manifold
https://developer.blender.org/rBa017d653a9c3d16034801c3ad8a878a1fa4ab8b7

Extract non manifold edges.

===

M   source/blender/blenkernel/BKE_pbvh_pixels.hh
M   source/blender/blenkernel/intern/pbvh_pixels.cc
M   source/blender/blenkernel/intern/pbvh_pixels_copy.cc
A   source/blender/blenkernel/intern/pbvh_pixels_copy.hh

===

diff --git a/source/blender/blenkernel/BKE_pbvh_pixels.hh 
b/source/blender/blenkernel/BKE_pbvh_pixels.hh
index 28e02dbef8e..2d7d3df4ac3 100644
--- a/source/blender/blenkernel/BKE_pbvh_pixels.hh
+++ b/source/blender/blenkernel/BKE_pbvh_pixels.hh
@@ -287,6 +287,7 @@ struct PixelCopyCommand {
   /** Factor to mix between first and second source. */
   float mix_factor;
 
+  PixelCopyCommand() = default;
   PixelCopyCommand(const PixelCopyGroup )
   : destination(group.destination),
 source_1(group.destination),
@@ -317,6 +318,10 @@ struct PixelCopyTile {
   image::TileNumber tile_number;
   Vector groups;
 
+  PixelCopyTile(image::TileNumber tile_number) : tile_number(tile_number)
+  {
+  }
+
   void copy_pixels(ImBuf _buffer) const
   {
 if (tile_buffer.rect_float) {
@@ -378,9 +383,9 @@ NodeData _pbvh_pixels_node_data_get(PBVHNode );
 void BKE_pbvh_pixels_mark_image_dirty(PBVHNode , Image , ImageUser 
_user);
 PBVHData _pbvh_pixels_data_get(PBVH );
 
-void BKE_pbvh_pixels_copy_update(PBVH , Image , ImageUser 
_user);
 void BKE_pbvh_pixels_copy_pixels(PBVH ,
  Image ,
  ImageUser _user,
  image::TileNumber tile_number);
+
 }  // namespace blender::bke::pbvh::pixels
diff --git a/source/blender/blenkernel/intern/pbvh_pixels.cc 
b/source/blender/blenkernel/intern/pbvh_pixels.cc
index e21103c9f19..3d318c6fb2a 100644
--- a/source/blender/blenkernel/intern/pbvh_pixels.cc
+++ b/source/blender/blenkernel/intern/pbvh_pixels.cc
@@ -20,6 +20,7 @@
 #include "bmesh.h"
 
 #include "pbvh_intern.h"
+#include "pbvh_pixels_copy.hh"
 #include "pbvh_uv_islands.hh"
 
 namespace blender::bke::pbvh::pixels {
@@ -405,6 +406,9 @@ static void update_pixels(PBVH *pbvh, Mesh *mesh, Image 
*image, ImageUser *image
 apply_watertight_check(pbvh, image, image_user);
   }
 
+  /* Add solution for non-manifold parts of the model. */
+  BKE_pbvh_pixels_copy_update(*pbvh, *image, *image_user, mesh_data);
+
   /* Rebuild the undo regions. */
   for (PBVHNode *node : nodes_to_update) {
 NodeData *node_data = static_cast(node->pixels.node_data);
diff --git a/source/blender/blenkernel/intern/pbvh_pixels_copy.cc 
b/source/blender/blenkernel/intern/pbvh_pixels_copy.cc
index ca850812f02..7a7446ac237 100644
--- a/source/blender/blenkernel/intern/pbvh_pixels_copy.cc
+++ b/source/blender/blenkernel/intern/pbvh_pixels_copy.cc
@@ -1,6 +1,8 @@
 /* SPDX-License-Identifier: GPL-2.0-or-later
  * Copyright 2022 Blender Foundation. All rights reserved. */
 
+#include "BLI_array.hh"
+#include "BLI_bit_vector.hh"
 #include "BLI_math.h"
 #include "BLI_math_vec_types.hh"
 #include "BLI_vector.hh"
@@ -12,31 +14,252 @@
 #include "BKE_pbvh.h"
 #include "BKE_pbvh_pixels.hh"
 
+#include "pbvh_intern.h"
+#include "pbvh_pixels_copy.hh"
+#include "pbvh_uv_islands.hh"
+
 namespace blender::bke::pbvh::pixels {
 
+enum class CoordSpace {
+  UV,
+  Tile,
+};
+
+template struct Vertex {
+  float2 co;
+};
+
+template struct Edge {
+  Vertex v1;
+  Vertex v2;
+};
+
+class NonManifoldTileEdges : public Vector> {};
+
+class NonManifoldUVEdges : public Vector> {
+ public:
+  NonManifoldUVEdges(const uv_islands::MeshData _data)
+  {
+reserve(count_non_manifold_edges(mesh_data));
+
+for (const uv_islands::MeshPrimitive _primitive : 
mesh_data.primitives) {
+  for (int i = 0; i < 3; i++) {
+const uv_islands::MeshEdge _edge = *mesh_primitive.edges[i];
+if (is_manifold(mesh_edge)) {
+  continue;
+}
+Edge edge;
+edge.v1.co = find_uv_vert(mesh_primitive, mesh_edge.vert1).uv;
+edge.v2.co = find_uv_vert(mesh_primitive, mesh_edge.vert1).uv;
+append(edge);
+  }
+}
+  }
+
+  NonManifoldTileEdges extract_tile_edges(const image::ImageTileWrapper 
image_tile,
+  const int2 tile_resolution)
+  {
+NonManifoldTileEdges result;
+// TODO add edges that intersects with the given tile.
+// Convert the space from uv to tile.
+return result;
+  }
+
+ private:
+  static int64_t count_non_manifold_edges(const uv_islands::MeshData 
_data)
+  {
+int64_t result = 0;
+for (const uv_islands::MeshPrimitive _primitive : 
mesh_data.primitives) {
+  for (int i = 0; i < 3; i++) {
+const uv_islands::MeshEdge _edge = 

[Bf-blender-cvs] [3dad290abe7] temp-T101739-fix-seam-bleeding-non-manifold: Remove debug prints.

2023-01-10 Thread Jeroen Bakker
Commit: 3dad290abe7a1337a36c87b1f9a1782857963697
Author: Jeroen Bakker
Date:   Tue Jan 10 13:00:20 2023 +0100
Branches: temp-T101739-fix-seam-bleeding-non-manifold
https://developer.blender.org/rB3dad290abe7a1337a36c87b1f9a1782857963697

Remove debug prints.

===

M   release/datafiles/locale
M   release/scripts/addons
M   release/scripts/addons_contrib
M   source/blender/blenkernel/intern/pbvh_pixels_copy.cc

===

diff --git a/release/datafiles/locale b/release/datafiles/locale
index 7084c4ecd97..4f6dbb69893 16
--- a/release/datafiles/locale
+++ b/release/datafiles/locale
@@ -1 +1 @@
-Subproject commit 7084c4ecd97d93459d9d23fd90f81589b09be5df
+Subproject commit 4f6dbb69893bd6bdf73467effe77ae46c8e4ee37
diff --git a/release/scripts/addons b/release/scripts/addons
index a9d4443c244..5a774a6dad4 16
--- a/release/scripts/addons
+++ b/release/scripts/addons
@@ -1 +1 @@
-Subproject commit a9d4443c244f89399ec4bcc427e05a07950528cc
+Subproject commit 5a774a6dad4378f173ec7fdcdcd406048fcc9a29
diff --git a/release/scripts/addons_contrib b/release/scripts/addons_contrib
index bdcfdd47ec3..0f72f6c85c3 16
--- a/release/scripts/addons_contrib
+++ b/release/scripts/addons_contrib
@@ -1 +1 @@
-Subproject commit bdcfdd47ec3451822b21d1cff2ea2db751093c9a
+Subproject commit 0f72f6c85c3743a9072273acb6a8a34b1cf1064b
diff --git a/source/blender/blenkernel/intern/pbvh_pixels_copy.cc 
b/source/blender/blenkernel/intern/pbvh_pixels_copy.cc
index 7c8243a1ebc..0fedde9963e 100644
--- a/source/blender/blenkernel/intern/pbvh_pixels_copy.cc
+++ b/source/blender/blenkernel/intern/pbvh_pixels_copy.cc
@@ -398,14 +398,6 @@ struct Rows {
 }
   }
 }
-
-void print_debug() const
-{
-  for (const Elem  : pixels) {
-printf("%d", pixel.type);
-  }
-  printf("\n");
-}
   };
 
   int2 resolution;
@@ -473,7 +465,6 @@ void BKE_pbvh_pixels_copy_update(PBVH ,
 for (int y = 0; y < tile_resolution.y; y++) {
   Rows::Row  = rows.rows[y];
   // row.determine_copy_pixels(tile_edges, image.seam_margin, 
tile_resolution);
-  row.print_debug();
   row.pack_into(copy_tile.groups);
 }

___
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] [c9b40d8af05] temp-T101739-fix-seam-bleeding-non-manifold: First pixels being copied.

2023-01-10 Thread Jeroen Bakker
Commit: c9b40d8af05985214ffe0a1c5ba2df642dd9d7b2
Author: Jeroen Bakker
Date:   Tue Jan 10 12:50:53 2023 +0100
Branches: temp-T101739-fix-seam-bleeding-non-manifold
https://developer.blender.org/rBc9b40d8af05985214ffe0a1c5ba2df642dd9d7b2

First pixels being copied.

===

M   source/blender/blenkernel/intern/pbvh_pixels_copy.cc
M   source/blender/editors/sculpt_paint/sculpt_paint_image.cc

===

diff --git a/source/blender/blenkernel/intern/pbvh_pixels_copy.cc 
b/source/blender/blenkernel/intern/pbvh_pixels_copy.cc
index c8eca17606a..7c8243a1ebc 100644
--- a/source/blender/blenkernel/intern/pbvh_pixels_copy.cc
+++ b/source/blender/blenkernel/intern/pbvh_pixels_copy.cc
@@ -385,7 +385,7 @@ struct Rows {
   return last_command;
 }
 
-void pack_into(Vector groups) const
+void pack_into(Vector ) const
 {
   for (const Elem  : pixels) {
 if (elem.type == PixelType::CopyFromClosestEdge) {
@@ -490,6 +490,7 @@ void BKE_pbvh_pixels_copy_pixels(PBVH ,
   std::optional> pixel_tile =
   pbvh_data.tiles_copy_pixels.find_tile(tile_number);
   if (!pixel_tile.has_value()) {
+printf("%s: found no pixels to copy for tile %d\n", __func__, tile_number);
 return;
   }
 
@@ -497,6 +498,7 @@ void BKE_pbvh_pixels_copy_pixels(PBVH ,
   tile_user.tile = tile_number;
   ImBuf *tile_buffer = BKE_image_acquire_ibuf(, _user, nullptr);
   if (tile_buffer == nullptr) {
+printf("%s: found no tile buffer for tile %d\n", __func__, tile_number);
 return;
   }
   pixel_tile->get().copy_pixels(*tile_buffer);
diff --git a/source/blender/editors/sculpt_paint/sculpt_paint_image.cc 
b/source/blender/editors/sculpt_paint/sculpt_paint_image.cc
index 6244cf8e33d..cae5c0c283e 100644
--- a/source/blender/editors/sculpt_paint/sculpt_paint_image.cc
+++ b/source/blender/editors/sculpt_paint/sculpt_paint_image.cc
@@ -539,5 +539,9 @@ void SCULPT_do_paint_brush_image(
   TaskParallelSettings settings_flush;
   BKE_pbvh_parallel_range_settings(_flush, false, totnode);
   BLI_task_parallel_range(0, totnode, , do_mark_dirty_regions, 
_flush);
+
+  /* TODO: should be done at the end of the stroke.*/
+  BKE_pbvh_pixels_copy_pixels(
+  *ob->sculpt->pbvh, *data.image_data.image, *data.image_data.image_user, 
1001);
 }
 }

___
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] [abcac1a9fcb] temp-T101739-fix-seam-bleeding-non-manifold: Use seam_margin.

2023-01-10 Thread Jeroen Bakker
Commit: abcac1a9fcbb5f8495e15602a3004c2ed33fa20a
Author: Jeroen Bakker
Date:   Tue Jan 10 13:03:41 2023 +0100
Branches: temp-T101739-fix-seam-bleeding-non-manifold
https://developer.blender.org/rBabcac1a9fcbb5f8495e15602a3004c2ed33fa20a

Use seam_margin.

===

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

===

diff --git a/source/blender/blenkernel/intern/pbvh_pixels_copy.cc 
b/source/blender/blenkernel/intern/pbvh_pixels_copy.cc
index 0fedde9963e..dc66405adda 100644
--- a/source/blender/blenkernel/intern/pbvh_pixels_copy.cc
+++ b/source/blender/blenkernel/intern/pbvh_pixels_copy.cc
@@ -307,7 +307,7 @@ struct Rows {
   }
 }
 
-void solution2(Rows )
+void solution2(Rows , int margin)
 {
   for (int x : pixels.index_range()) {
 Elem  = pixels[x];
@@ -318,7 +318,7 @@ struct Rows {
 
 rcti bounds;
 BLI_rcti_init(, x, x, row_number, row_number);
-add_margin(bounds, 8);
+add_margin(bounds, margin);
 clamp(bounds, rows.resolution);
 
 float found_distance = std::numeric_limits().max();
@@ -415,10 +415,10 @@ struct Rows {
 }
   }
 
-  void find_copy_source()
+  void find_copy_source(int margin)
   {
 for (Row  : rows) {
-  row.solution2(*this);
+  row.solution2(*this, margin);
 }
   }
 };  // namespace blender::bke::pbvh::pixels
@@ -460,7 +460,7 @@ void BKE_pbvh_pixels_copy_update(PBVH ,
 PixelCopyTile copy_tile(image_tile.get_tile_number());
 
 Rows rows(tile_resolution, image.seam_margin, nodes_tile_pixels);
-rows.find_copy_source();
+rows.find_copy_source(image.seam_margin);
 
 for (int y = 0; y < tile_resolution.y; y++) {
   Rows::Row  = rows.rows[y];

___
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] [510235a1409] temp-T101739-fix-seam-bleeding-non-manifold: Move structs to header file.

2023-01-10 Thread Jeroen Bakker
Commit: 510235a1409a7796fd33c5a09b8447724ddc4904
Author: Jeroen Bakker
Date:   Thu Jan 5 12:44:04 2023 +0100
Branches: temp-T101739-fix-seam-bleeding-non-manifold
https://developer.blender.org/rB510235a1409a7796fd33c5a09b8447724ddc4904

Move structs to header file.

===

M   source/blender/blenkernel/BKE_pbvh_pixels.hh
M   source/blender/blenkernel/intern/pbvh_pixels_copy.cc

===

diff --git a/source/blender/blenkernel/BKE_pbvh_pixels.hh 
b/source/blender/blenkernel/BKE_pbvh_pixels.hh
index 1b0d51fd37d..28e02dbef8e 100644
--- a/source/blender/blenkernel/BKE_pbvh_pixels.hh
+++ b/source/blender/blenkernel/BKE_pbvh_pixels.hh
@@ -3,6 +3,8 @@
 
 #pragma once
 
+#include 
+
 #include "BLI_math.h"
 #include "BLI_math_vec_types.hh"
 #include "BLI_rect.h"
@@ -242,10 +244,130 @@ struct NodeData {
   }
 };
 
+template struct ImageBufferAccessor {
+  ImBuf _buffer;
+
+  ImageBufferAccessor(ImBuf _buffer) : image_buffer(image_buffer)
+  {
+  }
+
+  float4 read_pixel(const int2 coordinate)
+  {
+int offset = (coordinate.y * image_buffer.x + coordinate.x) * Channels;
+return float4(_buffer.rect_float[offset]);
+  }
+
+  void write_pixel(const int2 coordinate, float4 new_value)
+  {
+int offset = (coordinate.y * image_buffer.x + coordinate.x) * Channels;
+copy_v4_v4(_buffer.rect_float[offset], new_value);
+  }
+};
+
+struct PixelCopyItem {
+  uint8_t delta_destination_x;
+  char2 delta_source_1;
+  char2 delta_source_2;
+  uint8_t mix_factor;
+};
+
+struct PixelCopyGroup {
+  int2 destination;
+  Vector items;
+};
+
+/** Pixel copy command to mix 2 source pixels and write to a destination 
pixel. */
+struct PixelCopyCommand {
+  /** Pixel coordinate to write to. */
+  int2 destination;
+  /** Pixel coordinate to read first source from. */
+  int2 source_1;
+  /** Pixel coordinate to read second source from. */
+  int2 source_2;
+  /** Factor to mix between first and second source. */
+  float mix_factor;
+
+  PixelCopyCommand(const PixelCopyGroup )
+  : destination(group.destination),
+source_1(group.destination),
+source_2(group.destination),
+mix_factor(0.0f)
+  {
+  }
+
+  template
+  void mix_source_and_write_destination(ImageBufferAccessor _buffer) 
const
+  {
+float4 source_color_1 = tile_buffer.read_pixel(source_1);
+float4 source_color_2 = tile_buffer.read_pixel(source_2);
+float4 destination_color = source_color_1 * (1.0f - mix_factor) + 
source_color_2 * mix_factor;
+tile_buffer.write_pixel(destination, destination_color);
+  }
+
+  void apply(const PixelCopyItem )
+  {
+destination.x += int(item.delta_destination_x);
+source_1 += int2(item.delta_source_1);
+source_2 += int2(item.delta_source_2);
+mix_factor = float(item.mix_factor) / 255.0f;
+  }
+};
+
+struct PixelCopyTile {
+  image::TileNumber tile_number;
+  Vector groups;
+
+  void copy_pixels(ImBuf _buffer) const
+  {
+if (tile_buffer.rect_float) {
+  ImageBufferAccessor accessor(tile_buffer);
+  copy_pixels(accessor);
+}
+else {
+  ImageBufferAccessor accessor(tile_buffer);
+  copy_pixels(accessor);
+}
+  }
+
+ private:
+  template void copy_pixels(ImageBufferAccessor _buffer) 
const
+  {
+for (const PixelCopyGroup  : groups) {
+  PixelCopyCommand copy_command(group);
+  for (const PixelCopyItem  : group.items) {
+copy_command.apply(item);
+copy_command.mix_source_and_write_destination(image_buffer);
+  }
+}
+  }
+};
+
+struct PixelCopyTiles {
+  Vector tiles;
+
+  std::optional> 
find_tile(image::TileNumber tile_number)
+  {
+for (PixelCopyTile  : tiles) {
+  if (tile.tile_number == tile_number) {
+return tile;
+  }
+}
+return std::nullopt;
+  }
+
+  void clear()
+  {
+tiles.clear();
+  }
+};
+
 struct PBVHData {
   /* Per UVPRimitive contains the paint data. */
   PaintGeometryPrimitives geom_primitives;
 
+  /** Per ImageTile the pixels to copy to fix non-manifold bleeding. */
+  PixelCopyTiles tiles_copy_pixels;
+
   void clear_data()
   {
 geom_primitives.clear();
@@ -256,4 +378,9 @@ NodeData _pbvh_pixels_node_data_get(PBVHNode );
 void BKE_pbvh_pixels_mark_image_dirty(PBVHNode , Image , ImageUser 
_user);
 PBVHData _pbvh_pixels_data_get(PBVH );
 
+void BKE_pbvh_pixels_copy_update(PBVH , Image , ImageUser 
_user);
+void BKE_pbvh_pixels_copy_pixels(PBVH ,
+ Image ,
+ ImageUser _user,
+ image::TileNumber tile_number);
 }  // namespace blender::bke::pbvh::pixels
diff --git a/source/blender/blenkernel/intern/pbvh_pixels_copy.cc 
b/source/blender/blenkernel/intern/pbvh_pixels_copy.cc
index a80e6606037..ca850812f02 100644
--- a/source/blender/blenkernel/intern/pbvh_pixels_copy.cc
+++ b/source/blender/blenkernel/intern/pbvh_pixels_copy.cc
@@ -1,109 

[Bf-blender-cvs] [99e2195a57e] temp-T101739-fix-seam-bleeding-non-manifold: Merge branch 'master' into temp-T101739-fix-seam-bleeding-non-manifold

2023-01-10 Thread Jeroen Bakker
Commit: 99e2195a57ee791e9ca605dbc55c71100b6ce542
Author: Jeroen Bakker
Date:   Thu Jan 5 09:47:01 2023 +0100
Branches: temp-T101739-fix-seam-bleeding-non-manifold
https://developer.blender.org/rB99e2195a57ee791e9ca605dbc55c71100b6ce542

Merge branch 'master' into temp-T101739-fix-seam-bleeding-non-manifold

===



===



___
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] [c6b4bd407ef] master: Cleanup: deduplicate conditions in transform code

2023-01-10 Thread Germano Cavalcante
Commit: c6b4bd407ef1068ba201c49d971213e5d6785e59
Author: Germano Cavalcante
Date:   Tue Jan 10 09:35:59 2023 -0300
Branches: master
https://developer.blender.org/rBc6b4bd407ef1068ba201c49d971213e5d6785e59

Cleanup: deduplicate conditions in transform code

The `t->spacetype` check is already done in `setSnappingCallback`.

===

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 0eebe05fa0c..00ccf1ed632 100644
--- a/source/blender/editors/transform/transform_snap.cc
+++ b/source/blender/editors/transform/transform_snap.cc
@@ -741,12 +741,7 @@ static void initSnappingMode(TransInfo *t)
 t->tsnap.project = false;
   }
 
-  if (ELEM(t->spacetype, SPACE_VIEW3D, SPACE_IMAGE, SPACE_NODE, SPACE_SEQ)) {
-/* Not with camera selected in camera view. */
-if (!(t->options & CTX_CAMERA)) {
-  setSnappingCallback(t);
-}
-  }
+  setSnappingCallback(t);
 
   if (t->spacetype == SPACE_VIEW3D) {
 if (t->tsnap.object_context == nullptr) {
@@ -903,6 +898,10 @@ void freeSnapping(TransInfo *t)
 static void setSnappingCallback(TransInfo *t)
 {
   if (t->spacetype == SPACE_VIEW3D) {
+if (t->options & CTX_CAMERA) {
+  /* Not with camera selected in camera view. */
+  return;
+}
 t->tsnap.calcSnap = snap_calc_view3d_fn;
   }
   else if (t->spacetype == SPACE_IMAGE) {
@@ -924,6 +923,9 @@ static void setSnappingCallback(TransInfo *t)
 /* The target is calculated along with the snap point. */
 return;
   }
+  else {
+return;
+  }
 
   switch (t->tsnap.source_select) {
 case SCE_SNAP_SOURCE_CLOSEST:

___
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] [08684b2601c] microfacet_hair: Merge branch 'master' into microfacet_hair

2023-01-10 Thread Weizhen Huang
Commit: 08684b2601c7c1826e9214d519670bebb0d6f527
Author: Weizhen Huang
Date:   Tue Jan 10 13:24:52 2023 +0100
Branches: microfacet_hair
https://developer.blender.org/rB08684b2601c7c1826e9214d519670bebb0d6f527

Merge branch 'master' into microfacet_hair

===



===

diff --cc source/blender/blenkernel/intern/geometry_component_curves.cc
index 5a6551f0c8e,075a6838704..44f662300fc
--- a/source/blender/blenkernel/intern/geometry_component_curves.cc
+++ b/source/blender/blenkernel/intern/geometry_component_curves.cc
@@@ -505,12 -501,12 +505,12 @@@ static ComponentAttributeProviders crea
  
tag_component_topology_changed,
  
AttributeValidator{_order_clamp});
  
-   static const fn::CustomMF_SI_SO normal_mode_clamp{
+   static const auto normal_mode_clamp = mf::build::SI1_SO(
"Normal Mode Validate",
[](int8_t value) {
 -return std::clamp(value, NORMAL_MODE_MINIMUM_TWIST, 
NORMAL_MODE_Z_UP);
 +return std::clamp(value, NORMAL_MODE_MINIMUM_TWIST, 
NORMAL_MODE_CURVATURE_VECTOR);
},
-   fn::CustomMF_presets::AllSpanOrSingle()};
+   mf::build::exec_presets::AllSpanOrSingle());
static BuiltinCustomDataLayerProvider normal_mode("normal_mode",
  ATTR_DOMAIN_CURVE,
  CD_PROP_INT8,

___
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] [6f38ce5a406] master: Fix T103679: Add missing operators in object context menu for point cloud and curves

2023-01-10 Thread Pratik Borhade
Commit: 6f38ce5a406ec2771090e6536d96219b2c0f3743
Author: Pratik Borhade
Date:   Tue Jan 10 15:27:57 2023 +0530
Branches: master
https://developer.blender.org/rB6f38ce5a406ec2771090e6536d96219b2c0f3743

Fix T103679: Add missing operators in object context menu for point cloud and 
curves

Set origin and convert operator now accepts point cloud and new curve
object. But these operators were not added in context menu.
Support for set origin and convert operator was added in
rBadb4dd911b91, rB933d56d9e98d and rB2752a88478a8

Reviewed by: HooglyBoogly

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

===

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 60494aa4d9e..0af3325ae2c 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -2696,14 +2696,14 @@ class VIEW3D_MT_object_context_menu(Menu):
 if selected_objects_len > 1:
 layout.operator("object.join")
 
-if obj.type in {'MESH', 'CURVE', 'SURFACE', 'POINTCLOUD', 'META', 
'FONT'}:
+if obj.type in {'MESH', 'CURVE', 'CURVES', 'SURFACE', 
'POINTCLOUD', 'META', 'FONT'}:
 layout.operator_menu_enum("object.convert", "target")
 
 if obj.type == 'GPENCIL':
 layout.operator_menu_enum("gpencil.convert", "type", 
text="Convert To")
 
 if (
-obj.type in {'MESH', 'CURVE', 'SURFACE', 'GPENCIL', 
'LATTICE', 'ARMATURE', 'META', 'FONT'} or
+obj.type in {'MESH', 'CURVE', 'CURVES', 'SURFACE', 
'GPENCIL', 'LATTICE', 'ARMATURE', 'META', 'FONT', 'POINTCLOUD'} or
 (obj.type == 'EMPTY' and obj.instance_collection is not 
None)
 ):
 layout.operator_context = 'INVOKE_REGION_WIN'

___
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] [b7f5e4b1b61] master: Fix building on MSVC

2023-01-10 Thread Campbell Barton
Commit: b7f5e4b1b61653a8c50f6593df74b4aa4995ff6f
Author: Campbell Barton
Date:   Tue Jan 10 19:04:07 2023 +1100
Branches: master
https://developer.blender.org/rBb7f5e4b1b61653a8c50f6593df74b4aa4995ff6f

Fix building on MSVC

Empty struct introduced in dad9f45561a1cd129d86cbdd93b883dcaef0df26.

===

M   source/blender/makesdna/DNA_modifier_defaults.h

===

diff --git a/source/blender/makesdna/DNA_modifier_defaults.h 
b/source/blender/makesdna/DNA_modifier_defaults.h
index 6ba973ee4ec..44644d7eb78 100644
--- a/source/blender/makesdna/DNA_modifier_defaults.h
+++ b/source/blender/makesdna/DNA_modifier_defaults.h
@@ -616,7 +616,7 @@
 
 #define _DNA_DEFAULT_SurfaceModifierData \
   { \
-/* Intentionally empty (all run-time data). */ \
+   .runtime = {NULL}, /* Include to avoid empty an struct (for MSVC). */ \
   }
 
 #define _DNA_DEFAULT_SurfaceDeformModifierData \

___
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