[Bf-blender-cvs] [a652568570a] master: Cleanup: use 'num' / 'size' suffix instead of 'sz'

2022-05-10 Thread Campbell Barton
Commit: a652568570a5c86247966e7805740f190ee7e388
Author: Campbell Barton
Date:   Wed May 11 13:37:10 2022 +1000
Branches: master
https://developer.blender.org/rBa652568570a5c86247966e7805740f190ee7e388

Cleanup: use 'num' / 'size' suffix instead of 'sz'

GPU code used `sz` as an abbreviation for size, as well as a few other
places. Use size where this represents a size in bytes, see: T85728.

===

M   source/blender/blenkernel/intern/main.c
M   source/blender/blenlib/BLI_fileops.h
M   source/blender/blenlib/intern/BLI_filelist.c
M   source/blender/blenlib/tests/performance/BLI_ghash_performance_test.cc
M   source/blender/blenloader/intern/readfile.c
M   source/blender/compositor/operations/COM_FastGaussianBlurOperation.cc
M   source/blender/editors/animation/keyframes_draw.c
M   source/blender/gpu/GPU_vertex_format.h
M   source/blender/gpu/intern/gpu_debug.cc
M   source/blender/gpu/intern/gpu_immediate.cc
M   source/blender/gpu/intern/gpu_vertex_buffer.cc
M   source/blender/gpu/intern/gpu_vertex_format.cc
M   source/blender/gpu/opengl/gl_vertex_array.cc
M   source/blender/nodes/texture/node_texture_util.c

===

diff --git a/source/blender/blenkernel/intern/main.c 
b/source/blender/blenkernel/intern/main.c
index 03e03dacfbc..b9ed783fa8c 100644
--- a/source/blender/blenkernel/intern/main.c
+++ b/source/blender/blenkernel/intern/main.c
@@ -502,13 +502,13 @@ BlendThumbnail *BKE_main_thumbnail_from_imbuf(Main 
*bmain, ImBuf *img)
   }
 
   if (img) {
-const size_t sz = BLEN_THUMB_MEMSIZE(img->x, img->y);
-data = MEM_mallocN(sz, __func__);
+const size_t data_size = BLEN_THUMB_MEMSIZE(img->x, img->y);
+data = MEM_mallocN(data_size, __func__);
 
 IMB_rect_from_float(img); /* Just in case... */
 data->width = img->x;
 data->height = img->y;
-memcpy(data->rect, img->rect, sz - sizeof(*data));
+memcpy(data->rect, img->rect, data_size - sizeof(*data));
   }
 
   if (bmain) {
diff --git a/source/blender/blenlib/BLI_fileops.h 
b/source/blender/blenlib/BLI_fileops.h
index 3ce2b90e729..9a24b09fc66 100644
--- a/source/blender/blenlib/BLI_fileops.h
+++ b/source/blender/blenlib/BLI_fileops.h
@@ -178,7 +178,7 @@ void BLI_filelist_free(struct direntry *filelist, unsigned 
int nrentries);
  * Convert given entry's size into human-readable strings.
  */
 void BLI_filelist_entry_size_to_string(const struct stat *st,
-   uint64_t sz,
+   uint64_t st_size_fallback,
bool compact,
char 
r_size[FILELIST_DIRENTRY_SIZE_LEN]);
 /**
diff --git a/source/blender/blenlib/intern/BLI_filelist.c 
b/source/blender/blenlib/intern/BLI_filelist.c
index 76fc5b6342a..c6178ebb3a0 100644
--- a/source/blender/blenlib/intern/BLI_filelist.c
+++ b/source/blender/blenlib/intern/BLI_filelist.c
@@ -237,7 +237,7 @@ unsigned int BLI_filelist_dir_contents(const char *dirname, 
struct direntry **r_
 }
 
 void BLI_filelist_entry_size_to_string(const struct stat *st,
-   const uint64_t sz,
+   const uint64_t st_size_fallback,
/* Used to change MB -> M, etc. - is 
that really useful? */
const bool UNUSED(compact),
char r_size[FILELIST_DIRENTRY_SIZE_LEN])
@@ -247,7 +247,7 @@ void BLI_filelist_entry_size_to_string(const struct stat 
*st,
* will buy us some time until files get bigger than 4GB or until
* everyone starts using __USE_FILE_OFFSET64 or equivalent.
*/
-  double size = (double)(st ? st->st_size : sz);
+  double size = (double)(st ? st->st_size : st_size_fallback);
 #ifdef WIN32
   BLI_str_format_byte_unit(r_size, size, false);
 #else
diff --git 
a/source/blender/blenlib/tests/performance/BLI_ghash_performance_test.cc 
b/source/blender/blenlib/tests/performance/BLI_ghash_performance_test.cc
index 0ff488202c2..09bb1e7239f 100644
--- a/source/blender/blenlib/tests/performance/BLI_ghash_performance_test.cc
+++ b/source/blender/blenlib/tests/performance/BLI_ghash_performance_test.cc
@@ -57,23 +57,23 @@ static void str_ghash_tests(GHash *ghash, const char *id)
   printf("\n== STARTING %s ==\n", id);
 
 #ifdef TEXT_CORPUS_PATH
-  size_t sz = 0;
+  size_t data_size = 0;
   char *data;
   {
 struct stat st;
 if (stat(TEXT_CORPUS_PATH, ) == 0)
-  sz = st.st_size;
+  data_size = st.st_size;
   }
-  if (sz != 0) {
+  if (data_size != 0) {
 FILE *f = fopen(TEXT_CORPUS_PATH, "r");
 
-data = (char *)MEM_mallocN(sz + 1, __func__);
-if (fread(data, sizeof(*data), sz, f) != sz) {
+data = (char *)MEM_mallocN(data_size + 1, __func__);
+if (fread(data, 

[Bf-blender-cvs] [42e275a7d4f] master: Cleanup: use '_num' suffix, mostly for curves & spline code

2022-05-10 Thread Campbell Barton
Commit: 42e275a7d4fff6464024d99a78f69f1cb490d930
Author: Campbell Barton
Date:   Wed May 11 12:59:58 2022 +1000
Branches: master
https://developer.blender.org/rB42e275a7d4fff6464024d99a78f69f1cb490d930

Cleanup: use '_num' suffix, mostly for curves & spline code

Replace tot/amount & size with num, in keeping with T85728.

===

M   source/blender/blenkernel/BKE_curves.hh
M   source/blender/blenkernel/BKE_geometry_set.hh
M   source/blender/blenkernel/BKE_spline.hh
M   source/blender/blenkernel/intern/attribute_access.cc
M   source/blender/blenkernel/intern/attribute_access_intern.hh
M   source/blender/blenkernel/intern/curve_catmull_rom.cc
M   source/blender/blenkernel/intern/curve_eval.cc
M   source/blender/blenkernel/intern/curve_nurbs.cc
M   source/blender/blenkernel/intern/curve_to_mesh_convert.cc
M   source/blender/blenkernel/intern/curves_geometry.cc
M   source/blender/blenkernel/intern/geometry_component_curve.cc
M   source/blender/blenkernel/intern/geometry_component_curves.cc
M   source/blender/blenkernel/intern/geometry_component_instances.cc
M   source/blender/blenkernel/intern/geometry_component_mesh.cc
M   source/blender/blenkernel/intern/geometry_component_pointcloud.cc
M   source/blender/blenkernel/intern/geometry_set.cc
M   source/blender/blenkernel/intern/spline_base.cc
M   source/blender/blenkernel/intern/spline_bezier.cc
M   source/blender/blenkernel/intern/spline_nurbs.cc
M   source/blender/blenkernel/intern/spline_poly.cc
M   source/blender/blenlib/BLI_length_parameterize.hh
M   source/blender/draw/intern/draw_cache_impl_curve.cc
M   source/blender/editors/space_node/node_draw.cc
M   
source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc
M   source/blender/editors/space_spreadsheet/spreadsheet_dataset_draw.cc
M   source/blender/geometry/intern/realize_instances.cc
M   source/blender/modifiers/intern/MOD_nodes.cc
M   source/blender/nodes/NOD_geometry_nodes_eval_log.hh
M   source/blender/nodes/geometry/nodes/node_geo_accumulate_field.cc
M   source/blender/nodes/geometry/nodes/node_geo_attribute_capture.cc
M   source/blender/nodes/geometry/nodes/node_geo_attribute_domain_size.cc
M   source/blender/nodes/geometry/nodes/node_geo_attribute_statistic.cc
M   source/blender/nodes/geometry/nodes/node_geo_convex_hull.cc
M   source/blender/nodes/geometry/nodes/node_geo_curve_fillet.cc
M   source/blender/nodes/geometry/nodes/node_geo_curve_reverse.cc
M   source/blender/nodes/geometry/nodes/node_geo_curve_spline_type.cc
M   source/blender/nodes/geometry/nodes/node_geo_curve_subdivide.cc
M   source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc
M   source/blender/nodes/geometry/nodes/node_geo_curve_trim.cc
M   source/blender/nodes/geometry/nodes/node_geo_delete_geometry.cc
M   
source/blender/nodes/geometry/nodes/node_geo_distribute_points_on_faces.cc
M   source/blender/nodes/geometry/nodes/node_geo_duplicate_elements.cc
M   source/blender/nodes/geometry/nodes/node_geo_edge_split.cc
M   source/blender/nodes/geometry/nodes/node_geo_field_at_index.cc
M   source/blender/nodes/geometry/nodes/node_geo_flip_faces.cc
M   source/blender/nodes/geometry/nodes/node_geo_input_mesh_island.cc
M   source/blender/nodes/geometry/nodes/node_geo_instance_on_points.cc
M   source/blender/nodes/geometry/nodes/node_geo_instances_to_points.cc
M   source/blender/nodes/geometry/nodes/node_geo_join_geometry.cc
M   source/blender/nodes/geometry/nodes/node_geo_merge_by_distance.cc
M   source/blender/nodes/geometry/nodes/node_geo_mesh_to_curve.cc
M   source/blender/nodes/geometry/nodes/node_geo_mesh_to_points.cc
M   source/blender/nodes/geometry/nodes/node_geo_points_to_vertices.cc
M   source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc
M   source/blender/nodes/geometry/nodes/node_geo_raycast.cc
M   source/blender/nodes/geometry/nodes/node_geo_rotate_instances.cc
M   source/blender/nodes/geometry/nodes/node_geo_scale_instances.cc
M   source/blender/nodes/geometry/nodes/node_geo_set_curve_handles.cc
M   source/blender/nodes/geometry/nodes/node_geo_set_curve_radius.cc
M   source/blender/nodes/geometry/nodes/node_geo_set_curve_tilt.cc
M   source/blender/nodes/geometry/nodes/node_geo_set_id.cc
M   source/blender/nodes/geometry/nodes/node_geo_set_material_index.cc
M   source/blender/nodes/geometry/nodes/node_geo_set_point_radius.cc
M   source/blender/nodes/geometry/nodes/node_geo_set_position.cc
M   source/blender/nodes/geometry/nodes/node_geo_set_shade_smooth.cc
M   source/blender/nodes/geometry/nodes/node_geo_set_spline_cyclic.cc
M   source/blender/nodes/geometry/nodes/node_geo_set_spline_resolution.cc
M   

[Bf-blender-cvs] [2fa2612b06d] master: Cleanup: use '_num' / '_count' suffix instead of '_ct'

2022-05-10 Thread Campbell Barton
Commit: 2fa2612b06d05c0ef4b3a78d2701cb53e1899d90
Author: Campbell Barton
Date:   Wed May 11 13:19:56 2022 +1000
Branches: master
https://developer.blender.org/rB2fa2612b06d05c0ef4b3a78d2701cb53e1899d90

Cleanup: use '_num' / '_count' suffix instead of '_ct'

Use num & count (for counters), in drawing code, see: T85728.

===

M   source/blender/draw/engines/eevee/eevee_lightcache.c
M   source/blender/draw/engines/gpencil/gpencil_render.c
M   source/blender/draw/engines/overlay/overlay_gpencil.c
M   source/blender/draw/engines/workbench/workbench_render.c
M   source/blender/draw/engines/workbench/workbench_volume.c
M   source/blender/draw/intern/DRW_render.h
M   source/blender/draw/intern/draw_manager.c
M   source/blender/draw/intern/draw_manager.h
M   source/blender/draw/intern/draw_manager_data.c

===

diff --git a/source/blender/draw/engines/eevee/eevee_lightcache.c 
b/source/blender/draw/engines/eevee/eevee_lightcache.c
index 4f562dd9804..0b9909a904b 100644
--- a/source/blender/draw/engines/eevee/eevee_lightcache.c
+++ b/source/blender/draw/engines/eevee/eevee_lightcache.c
@@ -95,7 +95,7 @@ typedef struct EEVEE_LightBake {
   /** Target layer to store the data to. */
   int layer;
   /** Sample count for the convolution. */
-  float samples_ct, invsamples_ct;
+  float samples_count, invsamples_count;
   /** Sampling bias during convolution step. */
   float lod_factor;
   /** Max cube-map LOD to sample when convolving. */
@@ -282,14 +282,14 @@ static void irradiance_pool_size_get(int visibility_size, 
int total_samples, int
 (visibility_size / IRRADIANCE_SAMPLE_SIZE_Y);
 
   /* The irradiance itself take one layer, hence the +1 */
-  int layer_ct = MIN2(irr_per_vis + 1, IRRADIANCE_MAX_POOL_LAYER);
+  int layer_count = MIN2(irr_per_vis + 1, IRRADIANCE_MAX_POOL_LAYER);
 
-  int texel_ct = (int)ceilf((float)total_samples / (float)(layer_ct - 1));
+  int texel_count = (int)ceilf((float)total_samples / (float)(layer_count - 
1));
   r_size[0] = visibility_size *
-  max_ii(1, min_ii(texel_ct, (IRRADIANCE_MAX_POOL_SIZE / 
visibility_size)));
+  max_ii(1, min_ii(texel_count, (IRRADIANCE_MAX_POOL_SIZE / 
visibility_size)));
   r_size[1] = visibility_size *
-  max_ii(1, (texel_ct / (IRRADIANCE_MAX_POOL_SIZE / 
visibility_size)));
-  r_size[2] = layer_ct;
+  max_ii(1, (texel_count / (IRRADIANCE_MAX_POOL_SIZE / 
visibility_size)));
+  r_size[2] = layer_count;
 }
 
 static bool EEVEE_lightcache_validate(const LightCache *light_cache,
diff --git a/source/blender/draw/engines/gpencil/gpencil_render.c 
b/source/blender/draw/engines/gpencil/gpencil_render.c
index 19afdb3de5a..c7ef8677336 100644
--- a/source/blender/draw/engines/gpencil/gpencil_render.c
+++ b/source/blender/draw/engines/gpencil/gpencil_render.c
@@ -61,10 +61,10 @@ void GPENCIL_render_init(GPENCIL_Data *vedata,
 /* Depth need to be remapped to [0..1] range. */
 pix_z = MEM_dupallocN(pix_z);
 
-int pix_ct = rpass_z_src->rectx * rpass_z_src->recty;
+int pix_num = rpass_z_src->rectx * rpass_z_src->recty;
 
 if (DRW_view_is_persp_get(view)) {
-  for (int i = 0; i < pix_ct; i++) {
+  for (int i = 0; i < pix_num; i++) {
 pix_z[i] = (-winmat[3][2] / -pix_z[i]) - winmat[2][2];
 pix_z[i] = clamp_f(pix_z[i] * 0.5f + 0.5f, 0.0f, 1.0f);
   }
@@ -74,7 +74,7 @@ void GPENCIL_render_init(GPENCIL_Data *vedata,
   float near = DRW_view_near_distance_get(view);
   float far = DRW_view_far_distance_get(view);
   float range_inv = 1.0f / fabsf(far - near);
-  for (int i = 0; i < pix_ct; i++) {
+  for (int i = 0; i < pix_num; i++) {
 pix_z[i] = (pix_z[i] + near) * range_inv;
 pix_z[i] = clamp_f(pix_z[i], 0.0f, 1.0f);
   }
@@ -172,11 +172,11 @@ static void GPENCIL_render_result_z(struct RenderLayer 
*rl,
 float winmat[4][4];
 DRW_view_winmat_get(NULL, winmat, false);
 
-int pix_ct = BLI_rcti_size_x(rect) * BLI_rcti_size_y(rect);
+int pix_num = BLI_rcti_size_x(rect) * BLI_rcti_size_y(rect);
 
 /* Convert GPU depth [0..1] to view Z [near..far] */
 if (DRW_view_is_persp_get(NULL)) {
-  for (int i = 0; i < pix_ct; i++) {
+  for (int i = 0; i < pix_num; i++) {
 if (rp->rect[i] == 1.0f) {
   rp->rect[i] = 1e10f; /* Background */
 }
@@ -192,7 +192,7 @@ static void GPENCIL_render_result_z(struct RenderLayer *rl,
   float far = DRW_view_far_distance_get(NULL);
   float range = fabsf(far - near);
 
-  for (int i = 0; i < pix_ct; i++) {
+  for (int i = 0; i < pix_num; i++) {
 if (rp->rect[i] == 1.0f) {
   rp->rect[i] = 1e10f; /* Background */
 }
diff --git a/source/blender/draw/engines/overlay/overlay_gpencil.c 
b/source/blender/draw/engines/overlay/overlay_gpencil.c
index 

[Bf-blender-cvs] [09e05193c7d] temp-pbvh-split: temp-pbvh-split: Use TaskPool API for texture node splitting

2022-05-10 Thread Joseph Eagar
Commit: 09e05193c7dd6f1db837dcbf2f6a6deb535b841e
Author: Joseph Eagar
Date:   Tue May 10 18:39:22 2022 -0700
Branches: temp-pbvh-split
https://developer.blender.org/rB09e05193c7dd6f1db837dcbf2f6a6deb535b841e

temp-pbvh-split: Use TaskPool API for texture node splitting

===

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

===

diff --git a/source/blender/blenkernel/intern/pbvh_pixels.cc 
b/source/blender/blenkernel/intern/pbvh_pixels.cc
index 8bf691ba1fa..457a7bc9af1 100644
--- a/source/blender/blenkernel/intern/pbvh_pixels.cc
+++ b/source/blender/blenkernel/intern/pbvh_pixels.cc
@@ -71,18 +71,18 @@ int count_node_pixels(PBVHNode )
   return totpixel;
 }
 
-struct SplitThreadData {
+struct SplitQueueData {
   ThreadQueue *queue;
   ThreadQueue *new_nodes;
-  int thread_num, thread_nr;
-  std::atomic *working;
-
-  std::atomic *nodes_num;
+  int thread_num;
 
   PBVH *pbvh;
   Mesh *mesh;
   Image *image;
   ImageUser *image_user;
+
+  std::atomic *working;
+  std::atomic *nodes_num;
 };
 
 struct SplitNodePair {
@@ -104,7 +104,7 @@ static void split_pixel_node(PBVH *pbvh,
  Mesh *mesh,
  Image *image,
  ImageUser *image_user,
- SplitThreadData *tdata)
+ SplitQueueData *tdata)
 {
   BB cb;
   PBVHNode *node = >node;
@@ -256,7 +256,7 @@ static void split_pixel_node(PBVH *pbvh,
   BLI_thread_queue_push(tdata->queue, static_cast(split2));
 }
 
-static void split_flush_final_nodes(SplitThreadData *tdata)
+static void split_flush_final_nodes(SplitQueueData *tdata)
 {
   PBVH *pbvh = tdata->pbvh;
   Vector splits;
@@ -293,10 +293,10 @@ static void split_flush_final_nodes(SplitThreadData 
*tdata)
   }
 }
 
-extern "C" static void *split_thread_job(void *_tdata)
+extern "C" static void split_thread_job(TaskPool *__restrict pool, void 
*taskdata)
 {
-  SplitThreadData *tdata = static_cast(_tdata);
-  int thread_nr = tdata->thread_nr;
+  SplitQueueData *tdata = static_cast(BLI_task_pool_user_data(pool));
+  int thread_nr = POINTER_AS_UINT(taskdata);
 
   tdata->working[thread_nr].store(false);
 
@@ -306,6 +306,8 @@ extern "C" static void *split_thread_job(void *_tdata)
 if (work) {
   SplitNodePair *split = static_cast(work);
 
+  /* Signal to other threads that we are working, needed to prevent
+ premature task exit when the queue is temporarily empty. */
   tdata->working[thread_nr].store(true);
   split_pixel_node(tdata->pbvh, split, tdata->mesh, tdata->image, 
tdata->image_user, tdata);
   tdata->working[thread_nr].store(false);
@@ -321,12 +323,11 @@ extern "C" static void *split_thread_job(void *_tdata)
   }
 }
 
+/* No nodes left in queue? End task. */
 if (ok) {
   break;
 }
   }
-
-  return nullptr;
 }
 
 static void split_pixel_nodes(PBVH *pbvh, Mesh *mesh, Image *image, ImageUser 
*image_user)
@@ -343,7 +344,7 @@ static void split_pixel_nodes(PBVH *pbvh, Mesh *mesh, Image 
*image, ImageUser *i
 pbvh->pixel_leaf_limit = 256 * 256; /* TODO: move into a constant */
   }
 
-  SplitThreadData tdata;
+  SplitQueueData tdata;
 
   tdata.nodes_num = MEM_new>("tdata.nodes_num");
   tdata.nodes_num->store(pbvh->totnode);
@@ -369,24 +370,22 @@ static void split_pixel_nodes(PBVH *pbvh, Mesh *mesh, 
Image *image, ImageUser *i
 }
   }
 
-  Vector tdatas;
   int thread_num = tdata.thread_num = G.debug_value != 892 ? 
BLI_system_thread_count() : 1;
-
   tdata.working = new std::atomic[thread_num];
 
-  ListBase threads;
-  BLI_threadpool_init(, split_thread_job, thread_num);
+#if 0
+  TaskPool *pool = BLI_task_pool_create_no_threads();
+#else
+  TaskPool *pool = BLI_task_pool_create_suspended(, TASK_PRIORITY_HIGH);
+#endif
 
   for (int i : IndexRange(thread_num)) {
-tdata.thread_nr = i;
-tdatas.append(tdata);
+BLI_task_pool_push(pool, split_thread_job, POINTER_FROM_UINT(i), false, 
nullptr);
   }
 
-  for (int i : IndexRange(thread_num)) {
-BLI_threadpool_insert(, [i]);
-  }
+  BLI_task_pool_work_and_wait(pool);
+  BLI_task_pool_free(pool);
 
-  BLI_threadpool_end();
   split_flush_final_nodes();
 
   delete[] tdata.working;
@@ -763,7 +762,11 @@ void pbvh_pixels_free(PBVHNode *node)
 {
   NodeData *node_data = static_cast(node->pixels.node_data);
 
-  if (node->flag & PBVH_Leaf) {
+  if (!node_data) {
+return;
+  }
+
+  if (node_data->triangles && (node->flag & PBVH_Leaf)) {
 MEM_delete(node_data->triangles);
   }

___
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] [b617e66e36f] temp-pbvh-split: Merge branch 'master' into temp-pbvh-split

2022-05-10 Thread Joseph Eagar
Commit: b617e66e36fc93fbea49930ae5dc88a672a64568
Author: Joseph Eagar
Date:   Tue May 10 17:10:37 2022 -0700
Branches: temp-pbvh-split
https://developer.blender.org/rBb617e66e36fc93fbea49930ae5dc88a672a64568

Merge branch 'master' into temp-pbvh-split

===



===



___
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] [0d24e8af62d] temp-pbvh-split: temp-pbvh-split: reuse triangles array.

2022-05-10 Thread Joseph Eagar
Commit: 0d24e8af62db5836da13dec0f518bb5643688506
Author: Joseph Eagar
Date:   Tue May 10 18:05:54 2022 -0700
Branches: temp-pbvh-split
https://developer.blender.org/rB0d24e8af62db5836da13dec0f518bb5643688506

temp-pbvh-split: reuse triangles array.

===

M   source/blender/blenkernel/BKE_pbvh_pixels.hh
M   source/blender/blenkernel/intern/pbvh.c
M   source/blender/blenkernel/intern/pbvh_pixels.cc
M   source/blender/editors/sculpt_paint/sculpt_paint_image.cc
M   source/tools

===

diff --git a/source/blender/blenkernel/BKE_pbvh_pixels.hh 
b/source/blender/blenkernel/BKE_pbvh_pixels.hh
index fdfb5fa037e..194cd7e3b07 100644
--- a/source/blender/blenkernel/BKE_pbvh_pixels.hh
+++ b/source/blender/blenkernel/BKE_pbvh_pixels.hh
@@ -138,7 +138,7 @@ struct NodeData {
   } flags;
 
   Vector tiles;
-  Triangles triangles;
+  Triangles *triangles = nullptr;
 
   NodeData()
   {
@@ -168,7 +168,6 @@ struct NodeData {
   void clear_data()
   {
 tiles.clear();
-triangles.clear();
   }
 
   static void free_func(void *instance)
diff --git a/source/blender/blenkernel/intern/pbvh.c 
b/source/blender/blenkernel/intern/pbvh.c
index 129624d0885..23db3b8350a 100644
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@ -689,7 +689,7 @@ void BKE_pbvh_free(PBVH *pbvh)
   }
 }
 
-if (node->flag & PBVH_TexLeaf) {
+if (node->flag & (PBVH_Leaf | PBVH_TexLeaf)) {
   pbvh_pixels_free(node);
 }
   }
diff --git a/source/blender/blenkernel/intern/pbvh_pixels.cc 
b/source/blender/blenkernel/intern/pbvh_pixels.cc
index c30dcbbc909..8bf691ba1fa 100644
--- a/source/blender/blenkernel/intern/pbvh_pixels.cc
+++ b/source/blender/blenkernel/intern/pbvh_pixels.cc
@@ -179,7 +179,7 @@ static void split_pixel_node(PBVH *pbvh,
   UDIMTilePixels *tile1 = >tiles[i];
   UDIMTilePixels *tile2 = >tiles[i];
 
-  TrianglePaintInput  = data.triangles.paint_input[row.triangle_index];
+  TrianglePaintInput  = 
data.triangles->paint_input[row.triangle_index];
 
   float verts[3][3];
 
@@ -242,7 +242,12 @@ static void split_pixel_node(PBVH *pbvh,
 BKE_image_release_ibuf(image, image_buffer, nullptr);
   }
 
-  pbvh_pixels_free(node);
+  if (node->flag & PBVH_Leaf) {
+data.clear_data();
+  }
+  else {
+pbvh_pixels_free(node);
+  }
 
   BLI_thread_queue_push(tdata->new_nodes, static_cast(split1));
   BLI_thread_queue_push(tdata->new_nodes, static_cast(split2));
@@ -440,9 +445,15 @@ static void extract_barycentric_pixels(UDIMTilePixels 
_data,
 
 static void init_triangles(PBVH *pbvh, PBVHNode *node, NodeData *node_data, 
const MLoop *mloop)
 {
+  if (node_data->triangles) {
+MEM_delete(node_data->triangles);
+  }
+
+  node_data->triangles = MEM_new("triangles");
+
   for (int i = 0; i < node->totprim; i++) {
 const MLoopTri *lt = >looptri[node->prim_indices[i]];
-node_data->triangles.append(
+node_data->triangles->append(
 int3(mloop[lt->tri[0]].v, mloop[lt->tri[1]].v, mloop[lt->tri[2]].v));
   }
 }
@@ -476,7 +487,7 @@ static void do_encode_pixels(void *__restrict userdata,
 float2 tile_offset = float2(image_tile.get_tile_offset());
 UDIMTilePixels tile_data;
 
-Triangles  = node_data->triangles;
+Triangles  = *node_data->triangles;
 for (int triangle_index = 0; triangle_index < triangles.size(); 
triangle_index++) {
   const MLoopTri *lt = >looptri[node->prim_indices[triangle_index]];
   float2 uvs[3] = {
@@ -574,6 +585,11 @@ static bool find_nodes_to_update(PBVH *pbvh, 
Vector _nodes_to_upda
 else {
   NodeData *node_data = static_cast(node->pixels.node_data);
   node_data->clear_data();
+
+  if (node_data->triangles && (node->flag & PBVH_Leaf)) {
+MEM_delete(node_data->triangles);
+node_data->triangles = nullptr;
+  }
 }
   }
 
@@ -746,6 +762,11 @@ void BKE_pbvh_build_pixels(PBVH *pbvh, Mesh *mesh, Image 
*image, ImageUser *imag
 void pbvh_pixels_free(PBVHNode *node)
 {
   NodeData *node_data = static_cast(node->pixels.node_data);
+
+  if (node->flag & PBVH_Leaf) {
+MEM_delete(node_data->triangles);
+  }
+
   MEM_delete(node_data);
   node->pixels.node_data = nullptr;
 }
diff --git a/source/blender/editors/sculpt_paint/sculpt_paint_image.cc 
b/source/blender/editors/sculpt_paint/sculpt_paint_image.cc
index 62dd85b3ed6..ba09a8f89ac 100644
--- a/source/blender/editors/sculpt_paint/sculpt_paint_image.cc
+++ b/source/blender/editors/sculpt_paint/sculpt_paint_image.cc
@@ -321,7 +321,7 @@ static void do_paint_pixels(void *__restrict userdata,
   const int thread_id = BLI_task_parallel_thread_id(tls);
   MVert *mvert = SCULPT_mesh_deformed_mverts_get(ss);
 
-  std::vector brush_test = init_triangle_brush_test(ss, 
node_data.triangles, mvert);
+  std::vector brush_test = init_triangle_brush_test(ss, 
*node_data.triangles, 

[Bf-blender-cvs] [17ab0342acf] master: Cleanup: spelling in comments

2022-05-10 Thread Campbell Barton
Commit: 17ab0342acfd36a15812011311d8be88cf782192
Author: Campbell Barton
Date:   Wed May 11 10:03:17 2022 +1000
Branches: master
https://developer.blender.org/rB17ab0342acfd36a15812011311d8be88cf782192

Cleanup: spelling in comments

Revert change from [0] that assumed UNORM was a mis-spelling of UNIFORM.

[0]: 2c75857f9fc0dc5d524e4a0407e0a68856e5906e

===

M   source/blender/editors/sculpt_paint/curves_sculpt_add.cc
M   source/blender/geometry/GEO_resample_curves.hh
M   source/blender/gpu/GPU_shader.h
M   source/blender/gpu/GPU_texture.h
M   source/blender/gpu/opengl/gl_texture.hh
M   source/blender/imbuf/intern/jpeg.c

===

diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_add.cc 
b/source/blender/editors/sculpt_paint/curves_sculpt_add.cc
index 18bdbb88d8f..feda57fff1f 100644
--- a/source/blender/editors/sculpt_paint/curves_sculpt_add.cc
+++ b/source/blender/editors/sculpt_paint/curves_sculpt_add.cc
@@ -234,7 +234,7 @@ struct AddOperationExecutor {
   neighbors_per_curve = this->find_curve_neighbors(added_points);
 }
 
-/* Resize to add the new curves, building the offests in the array owned 
by thge curves. */
+/* Resize to add the new curves, building the offsets in the array owned 
by the curves. */
 const int tot_added_curves = added_points.bary_coords.size();
 curves_->resize(curves_->points_num(), curves_->curves_num() + 
tot_added_curves);
 if (interpolate_point_count_) {
diff --git a/source/blender/geometry/GEO_resample_curves.hh 
b/source/blender/geometry/GEO_resample_curves.hh
index 7cfb5dadde6..97399ccb0a5 100644
--- a/source/blender/geometry/GEO_resample_curves.hh
+++ b/source/blender/geometry/GEO_resample_curves.hh
@@ -15,7 +15,7 @@ namespace blender::geometry {
  * samples defined by the count field. Interpolate attributes to the result, 
with an accuracy that
  * depends on the curve's resolution parameter.
  *
- * \note The values provided by the #count_field are clampled to 1 or greater.
+ * \note The values provided by the #count_field are clamped to 1 or greater.
  */
 Curves *resample_to_count(const CurveComponent _component,
   const fn::Field _field,
diff --git a/source/blender/gpu/GPU_shader.h b/source/blender/gpu/GPU_shader.h
index 72a36ebfac4..3460d33fe68 100644
--- a/source/blender/gpu/GPU_shader.h
+++ b/source/blender/gpu/GPU_shader.h
@@ -282,7 +282,7 @@ typedef enum eGPUBuiltinShader {
   /**
* Draw a texture in 3D. Take a 3D position and a 2D texture coordinate for 
each vertex.
*
-   * Exposed via pyapi for add-ons.
+   * Exposed via Python-API for add-ons.
*
* \param image: uniform sampler2D
* \param texCoord: in vec2
diff --git a/source/blender/gpu/GPU_texture.h b/source/blender/gpu/GPU_texture.h
index 474205ce8c3..b045d908438 100644
--- a/source/blender/gpu/GPU_texture.h
+++ b/source/blender/gpu/GPU_texture.h
@@ -282,7 +282,7 @@ void *GPU_texture_read(GPUTexture *tex, eGPUDataFormat 
data_format, int miplvl);
  * \warning Only work for 2D texture for now.
  * \warning Only clears the MIP 0 of the texture.
  * \param data_format: data format of the pixel data.
- * \note The format is float for uniform textures.
+ * \note The format is float for UNORM textures.
  * \param data: 1 pixel worth of data to fill the texture with.
  */
 void GPU_texture_clear(GPUTexture *tex, eGPUDataFormat data_format, const void 
*data);
diff --git a/source/blender/gpu/opengl/gl_texture.hh 
b/source/blender/gpu/opengl/gl_texture.hh
index 2dde8d6c86b..e5b879f1f15 100644
--- a/source/blender/gpu/opengl/gl_texture.hh
+++ b/source/blender/gpu/opengl/gl_texture.hh
@@ -363,7 +363,7 @@ inline GLenum to_gl_data_format(eGPUTextureFormat format)
 }
 
 /**
- * Assume Unorm / Float target. Used with #glReadPixels.
+ * Assume UNORM/Float target. Used with #glReadPixels.
  */
 inline GLenum channel_len_to_gl(int channel_len)
 {
diff --git a/source/blender/imbuf/intern/jpeg.c 
b/source/blender/imbuf/intern/jpeg.c
index 80fcceb0aa7..cffa61977f7 100644
--- a/source/blender/imbuf/intern/jpeg.c
+++ b/source/blender/imbuf/intern/jpeg.c
@@ -286,8 +286,8 @@ static ImBuf *ibJpegImageFromCinfo(struct 
jpeg_decompress_struct *cinfo,
 }
 
 if (max_size > 0) {
-  /* libjpeg can more quickly decompress while scaling down to 1/2, 1/4, 
1/8,
-   * while libjpeg-turbo can also do 3/8, 5/8, etc. But max is 1/8. */
+  /* `libjpeg` can more quickly decompress while scaling down to 1/2, 1/4, 
1/8,
+   * while `libjpeg-turbo` can also do 3/8, 5/8, etc. But max is 1/8. */
   float scale = (float)max_size / MAX2(cinfo->image_width, 
cinfo->image_height);
   cinfo->scale_denom = 8;
   cinfo->scale_num = max_uu(1, min_uu(8, ceill(scale * 
(float)cinfo->scale_denom)));
@@ -520,9 +520,9 @@ struct ImBuf *imb_thumbnail_jpeg(const char *filepath,
 
   if ((fgetc(infile) 

[Bf-blender-cvs] [8f1a11c35ac] master: WM: clear wmEvent.flag for file-select events

2022-05-10 Thread Campbell Barton
Commit: 8f1a11c35ace98c9fd0ee6db131a02852660ed25
Author: Campbell Barton
Date:   Wed May 11 10:03:37 2022 +1000
Branches: master
https://developer.blender.org/rB8f1a11c35ace98c9fd0ee6db131a02852660ed25

WM: clear wmEvent.flag for file-select events

Harmless but could cause file-select events to have WM_EVENT_IS_REPEAT
set which logged a warning as this is only intended for keyboard events.

===

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

===

diff --git a/source/blender/windowmanager/intern/wm_event_system.c 
b/source/blender/windowmanager/intern/wm_event_system.c
index 082e6443ba2..58d7a55eddc 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -4027,6 +4027,7 @@ void WM_event_fileselect_event(wmWindowManager *wm, void 
*ophandle, int eventval
 
 event.type = EVT_FILESELECT;
 event.val = eventval;
+event.flag = 0;
 event.customdata = ophandle; /* Only as void pointer type check. */
 
 wm_event_add(win, );
@@ -5834,6 +5835,7 @@ void WM_window_cursor_keymap_status_refresh(bContext *C, 
wmWindow *win)
 wmEvent test_event = *win->eventstate;
 test_event.type = event_data[data_index].event_type;
 test_event.val = event_data[data_index].event_value;
+test_event.flag = 0;
 wm_eventemulation(_event, true);
 wmKeyMapItem *kmi = NULL;
 for (int handler_index = 0; handler_index < ARRAY_SIZE(handlers); 
handler_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] [0091c97b327] master: Cleanup: use '_num' suffix instead of '_size' for CurveGeometry

2022-05-10 Thread Campbell Barton
Commit: 0091c97b3277c22688a229a4264ee34dfff89d7a
Author: Campbell Barton
Date:   Wed May 11 09:58:39 2022 +1000
Branches: master
https://developer.blender.org/rB0091c97b3277c22688a229a4264ee34dfff89d7a

Cleanup: use '_num' suffix instead of '_size' for CurveGeometry

Follow conventions from T85728.

===

M   source/blender/blenkernel/BKE_curves.hh
M   source/blender/blenkernel/intern/attribute.c
M   source/blender/blenkernel/intern/curves.cc
M   source/blender/blenkernel/intern/curves_geometry.cc
M   source/blender/draw/intern/draw_cache_impl_curves.cc
M   source/blender/editors/curves/intern/curves_add.cc
M   source/blender/geometry/intern/realize_instances.cc
M   source/blender/makesdna/DNA_curves_types.h
M   source/blender/makesdna/intern/dna_rename_defs.h
M   source/blender/makesrna/intern/rna_curves.c

===

diff --git a/source/blender/blenkernel/BKE_curves.hh 
b/source/blender/blenkernel/BKE_curves.hh
index 8ef7d2811b1..3e57041dec3 100644
--- a/source/blender/blenkernel/BKE_curves.hh
+++ b/source/blender/blenkernel/BKE_curves.hh
@@ -127,7 +127,7 @@ class CurvesGeometry : public ::CurvesGeometry {
* Create curves with the given size. Only the position attribute is 
created, along with the
* offsets.
*/
-  CurvesGeometry(int point_size, int curve_size);
+  CurvesGeometry(int point_num, int curve_num);
   CurvesGeometry(const CurvesGeometry );
   CurvesGeometry(CurvesGeometry &);
   CurvesGeometry =(const CurvesGeometry );
@@ -686,11 +686,11 @@ std::array 
calculate_type_counts(const VArray 
 
 inline int CurvesGeometry::points_num() const
 {
-  return this->point_size;
+  return this->point_num;
 }
 inline int CurvesGeometry::curves_num() const
 {
-  return this->curve_size;
+  return this->curve_num;
 }
 inline IndexRange CurvesGeometry::points_range() const
 {
@@ -720,7 +720,7 @@ inline const std::array 
::curve_type_counts
 inline IndexRange CurvesGeometry::points_for_curve(const int index) const
 {
   /* Offsets are not allocated when there are no curves. */
-  BLI_assert(this->curve_size > 0);
+  BLI_assert(this->curve_num > 0);
   BLI_assert(this->curve_offsets != nullptr);
   const int offset = this->curve_offsets[index];
   const int offset_next = this->curve_offsets[index + 1];
@@ -730,7 +730,7 @@ inline IndexRange CurvesGeometry::points_for_curve(const 
int index) const
 inline IndexRange CurvesGeometry::points_for_curves(const IndexRange curves) 
const
 {
   /* Offsets are not allocated when there are no curves. */
-  BLI_assert(this->curve_size > 0);
+  BLI_assert(this->curve_num > 0);
   BLI_assert(this->curve_offsets != nullptr);
   const int offset = this->curve_offsets[curves.start()];
   const int offset_next = this->curve_offsets[curves.one_after_last()];
@@ -752,7 +752,7 @@ inline IndexRange 
CurvesGeometry::evaluated_points_for_curve(int index) const
 inline IndexRange CurvesGeometry::evaluated_points_for_curves(const IndexRange 
curves) const
 {
   BLI_assert(!this->runtime->offsets_cache_dirty);
-  BLI_assert(this->curve_size > 0);
+  BLI_assert(this->curve_num > 0);
   const int offset = this->runtime->evaluated_offsets_cache[curves.start()];
   const int offset_next = 
this->runtime->evaluated_offsets_cache[curves.one_after_last()];
   return {offset, offset_next - offset};
diff --git a/source/blender/blenkernel/intern/attribute.c 
b/source/blender/blenkernel/intern/attribute.c
index 0cb0704ff80..7f93eb7b393 100644
--- a/source/blender/blenkernel/intern/attribute.c
+++ b/source/blender/blenkernel/intern/attribute.c
@@ -75,9 +75,9 @@ static void get_domains(const ID *id, DomainInfo 
info[ATTR_DOMAIN_NUM])
 case ID_CV: {
   Curves *curves = (Curves *)id;
   info[ATTR_DOMAIN_POINT].customdata = >geometry.point_data;
-  info[ATTR_DOMAIN_POINT].length = curves->geometry.point_size;
+  info[ATTR_DOMAIN_POINT].length = curves->geometry.point_num;
   info[ATTR_DOMAIN_CURVE].customdata = >geometry.curve_data;
-  info[ATTR_DOMAIN_CURVE].length = curves->geometry.curve_size;
+  info[ATTR_DOMAIN_CURVE].length = curves->geometry.curve_num;
   break;
 }
 default:
diff --git a/source/blender/blenkernel/intern/curves.cc 
b/source/blender/blenkernel/intern/curves.cc
index bcfd6206a78..84ba98db54b 100644
--- a/source/blender/blenkernel/intern/curves.cc
+++ b/source/blender/blenkernel/intern/curves.cc
@@ -78,12 +78,12 @@ static void curves_copy_data(Main *UNUSED(bmain), ID 
*id_dst, const ID *id_src,
* shallow copy from the source to the destination, and because the 
copy-on-write functionality
* isn't supported more generically yet. */
 
-  dst.point_size = src.point_size;
-  dst.curve_size = src.curve_size;
+  dst.point_num = src.point_num;
+  dst.curve_num = src.curve_num;
 
   const eCDAllocType alloc_type = (flag & LIB_ID_COPY_CD_REFERENCE) ? 
CD_REFERENCE : 

[Bf-blender-cvs] [baf8ec2e54e] master: Cleanup: use doxy sections for node_edit.cc

2022-05-10 Thread Campbell Barton
Commit: baf8ec2e54e3808033e3435eef60f38dd35cbaf2
Author: Campbell Barton
Date:   Wed May 11 09:39:43 2022 +1000
Branches: master
https://developer.blender.org/rBbaf8ec2e54e3808033e3435eef60f38dd35cbaf2

Cleanup: use doxy sections for node_edit.cc

===

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

===

diff --git a/source/blender/editors/space_node/node_edit.cc 
b/source/blender/editors/space_node/node_edit.cc
index 2d7972e2291..fb2f1bf3751 100644
--- a/source/blender/editors/space_node/node_edit.cc
+++ b/source/blender/editors/space_node/node_edit.cc
@@ -66,7 +66,9 @@ namespace blender::ed::space_node {
 
 #define USE_ESC_COMPO
 
-/* * composite job manager ** */
+/*  */
+/** \name Composite Job Manager
+ * \{ */
 
 enum {
   COM_RECALC_COMPOSITE = 1,
@@ -293,6 +295,12 @@ static void compo_startjob(void *cjv,
 
 }  // namespace blender::ed::space_node
 
+/** \} */
+
+/*  */
+/** \name Composite Job C API
+ * \{ */
+
 void ED_node_composite_job(const bContext *C, struct bNodeTree *nodetree, 
Scene *scene_owner)
 {
   using namespace blender::ed::space_node;
@@ -336,9 +344,13 @@ void ED_node_composite_job(const bContext *C, struct 
bNodeTree *nodetree, Scene
   WM_jobs_start(CTX_wm_manager(C), wm_job);
 }
 
+/** \} */
+
 namespace blender::ed::space_node {
 
-/* * */
+/*  */
+/** \name Composite Poll & Utility Functions
+ * \{ */
 
 bool composite_node_active(bContext *C)
 {
@@ -388,8 +400,14 @@ static void send_notifiers_after_tree_change(ID *id, 
bNodeTree *ntree)
   }
 }
 
+/** \} */
+
 }  // namespace blender::ed::space_node
 
+/*  */
+/** \name Node Editor Public API Functions
+ * \{ */
+
 void ED_node_tree_propagate_change(const bContext *C, Main *bmain, bNodeTree 
*root_ntree)
 {
   if (C != nullptr) {
@@ -783,9 +801,13 @@ void ED_node_post_apply_transform(bContext *UNUSED(C), 
bNodeTree *UNUSED(ntree))
   // node_update_nodetree(C, ntree, 0.0f, 0.0f);
 }
 
+/** \} */
+
 namespace blender::ed::space_node {
 
-/* * generic operator functions for nodes * */
+/*  */
+/** \name Generic Operator Functions for Nodes
+ * \{ */
 
 #if 0 /* UNUSED */
 
@@ -861,7 +883,11 @@ static void edit_node_properties_get(
 }
 #endif
 
-/* ** Node generic ** */
+/** \} */
+
+/*  */
+/** \name Node Generic
+ * \{ */
 
 /* is rct in visible part of node? */
 static bNode *visible_node(SpaceNode , const rctf )
@@ -874,7 +900,11 @@ static bNode *visible_node(SpaceNode , const rctf 
)
   return nullptr;
 }
 
-/* ** size widget operator  */
+/** \} */
+
+/*  */
+/** \name Node Size Widget Operator
+ * \{ */
 
 struct NodeSizeWidget {
   float mxstart, mystart;
@@ -1077,7 +1107,11 @@ void NODE_OT_resize(wmOperatorType *ot)
   ot->flag = OPTYPE_BLOCKING;
 }
 
-/* ** hidden sockets  */
+/** \} */
+
+/*  */
+/** \name Node Hidden Sockets
+ * \{ */
 
 bool node_has_hidden_sockets(bNode *node)
 {
@@ -1211,7 +1245,11 @@ bool node_find_indicated_socket(SpaceNode ,
   return false;
 }
 
-/* ** Link Dimming *** */
+/** \} */
+
+/*  */
+/** \name Node Link Dimming
+ * \{ */
 
 float node_link_dim_factor(const View2D , const bNodeLink )
 {
@@ -1237,7 +1275,11 @@ bool node_link_is_hidden_or_dimmed(const View2D , 
const bNodeLink )
   return nodeLinkIsHidden() || node_link_dim_factor(v2d, link) < 0.5f;
 }
 
-/* ** Duplicate *** */
+/** \} */
+
+/*  */
+/** \name Node Duplicate Operator
+ * \{ */
 
 static void node_duplicate_reparent_recursive(const Map _map,
   bNode *node)
@@ -1422,8 +1464,7 @@ void node_select_all(ListBase *lb, int action)
   }
 }
 
-/*  */
-/* XXX some code needing updating to operators. */
+/* XXX: some code needing updating to operators. */
 
 /* goes over all scenes, reads render layers */
 static int node_read_viewlayers_exec(bContext *C, wmOperator *UNUSED(op))
@@ -1526,7 +1567,11 @@ void NODE_OT_render_changed(wmOperatorType *ot)
   ot->flag = 0;
 

[Bf-blender-cvs] [f9e0b94c2fa] master: Cleanup: format

2022-05-10 Thread Campbell Barton
Commit: f9e0b94c2fadea99ba8d14094c9ed5c1a92e03ef
Author: Campbell Barton
Date:   Wed May 11 09:50:54 2022 +1000
Branches: master
https://developer.blender.org/rBf9e0b94c2fadea99ba8d14094c9ed5c1a92e03ef

Cleanup: format

===

M   doc/python_api/examples/bpy.types.Image.py
M   source/blender/editors/sculpt_paint/sculpt_filter_color.c
M   source/blender/gpencil_modifiers/CMakeLists.txt
M   source/blender/io/common/CMakeLists.txt
M   source/blender/io/common/IO_path_util.hh
M   source/blender/io/common/intern/path_util.cc
M   source/blender/makesrna/intern/rna_userdef.c

===

diff --git a/doc/python_api/examples/bpy.types.Image.py 
b/doc/python_api/examples/bpy.types.Image.py
index 715623f6f76..f0c1a780e24 100644
--- a/doc/python_api/examples/bpy.types.Image.py
+++ b/doc/python_api/examples/bpy.types.Image.py
@@ -44,4 +44,3 @@ image_dest = image_src.copy()
 image_dest.update()
 print(image_dest.size)
 print(image_dest.pixels[0:4])
-
diff --git a/source/blender/editors/sculpt_paint/sculpt_filter_color.c 
b/source/blender/editors/sculpt_paint/sculpt_filter_color.c
index 9bddc2ad855..f71a814aff4 100644
--- a/source/blender/editors/sculpt_paint/sculpt_filter_color.c
+++ b/source/blender/editors/sculpt_paint/sculpt_filter_color.c
@@ -125,7 +125,7 @@ static void color_filter_task_cb(void *__restrict userdata,
   case COLOR_FILTER_HUE:
 rgb_to_hsv_v(orig_color, hsv_color);
 hue = hsv_color[0];
-hsv_color[0] = fmod((hsv_color[0] + fabs(fade)) - hue,1);
+hsv_color[0] = fmod((hsv_color[0] + fabs(fade)) - hue, 1);
 hsv_to_rgb_v(hsv_color, final_color);
 break;
   case COLOR_FILTER_SATURATION:
diff --git a/source/blender/gpencil_modifiers/CMakeLists.txt 
b/source/blender/gpencil_modifiers/CMakeLists.txt
index f87c85f808f..69fc26c99e9 100644
--- a/source/blender/gpencil_modifiers/CMakeLists.txt
+++ b/source/blender/gpencil_modifiers/CMakeLists.txt
@@ -72,7 +72,6 @@ set(SRC
 
   intern/lineart/MOD_lineart.h
   intern/lineart/lineart_intern.h
-
 )
 
 if(WITH_TBB)
diff --git a/source/blender/io/common/CMakeLists.txt 
b/source/blender/io/common/CMakeLists.txt
index 95ffbe19ada..e80bd850825 100644
--- a/source/blender/io/common/CMakeLists.txt
+++ b/source/blender/io/common/CMakeLists.txt
@@ -8,7 +8,6 @@ set(INC
   ../../depsgraph
   ../../makesdna
   ../../../../intern/guardedalloc
-
 )
 
 set(INC_SYS
diff --git a/source/blender/io/common/IO_path_util.hh 
b/source/blender/io/common/IO_path_util.hh
index ac2f935523e..eeb5a9dbcfe 100644
--- a/source/blender/io/common/IO_path_util.hh
+++ b/source/blender/io/common/IO_path_util.hh
@@ -1,8 +1,8 @@
 /* SPDX-License-Identifier: GPL-2.0-or-later */
 #pragma once
 
-#include "BLI_string_ref.hh"
 #include "BLI_set.hh"
+#include "BLI_string_ref.hh"
 
 #include "IO_path_util_types.h"
 
@@ -14,7 +14,7 @@ namespace blender::io {
  *
  * When PATH_REFERENCE_COPY mode is used, the file path pair (source
  * path, destination path) is added to the `copy_set`.
- * 
+ *
  * Equivalent of bpy_extras.io_utils.path_reference.
  */
 std::string path_reference(StringRefNull filepath,
@@ -26,4 +26,4 @@ std::string path_reference(StringRefNull filepath,
 /** Execute copying files of path_reference. */
 void path_reference_copy(const Set> 
_set);
 
-} // namespace blender::io
+}  // namespace blender::io
diff --git a/source/blender/io/common/intern/path_util.cc 
b/source/blender/io/common/intern/path_util.cc
index 2b9a1d67b44..902cf552bf0 100644
--- a/source/blender/io/common/intern/path_util.cc
+++ b/source/blender/io/common/intern/path_util.cc
@@ -28,7 +28,8 @@ std::string path_reference(StringRefNull filepath,
   }
   else if (mode == PATH_REFERENCE_COPY) {
 char filepath_cpy[PATH_MAX];
-BLI_path_join(filepath_cpy, PATH_MAX, base_dst.c_str(), 
BLI_path_basename(filepath_abs), nullptr);
+BLI_path_join(
+filepath_cpy, PATH_MAX, base_dst.c_str(), 
BLI_path_basename(filepath_abs), nullptr);
 copy_set->add(std::make_pair(filepath_abs, filepath_cpy));
 BLI_strncpy(filepath_abs, filepath_cpy, PATH_MAX);
 mode = PATH_REFERENCE_RELATIVE;
diff --git a/source/blender/makesrna/intern/rna_userdef.c 
b/source/blender/makesrna/intern/rna_userdef.c
index 1b5536c755e..b3d4ae80713 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -6426,7 +6426,8 @@ static void rna_def_userdef_experimental(BlenderRNA *brna)
 
   prop = RNA_def_property(srna, "use_draw_manager_acquire_lock", PROP_BOOLEAN, 
PROP_NONE);
   RNA_def_property_boolean_sdna(prop, NULL, "use_draw_manager_acquire_lock", 
1);
-  RNA_def_property_ui_text(prop, "Draw Manager Locking", "Don't lock UI during 
background rendering");
+  RNA_def_property_ui_text(
+  prop, "Draw Manager Locking", "Don't lock UI during background 
rendering");
 
   prop = 

[Bf-blender-cvs] [046b45749c3] master: Fix cursor snap not acting on selected UVs

2022-05-10 Thread Germano Cavalcante
Commit: 046b45749c36cf356e44b7661c51e1cdfcf60ab9
Author: Germano Cavalcante
Date:   Tue May 10 21:22:16 2022 -0300
Branches: master
https://developer.blender.org/rB046b45749c36cf356e44b7661c51e1cdfcf60ab9

Fix cursor snap not acting on selected UVs

Regression in rBd2271cf939.

===

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

===

diff --git a/source/blender/editors/transform/transform_snap.c 
b/source/blender/editors/transform/transform_snap.c
index e119b264ae7..769fd28c57b 100644
--- a/source/blender/editors/transform/transform_snap.c
+++ b/source/blender/editors/transform/transform_snap.c
@@ -1020,7 +1020,7 @@ static void snap_calc_uv_fn(TransInfo *t, float 
*UNUSED(vec))
objects,
objects_len,
t->mval,
-   true,
+   t->tsnap.modeSelect == SNAP_NOT_SELECTED,
_sq,
t->tsnap.snapPoint)) {
   t->tsnap.snapPoint[0] *= t->aspect[0];

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


[Bf-blender-cvs] [1bb7fda600c] master: CMake: Fix noisy PUGIXML warning.

2022-05-10 Thread Ray Molenkamp
Commit: 1bb7fda600c0ef09f49da1354e06442fb62266ce
Author: Ray Molenkamp
Date:   Tue May 10 16:38:20 2022 -0600
Branches: master
https://developer.blender.org/rB1bb7fda600c0ef09f49da1354e06442fb62266ce

CMake: Fix noisy PUGIXML warning.

When doing a lite build, a warning is displayed
that due to PUGIXML being off WITH_CYCLES_OSL
is being disabled as well.

If WITH_CYCLES is off this is just useless
noise.

this diff changes the warning to only emit when
WITH_CYCLES is on.

===

M   CMakeLists.txt

===

diff --git a/CMakeLists.txt b/CMakeLists.txt
index f48334a298b..3e038fe3edd 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -781,7 +781,9 @@ set_and_warn_dependency(WITH_BOOST WITH_OPENCOLORIOOFF)
 set_and_warn_dependency(WITH_BOOST WITH_QUADRIFLOW OFF)
 set_and_warn_dependency(WITH_BOOST WITH_USDOFF)
 set_and_warn_dependency(WITH_BOOST WITH_ALEMBICOFF)
-set_and_warn_dependency(WITH_PUGIXML WITH_CYCLES_OSL   OFF)
+if(WITH_CYCLES)
+  set_and_warn_dependency(WITH_PUGIXML WITH_CYCLES_OSL   OFF)
+endif()
 set_and_warn_dependency(WITH_PUGIXML WITH_OPENIMAGEIO  OFF)
 
 if(WITH_BOOST AND NOT (WITH_CYCLES OR WITH_OPENIMAGEIO OR WITH_INTERNATIONAL OR

___
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] [610862927e0] cycles_oneapi: Cycles: use immediate commandlists in oneAPI backend

2022-05-10 Thread Xavier Hallade
Commit: 610862927e05bf51281fa2241066c24471cf9c05
Author: Xavier Hallade
Date:   Thu May 5 09:16:16 2022 +0200
Branches: cycles_oneapi
https://developer.blender.org/rB610862927e05bf51281fa2241066c24471cf9c05

Cycles: use immediate commandlists in oneAPI backend

through SYCL specific environment variables and without overriding
already defined ones.
Immediate commandlists improve stability when using
sycl-nightly/20220416 and newer.

===

M   intern/cycles/device/oneapi/device.cpp

===

diff --git a/intern/cycles/device/oneapi/device.cpp 
b/intern/cycles/device/oneapi/device.cpp
index 235d9b39374..ff617673b17 100644
--- a/intern/cycles/device/oneapi/device.cpp
+++ b/intern/cycles/device/oneapi/device.cpp
@@ -86,18 +86,28 @@ bool device_oneapi_init()
 
   // NOTE(sirgienko) we need to enable JIT cache from here and
   // right now this cache policy is controlled by env. variables
-  VLOG(1) << "Enable oneAPI persistent cache via environment variables";
+  // NOTE(hallade) we also enable immediate command lists + device scope events
+  // as they improve stability as of intel/llvm sycl-nighly/20220501.
+  // All these env variable can be set beforehand by end-users and
+  // will in that case -not- be overwritten.
 #  ifdef _WIN32
-  _putenv_s("SYCL_CACHE_PERSISTENT", "1");
-  _putenv_s("SYCL_CACHE_THRESHOLD", "0");
-  VLOG(1) << "Enabled oneAPI JIT caching on Windows platform";
+  if (getenv("SYCL_CACHE_PERSISTENT") == nullptr) {
+_putenv_s("SYCL_CACHE_PERSISTENT", "1");
+  }
+  if (getenv("SYCL_CACHE_TRESHOLD") == nullptr) {
+_putenv_s("SYCL_CACHE_THRESHOLD", "0");
+  }
+  if (getenv("SYCL_PI_LEVEL_ZERO_DEVICE_SCOPE_EVENTS") == nullptr) {
+_putenv_s("SYCL_PI_LEVEL_ZERO_DEVICE_SCOPE_EVENTS", "0");
+  }
+  if (getenv("SYCL_PI_LEVEL_ZERO_USE_IMMEDIATE_COMMANDLISTS") == nullptr) {
+_putenv_s("SYCL_PI_LEVEL_ZERO_USE_IMMEDIATE_COMMANDLISTS", "1");
+  }
 #  elif __linux__
-  setenv("SYCL_CACHE_PERSISTENT", "1", true);
-  setenv("SYCL_CACHE_THRESHOLD", "0", true);
-  VLOG(1) << "Enabled oneAPI JIT caching on Linux platform ";
-#  else
-  VLOG(1) << "Could not enable oneAPI JIT caching because the OS (Operating 
System) platform is "
- "neither Linux nor Windows";
+  setenv("SYCL_CACHE_PERSISTENT", "1", false);
+  setenv("SYCL_CACHE_THRESHOLD", "0", false);
+  setenv("SYCL_PI_LEVEL_ZERO_DEVICE_SCOPE_EVENTS", "0", false);
+  setenv("SYCL_PI_LEVEL_ZERO_USE_IMMEDIATE_COMMANDLISTS", "1", false);
 #  endif
 
   return 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] [77e66a23a41] cycles_oneapi: Cycles: enable use of zebin for Intel GPU binaries

2022-05-10 Thread Xavier Hallade
Commit: 77e66a23a41fa9640f0ad99814199ac3165b2275
Author: Xavier Hallade
Date:   Tue May 10 17:43:57 2022 +0200
Branches: cycles_oneapi
https://developer.blender.org/rB77e66a23a41fa9640f0ad99814199ac3165b2275

Cycles: enable use of zebin for Intel GPU binaries

zebin format greatly improves backward and forward compatibility of GPU 
binaries across driver versions.
--format zebin is passed to ocloc that needs to support it, ie. includes
this commit: 
https://github.com/intel/compute-runtime/commit/dd393d11a28bf749dcdf1f952271784ba9bd1404

===

M   intern/cycles/kernel/CMakeLists.txt

===

diff --git a/intern/cycles/kernel/CMakeLists.txt 
b/intern/cycles/kernel/CMakeLists.txt
index 15b09bbfb17..1af852ceb48 100644
--- a/intern/cycles/kernel/CMakeLists.txt
+++ b/intern/cycles/kernel/CMakeLists.txt
@@ -743,7 +743,7 @@ if(WITH_CYCLES_DEVICE_ONEAPI)
 list(APPEND sycl_compiler_flags
   -fsycl-targets=spir64,spir64_gen
   -Xsycl-target-backend=spir64 "${CYCLES_ONEAPI_GPU_COMPILATION_OPTIONS}"
-  -Xsycl-target-backend=spir64_gen "-device ${CYCLES_ONEAPI_AOT_TARGETS} 
${CYCLES_ONEAPI_GPU_COMPILATION_OPTIONS}")
+  -Xsycl-target-backend=spir64_gen "-device ${CYCLES_ONEAPI_AOT_TARGETS} 
--format zebin ${CYCLES_ONEAPI_GPU_COMPILATION_OPTIONS}")
   else()
 list(APPEND sycl_compiler_flags
   -fsycl-targets=spir64

___
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] [81b797af669] blender-v3.2-release: Fix T97908: Cycles missing motion from on pointcloud generated by geometry nodes

2022-05-10 Thread Brecht Van Lommel
Commit: 81b797af669d21fc01855f94032faa6c92a4fd9b
Author: Brecht Van Lommel
Date:   Tue May 10 20:38:31 2022 +0200
Branches: blender-v3.2-release
https://developer.blender.org/rB81b797af669d21fc01855f94032faa6c92a4fd9b

Fix T97908: Cycles missing motion from on pointcloud generated by geometry nodes

Assume geometry is always potentially animated, since we can't use our heuristic
to detect if the object is potentially animated by looking at modifiers on the
object.

The main original reason for this check was to avoid evaluating subdivision
surfaces for many static objects, which is not happening here anyway.

===

M   intern/cycles/blender/util.h

===

diff --git a/intern/cycles/blender/util.h b/intern/cycles/blender/util.h
index eead6cec08c..49cecb6d0f3 100644
--- a/intern/cycles/blender/util.h
+++ b/intern/cycles/blender/util.h
@@ -262,8 +262,11 @@ static inline bool BKE_object_is_modified(BL::Object 
, BL::Scene , bo
 static inline bool BKE_object_is_deform_modified(BObjectInfo , BL::Scene 
, bool preview)
 {
   if (!self.is_real_object_data()) {
-return false;
+/* Comes from geometry nodes, can't use heuristic to guess if it's 
animated. */
+return true;
   }
+
+  /* Use heuristic to quickly check if object is potentially animated. */
   return self.real_object.is_deform_modified(scene, (preview) ? (1 << 0) : (1 
<< 1)) ? true :

false;
 }

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


[Bf-blender-cvs] [74228e2cd25] blender-v3.2-release: Fix T97945: Cycles baking max distance is wrong

2022-05-10 Thread Brecht Van Lommel
Commit: 74228e2cd253c66a9204cc3926243dd8e07edd53
Author: Brecht Van Lommel
Date:   Tue May 10 20:49:49 2022 +0200
Branches: blender-v3.2-release
https://developer.blender.org/rB74228e2cd253c66a9204cc3926243dd8e07edd53

Fix T97945: Cycles baking max distance is wrong

It was effectively sqrt(max_distance) before this fix.

Thanks to Omar Emara for identifying the solution.

===

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

===

diff --git a/source/blender/render/intern/bake.c 
b/source/blender/render/intern/bake.c
index 5953c0f0f8f..bf876163013 100644
--- a/source/blender/render/intern/bake.c
+++ b/source/blender/render/intern/bake.c
@@ -330,10 +330,10 @@ static bool cast_ray_highpoly(BVHTreeFromMesh *treeData,
 {
   int i;
   int hit_mesh = -1;
-  float hit_distance = max_ray_distance;
-  if (hit_distance == 0.0f) {
+  float hit_distance_squared = max_ray_distance * max_ray_distance;
+  if (hit_distance_squared == 0.0f) {
 /* No ray distance set, use maximum. */
-hit_distance = FLT_MAX;
+hit_distance_squared = FLT_MAX;
   }
 
   BVHTreeRayHit *hits;
@@ -365,16 +365,14 @@ static bool cast_ray_highpoly(BVHTreeFromMesh *treeData,
 }
 
 if (hits[i].index != -1) {
-  float distance;
-  float hit_world[3];
-
   /* distance comparison in world space */
+  float hit_world[3];
   mul_v3_m4v3(hit_world, highpoly[i].obmat, hits[i].co);
-  distance = len_squared_v3v3(hit_world, co);
+  float distance_squared = len_squared_v3v3(hit_world, co);
 
-  if (distance < hit_distance) {
+  if (distance_squared < hit_distance_squared) {
 hit_mesh = i;
-hit_distance = distance;
+hit_distance_squared = distance_squared;
   }
 }
   }

___
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] [28240f78cef] master: UI: Geometry Nodes Icon

2022-05-10 Thread Dalai Felinto
Commit: 28240f78cefd880e65c71a971570425fcbab9264
Author: Dalai Felinto
Date:   Tue May 10 19:21:26 2022 +0200
Branches: master
https://developer.blender.org/rB28240f78cefd880e65c71a971570425fcbab9264

UI: Geometry Nodes Icon

Geometry Nodes (new) icon. So far we were using the generic node-tree
icon for geometry nodes, not anymore.

The new icon is composed of 4 spheres that is a reference to the
original pebbles demo. Scattering points was also the turning point for
the project (which originally was focusing on dynamic effects), and to
this day is one of the first steps for everything procedural such as
hair.

Note that the modifier icon is still showing as white in the outliner.
The alternative is to be blue everywhere.

Patch review and feedback by Hans Goudey.

Icon creation in collaboration with Pablo Vazquez.

===

M   release/datafiles/blender_icons.svg
A   release/datafiles/blender_icons16/icon16_geometry_nodes.dat
A   release/datafiles/blender_icons32/icon32_geometry_nodes.dat
M   source/blender/editors/include/UI_icons.h
M   source/blender/editors/space_node/node_context_path.cc
M   source/blender/makesrna/intern/rna_modifier.c
M   source/blender/makesrna/intern/rna_nodetree.c
M   source/blender/makesrna/intern/rna_space.c
M   source/blender/modifiers/intern/MOD_nodes.cc
M   source/blender/nodes/geometry/node_geometry_tree.cc

===

diff --git a/release/datafiles/blender_icons.svg 
b/release/datafiles/blender_icons.svg
index 6f0216176d7..f8164d1f646 100644
--- a/release/datafiles/blender_icons.svg
+++ b/release/datafiles/blender_icons.svg
@@ -13657,6 +13657,38 @@
  d="m 475.00071,508.00091 c -3.8601,0 -7,-3.1399 -7,-7 0,-3.8601 
3.1399,-7 7,-7 3.8601,0 7,3.1399 7,7 0,3.8601 -3.1399,7 -7,7 z m 
2.96094,-1.99804 a 1.0001,1.0001 0 0 0 1.04102,-0.98633 1.0001,1.0001 0 0 0 
-0.20899,-0.62305 l -2.57617,-3.43555 1.60742,-2.41015 a 1.0001,1.0001 0 1 0 
-1.66406,-1.10938 l -1.91211,2.86914 a 1.0001,1.0001 0 0 0 -0.26367,0.68164 
1.0001,1.0001 0 0 0 0.004,0.0801 1.0001,1.0001 0 0 0 0.30664,0.66016 l 
2.89844,3.86328 a 1.0001,1.0001 0 0 0 0.76758,0.41016 z"
  
style="color:#00;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#00;letter-spacing:nor
 [...]
 
+
+  
+
+
+
+
+  
+
 https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [dc55e095e6f] blender-v3.2-release: Fix T97056: Cycles MNEE not working with glass and pure refraction BSDFs

2022-05-10 Thread Olivier Maury
Commit: dc55e095e6f2836c65f83c9b1bad2f7d9d98022d
Author: Olivier Maury
Date:   Tue May 10 18:50:54 2022 +0200
Branches: blender-v3.2-release
https://developer.blender.org/rBdc55e095e6f2836c65f83c9b1bad2f7d9d98022d

Fix T97056: Cycles MNEE not working with glass and pure refraction BSDFs

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

===

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

===

diff --git a/intern/cycles/kernel/integrator/mnee.h 
b/intern/cycles/kernel/integrator/mnee.h
index 455d15b28c2..7820d71f15c 100644
--- a/intern/cycles/kernel/integrator/mnee.h
+++ b/intern/cycles/kernel/integrator/mnee.h
@@ -1026,7 +1026,9 @@ ccl_device_forceinline int 
kernel_path_mnee_sample(KernelGlobals kg,
 if (bsdf->type == CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID ||
 bsdf->type == CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID ||
 bsdf->type == CLOSURE_BSDF_MICROFACET_MULTI_GGX_GLASS_ID ||
-bsdf->type == CLOSURE_BSDF_MICROFACET_MULTI_GGX_GLASS_FRESNEL_ID) {
+bsdf->type == CLOSURE_BSDF_MICROFACET_MULTI_GGX_GLASS_FRESNEL_ID ||
+bsdf->type == CLOSURE_BSDF_REFRACTION_ID ||
+bsdf->type == CLOSURE_BSDF_SHARP_GLASS_ID) {
   /* Note that CLOSURE_BSDF_MICROFACET_MULTI_GGX_GLASS_ID and
* CLOSURE_BSDF_MICROFACET_MULTI_GGX_GLASS_FRESNEL_ID are treated as
* CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID further below. */
@@ -1038,11 +1040,14 @@ ccl_device_forceinline int 
kernel_path_mnee_sample(KernelGlobals kg,
   const float eta = (sd_mnee->flag & SD_BACKFACING) ? 1.0f / 
microfacet_bsdf->ior :
   
microfacet_bsdf->ior;
 
-  /* Sample transmissive microfacet bsdf. */
-  float bsdf_u, bsdf_v;
-  path_state_rng_2D(kg, rng_state, PRNG_BSDF_U, _u, _v);
-  float2 h = mnee_sample_bsdf_dh(
-  bsdf->type, microfacet_bsdf->alpha_x, microfacet_bsdf->alpha_y, 
bsdf_u, bsdf_v);
+  float2 h = zero_float2();
+  if (microfacet_bsdf->alpha_x > 0.f && microfacet_bsdf->alpha_y > 
0.f) {
+/* Sample transmissive microfacet bsdf. */
+float bsdf_u, bsdf_v;
+path_state_rng_2D(kg, rng_state, PRNG_BSDF_U, _u, _v);
+h = mnee_sample_bsdf_dh(
+bsdf->type, microfacet_bsdf->alpha_x, 
microfacet_bsdf->alpha_y, bsdf_u, bsdf_v);
+  }
 
   /* Setup differential geometry on vertex. */
   mnee_setup_manifold_vertex(

___
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] [dcce4a59a05] blender-v3.2-release: Fix T97966: Cycles shadow terminator offset wrong for scaled object instances

2022-05-10 Thread Mikhail Matrosov
Commit: dcce4a59a05245807a4b9a50cc331ce307674981
Author: Mikhail Matrosov
Date:   Tue May 10 18:52:00 2022 +0200
Branches: blender-v3.2-release
https://developer.blender.org/rBdcce4a59a05245807a4b9a50cc331ce307674981

Fix T97966: Cycles shadow terminator offset wrong for scaled object instances

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

===

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

===

diff --git a/intern/cycles/kernel/light/sample.h 
b/intern/cycles/kernel/light/sample.h
index 5acfc92cca1..9bbbd5b0d10 100644
--- a/intern/cycles/kernel/light/sample.h
+++ b/intern/cycles/kernel/light/sample.h
@@ -143,7 +143,7 @@ ccl_device_inline float3 shadow_ray_smooth_surface_offset(
   float3 n = N[0] * u + N[1] * v + N[2] * w; /* We get away without 
normalization */
 
   if (!(sd->object_flag & SD_OBJECT_TRANSFORM_APPLIED)) {
-object_normal_transform(kg, sd, ); /* Normal x scale, world space */
+object_dir_transform(kg, sd, ); /* Normal x scale, to world space */
   }
 
   /* Parabolic approximation */

___
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] [335f8000c8c] gpencil-new-data-proposal: Basic GPLayerGroup constructor

2022-05-10 Thread Falk David
Commit: 335f8000c8c8dead2ef64d92272cfd41c91e656d
Author: Falk David
Date:   Tue May 10 18:55:02 2022 +0200
Branches: gpencil-new-data-proposal
https://developer.blender.org/rB335f8000c8c8dead2ef64d92272cfd41c91e656d

Basic GPLayerGroup constructor

===

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

===

diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc 
b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
index a5d770f659f..31d26829349 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
@@ -21,7 +21,16 @@ class GPLayerGroup : ::GPLayerGroup {
  public:
   GPLayerGroup()
   {
-/* TODO */
+this->children = nullptr;
+this->children_size = 0;
+this->layer_indices = nullptr;
+this->layer_indices_size = 0;
+  }
+
+  GPLayerGroup(const StringRefNull name) : GPLayerGroup()
+  {
+BLI_assert(name.size() < 128);
+strcpy(this->name, name.c_str());
   }
 
   ~GPLayerGroup()
@@ -34,6 +43,11 @@ class GPLayerGroup : ::GPLayerGroup {
 MEM_SAFE_FREE(this->children);
 MEM_SAFE_FREE(this->layer_indices);
   }
+
+  IndexMask layers_index_mask()
+  {
+return {reinterpret_cast(this->layer_indices), 
this->layer_indices_size};
+  }
 };
 
 class GPDataRuntime {

___
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] [68e77e6f80d] gpencil-new-data-proposal: Add mutex to cached frame index masks

2022-05-10 Thread Falk David
Commit: 68e77e6f80dde470cf7d06978bf3370bcc2adf73
Author: Falk David
Date:   Tue May 10 18:42:31 2022 +0200
Branches: gpencil-new-data-proposal
https://developer.blender.org/rB68e77e6f80dde470cf7d06978bf3370bcc2adf73

Add mutex to cached frame index masks

===

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

===

diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc 
b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
index 13ea1252fb7..a5d770f659f 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
@@ -43,11 +43,12 @@ class GPDataRuntime {
   /**
* Cache that maps the index of a layer to the index mask of the frames in 
that layer.
*/
-  mutable Map> cached_frame_index_masks;
+  mutable Map> frame_index_masks_cache;
+  mutable std::mutex frame_index_masks_cache_mutex;
 
   IndexMask get_cached_frame_index_mask(int layer_index)
   {
-return cached_frame_index_masks.lookup(layer_index).as_span();
+return frame_index_masks_cache.lookup(layer_index).as_span();
   }
 };
 
@@ -276,7 +277,13 @@ class GPData : public ::GPData {
 }
 
 /* If the indices are cached for this layer, use the cache. */
-if (this->runtime->cached_frame_index_masks.contains(layer_index)) {
+if (this->runtime->frame_index_masks_cache.contains(layer_index)) {
+  return this->runtime->get_cached_frame_index_mask(layer_index);
+}
+
+/* A double checked lock. */
+std::scoped_lock{this->runtime->frame_index_masks_cache_mutex};
+if (this->runtime->frame_index_masks_cache.contains(layer_index)) {
   return this->runtime->get_cached_frame_index_mask(layer_index);
 }
 
@@ -287,7 +294,7 @@ class GPData : public ::GPData {
 });
 
 /* Cache the resulting index mask. */
-this->runtime->cached_frame_index_masks.add(layer_index, 
std::move(indices));
+this->runtime->frame_index_masks_cache.add(layer_index, 
std::move(indices));
 return mask;
   }
 
@@ -441,7 +448,7 @@ class GPData : public ::GPData {
 std::sort(this->frames_for_write().begin(), 
this->frames_for_write().end());
 
 /* Clear the cached indices since they are probably no longer valid. */
-this->runtime->cached_frame_index_masks = {};
+this->runtime->frame_index_masks_cache.clear();
   }
 };
 
@@ -593,13 +600,13 @@ TEST(gpencil_proposal, IterateOverFramesOnLayer)
   }
 
   IndexMask indices_frames_layer1 = data.frames_on_layer(layer1_idx);
-  EXPECT_TRUE(data.runtime->cached_frame_index_masks.contains(0));
+  EXPECT_TRUE(data.runtime->frame_index_masks_cache.contains(layer1_idx));
   for (const int i : indices_frames_layer1.index_range()) {
 EXPECT_EQ(data.frames()[indices_frames_layer1[i]].start, 
frame_numbers_sorted1[i]);
   }
 
   IndexMask indices_frames_layer2 = data.frames_on_layer(layer2_idx);
-  EXPECT_TRUE(data.runtime->cached_frame_index_masks.contains(1));
+  EXPECT_TRUE(data.runtime->frame_index_masks_cache.contains(layer2_idx));
   for (const int i : indices_frames_layer2.index_range()) {
 EXPECT_EQ(data.frames()[indices_frames_layer2[i]].start, 
frame_numbers_sorted2[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] [c171c99fa1b] blender-v3.2-release: Fix part of T97895: Cycles not rendering edge domain attributes

2022-05-10 Thread Brecht Van Lommel
Commit: c171c99fa1bd7a5054bf04934a3ddc09678b7100
Author: Brecht Van Lommel
Date:   Tue May 10 18:12:17 2022 +0200
Branches: blender-v3.2-release
https://developer.blender.org/rBc171c99fa1bd7a5054bf04934a3ddc09678b7100

Fix part of T97895: Cycles not rendering edge domain attributes

These aren't really ideal for rendering, but better to show something. Edge
values are averaged at vertices.

===

M   intern/cycles/blender/mesh.cpp

===

diff --git a/intern/cycles/blender/mesh.cpp b/intern/cycles/blender/mesh.cpp
index 624a07762f2..de67e27923d 100644
--- a/intern/cycles/blender/mesh.cpp
+++ b/intern/cycles/blender/mesh.cpp
@@ -301,11 +301,11 @@ static void attr_create_sculpt_vertex_color(Scene *scene,
 template
 static void fill_generic_attribute(BL::Mesh _mesh,
TypeInCycles *data,
-   const AttributeElement element,
+   const BL::Attribute::domain_enum b_domain,
const GetValueAtIndex _value_at_index)
 {
-  switch (element) {
-case ATTR_ELEMENT_CORNER: {
+  switch (b_domain) {
+case BL::Attribute::domain_CORNER: {
   for (BL::MeshLoopTriangle  : b_mesh.loop_triangles) {
 const int index = t.index() * 3;
 BL::Array loops = t.loops();
@@ -315,14 +315,37 @@ static void fill_generic_attribute(BL::Mesh _mesh,
   }
   break;
 }
-case ATTR_ELEMENT_VERTEX: {
+case BL::Attribute::domain_EDGE: {
+  /* Averge edge attributes at vertices. */
+  const size_t num_verts = b_mesh.vertices.length();
+  vector count(num_verts, 0);
+
+  for (BL::MeshEdge  : b_mesh.edges) {
+BL::Array vertices = e.vertices();
+TypeInCycles value = get_value_at_index(e.index());
+
+data[vertices[0]] += value;
+data[vertices[1]] += value;
+count[vertices[0]]++;
+count[vertices[1]]++;
+  }
+
+  for (size_t i = 0; i < num_verts; i++) {
+if (count[i] > 1) {
+  data[i] /= (float)count[i];
+}
+  }
+
+  break;
+}
+case BL::Attribute::domain_POINT: {
   const int num_verts = b_mesh.vertices.length();
   for (int i = 0; i < num_verts; i++) {
 data[i] = get_value_at_index(i);
   }
   break;
 }
-case ATTR_ELEMENT_FACE: {
+case BL::Attribute::domain_FACE: {
   for (BL::MeshLoopTriangle  : b_mesh.loop_triangles) {
 data[t.index()] = get_value_at_index(t.polygon_index());
   }
@@ -404,6 +427,9 @@ static void attr_create_generic(Scene *scene,
   case BL::Attribute::domain_POINT:
 element = ATTR_ELEMENT_VERTEX;
 break;
+  case BL::Attribute::domain_EDGE:
+element = ATTR_ELEMENT_VERTEX;
+break;
   case BL::Attribute::domain_FACE:
 element = ATTR_ELEMENT_FACE;
 break;
@@ -420,15 +446,16 @@ static void attr_create_generic(Scene *scene,
 Attribute *attr = attributes.add(name, TypeFloat, element);
 float *data = attr->data_float();
 fill_generic_attribute(
-b_mesh, data, element, [&](int i) { return 
b_float_attribute.data[i].value(); });
+b_mesh, data, b_domain, [&](int i) { return 
b_float_attribute.data[i].value(); });
 break;
   }
   case BL::Attribute::data_type_BOOLEAN: {
 BL::BoolAttribute b_bool_attribute{b_attribute};
 Attribute *attr = attributes.add(name, TypeFloat, element);
 float *data = attr->data_float();
-fill_generic_attribute(
-b_mesh, data, element, [&](int i) { return 
(float)b_bool_attribute.data[i].value(); });
+fill_generic_attribute(b_mesh, data, b_domain, [&](int i) {
+  return (float)b_bool_attribute.data[i].value();
+});
 break;
   }
   case BL::Attribute::data_type_INT: {
@@ -436,14 +463,14 @@ static void attr_create_generic(Scene *scene,
 Attribute *attr = attributes.add(name, TypeFloat, element);
 float *data = attr->data_float();
 fill_generic_attribute(
-b_mesh, data, element, [&](int i) { return 
(float)b_int_attribute.data[i].value(); });
+b_mesh, data, b_domain, [&](int i) { return 
(float)b_int_attribute.data[i].value(); });
 break;
   }
   case BL::Attribute::data_type_FLOAT_VECTOR: {
 BL::FloatVectorAttribute b_vector_attribute{b_attribute};
 Attribute *attr = attributes.add(name, TypeVector, element);
 float3 *data = attr->data_float3();
-fill_generic_attribute(b_mesh, data, element, [&](int i) {
+fill_generic_attribute(b_mesh, data, b_domain, [&](int i) {
   BL::Array v = b_vector_attribute.data[i].vector();
   return make_float3(v[0], v[1], v[2]);
 });
@@ -453,7 +480,7 @@ static void attr_create_generic(Scene *scene,
   

[Bf-blender-cvs] [8852191b779] master: Curves: Interpolate point count in add brush

2022-05-10 Thread Hans Goudey
Commit: 8852191b779e880fe4d5116f2bee3fcddb8aced4
Author: Hans Goudey
Date:   Tue May 10 18:27:24 2022 +0200
Branches: master
https://developer.blender.org/rB8852191b779e880fe4d5116f2bee3fcddb8aced4

Curves: Interpolate point count in add brush

This commit adds an option to interpolate the number of control points
in new curves based on the count in neighboring existing curves. The
idea is to provide a more automatic default than manually controlling
the number of points in a curve, so users don't have to think about
the resolution quite as much.

Internally, some utilities for creating new curves are extracted to a
new header file. These can be used for the various nodes and operators
that create new curves.

The top-bar UI will be adjusted in a separate patch, probably moving
all of the settings that affect the size and shape of the new curves
into a popover.

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

===

M   release/scripts/startup/bl_ui/space_view3d.py
A   source/blender/blenkernel/BKE_curves_utils.hh
M   source/blender/blenkernel/CMakeLists.txt
A   source/blender/blenkernel/intern/curves_utils.cc
M   source/blender/editors/sculpt_paint/curves_sculpt_add.cc
M   source/blender/geometry/intern/resample_curves.cc
M   source/blender/makesdna/DNA_brush_enums.h
M   source/blender/makesrna/intern/rna_brush.c

===

diff --git a/release/scripts/startup/bl_ui/space_view3d.py 
b/release/scripts/startup/bl_ui/space_view3d.py
index 122c7078c04..7bac7343bca 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -523,6 +523,7 @@ class _draw_tool_settings_context_mode:
 layout.prop(brush.curves_sculpt_settings, "curve_length")
 layout.prop(brush.curves_sculpt_settings, "interpolate_length")
 layout.prop(brush.curves_sculpt_settings, "interpolate_shape")
+layout.prop(brush.curves_sculpt_settings, 
"interpolate_point_count")
 
 if brush.curves_sculpt_tool == 'GROW_SHRINK':
 layout.prop(brush, "direction", expand=True, text="")
diff --git a/source/blender/blenkernel/BKE_curves_utils.hh 
b/source/blender/blenkernel/BKE_curves_utils.hh
new file mode 100644
index 000..62b060093e9
--- /dev/null
+++ b/source/blender/blenkernel/BKE_curves_utils.hh
@@ -0,0 +1,26 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+#pragma once
+
+#include "BKE_curves.hh"
+
+/** \file
+ * \ingroup bke
+ * \brief Low-level operations for curves.
+ */
+
+namespace blender::bke::curves {
+
+/**
+ * Copy the size of every curve in #curve_ranges to the corresponding index in 
#counts.
+ */
+void fill_curve_counts(const bke::CurvesGeometry ,
+   Span curve_ranges,
+   MutableSpan counts);
+
+/**
+ * Turn an array of sizes into the offset at each index including all previous 
sizes.
+ */
+void accumulate_counts_to_offsets(MutableSpan counts_to_offsets, int 
start_offset = 0);
+
+}  // namespace blender::bke::curves
diff --git a/source/blender/blenkernel/CMakeLists.txt 
b/source/blender/blenkernel/CMakeLists.txt
index c9e88362b80..0b4f81df452 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -117,6 +117,7 @@ set(SRC
   intern/curveprofile.cc
   intern/curves.cc
   intern/curves_geometry.cc
+  intern/curves_utils.cc
   intern/customdata.cc
   intern/customdata_file.c
   intern/data_transfer.c
@@ -356,6 +357,7 @@ set(SRC
   BKE_curveprofile.h
   BKE_curves.h
   BKE_curves.hh
+  BKE_curves_utils.hh
   BKE_customdata.h
   BKE_customdata_file.h
   BKE_data_transfer.h
diff --git a/source/blender/blenkernel/intern/curves_utils.cc 
b/source/blender/blenkernel/intern/curves_utils.cc
new file mode 100644
index 000..78c2382b62f
--- /dev/null
+++ b/source/blender/blenkernel/intern/curves_utils.cc
@@ -0,0 +1,38 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+/** \file
+ * \ingroup bke
+ */
+
+#include "BKE_curves_utils.hh"
+
+namespace blender::bke::curves {
+
+void fill_curve_counts(const bke::CurvesGeometry ,
+   const Span curve_ranges,
+   MutableSpan counts)
+{
+  threading::parallel_for(curve_ranges.index_range(), 512, [&](IndexRange 
ranges_range) {
+for (const IndexRange curves_range : curve_ranges.slice(ranges_range)) {
+  threading::parallel_for(curves_range, 4096, [&](IndexRange range) {
+for (const int i : range) {
+  counts[i] = curves.points_for_curve(i).size();
+}
+  });
+}
+  });
+}
+
+void accumulate_counts_to_offsets(MutableSpan counts_to_offsets, const 
int start_offset)
+{
+  int offset = start_offset;
+  for (const int i : counts_to_offsets.index_range().drop_back(1)) {
+const int count = counts_to_offsets[i];
+BLI_assert(count > 0);
+

[Bf-blender-cvs] [6f7959f55fd] master: Merge branch 'blender-v3.2-release'

2022-05-10 Thread Aras Pranckevicius
Commit: 6f7959f55fd2b3d291f63f0601d179bf581c5b28
Author: Aras Pranckevicius
Date:   Tue May 10 18:59:46 2022 +0300
Branches: master
https://developer.blender.org/rB6f7959f55fd2b3d291f63f0601d179bf581c5b28

Merge branch 'blender-v3.2-release'

===



===

diff --cc source/blender/io/common/CMakeLists.txt
index 02bd5b2b81f,b5766b44025..95ffbe19ada
--- a/source/blender/io/common/CMakeLists.txt
+++ b/source/blender/io/common/CMakeLists.txt
@@@ -7,6 -7,8 +7,8 @@@ set(IN
../../blenlib
../../depsgraph
../../makesdna
+   ../../../../intern/guardedalloc
 -  ../../../../extern/fast_float
++
  )
  
  set(INC_SYS
@@@ -17,9 -19,14 +19,12 @@@ set(SR
intern/dupli_parent_finder.cc
intern/dupli_persistent_id.cc
intern/object_identifier.cc
+   intern/path_util.cc
 -  intern/string_utils.cc
  
IO_abstract_hierarchy_iterator.h
IO_dupli_persistent_id.hh
+   IO_path_util.hh
+   IO_path_util_types.h
 -  IO_string_utils.hh
IO_types.h
intern/dupli_parent_finder.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] [3bc037a7eb8] blender-v3.2-release: Fix T96399: New 3.1 OBJ exporter is missing Path Mode setting

2022-05-10 Thread Aras Pranckevicius
Commit: 3bc037a7eb8d214aac9d755f8b2dd0e04cdf3a85
Author: Aras Pranckevicius
Date:   Tue May 10 11:34:42 2022 +0300
Branches: blender-v3.2-release
https://developer.blender.org/rB3bc037a7eb8d214aac9d755f8b2dd0e04cdf3a85

Fix T96399: New 3.1 OBJ exporter is missing Path Mode setting

New OBJ exporter is missing "Path Mode" setting for exporting .mtl
files. The options that used to be available were: Auto, Absolute,
Relative, Match, Strip Path, Copy. All of them are important. The new
behavior (without any UI option to control it) curiously does not match
any of the previous setting. New behavior is like "Relative, but to the
source blender file, and not the destination export file".

Most of the previous logic was only present in Python based code
(bpy_extras.io_utils.path_reference and friends). The bulk of this
commit is porting that to C++.

Reviewed By: Howard Trickey
Differential Revision: https://developer.blender.org/D14906

===

M   source/blender/editors/io/CMakeLists.txt
M   source/blender/editors/io/io_obj.c
M   source/blender/io/common/CMakeLists.txt
A   source/blender/io/common/IO_path_util.hh
A   source/blender/io/common/IO_path_util_types.h
A   source/blender/io/common/intern/path_util.cc
M   source/blender/io/wavefront_obj/IO_wavefront_obj.h
M   source/blender/io/wavefront_obj/exporter/obj_export_file_writer.cc
M   source/blender/io/wavefront_obj/exporter/obj_export_file_writer.hh
M   source/blender/io/wavefront_obj/exporter/obj_export_mtl.cc
M   source/blender/io/wavefront_obj/exporter/obj_exporter.cc
M   source/blender/io/wavefront_obj/tests/obj_exporter_tests.cc
M   source/blender/io/wavefront_obj/tests/obj_exporter_tests.hh

===

diff --git a/source/blender/editors/io/CMakeLists.txt 
b/source/blender/editors/io/CMakeLists.txt
index 418a399db28..ef093a01ff8 100644
--- a/source/blender/editors/io/CMakeLists.txt
+++ b/source/blender/editors/io/CMakeLists.txt
@@ -9,6 +9,7 @@ set(INC
   ../../depsgraph
   ../../io/alembic
   ../../io/collada
+  ../../io/common
   ../../io/gpencil
   ../../io/usd
   ../../io/wavefront_obj
diff --git a/source/blender/editors/io/io_obj.c 
b/source/blender/editors/io/io_obj.c
index 9156ff15ded..886586ff236 100644
--- a/source/blender/editors/io/io_obj.c
+++ b/source/blender/editors/io/io_obj.c
@@ -29,6 +29,7 @@
 
 #include "DEG_depsgraph.h"
 
+#include "IO_path_util_types.h"
 #include "IO_wavefront_obj.h"
 #include "io_obj.h"
 
@@ -59,6 +60,15 @@ static const EnumPropertyItem 
io_obj_export_evaluation_mode[] = {
  "Export objects as they appear in the viewport"},
 {0, NULL, 0, NULL, NULL}};
 
+static const EnumPropertyItem io_obj_path_mode[] = {
+{PATH_REFERENCE_AUTO, "AUTO", 0, "Auto", "Use Relative paths with 
subdirectories only"},
+{PATH_REFERENCE_ABSOLUTE, "ABSOLUTE", 0, "Absolute", "Always write 
absolute paths"},
+{PATH_REFERENCE_RELATIVE, "RELATIVE", 0, "Relative", "Write relative paths 
where possible"},
+{PATH_REFERENCE_MATCH, "MATCH", 0, "Match", "Match Absolute/Relative 
setting with input path"},
+{PATH_REFERENCE_STRIP, "STRIP", 0, "Strip", "Write filename only"},
+{PATH_REFERENCE_COPY, "COPY", 0, "Copy", "Copy the file to the destination 
path"},
+{0, NULL, 0, NULL, NULL}};
+
 static int wm_obj_export_invoke(bContext *C, wmOperator *op, const wmEvent 
*UNUSED(event))
 {
   if (!RNA_struct_property_is_set(op->ptr, "filepath")) {
@@ -87,6 +97,7 @@ static int wm_obj_export_exec(bContext *C, wmOperator *op)
 return OPERATOR_CANCELLED;
   }
   struct OBJExportParams export_params;
+  export_params.file_base_for_tests[0] = '\0';
   RNA_string_get(op->ptr, "filepath", export_params.filepath);
   export_params.blen_filepath = CTX_data_main(C)->filepath;
   export_params.export_animation = RNA_boolean_get(op->ptr, 
"export_animation");
@@ -103,6 +114,7 @@ static int wm_obj_export_exec(bContext *C, wmOperator *op)
   export_params.export_uv = RNA_boolean_get(op->ptr, "export_uv");
   export_params.export_normals = RNA_boolean_get(op->ptr, "export_normals");
   export_params.export_materials = RNA_boolean_get(op->ptr, 
"export_materials");
+  export_params.path_mode = RNA_enum_get(op->ptr, "path_mode");
   export_params.export_triangulated_mesh = RNA_boolean_get(op->ptr, 
"export_triangulated_mesh");
   export_params.export_curves_as_nurbs = RNA_boolean_get(op->ptr, 
"export_curves_as_nurbs");
 
@@ -119,9 +131,9 @@ static int wm_obj_export_exec(bContext *C, wmOperator *op)
 
 static void ui_obj_export_settings(uiLayout *layout, PointerRNA *imfptr)
 {
-
   const bool export_animation = RNA_boolean_get(imfptr, "export_animation");
   const bool export_smooth_groups = RNA_boolean_get(imfptr, 
"export_smooth_groups");
+  const bool export_materials = RNA_boolean_get(imfptr, "export_materials");
 
   uiLayoutSetPropSep(layout, true);
   

[Bf-blender-cvs] [9c2613d1b6d] master: Merge branch 'blender-v3.2-release'

2022-05-10 Thread Bastien Montagne
Commit: 9c2613d1b6d034b4d80367df06ec4cd08d9bbbaa
Author: Bastien Montagne
Date:   Tue May 10 17:57:41 2022 +0200
Branches: master
https://developer.blender.org/rB9c2613d1b6d034b4d80367df06ec4cd08d9bbbaa

Merge branch 'blender-v3.2-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] [1dd17724190] blender-v3.2-release: LibOverride: Fix memory leak in resyncing code.

2022-05-10 Thread Bastien Montagne
Commit: 1dd177241908906254527052beb01aa52745b6a8
Author: Bastien Montagne
Date:   Tue May 10 17:43:01 2022 +0200
Branches: blender-v3.2-release
https://developer.blender.org/rB1dd177241908906254527052beb01aa52745b6a8

LibOverride: Fix memory leak in resyncing code.

===

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

===

diff --git a/source/blender/blenkernel/intern/lib_override.c 
b/source/blender/blenkernel/intern/lib_override.c
index 936587a9a16..9dc64365f0c 100644
--- a/source/blender/blenkernel/intern/lib_override.c
+++ b/source/blender/blenkernel/intern/lib_override.c
@@ -1465,6 +1465,7 @@ static void lib_override_library_remap(Main *bmain,
remapper,
ID_REMAP_FORCE_USER_REFCOUNT | 
ID_REMAP_FORCE_NEVER_NULL_USAGE);
   BKE_id_remapper_free(remapper);
+  BLI_linklist_free(nomain_ids, NULL);
 }
 
 static bool lib_override_library_resync(Main *bmain,

___
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] [6c679aca177] blender-v3.2-release: LibOverride: Make process checking validity of hierarchy roots more robust.

2022-05-10 Thread Bastien Montagne
Commit: 6c679aca1770c37a32c089512d47d98ae795284b
Author: Bastien Montagne
Date:   Tue May 10 17:32:31 2022 +0200
Branches: blender-v3.2-release
https://developer.blender.org/rB6c679aca1770c37a32c089512d47d98ae795284b

LibOverride: Make process checking validity of hierarchy roots more robust.

Code was not really designed to hanlde corrupted (e.g. local ID) root
hierarchies, now it should handle better those invalid cases and restore
proper sane situation as best as possible.

Fixes crashes with some corrupted files from Blender studio.

===

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

===

diff --git a/source/blender/blenkernel/intern/lib_override.c 
b/source/blender/blenkernel/intern/lib_override.c
index a2338eb9b39..3c115ba3a74 100644
--- a/source/blender/blenkernel/intern/lib_override.c
+++ b/source/blender/blenkernel/intern/lib_override.c
@@ -1384,7 +1384,21 @@ void 
BKE_lib_override_library_main_hierarchy_root_ensure(Main *bmain)
   continue;
 }
 if (id->override_library->hierarchy_root != NULL) {
-  continue;
+  if (!ID_IS_OVERRIDE_LIBRARY_REAL(id->override_library->hierarchy_root) ||
+  id->override_library->hierarchy_root->lib != id->lib) {
+CLOG_ERROR(
+,
+"Existing override hierarchy root ('%s') for ID '%s' is invalid, 
will try to find a "
+"new valid one",
+id->override_library->hierarchy_root != NULL ?
+id->override_library->hierarchy_root->name :
+"",
+id->name);
+id->override_library->hierarchy_root = NULL;
+  }
+  else {
+continue;
+  }
 }
 
 BKE_main_relations_tag_set(bmain, MAINIDRELATIONS_ENTRY_TAGS_PROCESSED, 
false);
@@ -2058,6 +2072,10 @@ static bool lib_override_resync_tagging_finalize_recurse(
 
 CLOG_INFO(, 4, "Found root ID '%s' for resync root ID '%s'", 
id_root->name, id->name);
 
+if (id_root->override_library == NULL) {
+  BLI_assert(0);
+}
+
 LinkNodePair **id_resync_roots_p;
 if (!BLI_ghash_ensure_p(id_roots, id_root, (void ***)_resync_roots_p)) {
   *id_resync_roots_p = MEM_callocN(sizeof(**id_resync_roots_p), __func__);

___
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] [0134ab4b563] blender-v3.2-release: LibOverride: Fix bad ID getting hierarchy root updated.

2022-05-10 Thread Bastien Montagne
Commit: 0134ab4b563798c619b00b20f3c9704934c3c531
Author: Bastien Montagne
Date:   Tue May 10 17:42:00 2022 +0200
Branches: blender-v3.2-release
https://developer.blender.org/rB0134ab4b563798c619b00b20f3c9704934c3c531

LibOverride: Fix bad ID getting hierarchy root updated.

Followup to rB6c679aca1770c37.

===

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

===

diff --git a/source/blender/blenkernel/intern/lib_override.c 
b/source/blender/blenkernel/intern/lib_override.c
index 3c115ba3a74..936587a9a16 100644
--- a/source/blender/blenkernel/intern/lib_override.c
+++ b/source/blender/blenkernel/intern/lib_override.c
@@ -1416,7 +1416,7 @@ void 
BKE_lib_override_library_main_hierarchy_root_ensure(Main *bmain)
   continue;
 }
 
-lib_override_root_hierarchy_set(bmain, id_root, id_root, NULL);
+lib_override_root_hierarchy_set(bmain, id_root, id, NULL);
 
 BLI_assert(id->override_library->hierarchy_root != NULL);
   }

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


[Bf-blender-cvs] [46934eaf250] asset-browser-grid-view: Merge branch 'master' into asset-browser-grid-view

2022-05-10 Thread Julian Eisel
Commit: 46934eaf25070846573b70365be8f61d03529e9d
Author: Julian Eisel
Date:   Tue May 10 17:09:32 2022 +0200
Branches: asset-browser-grid-view
https://developer.blender.org/rB46934eaf25070846573b70365be8f61d03529e9d

Merge branch 'master' into asset-browser-grid-view

===



===



___
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] [c67a650718a] asset-browser-grid-view: Merge branch 'master' into asset-browser-grid-view

2022-05-10 Thread Julian Eisel
Commit: c67a650718a692b7400bd78fddf83e4dba054331
Author: Julian Eisel
Date:   Tue May 10 17:09:13 2022 +0200
Branches: asset-browser-grid-view
https://developer.blender.org/rBc67a650718a692b7400bd78fddf83e4dba054331

Merge branch 'master' into asset-browser-grid-view

===



===

diff --cc source/blender/makesdna/DNA_space_types.h
index dcb4c35099b,8e29d88a583..3317a3860e9
--- a/source/blender/makesdna/DNA_space_types.h
+++ b/source/blender/makesdna/DNA_space_types.h
@@@ -2084,10 -2064,9 +2094,10 @@@ typedef enum eSpace_Type 
SPACE_CLIP = 20,
SPACE_TOPBAR = 21,
SPACE_STATUSBAR = 22,
 -  SPACE_SPREADSHEET = 23
 +  SPACE_SPREADSHEET = 23,
 +  SPACE_ASSETS = 24
  
- #define SPACE_TYPE_LAST SPACE_ASSETS
 -#define SPACE_TYPE_NUM (SPACE_SPREADSHEET + 1)
++#define SPACE_TYPE_NUM (SPACE_ASSETS + 1)
  } eSpace_Type;
  
  /* use for function args */

___
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] [3ad2597a4ec] temp-ceres_update: Update Ceres to latest upstream version 2.1.0

2022-05-10 Thread Sergey Sharybin
Commit: 3ad2597a4eca5091031c213445c6583e21097d5f
Author: Sergey Sharybin
Date:   Tue May 10 16:36:22 2022 +0200
Branches: temp-ceres_update
https://developer.blender.org/rB3ad2597a4eca5091031c213445c6583e21097d5f

Update Ceres to latest upstream version 2.1.0

This release deprecated the Parameterization API and the new Manifolds
API is to be used instead. This is what was done in the Libmv as part
of this change.

Additionally, remove the bundling scripts. Nowadays those are only
leading to a duplicated work to maintain.

===

M   CMakeLists.txt
M   extern/ceres/CMakeLists.txt
D   extern/ceres/ChangeLog
M   extern/ceres/LICENSE
D   extern/ceres/README
M   extern/ceres/README.blender
A   extern/ceres/README.md
D   extern/ceres/bundle.sh
M   extern/ceres/config/ceres/internal/config.h
A   extern/ceres/config/ceres/internal/export.h
D   extern/ceres/files.txt
M   extern/ceres/include/ceres/autodiff_cost_function.h
M   extern/ceres/include/ceres/autodiff_first_order_function.h
M   extern/ceres/include/ceres/autodiff_local_parameterization.h
A   extern/ceres/include/ceres/autodiff_manifold.h
M   extern/ceres/include/ceres/c_api.h
M   extern/ceres/include/ceres/ceres.h
M   extern/ceres/include/ceres/conditioned_cost_function.h
M   extern/ceres/include/ceres/context.h
M   extern/ceres/include/ceres/cost_function.h
M   extern/ceres/include/ceres/cost_function_to_functor.h
M   extern/ceres/include/ceres/covariance.h
M   extern/ceres/include/ceres/crs_matrix.h
M   extern/ceres/include/ceres/cubic_interpolation.h
M   extern/ceres/include/ceres/dynamic_autodiff_cost_function.h
M   extern/ceres/include/ceres/dynamic_cost_function.h
M   extern/ceres/include/ceres/dynamic_cost_function_to_functor.h
M   extern/ceres/include/ceres/dynamic_numeric_diff_cost_function.h
M   extern/ceres/include/ceres/evaluation_callback.h
M   extern/ceres/include/ceres/first_order_function.h
M   extern/ceres/include/ceres/gradient_checker.h
M   extern/ceres/include/ceres/gradient_problem.h
M   extern/ceres/include/ceres/gradient_problem_solver.h
M   extern/ceres/include/ceres/internal/array_selector.h
M   extern/ceres/include/ceres/internal/autodiff.h
M   extern/ceres/include/ceres/internal/eigen.h
M   extern/ceres/include/ceres/internal/householder_vector.h
M   extern/ceres/include/ceres/internal/integer_sequence_algorithm.h
A   extern/ceres/include/ceres/internal/jet_traits.h
M   extern/ceres/include/ceres/internal/numeric_diff.h
M   extern/ceres/include/ceres/internal/port.h
A   extern/ceres/include/ceres/internal/sphere_manifold_functions.h
M   extern/ceres/include/ceres/internal/variadic_evaluate.h
M   extern/ceres/include/ceres/iteration_callback.h
M   extern/ceres/include/ceres/jet.h
R071extern/ceres/internal/ceres/split.h 
extern/ceres/include/ceres/jet_fwd.h
A   extern/ceres/include/ceres/line_manifold.h
M   extern/ceres/include/ceres/local_parameterization.h
M   extern/ceres/include/ceres/loss_function.h
A   extern/ceres/include/ceres/manifold.h
A   extern/ceres/include/ceres/manifold_test_utils.h
M   extern/ceres/include/ceres/normal_prior.h
M   extern/ceres/include/ceres/numeric_diff_cost_function.h
A   extern/ceres/include/ceres/numeric_diff_first_order_function.h
M   extern/ceres/include/ceres/numeric_diff_options.h
M   extern/ceres/include/ceres/ordered_groups.h
M   extern/ceres/include/ceres/problem.h
A   extern/ceres/include/ceres/product_manifold.h
M   extern/ceres/include/ceres/rotation.h
M   extern/ceres/include/ceres/sized_cost_function.h
M   extern/ceres/include/ceres/solver.h
A   extern/ceres/include/ceres/sphere_manifold.h
M   extern/ceres/include/ceres/tiny_solver.h
M   extern/ceres/include/ceres/tiny_solver_autodiff_function.h
M   extern/ceres/include/ceres/tiny_solver_cost_function_adapter.h
M   extern/ceres/include/ceres/types.h
M   extern/ceres/include/ceres/version.h
M   extern/ceres/internal/ceres/accelerate_sparse.cc
M   extern/ceres/internal/ceres/accelerate_sparse.h
M   extern/ceres/internal/ceres/array_utils.cc
M   extern/ceres/internal/ceres/array_utils.h
M   extern/ceres/internal/ceres/block_evaluate_preparer.cc
M   extern/ceres/internal/ceres/block_evaluate_preparer.h
M   extern/ceres/internal/ceres/block_jacobi_preconditioner.cc
M   extern/ceres/internal/ceres/block_jacobi_preconditioner.h
M   extern/ceres/internal/ceres/block_jacobian_writer.cc
M   extern/ceres/internal/ceres/block_jacobian_writer.h
M   extern/ceres/internal/ceres/block_random_access_dense_matrix.cc
M   extern/ceres/internal/ceres/block_random_access_dense_matrix.h
M   extern/ceres/internal/ceres/block_random_access_diagonal_matrix.cc
M   

[Bf-blender-cvs] [cd349dc4023] master: LineArt: Use thread safe bound box.

2022-05-10 Thread YimingWu
Commit: cd349dc4023aa1e6b4728ae6804ae36a5e170758
Author: YimingWu
Date:   Tue May 10 14:41:35 2022 +0800
Branches: master
https://developer.blender.org/rBcd349dc4023aa1e6b4728ae6804ae36a5e170758

LineArt: Use thread safe bound box.

The old method is not thread safe, which will lead to minor
memory leaks. This patch fixed that.

Reviewed By: Sebastian Parborg (zeddb)

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

===

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

===

diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c 
b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
index dbe2ae0b890..b09bb15ce81 100644
--- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
+++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
@@ -2358,18 +2358,21 @@ static void 
lineart_geometry_load_assign_thread(LineartObjectLoadTaskInfo *olti_
 static bool lineart_geometry_check_visible(double (*model_view_proj)[4],
double shift_x,
double shift_y,
-   Object *use_ob)
+   Mesh *use_mesh)
 {
-  const BoundBox *bb = BKE_object_boundbox_get(use_ob);
-  if (!bb) {
-/* For lights and empty stuff there will be no bbox. */
+  if (!use_mesh) {
 return false;
   }
+  float mesh_min[3], mesh_max[3];
+  INIT_MINMAX(mesh_min, mesh_max);
+  BKE_mesh_minmax(use_mesh, mesh_min, mesh_max);
+  BoundBox bb = {0};
+  BKE_boundbox_init_from_minmax(, mesh_min, mesh_max);
 
   double co[8][4];
   double tmp[3];
   for (int i = 0; i < 8; i++) {
-copy_v3db_v3fl(co[i], bb->vec[i]);
+copy_v3db_v3fl(co[i], bb.vec[i]);
 copy_v3_v3_db(tmp, co[i]);
 mul_v4_m4v3_db(co[i], model_view_proj, tmp);
 co[i][0] -= shift_x * 2 * co[i][3];
@@ -2481,13 +2484,6 @@ static void lineart_main_load_geometries(
   continue;
 }
 
-if (!lineart_geometry_check_visible(obi->model_view_proj, rb->shift_x, 
rb->shift_y, use_ob)) {
-  if (G.debug_value == 4000) {
-bound_box_discard_count++;
-  }
-  continue;
-}
-
 if (use_ob->type == OB_MESH) {
   use_mesh = BKE_object_get_evaluated_mesh(use_ob);
 }
@@ -2506,6 +2502,17 @@ static void lineart_main_load_geometries(
   continue;
 }
 
+if (!lineart_geometry_check_visible(
+obi->model_view_proj, rb->shift_x, rb->shift_y, use_mesh)) {
+  if (ob->type != OB_MESH) {
+BKE_id_free(NULL, use_mesh);
+  }
+  if (G.debug_value == 4000) {
+bound_box_discard_count++;
+  }
+  continue;
+}
+
 if (ob->type != OB_MESH) {
   obi->free_use_mesh = true;
 }

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


[Bf-blender-cvs] [c60b570841f] master: Remove debug code enabled in previous commit.

2022-05-10 Thread Jeroen Bakker
Commit: c60b570841f0aa468014123c1b75afdd66f1b387
Author: Jeroen Bakker
Date:   Tue May 10 15:54:59 2022 +0200
Branches: master
https://developer.blender.org/rBc60b570841f0aa468014123c1b75afdd66f1b387

Remove debug code enabled in previous commit.

===

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

===

diff --git a/source/blender/blenkernel/intern/pbvh_pixels.cc 
b/source/blender/blenkernel/intern/pbvh_pixels.cc
index 9ea7f991677..8b3fcffd9cd 100644
--- a/source/blender/blenkernel/intern/pbvh_pixels.cc
+++ b/source/blender/blenkernel/intern/pbvh_pixels.cc
@@ -26,7 +26,7 @@ namespace blender::bke::pbvh::pixels {
  * During debugging this check could be enabled.
  * It will write to each image pixel that is covered by the PBVH.
  */
-constexpr bool USE_WATERTIGHT_CHECK = true;
+constexpr bool USE_WATERTIGHT_CHECK = false;
 
 /**
  * Calculate the delta of two neighbor UV coordinates in the given image 
buffer.

___
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] [d9d81cb1ffa] master: 3d texture painting: Use center uv pixel as anchor.

2022-05-10 Thread Jeroen Bakker
Commit: d9d81cb1ffa964439630963cd4cd504137c91d20
Author: Jeroen Bakker
Date:   Tue May 10 15:52:28 2022 +0200
Branches: master
https://developer.blender.org/rBd9d81cb1ffa964439630963cd4cd504137c91d20

3d texture painting: Use center uv pixel as anchor.

Previously the bottom left of a pixel was used during pixel extraction what 
resulted in
that the pixels were moved a bit to the bottom left. By using the center uv 
pixel the
extracted pixels are more balanced and would improve future features like seam 
bleeding.

===

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

===

diff --git a/source/blender/blenkernel/intern/pbvh_pixels.cc 
b/source/blender/blenkernel/intern/pbvh_pixels.cc
index 5623cac44ac..9ea7f991677 100644
--- a/source/blender/blenkernel/intern/pbvh_pixels.cc
+++ b/source/blender/blenkernel/intern/pbvh_pixels.cc
@@ -26,7 +26,7 @@ namespace blender::bke::pbvh::pixels {
  * During debugging this check could be enabled.
  * It will write to each image pixel that is covered by the PBVH.
  */
-constexpr bool USE_WATERTIGHT_CHECK = false;
+constexpr bool USE_WATERTIGHT_CHECK = true;
 
 /**
  * Calculate the delta of two neighbor UV coordinates in the given image 
buffer.
@@ -71,7 +71,7 @@ static void extract_barycentric_pixels(UDIMTilePixels 
_data,
 int x;
 
 for (x = minx; x < maxx; x++) {
-  float2 uv(float(x) / image_buffer->x, float(y) / image_buffer->y);
+  float2 uv((float(x) + 0.5f) / image_buffer->x, (float(y) + 0.5f) / 
image_buffer->y);
   float3 barycentric_weights;
   barycentric_weights_v2(uvs[0], uvs[1], uvs[2], uv, barycentric_weights);

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

2022-05-10 Thread Campbell Barton
Commit: de71cdb35df4790e2596fde12168d849206c663b
Author: Campbell Barton
Date:   Tue May 10 23:04:26 2022 +1000
Branches: master
https://developer.blender.org/rBde71cdb35df4790e2596fde12168d849206c663b

Merge branch 'blender-v3.2-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] [b4b85c5ce27] master: Merge branch 'blender-v3.2-release'

2022-05-10 Thread Campbell Barton
Commit: b4b85c5ce2752ea9241cbcfa1ddc3f639ad64262
Author: Campbell Barton
Date:   Tue May 10 23:04:37 2022 +1000
Branches: master
https://developer.blender.org/rBb4b85c5ce2752ea9241cbcfa1ddc3f639ad64262

Merge branch 'blender-v3.2-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] [4c3e91e5f56] blender-v3.2-release: Fix T96520 Node editor: Tweak fails with unselected nodes

2022-05-10 Thread Campbell Barton
Commit: 4c3e91e5f565b81dd79b5d42f55be5b93662d410
Author: Campbell Barton
Date:   Tue May 10 22:57:00 2022 +1000
Branches: blender-v3.2-release
https://developer.blender.org/rB4c3e91e5f565b81dd79b5d42f55be5b93662d410

Fix T96520 Node editor: Tweak fails with unselected nodes

Use the same method for node selection and dragging that is used
in the 3D viewport and UV editor. Instead of relying on a modal
operator - use the keymap to handle click/drag events.

Details:

Failure to transform unselected nodes was caused by [0] & [1] however
detecting drag relied on specific behavior which I don't think we should
be depending on.

This error happened when selection was defined both in the key-map for
the tool and for the node-editor.

- The left mouse button would activate selection in both the tool
  and "Node Editor" keymap.

- The first selection would return `FINISHED | PASS_THROUGH` when
  selecting a previously unselected node.

- The same PRESS would trigger a second selection would return
  `RUNNING_MODAL | PASS_THROUGH`,
  (starting a NODE_OT_select as a modal operator).

  - In 3.1 (with tweak events) the modal operator would then exit and
fall-back to the tweak event which would transform the selected
nodes.

  - In 3.2 (as of [0]) the PRESS that starts the modal operator is
considered "handled" and prevents drag event from being detected.

The correct behavior in this case isn't obvious:
If a modal operator starts on pressing a button, using that same the
release to generate drag/click events is disputable.

Even in the case or 3.1 it was inconsistent as tweak events were
generated but click events weren't.

Note: after investigating this bug it turns out a similar issue already
existed in 2.91 and all releases afterwards. While the bug is more
obscure, it's also caused by the tweak event being interrupted as
described here, this commit resolves T81824 as well.

[0]: 4d0f846b936c9101ecb76a6db962aac2d74a460a
[1]: 4986f718482b061082936f1f6aa13929741093a2

Reviewed By: Severin

Ref D14499

===

M   release/scripts/presets/keyconfig/keymap_data/blender_default.py
M   source/blender/editors/space_node/node_select.cc

===

diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py 
b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index 78620c41d1e..64e0917da65 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -2019,37 +2019,20 @@ def km_node_editor(params):
 {"items": items},
 )
 
-def node_select_ops(select_mouse):
-return [
-("node.select", {"type": select_mouse, "value": 'PRESS'},
- {"properties": [("deselect_all", True)]}),
-("node.select", {"type": select_mouse, "value": 'PRESS', "ctrl": 
True}, None),
-("node.select", {"type": select_mouse, "value": 'PRESS', "alt": 
True}, None),
-("node.select", {"type": select_mouse, "value": 'PRESS', "ctrl": 
True, "alt": True}, None),
-("node.select", {"type": select_mouse, "value": 'PRESS', "shift": 
True},
- {"properties": [("extend", True)]}),
-("node.select", {"type": select_mouse, "value": 'PRESS', "shift": 
True, "ctrl": True},
- {"properties": [("extend", True)]}),
-("node.select", {"type": select_mouse, "value": 'PRESS', "shift": 
True, "alt": True},
- {"properties": [("extend", True)]}),
-("node.select", {"type": select_mouse, "value": 'PRESS', "shift": 
True, "ctrl": True, "alt": True},
- {"properties": [("extend", True)]}),
-]
-
-# Allow node selection with both for RMB select
 if not params.legacy:
+items.extend(_template_node_select(type=params.select_mouse,
+ value=params.select_mouse_value, select_passthrough=True))
+# Allow node selection with both for RMB select.
 if params.select_mouse == 'RIGHTMOUSE':
-items.extend(node_select_ops('LEFTMOUSE'))
-items.extend(node_select_ops('RIGHTMOUSE'))
-else:
-items.extend(node_select_ops('LEFTMOUSE'))
+items.extend(_template_node_select(type='LEFTMOUSE', 
value='PRESS', select_passthrough=True))
 else:
-items.extend(node_select_ops('RIGHTMOUSE'))
+items.extend(_template_node_select(
+type='RIGHTMOUSE', value=params.select_mouse_value, 
select_passthrough=False))
 items.extend([
 ("node.select", {"type": 'LEFTMOUSE', "value": 'PRESS'},
  {"properties": [("deselect_all", False)]}),
 ("node.select", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": 
True},
- {"properties": [("extend", True)]}),
+ {"properties": [("toggle", True)]}),
 

[Bf-blender-cvs] [9173dd24adc] master: Fix for crash opening the file selector multiple times

2022-05-10 Thread Campbell Barton
Commit: 9173dd24adc7775b76840912b76ed37828938829
Author: Campbell Barton
Date:   Tue May 10 22:56:22 2022 +1000
Branches: master
https://developer.blender.org/rB9173dd24adc7775b76840912b76ed37828938829

Fix for crash opening the file selector multiple times

This is part of a fix for T88570, where the file selector would crash
when activated multiple times.

Calling save multiple times would free the operator, leaving a dangling
pointer which was used when panels were visible that accessed the
"active_operator".

Reviewed By: Severin

Ref D14905

===

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

===

diff --git a/source/blender/windowmanager/intern/wm_event_system.c 
b/source/blender/windowmanager/intern/wm_event_system.c
index d375fb04744..082e6443ba2 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -101,6 +101,7 @@ static int wm_operator_call_internal(bContext *C,
 
 static bool wm_operator_check_locked_interface(bContext *C, wmOperatorType 
*ot);
 static wmEvent *wm_event_add_mousemove_to_head(wmWindow *win);
+static void wm_operator_free_for_fileselect(wmOperator *file_operator);
 
 /*  */
 /** \name Event Management
@@ -2036,7 +2037,13 @@ void WM_event_remove_handlers(bContext *C, ListBase 
*handlers)
 }
 
 WM_cursor_grab_disable(win, NULL);
-WM_operator_free(handler->op);
+
+if (handler->is_fileselect) {
+  wm_operator_free_for_fileselect(handler->op);
+}
+else {
+  WM_operator_free(handler->op);
+}
   }
 }
 else if (handler_base->type == WM_HANDLER_TYPE_UI) {
@@ -2473,6 +2480,22 @@ static int wm_handler_operator_call(bContext *C,
   return WM_HANDLER_BREAK;
 }
 
+static void wm_operator_free_for_fileselect(wmOperator *file_operator)
+{
+  LISTBASE_FOREACH (bScreen *, screen, _MAIN->screens) {
+LISTBASE_FOREACH (ScrArea *, area, >areabase) {
+  if (area->spacetype == SPACE_FILE) {
+SpaceFile *sfile = area->spacedata.first;
+if (sfile->op == file_operator) {
+  sfile->op = NULL;
+}
+  }
+}
+  }
+
+  WM_operator_free(file_operator);
+}
+
 /**
  * File-select handlers are only in the window queue,
  * so it's safe to switch screens or area types.
@@ -2668,7 +2691,7 @@ static int wm_handler_fileselect_do(bContext *C,
 }
 
 if (retval & (OPERATOR_CANCELLED | OPERATOR_FINISHED)) {
-  WM_operator_free(handler->op);
+  wm_operator_free_for_fileselect(handler->op);
 }
   }
   else {
@@ -2683,8 +2706,7 @@ static int wm_handler_fileselect_do(bContext *C,
 wm->op_undo_depth--;
   }
 }
-
-WM_operator_free(handler->op);
+wm_operator_free_for_fileselect(handler->op);
   }
 
   CTX_wm_area_set(C, NULL);

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


[Bf-blender-cvs] [502c3d6c21e] master: Cleanup: remove non-existent include

2022-05-10 Thread Campbell Barton
Commit: 502c3d6c21e9ca5947f525dcd3870e795c1b2fc6
Author: Campbell Barton
Date:   Tue May 10 22:54:46 2022 +1000
Branches: master
https://developer.blender.org/rB502c3d6c21e9ca5947f525dcd3870e795c1b2fc6

Cleanup: remove non-existent include

guardedalloc was already included.

===

M   source/blender/geometry/CMakeLists.txt

===

diff --git a/source/blender/geometry/CMakeLists.txt 
b/source/blender/geometry/CMakeLists.txt
index cf89426bfc4..010c327d482 100644
--- a/source/blender/geometry/CMakeLists.txt
+++ b/source/blender/geometry/CMakeLists.txt
@@ -7,7 +7,6 @@ set(INC
   ../blenlib
   ../blentranslation
   ../functions
-  ../guardedalloc
   ../makesdna
   ../makesrna
   ../../../intern/eigen

___
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] [15021968c1e] master: DrawManager: Hide lock acquire behind experimental feature.

2022-05-10 Thread Jeroen Bakker
Commit: 15021968c1e962c364b08f1ade08023da49a28ec
Author: Jeroen Bakker
Date:   Tue May 10 14:01:02 2022 +0200
Branches: master
https://developer.blender.org/rB15021968c1e962c364b08f1ade08023da49a28ec

DrawManager: Hide lock acquire behind experimental feature.

The acquire locking of the draw manager introduced other issues.
The current implementation was a hacky solution as we know that the
final solution is something totally different {T98016}.

Related issues:
* {T97988}
* {T97600}

===

M   release/scripts/startup/bl_ui/space_userpref.py
M   source/blender/draw/intern/draw_manager.c
M   source/blender/makesdna/DNA_userdef_types.h
M   source/blender/makesrna/intern/rna_userdef.c
M   source/blender/windowmanager/intern/wm_draw.c

===

diff --git a/release/scripts/startup/bl_ui/space_userpref.py 
b/release/scripts/startup/bl_ui/space_userpref.py
index 6654053bef4..d4d1e6ace76 100644
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@ -2278,6 +2278,7 @@ class 
USERPREF_PT_experimental_prototypes(ExperimentalPanel, Panel):
 ({"property": "use_new_point_cloud_type"}, "T75717"),
 ({"property": "use_full_frame_compositor"}, "T88150"),
 ({"property": "enable_eevee_next"}, "T93220"),
+({"property": "use_draw_manager_acquire_lock"}, "T98016"),
 ),
 )
 
diff --git a/source/blender/draw/intern/draw_manager.c 
b/source/blender/draw/intern/draw_manager.c
index 6ab8d30109e..4bbcf6eaf42 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -1287,7 +1287,7 @@ void DRW_notify_view_update(const DRWUpdateContext 
*update_ctx)
 
   const bool gpencil_engine_needed = drw_gpencil_engine_needed(depsgraph, v3d);
 
-  if (G.is_rendering) {
+  if (G.is_rendering && U.experimental.use_draw_manager_acquire_lock) {
 return;
   }
 
diff --git a/source/blender/makesdna/DNA_userdef_types.h 
b/source/blender/makesdna/DNA_userdef_types.h
index a8fa1fd4271..275a89ec680 100644
--- a/source/blender/makesdna/DNA_userdef_types.h
+++ b/source/blender/makesdna/DNA_userdef_types.h
@@ -652,7 +652,7 @@ typedef struct UserDef_Experimental {
   char use_override_templates;
   char enable_eevee_next;
   char use_sculpt_texture_paint;
-  char _pad0[1];
+  char use_draw_manager_acquire_lock;
   /** `makesdna` does not allow empty structs. */
 } UserDef_Experimental;
 
diff --git a/source/blender/makesrna/intern/rna_userdef.c 
b/source/blender/makesrna/intern/rna_userdef.c
index 5ac324b3627..1b5536c755e 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -6424,6 +6424,10 @@ static void rna_def_userdef_experimental(BlenderRNA 
*brna)
   RNA_def_property_boolean_sdna(prop, NULL, "use_sculpt_texture_paint", 1);
   RNA_def_property_ui_text(prop, "Sculpt Texture Paint", "Use texture painting 
in Sculpt Mode");
 
+  prop = RNA_def_property(srna, "use_draw_manager_acquire_lock", PROP_BOOLEAN, 
PROP_NONE);
+  RNA_def_property_boolean_sdna(prop, NULL, "use_draw_manager_acquire_lock", 
1);
+  RNA_def_property_ui_text(prop, "Draw Manager Locking", "Don't lock UI during 
background rendering");
+
   prop = RNA_def_property(srna, "use_extended_asset_browser", PROP_BOOLEAN, 
PROP_NONE);
   RNA_def_property_ui_text(prop,
"Extended Asset Browser",
diff --git a/source/blender/windowmanager/intern/wm_draw.c 
b/source/blender/windowmanager/intern/wm_draw.c
index 02da798495b..d2ade7b0376 100644
--- a/source/blender/windowmanager/intern/wm_draw.c
+++ b/source/blender/windowmanager/intern/wm_draw.c
@@ -467,7 +467,7 @@ static bool wm_draw_region_bind(bContext *C, ARegion 
*region, int view)
   }
 
   if (region->draw_buffer->viewport) {
-if (G.is_rendering && C != NULL) {
+if (G.is_rendering && C != NULL && 
U.experimental.use_draw_manager_acquire_lock) {
   Scene *scene = CTX_data_scene(C);
   RenderEngineType *render_engine_type = RE_engines_find(scene->r.engine);
   if (RE_engine_is_opengl(render_engine_type)) {

___
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] [b38cd1bcbed] master: Fix: Missing curves type count cache update in add brush

2022-05-10 Thread Hans Goudey
Commit: b38cd1bcbedc5699896cec7ea26dd70bce52eb9c
Author: Hans Goudey
Date:   Tue May 10 14:27:36 2022 +0200
Branches: master
https://developer.blender.org/rBb38cd1bcbedc5699896cec7ea26dd70bce52eb9c

Fix: Missing curves type count cache update in add brush

===

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

===

diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_add.cc 
b/source/blender/editors/sculpt_paint/curves_sculpt_add.cc
index 1fdecf47bbd..6edc9194319 100644
--- a/source/blender/editors/sculpt_paint/curves_sculpt_add.cc
+++ b/source/blender/editors/sculpt_paint/curves_sculpt_add.cc
@@ -228,6 +228,8 @@ struct AddOperationExecutor {
 threading::parallel_invoke([&]() { 
this->initialize_curve_offsets(tot_added_curves); },
[&]() { 
this->initialize_attributes(added_points); });
 
+curves_->update_curve_types();
+
 DEG_id_tag_update(_id_->id, ID_RECALC_GEOMETRY);
 ED_region_tag_redraw(region_);
   }

___
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] [4ffeb2d4492] blender-v3.2-release: DrawManager: Hide lock acquire behind experimental feature.

2022-05-10 Thread Jeroen Bakker
Commit: 4ffeb2d449296fbc03d9f5af3288b8e0ff07c602
Author: Jeroen Bakker
Date:   Tue May 10 14:01:02 2022 +0200
Branches: blender-v3.2-release
https://developer.blender.org/rB4ffeb2d449296fbc03d9f5af3288b8e0ff07c602

DrawManager: Hide lock acquire behind experimental feature.

The acquire locking of the draw manager introduced other issues.
The current implementation was a hacky solution as we know that the
final solution is something totally different {T98016}.

Related issues:
* {T97988}
* {T97600}

===

M   release/scripts/startup/bl_ui/space_userpref.py
M   source/blender/draw/intern/draw_manager.c
M   source/blender/makesdna/DNA_userdef_types.h
M   source/blender/makesrna/intern/rna_userdef.c
M   source/blender/windowmanager/intern/wm_draw.c

===

diff --git a/release/scripts/startup/bl_ui/space_userpref.py 
b/release/scripts/startup/bl_ui/space_userpref.py
index e0abb3a8d89..af56b966f17 100644
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@ -2277,6 +2277,7 @@ class 
USERPREF_PT_experimental_prototypes(ExperimentalPanel, Panel):
 ({"property": "use_new_point_cloud_type"}, "T75717"),
 ({"property": "use_full_frame_compositor"}, "T88150"),
 ({"property": "enable_eevee_next"}, "T93220"),
+({"property": "use_draw_manager_acquire_lock"}, "T98016"),
 ),
 )
 
diff --git a/source/blender/draw/intern/draw_manager.c 
b/source/blender/draw/intern/draw_manager.c
index 6ab8d30109e..4bbcf6eaf42 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -1287,7 +1287,7 @@ void DRW_notify_view_update(const DRWUpdateContext 
*update_ctx)
 
   const bool gpencil_engine_needed = drw_gpencil_engine_needed(depsgraph, v3d);
 
-  if (G.is_rendering) {
+  if (G.is_rendering && U.experimental.use_draw_manager_acquire_lock) {
 return;
   }
 
diff --git a/source/blender/makesdna/DNA_userdef_types.h 
b/source/blender/makesdna/DNA_userdef_types.h
index 3de6453bbaa..21abb632b94 100644
--- a/source/blender/makesdna/DNA_userdef_types.h
+++ b/source/blender/makesdna/DNA_userdef_types.h
@@ -650,7 +650,8 @@ typedef struct UserDef_Experimental {
   char use_override_templates;
   char enable_eevee_next;
   char use_sculpt_texture_paint;
-  char _pad0[2];
+  char use_draw_manager_acquire_lock;
+  char _pad0[1];
   /** `makesdna` does not allow empty structs. */
 } UserDef_Experimental;
 
diff --git a/source/blender/makesrna/intern/rna_userdef.c 
b/source/blender/makesrna/intern/rna_userdef.c
index 1a2017f2dbb..053353b41ba 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -6408,6 +6408,10 @@ static void rna_def_userdef_experimental(BlenderRNA 
*brna)
   RNA_def_property_boolean_sdna(prop, NULL, "use_sculpt_texture_paint", 1);
   RNA_def_property_ui_text(prop, "Sculpt Texture Paint", "Use texture painting 
in Sculpt Mode");
 
+  prop = RNA_def_property(srna, "use_draw_manager_acquire_lock", PROP_BOOLEAN, 
PROP_NONE);
+  RNA_def_property_boolean_sdna(prop, NULL, "use_draw_manager_acquire_lock", 
1);
+  RNA_def_property_ui_text(prop, "Draw Manager Locking", "Don't lock UI during 
background rendering");
+
   prop = RNA_def_property(srna, "use_extended_asset_browser", PROP_BOOLEAN, 
PROP_NONE);
   RNA_def_property_ui_text(prop,
"Extended Asset Browser",
diff --git a/source/blender/windowmanager/intern/wm_draw.c 
b/source/blender/windowmanager/intern/wm_draw.c
index 02da798495b..d2ade7b0376 100644
--- a/source/blender/windowmanager/intern/wm_draw.c
+++ b/source/blender/windowmanager/intern/wm_draw.c
@@ -467,7 +467,7 @@ static bool wm_draw_region_bind(bContext *C, ARegion 
*region, int view)
   }
 
   if (region->draw_buffer->viewport) {
-if (G.is_rendering && C != NULL) {
+if (G.is_rendering && C != NULL && 
U.experimental.use_draw_manager_acquire_lock) {
   Scene *scene = CTX_data_scene(C);
   RenderEngineType *render_engine_type = RE_engines_find(scene->r.engine);
   if (RE_engine_is_opengl(render_engine_type)) {

___
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] [7849b56c3c4] master: Fix T88570: Crash when saving after pressing ctrl+S twice.

2022-05-10 Thread Julian Eisel
Commit: 7849b56c3c41c00af1008652936bda5ea5e3e175
Author: Julian Eisel
Date:   Tue May 10 12:27:04 2022 +0200
Branches: master
https://developer.blender.org/rB7849b56c3c41c00af1008652936bda5ea5e3e175

Fix T88570: Crash when saving after pressing ctrl+S twice.

Existing code to replace the file operation was failing when done from
the window for the file operation itself.

Basically, this patch does two things:
- Implement a well defined window context to use as the "owner" or
  "root" of the File Browser. This will be used for managing the File
  Browser and to execute the file operation, even after the File Browser
  was closed.
- Ensure the context is valid when dealing with file File Browser event
  handlers.

Previously the window context just wasn't well defined and just happened
to work well enough in most cases. Addressing this may unveil further
issues, see T88570#1355740.

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

Reviewed by: Campbell Barton

===

M   source/blender/editors/include/ED_fileselect.h
M   source/blender/editors/space_file/filesel.c
M   source/blender/windowmanager/intern/wm_event_system.c

===

diff --git a/source/blender/editors/include/ED_fileselect.h 
b/source/blender/editors/include/ED_fileselect.h
index c367072e6e7..e9fcd2bd5fe 100644
--- a/source/blender/editors/include/ED_fileselect.h
+++ b/source/blender/editors/include/ED_fileselect.h
@@ -164,8 +164,16 @@ void ED_fileselect_window_params_get(const struct wmWindow 
*win,
  int win_size[2],
  bool *is_maximized);
 
+/**
+ * Return the File Browser area in which \a file_operator is active.
+ */
 struct ScrArea *ED_fileselect_handler_area_find(const struct wmWindow *win,
 const struct wmOperator 
*file_operator);
+/**
+ * Check if there is any area in \a win that acts as a modal File Browser 
(#SpaceFile.op is set)
+ * and return it.
+ */
+struct ScrArea *ED_fileselect_handler_area_find_any_with_op(const struct 
wmWindow *win);
 
 /* TODO: Maybe we should move this to BLI?
  * On the other hand, it's using defines from space-file area, so not sure... 
*/
diff --git a/source/blender/editors/space_file/filesel.c 
b/source/blender/editors/space_file/filesel.c
index 011506368ee..ce36e3e4e4f 100644
--- a/source/blender/editors/space_file/filesel.c
+++ b/source/blender/editors/space_file/filesel.c
@@ -1364,3 +1364,21 @@ ScrArea *ED_fileselect_handler_area_find(const wmWindow 
*win, const wmOperator *
 
   return NULL;
 }
+
+ScrArea *ED_fileselect_handler_area_find_any_with_op(const wmWindow *win)
+{
+  const bScreen *screen = WM_window_get_active_screen(win);
+
+  ED_screen_areas_iter (win, screen, area) {
+if (area->spacetype != SPACE_FILE) {
+  continue;
+}
+
+const SpaceFile *sfile = area->spacedata.first;
+if (sfile->op) {
+  return area;
+}
+  }
+
+  return NULL;
+}
diff --git a/source/blender/windowmanager/intern/wm_event_system.c 
b/source/blender/windowmanager/intern/wm_event_system.c
index 1c3f7ed3e7a..d375fb04744 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -1904,8 +1904,15 @@ void wm_event_free_handler(wmEventHandler *handler)
   MEM_freeN(handler);
 }
 
-/* Only set context when area/region is part of screen. */
-static void wm_handler_op_context(bContext *C, wmEventHandler_Op *handler, 
const wmEvent *event)
+/**
+ * Check if the handler's area and/or region are actually part of the screen, 
and return them if
+ * so.
+ */
+static void wm_handler_op_context_get_if_valid(bContext *C,
+   wmEventHandler_Op *handler,
+   const wmEvent *event,
+   ScrArea **r_area,
+   ARegion **r_region)
 {
   wmWindow *win = handler->context.win ? handler->context.win : 
CTX_wm_window(C);
   /* It's probably fine to always use #WM_window_get_active_screen() to get 
the screen. But this
@@ -1913,12 +1920,15 @@ static void wm_handler_op_context(bContext *C, 
wmEventHandler_Op *handler, const
* possible. */
   bScreen *screen = handler->context.win ? WM_window_get_active_screen(win) : 
CTX_wm_screen(C);
 
+  *r_area = NULL;
+  *r_region = NULL;
+
   if (screen == NULL || handler->op == NULL) {
 return;
   }
 
   if (handler->context.area == NULL) {
-CTX_wm_area_set(C, NULL);
+/* Pass */
   }
   else {
 ScrArea *area = NULL;
@@ -1942,7 +1952,7 @@ static void wm_handler_op_context(bContext *C, 
wmEventHandler_Op *handler, const
 else {
   ARegion *region;
   wmOperator *op = handler->op ? (handler->op->opm ? handler->op->opm : 
handler->op) : NULL;
-  

[Bf-blender-cvs] [ee63f909935] gpencil-new-data-proposal: Comment

2022-05-10 Thread Falk David
Commit: ee63f9099350c14813517008b653e932cfb20f5a
Author: Falk David
Date:   Mon May 9 19:55:13 2022 +0200
Branches: gpencil-new-data-proposal
https://developer.blender.org/rBee63f9099350c14813517008b653e932cfb20f5a

Comment

===

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

===

diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc 
b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
index 651cf51d076..0c3a5656b4a 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
@@ -306,6 +306,8 @@ class GPData : public ::GPData {
 return {(GPLayer *)this->layers_array, this->layers_size};
   }
 
+  /* TODO: Rework this API to take a string instead and create the layer in 
here. Similar to how we
+   * do it with frames. */
   int add_layer(GPLayer _layer)
   {
 /* Ensure that the layer array has enough space. */
@@ -328,7 +330,7 @@ class GPData : public ::GPData {
 
 GPFrame frame(frame_start);
 frame.layer_index = layer_index;
-this->frames_for_write().last() = std::move(frame);/* TODO: Check for 
collisions. */
+this->frames_for_write().last() = std::move(frame); /* TODO: Check for 
collisions. */
 
 /* Sort frame array. */
 update_frames_array();

___
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] [c19b6642887] gpencil-new-data-proposal: Add functionality to iterate over frames in a specific layer

2022-05-10 Thread Falk David
Commit: c19b66428878a8adc89e2c8484b6b9743e32bbbc
Author: Falk David
Date:   Fri May 6 11:57:47 2022 +0200
Branches: gpencil-new-data-proposal
https://developer.blender.org/rBc19b66428878a8adc89e2c8484b6b9743e32bbbc

Add functionality to iterate over frames in a specific layer

===

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

===

diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal.hh 
b/source/blender/blenkernel/intern/gpencil_new_proposal.hh
index 680975ea671..27f3a0ae191 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal.hh
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal.hh
@@ -87,7 +87,7 @@ typedef struct GPFrame {
 
 typedef struct GPData {
   /**
-   * The array of grease pencil frames. This is kept in cronological order 
(tiebreaks for two
+   * The array of grease pencil frames. This is kept in chronological order 
(tiebreaks for two
* frames on different layers are resloved by the order of the layers).
*/
   GPFrame *frames_array;
diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc 
b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
index ce4f26378f4..37001ec1141 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
@@ -7,6 +7,8 @@
 #include 
 
 #include "BKE_curves.hh"
+
+#include "BLI_index_mask_ops.hh"
 #include "BLI_math_vec_types.hh"
 
 #include "gpencil_new_proposal.hh"
@@ -156,6 +158,22 @@ class GPData : public ::GPData {
 return {(GPFrame *)this->frames_array, this->frames_size};
   }
 
+  IndexMask frames_on_layer(int layer_index) const
+  {
+Vector indices;
+return index_mask_ops::find_indices_based_on_predicate(
+IndexMask(this->frames_size), 1024, indices, [&](const int index) {
+  return this->frames()[index].layer_index == layer_index;
+});
+  }
+
+  IndexMask frames_on_layer(GPLayer ) const
+  {
+int layer_index = this->layers().first_index_try(gpl);
+BLI_assert(layer_index != -1);
+return frames_on_layer(layer_index);
+  }
+
   Span layers() const
   {
 return {(const GPLayer *)this->layers_array, this->layers_size};
@@ -405,4 +423,34 @@ TEST(gpencil_proposal, CheckFramesSorted2)
   }
 }
 
+TEST(gpencil_proposal, IterateOverFramesOnLayer)
+{
+  GPData my_data;
+  GPLayer my_layer1("TestLayer1");
+  GPLayer my_layer2("TestLayer2");
+
+  const int frame_numbers_layer1[5] = {10, 5, 6, 1, 3};
+  const int frame_numbers_layer2[5] = {8, 5, 7, 1, 4};
+
+  const int frame_numbers_sorted1[5] = {1, 3, 5, 6, 10};
+  const int frame_numbers_sorted2[5] = {1, 4, 5, 7, 8};
+
+  my_data.add_layer(my_layer1);
+  my_data.add_layer(my_layer2);
+  for (int i : IndexRange(5)) {
+my_data.create_new_frame_on_layer(my_layer1, frame_numbers_layer1[i]);
+my_data.create_new_frame_on_layer(my_layer2, frame_numbers_layer2[i]);
+  }
+
+  IndexMask indices_frames_layer1 = my_data.frames_on_layer(my_layer1);
+  for (const int i : indices_frames_layer1.index_range()) {
+EXPECT_EQ(my_data.frames()[indices_frames_layer1[i]].start, 
frame_numbers_sorted1[i]);
+  }
+
+  IndexMask indices_frames_layer2 = my_data.frames_on_layer(my_layer2);
+  for (const int i : indices_frames_layer2.index_range()) {
+EXPECT_EQ(my_data.frames()[indices_frames_layer2[i]].start, 
frame_numbers_sorted2[i]);
+  }
+}
+
 }  // namespace blender::bke::gpencil::tests
\ No newline at end of file

___
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] [66a8dd87865] gpencil-new-data-proposal: Add function to set active layer

2022-05-10 Thread Falk David
Commit: 66a8dd87865be8e172bf8213b06647ae87f28016
Author: Falk David
Date:   Tue May 10 11:45:34 2022 +0200
Branches: gpencil-new-data-proposal
https://developer.blender.org/rB66a8dd87865be8e172bf8213b06647ae87f28016

Add function to set active layer

===

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

===

diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc 
b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
index 6ca3f0db51c..13ea1252fb7 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
@@ -372,6 +372,14 @@ class GPData : public ::GPData {
 return count;
   }
 
+  void set_active_layer(int layer_index)
+  {
+if (layer_index < 0 || layer_index >= this->layers_size) {
+  return;
+}
+this->active_layer_index = layer_index;
+  }
+
  private:
   const bool ensure_layers_array_has_size_at_least(int64_t 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] [ea43a2873e0] gpencil-new-data-proposal: Small refactor

2022-05-10 Thread Falk David
Commit: ea43a2873e03832646f5bd27f8151139703081f3
Author: Falk David
Date:   Tue May 10 11:45:22 2022 +0200
Branches: gpencil-new-data-proposal
https://developer.blender.org/rBea43a2873e03832646f5bd27f8151139703081f3

Small refactor

===

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

===

diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc 
b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
index 0c3a5656b4a..6ca3f0db51c 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
@@ -51,6 +51,10 @@ class GPDataRuntime {
   }
 };
 
+/**
+ * A wrapper class around a single curve in GPFrame.strokes (CurvesGeometry). 
It holds the offset
+ * of where to find the stroke in the frame and it's size.
+ */
 class GPStroke {
  public:
   GPStroke(int num_points, int offset_index)
@@ -63,6 +67,11 @@ class GPStroke {
 return num_points_;
   }
 
+  int point_offset() const
+  {
+return offset_index_;
+  }
+
  private:
   int num_points_;
   int offset_index_;
@@ -311,7 +320,7 @@ class GPData : public ::GPData {
   int add_layer(GPLayer _layer)
   {
 /* Ensure that the layer array has enough space. */
-if (!ensure_layer_array_has_size_at_least(this->layers_size + 1)) {
+if (!ensure_layers_array_has_size_at_least(this->layers_size + 1)) {
   return -1;
 }
 
@@ -324,7 +333,7 @@ class GPData : public ::GPData {
   {
 /* TODO: Check for collisions. */
 
-if (!ensure_frame_array_has_size_at_least(this->frames_size + 1)) {
+if (!ensure_frames_array_has_size_at_least(this->frames_size + 1)) {
   return nullptr;
 }
 
@@ -364,7 +373,7 @@ class GPData : public ::GPData {
   }
 
  private:
-  const bool ensure_layer_array_has_size_at_least(int64_t size)
+  const bool ensure_layers_array_has_size_at_least(int64_t size)
   {
 if (this->layers_size > size) {
   return true;
@@ -380,6 +389,7 @@ class GPData : public ::GPData {
 }
 
 if (this->layers_array != nullptr) {
+  /* Since the layers have default move constructors, we just use memcpy 
here. */
   memcpy(new_array, this->layers_array, old_size * sizeof(::GPLayer));
   MEM_SAFE_FREE(this->layers_array);
 }
@@ -388,7 +398,7 @@ class GPData : public ::GPData {
 return true;
   }
 
-  const bool ensure_frame_array_has_size_at_least(int64_t size)
+  const bool ensure_frames_array_has_size_at_least(int64_t size)
   {
 if (this->frames_size > size) {
   return 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] [c22d04fe2fc] gpencil-new-data-proposal: Rework gp frame api

2022-05-10 Thread Falk David
Commit: c22d04fe2fcb14401011cd9fcdae5f18d432a0b6
Author: Falk David
Date:   Mon May 9 19:53:54 2022 +0200
Branches: gpencil-new-data-proposal
https://developer.blender.org/rBc22d04fe2fcb14401011cd9fcdae5f18d432a0b6

Rework gp frame api

===

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

===

diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc 
b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
index 810decdb856..651cf51d076 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
@@ -5,6 +5,7 @@
  */
 
 #include 
+#include 
 
 #include "BKE_curves.hh"
 
@@ -73,26 +74,23 @@ class GPFrame : public ::GPFrame {
   {
   }
 
-  GPFrame(int layer_index) : GPFrame(layer_index, -1)
+  GPFrame(int start_frame) : GPFrame(start_frame, -1)
   {
   }
 
-  GPFrame(int layer_index, int start_frame)
+  GPFrame(int start_frame, int end_frame)
   {
-this->layer_index = layer_index;
 this->start = start_frame;
-
-/* Unused for now. */
-this->end = -1;
-
-this->strokes = MEM_new(__func__);
+this->end = end_frame;
+this->strokes = nullptr;
   }
 
-  GPFrame(const GPFrame ) : GPFrame(other.layer_index, other.start)
+  GPFrame(const GPFrame ) : GPFrame(other.start, other.end)
   {
 if (other.strokes != nullptr) {
   this->strokes_as_curves() = CurvesGeometry::wrap(*other.strokes);
 }
+this->layer_index = other.layer_index;
   }
 
   GPFrame =(const GPFrame )
@@ -102,14 +100,16 @@ class GPFrame : public ::GPFrame {
 }
 this->layer_index = other.layer_index;
 this->start = other.start;
+this->end = other.end;
 return *this;
   }
 
-  GPFrame(GPFrame &) : GPFrame(other.layer_index, other.start)
+  GPFrame(GPFrame &) : GPFrame(other.start, other.end)
   {
 if (this != ) {
   std::swap(this->strokes, other.strokes);
 }
+this->layer_index = other.layer_index;
   }
 
   GPFrame =(GPFrame &)
@@ -119,6 +119,7 @@ class GPFrame : public ::GPFrame {
 }
 this->layer_index = other.layer_index;
 this->start = other.start;
+this->end = other.end;
 return *this;
   }
 
@@ -157,11 +158,17 @@ class GPFrame : public ::GPFrame {
 
   int strokes_num() const
   {
+if (this->strokes == nullptr) {
+  return 0;
+}
 return this->strokes->curve_size;
   }
 
   GPStroke add_new_stroke(int num_points)
   {
+if (this->strokes == nullptr) {
+  this->strokes = MEM_new(__func__);
+}
 CurvesGeometry  = this->strokes_as_curves();
 strokes.resize(strokes.points_num() + num_points, strokes.curves_num() + 
1);
 return {num_points, strokes.offsets().last()};
@@ -256,7 +263,7 @@ class GPData : public ::GPData {
   IndexMask frames_on_layer(int layer_index) const
   {
 if (layer_index < 0 || layer_index > this->layers_size) {
-  return {};
+  return IndexMask();
 }
 
 /* If the indices are cached for this layer, use the cache. */
@@ -275,6 +282,15 @@ class GPData : public ::GPData {
 return mask;
   }
 
+  IndexMask frames_on_layer(GPLayer ) const
+  {
+int index = this->layers().first_index_try(layer);
+if (index == -1) {
+  return IndexMask();
+}
+return frames_on_layer(index);
+  }
+
   IndexMask frames_on_active_layer() const
   {
 return frames_on_layer(this->active_layer_index);
@@ -290,7 +306,7 @@ class GPData : public ::GPData {
 return {(GPLayer *)this->layers_array, this->layers_size};
   }
 
-  const int add_layer(GPLayer _layer)
+  int add_layer(GPLayer _layer)
   {
 /* Ensure that the layer array has enough space. */
 if (!ensure_layer_array_has_size_at_least(this->layers_size + 1)) {
@@ -298,61 +314,51 @@ class GPData : public ::GPData {
 }
 
 /* Move new_layer to the end in the array. */
-this->layers_for_write().last() = new_layer;
+this->layers_for_write().last() = std::move(new_layer);
 return this->layers_size - 1;
   }
 
-  int frame_index_at(const int layer_idx, const int start_frame_number)
+  GPFrame *add_frame_on_layer(int layer_index, int frame_start)
   {
+/* TODO: Check for collisions. */
+
+if (!ensure_frame_array_has_size_at_least(this->frames_size + 1)) {
+  return nullptr;
+}
+
+GPFrame frame(frame_start);
+frame.layer_index = layer_index;
+this->frames_for_write().last() = std::move(frame);/* TODO: Check for 
collisions. */
+
+/* Sort frame array. */
+update_frames_array();
+
 auto it = std::lower_bound(this->frames().begin(),
this->frames().end(),
-   std::pair(layer_idx, 
start_frame_number));
-if (it == this->frames().end() || it->start != start_frame_number) {
-  return -1;
+   std::pair(layer_index, frame.start));

[Bf-blender-cvs] [d66cb83c935] gpencil-new-data-proposal: Refactor GPFrame to use pointer to CurvesGeometry

2022-05-10 Thread Falk David
Commit: d66cb83c9354b795d7782c95eeb3b5f78951a4c5
Author: Falk David
Date:   Mon May 9 16:37:28 2022 +0200
Branches: gpencil-new-data-proposal
https://developer.blender.org/rBd66cb83c9354b795d7782c95eeb3b5f78951a4c5

Refactor GPFrame to use pointer to CurvesGeometry

===

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

===

diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal.hh 
b/source/blender/blenkernel/intern/gpencil_new_proposal.hh
index 27f3a0ae191..a649b2e078b 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal.hh
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal.hh
@@ -64,7 +64,7 @@ typedef struct GPFrame {
* The curves in this frame. Each individual curve is a single stroke. The 
CurvesGeometry
* structure also stores attributes on the strokes and points.
*/
-  CurvesGeometry strokes;
+  CurvesGeometry *strokes;
 
   /**
* The frame flag.
diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc 
b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
index 37001ec1141..810decdb856 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
@@ -37,49 +37,96 @@ class GPLayerGroup : ::GPLayerGroup {
 
 class GPDataRuntime {
  public:
-  /* mutable void *sbuffer */;
-};
+  /* mutable void *sbuffer */
 
-class GPLayer : public ::GPLayer {
- public:
-  GPLayer() : GPLayer("GP_Layer")
-  {
-  }
+  /**
+   * Cache that maps the index of a layer to the index mask of the frames in 
that layer.
+   */
+  mutable Map> cached_frame_index_masks;
 
-  GPLayer(const StringRefNull name)
+  IndexMask get_cached_frame_index_mask(int layer_index)
   {
-strcpy(this->name, name.c_str());
+return cached_frame_index_masks.lookup(layer_index).as_span();
   }
+};
 
-  ~GPLayer() = default;
+class GPStroke {
+ public:
+  GPStroke(int num_points, int offset_index)
+  : num_points_(num_points), offset_index_(offset_index){};
 
-  bool operator==(const GPLayer ) const
+  ~GPStroke() = default;
+
+  int points_num() const
   {
-return STREQ(this->name, other.name);
+return num_points_;
   }
+
+ private:
+  int num_points_;
+  int offset_index_;
 };
 
 class GPFrame : public ::GPFrame {
  public:
-  GPFrame()
+  GPFrame() : GPFrame(-1, -1)
   {
-this->layer_index = this->start = this->end = -1;
   }
 
-  GPFrame(int layer_index)
+  GPFrame(int layer_index) : GPFrame(layer_index, -1)
   {
-this->layer_index = layer_index;
-this->start = this->end = -1;
   }
 
   GPFrame(int layer_index, int start_frame)
   {
 this->layer_index = layer_index;
 this->start = start_frame;
+
+/* Unused for now. */
 this->end = -1;
+
+this->strokes = MEM_new(__func__);
+  }
+
+  GPFrame(const GPFrame ) : GPFrame(other.layer_index, other.start)
+  {
+if (other.strokes != nullptr) {
+  this->strokes_as_curves() = CurvesGeometry::wrap(*other.strokes);
+}
+  }
+
+  GPFrame =(const GPFrame )
+  {
+if (this !=  && other.strokes != nullptr) {
+  this->strokes_as_curves() = CurvesGeometry::wrap(*other.strokes);
+}
+this->layer_index = other.layer_index;
+this->start = other.start;
+return *this;
+  }
+
+  GPFrame(GPFrame &) : GPFrame(other.layer_index, other.start)
+  {
+if (this != ) {
+  std::swap(this->strokes, other.strokes);
+}
   }
 
-  ~GPFrame() = default;
+  GPFrame =(GPFrame &)
+  {
+if (this != ) {
+  std::swap(this->strokes, other.strokes);
+}
+this->layer_index = other.layer_index;
+this->start = other.start;
+return *this;
+  }
+
+  ~GPFrame()
+  {
+MEM_delete(reinterpret_cast(this->strokes));
+this->strokes = nullptr;
+  }
 
   bool operator<(const GPFrame ) const
   {
@@ -89,10 +136,55 @@ class GPFrame : public ::GPFrame {
 return this->start < other.start;
   }
 
+  /* Assumes that elem.first is the layer index and elem.second is the frame 
start. */
+  bool operator<(const std::pair elem) const
+  {
+if (this->start == elem.second) {
+  return this->layer_index < elem.first;
+}
+return this->start < elem.second;
+  }
+
   bool operator==(const GPFrame ) const
   {
 return this->layer_index == other.layer_index && this->start == 
other.start;
   }
+
+  CurvesGeometry _as_curves()
+  {
+return CurvesGeometry::wrap(*this->strokes);
+  }
+
+  int strokes_num() const
+  {
+return this->strokes->curve_size;
+  }
+
+  GPStroke add_new_stroke(int num_points)
+  {
+CurvesGeometry  = this->strokes_as_curves();
+strokes.resize(strokes.points_num() + num_points, strokes.curves_num() + 
1);
+return {num_points, strokes.offsets().last()};
+  }
+};
+
+class GPLayer : public ::GPLayer {
+ public:
+  GPLayer() : 

[Bf-blender-cvs] [2ea0d65b1d4] gpencil-new-data-proposal: Merge branch 'master' into gpencil-new-data-proposal

2022-05-10 Thread Falk David
Commit: 2ea0d65b1d47c4adce5283e2ee4f939d56458878
Author: Falk David
Date:   Tue May 10 11:47:50 2022 +0200
Branches: gpencil-new-data-proposal
https://developer.blender.org/rB2ea0d65b1d47c4adce5283e2ee4f939d56458878

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] [5788f6cc37a] gpencil-new-data-proposal: Implement adding frames to layers, add comments

2022-05-10 Thread Falk David
Commit: 5788f6cc37a9277032ae919741652784ee11018d
Author: Falk David
Date:   Thu May 5 11:07:17 2022 +0200
Branches: gpencil-new-data-proposal
https://developer.blender.org/rB5788f6cc37a9277032ae919741652784ee11018d

Implement adding frames to layers, add comments

===

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

===

diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal.hh 
b/source/blender/blenkernel/intern/gpencil_new_proposal.hh
index 5fc3fa4e870..680975ea671 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal.hh
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal.hh
@@ -24,30 +24,61 @@ typedef struct GPDataRuntimeHandle GPDataRuntimeHandle;
 #endif
 
 typedef struct GPLayerGroup {
+  /**
+   * An array of GPLayerGroup's. A layer group can have N >= 0 number of layer 
group children.
+   */
   struct GPLayerGroup *children;
   int children_size;
 
+  /**
+   * An array of indices to the layers in GPData.layers_array. These are the 
layers contained in
+   * the group.
+   */
   int *layer_indices;
   int layer_indices_size;
 
+  /**
+   * The name of the layer group.
+   */
   char name[128];
 
   /* ... */
 } GPLayerGroup;
 
 typedef struct GPLayer {
+  /**
+   * The name of the layer.
+   */
   char name[128];
 
+  /**
+   * The layer flag.
+   */
   int flag;
 
   /* ... */
 } GPLayer;
 
 typedef struct GPFrame {
+  /**
+   * The curves in this frame. Each individual curve is a single stroke. The 
CurvesGeometry
+   * structure also stores attributes on the strokes and points.
+   */
   CurvesGeometry strokes;
 
+  /**
+   * The frame flag.
+   */
   int flag;
 
+  /**
+   * The index of the layer in GPData.layers_array that this frame is in.
+   */
+  int layer_index;
+
+  /**
+   * The start and end frame in the scene that the grease pencil frame is 
displayed.
+   */
   int start;
   int end;
 
@@ -55,21 +86,41 @@ typedef struct GPFrame {
 } GPFrame;
 
 typedef struct GPData {
+  /**
+   * The array of grease pencil frames. This is kept in cronological order 
(tiebreaks for two
+   * frames on different layers are resloved by the order of the layers).
+   */
   GPFrame *frames_array;
   int frames_size;
+
+  /**
+   * All attributes stored on the frames.
+   */
   CustomData frame_data;
-  int active_frame_index;
 
+  /**
+   * The array of grease pencil layers.
+   */
   GPLayer *layers_array;
   int layers_size;
+
+  /**
+   * The index of the active layer in the GPData.layers_array.
+   */
   int active_layer_index;
 
+  /**
+   * The root layer group. This must not be nullptr.
+   */
   GPLayerGroup *default_group;
 
+  /**
+   * The runtime data.
+   */
   GPDataRuntimeHandle *runtime;
 } GPData;
 
-/* This is the ID_GP structure that holds all the */
+/* This is the ID_GP structure that holds all the information at the object 
data level. */
 typedef struct GreasePencil {
   ID id;
   /* Animation data (must be immediately after id). */
@@ -78,6 +129,7 @@ typedef struct GreasePencil {
   /* Pointer to the actual data-block containing the frames, layers and layer 
groups. */
   GPData *grease_pencil_data;
 
+  /* GreasePencil flag. */
   int flag;
 
   /** Materials array. */
diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc 
b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
index 93d5ae0541a..06cffb3e959 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
@@ -15,6 +15,7 @@ class GPLayerGroup : ::GPLayerGroup {
  public:
   GPLayerGroup()
   {
+/* TODO */
   }
 
   ~GPLayerGroup()
@@ -31,7 +32,7 @@ class GPLayerGroup : ::GPLayerGroup {
 
 class GPDataRuntime {
  public:
-  mutable void *sbuffer;
+  /* mutable void *sbuffer */;
 };
 
 class GPLayer : public ::GPLayer {
@@ -46,6 +47,27 @@ class GPLayer : public ::GPLayer {
   }
 
   ~GPLayer() = default;
+
+  bool operator==(const GPLayer ) const
+  {
+return STREQ(this->name, other.name);
+  }
+};
+
+class GPFrame : public ::GPFrame {
+ public:
+  GPFrame()
+  {
+this->layer_index = this->start = this->end = -1;
+  }
+
+  GPFrame(int layer_index)
+  {
+this->layer_index = layer_index;
+this->start = this->end = -1;
+  }
+
+  ~GPFrame() = default;
 };
 
 class GPData : public ::GPData {
@@ -65,11 +87,9 @@ class GPData : public ::GPData {
 if (this->frames_size > 0) {
   this->frames_array = reinterpret_cast<::GPFrame *>(
   MEM_calloc_arrayN(this->frames_size, sizeof(::GPFrame), __func__));
-  this->active_frame_index = 0;
 }
 else {
   this->frames_array = nullptr;
-  this->active_frame_index = -1;
 }
 CustomData_reset(>frame_data);
 
@@ -103,6 +123,16 @@ class GPData : public ::GPData {
 

[Bf-blender-cvs] [01ca56b9a32] gpencil-new-data-proposal: First working tests regarding GPData and GPLayers

2022-05-10 Thread Falk David
Commit: 01ca56b9a323c923b0d2a59ab07f0b0241ac9a90
Author: Falk David
Date:   Wed May 4 16:23:02 2022 +0200
Branches: gpencil-new-data-proposal
https://developer.blender.org/rB01ca56b9a323c923b0d2a59ab07f0b0241ac9a90

First working tests regarding GPData and GPLayers

===

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

===

diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal.hh 
b/source/blender/blenkernel/intern/gpencil_new_proposal.hh
index 5db38608f6e..5fc3fa4e870 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal.hh
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal.hh
@@ -14,18 +14,11 @@
 extern "C" {
 #endif
 
-/* Note: This should be in a file like BKE_gpencil.hh */
-namespace blender::bke::gpencil {
-class GPDataRuntime {
- public:
-  /* Runtime Data */
-  /* void *stroke_painting_buffer; */
-};
-}  // namespace blender::bke::gpencil
-
 #ifdef __cplusplus
+namespace blender::bke {
 class GPDataRuntime;
-using GPDataRuntimeHandle = blender::bke::gpencil::GPDataRuntime;
+}  // namespace blender::bke
+using GPDataRuntimeHandle = blender::bke::GPDataRuntime;
 #else
 typedef struct GPDataRuntimeHandle GPDataRuntimeHandle;
 #endif
@@ -62,12 +55,12 @@ typedef struct GPFrame {
 } GPFrame;
 
 typedef struct GPData {
-  GPFrame *frames;
+  GPFrame *frames_array;
   int frames_size;
   CustomData frame_data;
   int active_frame_index;
 
-  GPLayer *layers;
+  GPLayer *layers_array;
   int layers_size;
   int active_layer_index;
 
diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc 
b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
index 94a25a6e2b8..93d5ae0541a 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
@@ -9,125 +9,225 @@
 #include "gpencil_new_proposal.hh"
 #include "testing/testing.h"
 
-template class GPVector {
- private:
-  /**
-   * Address of the pointer to the begining of the vector.
-   */
-  T **start_;
-
-  /**
-   * Address of the size of the vector.
-   */
-  int *size_;
+namespace blender::bke {
 
+class GPLayerGroup : ::GPLayerGroup {
  public:
-  GPVector(T **start, int *size) {
-this->start_ = start;
-this->size_ = size;
+  GPLayerGroup()
+  {
   }
 
-  int size() {
-return size_;
+  ~GPLayerGroup()
+  {
+/* Recursivly free the children of this layer group first. */
+for (int i = 0; i < this->children_size; i++) {
+  MEM_delete(>children[i]);
+}
+/* Then free its data. */
+MEM_SAFE_FREE(this->children);
+MEM_SAFE_FREE(this->layer_indices);
   }
+};
 
-  T *data()
+class GPDataRuntime {
+ public:
+  mutable void *sbuffer;
+};
+
+class GPLayer : public ::GPLayer {
+ public:
+  GPLayer() : GPLayer("GP_Layer")
   {
-return *start_;
   }
 
-  void append(T ) {
-
+  GPLayer(const StringRefNull name)
+  {
+strcpy(this->name, name.c_str());
   }
- 
- private:
-  void realloc(const int64_t size)
+
+  ~GPLayer() = default;
+};
+
+class GPData : public ::GPData {
+ public:
+  GPData() : GPData(0, 0)
   {
-/* Overwrite the size. */
-*this->size_ = size;
-/* Reallocate the array and overwrite the pointer to the beginning of the 
array. */
-*this->start_ = static_cast(MEM_reallocN(*this->start_, size * 
sizeof(T)));
   }
 
-}
+  GPData(const int layers_size, const int frame_size)
+  {
+BLI_assert(layers_size >= 0);
+BLI_assert(frame_size >= 0);
 
-namespace blender::bke
-{
+this->frames_size = frame_size;
+this->layers_size = layers_size;
 
-  class GPLayerGroup : ::GPLayerGroup {
-   public:
-GPLayerGroup()
-{
+if (this->frames_size > 0) {
+  this->frames_array = reinterpret_cast<::GPFrame *>(
+  MEM_calloc_arrayN(this->frames_size, sizeof(::GPFrame), __func__));
+  this->active_frame_index = 0;
 }
-
-~GPLayerGroup()
-{
-  /* Recursivly free the children of this layer group first. */
-  for (int i = 0; i < this->children_size; i++) {
-MEM_delete(>children[i]);
-  }
-  /* Then free its data. */
-  MEM_SAFE_FREE(this->children);
-  MEM_SAFE_FREE(this->layer_indices);
+else {
+  this->frames_array = nullptr;
+  this->active_frame_index = -1;
 }
-  };
+CustomData_reset(>frame_data);
 
-  class GPData : ::GPData {
-   public:
-GPData()
-{
+if (this->layers_size > 0) {
+  this->layers_array = reinterpret_cast<::GPLayer *>(
+  MEM_calloc_arrayN(this->layers_size, sizeof(::GPLayer), __func__));
+  this->active_layer_index = 0;
+}
+else {
+  this->layers_array = nullptr;
+  this->active_layer_index = -1;
 }
 
-GPData(int layers_size)
-{
-  BLI_assert(layers_size > 0);
+this->default_group = 

[Bf-blender-cvs] [9039306a991] gpencil-new-data-proposal: Frame sorting

2022-05-10 Thread Falk David
Commit: 9039306a9912bc986ca0cf9d09355db24d569ac9
Author: Falk David
Date:   Thu May 5 18:03:09 2022 +0200
Branches: gpencil-new-data-proposal
https://developer.blender.org/rB9039306a9912bc986ca0cf9d09355db24d569ac9

Frame sorting

===

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

===

diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc 
b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
index 06cffb3e959..ce4f26378f4 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
@@ -3,6 +3,9 @@
 /** \file
  * \ingroup bke
  */
+
+#include 
+
 #include "BKE_curves.hh"
 #include "BLI_math_vec_types.hh"
 
@@ -67,7 +70,27 @@ class GPFrame : public ::GPFrame {
 this->start = this->end = -1;
   }
 
+  GPFrame(int layer_index, int start_frame)
+  {
+this->layer_index = layer_index;
+this->start = start_frame;
+this->end = -1;
+  }
+
   ~GPFrame() = default;
+
+  bool operator<(const GPFrame ) const
+  {
+if (this->start == other.start) {
+  return this->layer_index < other.layer_index;
+}
+return this->start < other.start;
+  }
+
+  bool operator==(const GPFrame ) const
+  {
+return this->layer_index == other.layer_index && this->start == 
other.start;
+  }
 };
 
 class GPData : public ::GPData {
@@ -155,22 +178,57 @@ class GPData : public ::GPData {
 return true;
   }
 
-  const GPFrame _frame_on_layer(const int layer_index)
+  /**
+   * Find a GPFrame in the frame_array given by the layer index and the frame 
number in logarithmic
+   * time. If the frame is found, returns a pointer/iterator to it, otherwise 
nullptr.
+   *
+   * Note: This assumes that the array is sorted.
+   */
+  const GPFrame *frame_at(const int layer_idx, const int start_frame_number)
   {
-BLI_assert(layer_index >= 0 && layer_index < this->layers_size);
+auto it = std::lower_bound(
+this->frames().begin(), this->frames().end(), GPFrame(layer_idx, 
start_frame_number));
+if (it == this->frames().end() || it->start != start_frame_number) {
+  return nullptr;
+}
+return it;
+  }
 
-GPFrame new_frame(layer_index);
+  void create_new_frame_on_layer(const int layer_index, const int 
start_frame_number)
+  {
+BLI_assert(layer_index >= 0 && layer_index < this->layers_size);
+/* Allocate new space for the frame. */
 ensure_frame_array_has_size_at_least(this->frames_size + 1);
+
+/* Create a new frame and append it at the end. */
+GPFrame new_frame(layer_index, start_frame_number);
 this->frames_for_write().last() = new_frame;
 
-return this->frames().last();
+/* Sort the frame array. */
+update_frames_array();
+  }
+
+  void create_new_frame_on_layer(GPLayer , const int start_frame_number)
+  {
+int index = this->layers().first_index_try(layer);
+BLI_assert(index != -1);
+create_new_frame_on_layer(index, start_frame_number);
+  }
+
+  const GPFrame _new_frame_on_layer(const int layer_index, const int 
start_frame_number)
+  {
+create_new_frame_on_layer(layer_index, start_frame_number);
+/* Find the frame in the array and return it. */
+const GPFrame *gpf = this->frame_at(layer_index, start_frame_number);
+BLI_assert(gpf != nullptr);
+return *gpf;
   }
 
-  const GPFrame _frame_on_layer(GPLayer )
+  const GPFrame _new_frame_on_layer(GPLayer , const int 
start_frame_number)
   {
 int index = this->layers().first_index_try(layer);
 BLI_assert(index != -1);
-return new_frame_on_layer(index);
+return get_new_frame_on_layer(index, start_frame_number);
   }
 
  private:
@@ -217,6 +275,12 @@ class GPData : public ::GPData {
 
 return true;
   }
+
+  void update_frames_array()
+  {
+/* Make sure frames are ordered chronologically and by layer order. */
+std::sort(this->frames_for_write().begin(), 
this->frames_for_write().end());
+  }
 };
 
 }  // namespace blender::bke
@@ -294,8 +358,51 @@ TEST(gpencil_proposal, AddFrameToLayer)
 
   my_data.add_layer(my_layer1);
   my_data.add_layer(my_layer2);
-  GPFrame my_frame = my_data.new_frame_on_layer(my_layer2);
+  GPFrame my_frame = my_data.get_new_frame_on_layer(my_layer2, 0);
   EXPECT_EQ(my_frame.layer_index, 1);
 }
 
+TEST(gpencil_proposal, CheckFramesSorted1)
+{
+  GPData my_data;
+  GPLayer my_layer1("TestLayer1");
+
+  const int frame_numbers1[5] = {10, 5, 6, 1, 3};
+  const int frame_numbers_sorted1[5] = {1, 3, 5, 6, 10};
+
+  my_data.add_layer(my_layer1);
+  for (int i : IndexRange(5)) {
+GPFrame my_frame = my_data.get_new_frame_on_layer(my_layer1, 
frame_numbers1[i]);
+int idx = my_data.frames().first_index(my_frame);
+EXPECT_EQ(my_data.frames()[idx].start, frame_numbers1[i]);
+  }
+
+  for (const int i : my_data.frames().index_range()) {
+

[Bf-blender-cvs] [96b9dc973ff] gpencil-new-data-proposal: Implement adding frames to layers, add comments

2022-05-10 Thread Falk David
Commit: 96b9dc973ffef744b0c5fb18e899bb170ad3206f
Author: Falk David
Date:   Thu May 5 11:07:17 2022 +0200
Branches: gpencil-new-data-proposal
https://developer.blender.org/rB96b9dc973ffef744b0c5fb18e899bb170ad3206f

Implement adding frames to layers, add comments

===

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

===

diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal.hh 
b/source/blender/blenkernel/intern/gpencil_new_proposal.hh
index 5fc3fa4e870..680975ea671 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal.hh
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal.hh
@@ -24,30 +24,61 @@ typedef struct GPDataRuntimeHandle GPDataRuntimeHandle;
 #endif
 
 typedef struct GPLayerGroup {
+  /**
+   * An array of GPLayerGroup's. A layer group can have N >= 0 number of layer 
group children.
+   */
   struct GPLayerGroup *children;
   int children_size;
 
+  /**
+   * An array of indices to the layers in GPData.layers_array. These are the 
layers contained in
+   * the group.
+   */
   int *layer_indices;
   int layer_indices_size;
 
+  /**
+   * The name of the layer group.
+   */
   char name[128];
 
   /* ... */
 } GPLayerGroup;
 
 typedef struct GPLayer {
+  /**
+   * The name of the layer.
+   */
   char name[128];
 
+  /**
+   * The layer flag.
+   */
   int flag;
 
   /* ... */
 } GPLayer;
 
 typedef struct GPFrame {
+  /**
+   * The curves in this frame. Each individual curve is a single stroke. The 
CurvesGeometry
+   * structure also stores attributes on the strokes and points.
+   */
   CurvesGeometry strokes;
 
+  /**
+   * The frame flag.
+   */
   int flag;
 
+  /**
+   * The index of the layer in GPData.layers_array that this frame is in.
+   */
+  int layer_index;
+
+  /**
+   * The start and end frame in the scene that the grease pencil frame is 
displayed.
+   */
   int start;
   int end;
 
@@ -55,21 +86,41 @@ typedef struct GPFrame {
 } GPFrame;
 
 typedef struct GPData {
+  /**
+   * The array of grease pencil frames. This is kept in cronological order 
(tiebreaks for two
+   * frames on different layers are resloved by the order of the layers).
+   */
   GPFrame *frames_array;
   int frames_size;
+
+  /**
+   * All attributes stored on the frames.
+   */
   CustomData frame_data;
-  int active_frame_index;
 
+  /**
+   * The array of grease pencil layers.
+   */
   GPLayer *layers_array;
   int layers_size;
+
+  /**
+   * The index of the active layer in the GPData.layers_array.
+   */
   int active_layer_index;
 
+  /**
+   * The root layer group. This must not be nullptr.
+   */
   GPLayerGroup *default_group;
 
+  /**
+   * The runtime data.
+   */
   GPDataRuntimeHandle *runtime;
 } GPData;
 
-/* This is the ID_GP structure that holds all the */
+/* This is the ID_GP structure that holds all the information at the object 
data level. */
 typedef struct GreasePencil {
   ID id;
   /* Animation data (must be immediately after id). */
@@ -78,6 +129,7 @@ typedef struct GreasePencil {
   /* Pointer to the actual data-block containing the frames, layers and layer 
groups. */
   GPData *grease_pencil_data;
 
+  /* GreasePencil flag. */
   int flag;
 
   /** Materials array. */
diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc 
b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
index 93d5ae0541a..e6a3bc9064e 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
@@ -15,6 +15,7 @@ class GPLayerGroup : ::GPLayerGroup {
  public:
   GPLayerGroup()
   {
+/* TODO */
   }
 
   ~GPLayerGroup()
@@ -31,7 +32,7 @@ class GPLayerGroup : ::GPLayerGroup {
 
 class GPDataRuntime {
  public:
-  mutable void *sbuffer;
+  /* mutable void *sbuffer */;
 };
 
 class GPLayer : public ::GPLayer {
@@ -46,6 +47,27 @@ class GPLayer : public ::GPLayer {
   }
 
   ~GPLayer() = default;
+
+  bool operator==(const GPLayer ) const
+  {
+return STREQ(this->name, other.name);
+  }
+};
+
+class GPFrame : public ::GPFrame {
+ public:
+  GPFrame()
+  {
+this->layer_index = this->start = this->end = -1;
+  }
+
+  GPFrame(int layer_index)
+  {
+this->layer_index = layer_index;
+this->start = this->end = -1;
+  }
+
+  ~GPFrame() = default;
 };
 
 class GPData : public ::GPData {
@@ -103,6 +125,16 @@ class GPData : public ::GPData {
 this->runtime = nullptr;
   }
 
+  Span frames() const
+  {
+return {(const GPFrame *)this->frames_array, this->frames_size};
+  }
+
+  MutableSpan frames_for_write()
+  {
+return {(GPFrame *)this->frames_array, this->frames_size};
+  }
+
   Span layers() const
   {
 return {(const GPLayer *)this->layers_array, this->layers_size};
@@ -121,10 +153,30 @@ class GPData : public ::GPData {
 }
 

[Bf-blender-cvs] [4d267da78e2] gpencil-new-data-proposal: WIP commit

2022-05-10 Thread Falk David
Commit: 4d267da78e20881ce9a064e4ad6a2e3f4ee0adbb
Author: Falk David
Date:   Tue May 3 10:02:58 2022 +0200
Branches: gpencil-new-data-proposal
https://developer.blender.org/rB4d267da78e20881ce9a064e4ad6a2e3f4ee0adbb

WIP commit

===

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

===

diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal.hh 
b/source/blender/blenkernel/intern/gpencil_new_proposal.hh
index b14290490a5..5db38608f6e 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal.hh
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal.hh
@@ -71,7 +71,7 @@ typedef struct GPData {
   int layers_size;
   int active_layer_index;
 
-  GPLayerGroup default_group;
+  GPLayerGroup *default_group;
 
   GPDataRuntimeHandle *runtime;
 } GPData;
diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc 
b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
index 27397331e45..94a25a6e2b8 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
@@ -9,30 +9,108 @@
 #include "gpencil_new_proposal.hh"
 #include "testing/testing.h"
 
-namespace blender::bke {
+template class GPVector {
+ private:
+  /**
+   * Address of the pointer to the begining of the vector.
+   */
+  T **start_;
+
+  /**
+   * Address of the size of the vector.
+   */
+  int *size_;
 
-class GPencilFrame : public CurvesGeometry {
  public:
-  GPencilFrame(){};
-  ~GPencilFrame() = default;
+  GPVector(T **start, int *size) {
+this->start_ = start;
+this->size_ = size;
+  }
+
+  int size() {
+return size_;
+  }
 
-  CurvesGeometry _curves_geometry()
+  T *data()
   {
-CurvesGeometry *geometry = reinterpret_cast(this);
-return *geometry;
+return *start_;
   }
 
-  bool bounds_min_max(float3 , float3 )
+  void append(T ) {
+
+  }
+ 
+ private:
+  void realloc(const int64_t size)
   {
-return as_curves_geometry().bounds_min_max(min, max);
+/* Overwrite the size. */
+*this->size_ = size;
+/* Reallocate the array and overwrite the pointer to the beginning of the 
array. */
+*this->start_ = static_cast(MEM_reallocN(*this->start_, size * 
sizeof(T)));
   }
-};
 
-class GPData : ::GPData {
- public:
-  GPData();
-  ~GPData();
-};
+}
+
+namespace blender::bke
+{
+
+  class GPLayerGroup : ::GPLayerGroup {
+   public:
+GPLayerGroup()
+{
+}
+
+~GPLayerGroup()
+{
+  /* Recursivly free the children of this layer group first. */
+  for (int i = 0; i < this->children_size; i++) {
+MEM_delete(>children[i]);
+  }
+  /* Then free its data. */
+  MEM_SAFE_FREE(this->children);
+  MEM_SAFE_FREE(this->layer_indices);
+}
+  };
+
+  class GPData : ::GPData {
+   public:
+GPData()
+{
+}
+
+GPData(int layers_size)
+{
+  BLI_assert(layers_size > 0);
+
+  this->frames_size = 0;
+  this->layers_size = layers_size;
+
+  this->frames = nullptr;
+  CustomData_reset(>frame_data);
+  this->active_frame_index = -1;
+
+  this->layers = (::GPLayer *)MEM_calloc_arrayN(this->layers_size, 
sizeof(::GPLayer), __func__);
+  this->active_layer_index = 0;
+
+  this->default_group = MEM_new(__func__);
+
+  this->runtime = MEM_new(__func__);
+}
+
+~GPData()
+{
+  /* Free frames and frame custom data. */
+  MEM_SAFE_FREE(this->frames);
+  CustomData_free(>frame_data, this->frames_size);
+
+  /* Free layer and layer groups. */
+  MEM_SAFE_FREE(this->layers);
+  MEM_delete(reinterpret_cast(this->default_group));
+  this->default_group = nullptr;
+
+  MEM_delete(this->runtime) this->runtime = nullptr;
+}
+  };
 
 }  // namespace blender::bke
 
@@ -40,9 +118,16 @@ namespace blender::bke::gpencil::tests {
 
 TEST(gpencil_proposal, Foo)
 {
-  GPencilFrame my_frame;
-  float3 min, max;
-  EXPECT_FALSE(my_frame.bounds_min_max(min, max));
+  GPData my_data;
+  GPLayer my_layer("FooLayer");
+
+  my_data.add_layer(my_layer);
+  GPFrame my_frame = my_data.new_frame_on_layer(my_layer);
+  my_frame.set_start_and_end(5, 10);
+
+  GPStroke my_stroke(100);
+  fill_stroke_with_points(my_stroke);
+  my_frame.insert_stroke(my_stroke);
 }
 
 }  // namespace blender::bke::gpencil::tests
\ No newline at end of file

___
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] [46e107a435b] gpencil-new-data-proposal: Merge branch 'gpencil-new-data-proposal' of github.com:falkdavid/blender-branches into gpencil-new-data-proposal

2022-05-10 Thread Falk David
Commit: 46e107a435bfdfde7fd514ff04b3a217ef43cfe1
Author: Falk David
Date:   Thu May 5 12:55:08 2022 +0200
Branches: gpencil-new-data-proposal
https://developer.blender.org/rB46e107a435bfdfde7fd514ff04b3a217ef43cfe1

Merge branch 'gpencil-new-data-proposal' of 
github.com:falkdavid/blender-branches 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] [c98981fc4e1] gpencil-new-data-proposal: Merge branch 'master' into gpencil-new-data-proposal

2022-05-10 Thread Falk David
Commit: c98981fc4e12bfc9a54b4cb669cc2727ecf9fd21
Author: Falk David
Date:   Wed May 4 16:23:28 2022 +0200
Branches: gpencil-new-data-proposal
https://developer.blender.org/rBc98981fc4e12bfc9a54b4cb669cc2727ecf9fd21

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] [394b107aeff] gpencil-new-data-proposal: Move DNA structs to separate file

2022-05-10 Thread Falk David
Commit: 394b107aeff75ee4b12c03bd63a6c70712ce7440
Author: Falk David
Date:   Mon May 2 12:51:20 2022 +0200
Branches: gpencil-new-data-proposal
https://developer.blender.org/rB394b107aeff75ee4b12c03bd63a6c70712ce7440

Move DNA structs to separate file

===

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

===

diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc 
b/source/blender/blenkernel/intern/gpencil_new_proposal.hh
similarity index 54%
copy from source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
copy to source/blender/blenkernel/intern/gpencil_new_proposal.hh
index a2c51f3d00b..b14290490a5 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal.hh
@@ -1,48 +1,28 @@
 /* SPDX-License-Identifier: GPL-2.0-or-later */
 
 /** \file
- * \ingroup bke
+ * \ingroup DNA
  */
 
-#include "BKE_curves.hh"
+#pragma once
 
-#include "testing/testing.h"
+#include "DNA_ID.h"
+#include "DNA_curves_types.h"
+#include "DNA_customdata_types.h"
 
-namespace blender::bke::gpencil {
-
-class GPencilFrame : public CurvesGeometry {
- public:
-  GPencilFrame(){};
-  ~GPencilFrame() = default;
-
-  CurvesGeometry _curves_geometry()
-  {
-CurvesGeometry *geometry = reinterpret_cast(this);
-return *geometry;
-  }
-
-  bool bounds_min_max(float3 , float3 )
-  {
-return as_curves_geometry().bounds_min_max(min, max);
-  }
-};
+#ifdef __cplusplus
+extern "C" {
+#endif
 
+/* Note: This should be in a file like BKE_gpencil.hh */
+namespace blender::bke::gpencil {
 class GPDataRuntime {
  public:
   /* Runtime Data */
   /* void *stroke_painting_buffer; */
 };
-
-class GPencilData : blender::dna::gpencil::GPData {
- public:
-  GPencilData();
-  ~GPencilData();
-};
-
 }  // namespace blender::bke::gpencil
 
-namespace blender::dna::gpencil {
-
 #ifdef __cplusplus
 class GPDataRuntime;
 using GPDataRuntimeHandle = blender::bke::gpencil::GPDataRuntime;
@@ -58,22 +38,37 @@ typedef struct GPLayerGroup {
   int layer_indices_size;
 
   char name[128];
+
+  /* ... */
 } GPLayerGroup;
 
 typedef struct GPLayer {
   char name[128];
+
   int flag;
+
+  /* ... */
 } GPLayer;
 
+typedef struct GPFrame {
+  CurvesGeometry strokes;
+
+  int flag;
+
+  int start;
+  int end;
+
+  /* ... */
+} GPFrame;
+
 typedef struct GPData {
-  CurvesGeometry *frames;
+  GPFrame *frames;
   int frames_size;
   CustomData frame_data;
   int active_frame_index;
 
   GPLayer *layers;
   int layers_size;
-  CustomData layer_data;
   int active_layer_index;
 
   GPLayerGroup default_group;
@@ -81,13 +76,14 @@ typedef struct GPData {
   GPDataRuntimeHandle *runtime;
 } GPData;
 
+/* This is the ID_GP structure that holds all the */
 typedef struct GreasePencil {
   ID id;
   /* Animation data (must be immediately after id). */
   struct AnimData *adt;
 
-  /**/
-  GPData grease_pencil_data;
+  /* Pointer to the actual data-block containing the frames, layers and layer 
groups. */
+  GPData *grease_pencil_data;
 
   int flag;
 
@@ -99,16 +95,6 @@ typedef struct GreasePencil {
   /* ... */
 } GreasePencil;
 
-}  // namespace blender::dna::gpencil
-
-namespace blender::bke::gpencil::tests {
-
-TEST(gpencil_proposal, Foo)
-{
-  using namespace blender::bke::gpencil;
-  GPencilFrame my_frame;
-  float3 min, max;
-  EXPECT_FALSE(my_frame.bounds_min_max(min, max));
+#ifdef __cplusplus
 }
-
-}  // namespace blender::bke::gpencil::tests
\ No newline at end of file
+#endif
\ No newline at end of file
diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc 
b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
index a2c51f3d00b..27397331e45 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
@@ -3,12 +3,13 @@
 /** \file
  * \ingroup bke
  */
-
 #include "BKE_curves.hh"
+#include "BLI_math_vec_types.hh"
 
+#include "gpencil_new_proposal.hh"
 #include "testing/testing.h"
 
-namespace blender::bke::gpencil {
+namespace blender::bke {
 
 class GPencilFrame : public CurvesGeometry {
  public:
@@ -27,85 +28,18 @@ class GPencilFrame : public CurvesGeometry {
   }
 };
 
-class GPDataRuntime {
+class GPData : ::GPData {
  public:
-  /* Runtime Data */
-  /* void *stroke_painting_buffer; */
+  GPData();
+  ~GPData();
 };
 
-class GPencilData : blender::dna::gpencil::GPData {
- public:
-  GPencilData();
-  ~GPencilData();
-};
-
-}  // namespace blender::bke::gpencil
-
-namespace blender::dna::gpencil {
-
-#ifdef __cplusplus
-class GPDataRuntime;
-using GPDataRuntimeHandle = blender::bke::gpencil::GPDataRuntime;
-#else
-typedef struct GPDataRuntimeHandle GPDataRuntimeHandle;
-#endif
-
-typedef struct GPLayerGroup {
-  struct GPLayerGroup 

[Bf-blender-cvs] [279b8597033] gpencil-new-data-proposal: Merge branch 'master' into gpencil-new-data-proposal

2022-05-10 Thread Falk David
Commit: 279b8597033b99ed45c426f55899f783b44c1b76
Author: Falk David
Date:   Mon May 2 12:08:53 2022 +0200
Branches: gpencil-new-data-proposal
https://developer.blender.org/rB279b8597033b99ed45c426f55899f783b44c1b76

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] [8e96d7f3d68] gpencil-new-data-proposal: WIP: refine structure

2022-05-10 Thread Falk David
Commit: 8e96d7f3d6821b6379cc9359beb6ab90d9385ac5
Author: Falk David
Date:   Wed Apr 13 15:05:56 2022 +0200
Branches: gpencil-new-data-proposal
https://developer.blender.org/rB8e96d7f3d6821b6379cc9359beb6ab90d9385ac5

WIP: refine structure

===

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

===

diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc 
b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
index 8d690bd0f15..a2c51f3d00b 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
@@ -10,11 +10,9 @@
 
 namespace blender::bke::gpencil {
 
-typedef struct bGPdata bGPdata;
-
 class GPencilFrame : public CurvesGeometry {
-  public:
-  GPencilFrame() {};
+ public:
+  GPencilFrame(){};
   ~GPencilFrame() = default;
 
   CurvesGeometry _curves_geometry()
@@ -23,42 +21,94 @@ class GPencilFrame : public CurvesGeometry {
 return *geometry;
   }
 
-  bool bounds_min_max(float3 , float3 ) 
+  bool bounds_min_max(float3 , float3 )
   {
 return as_curves_geometry().bounds_min_max(min, max);
   }
 };
 
-// class GPencilData : bGPdata {
-// public:
-//   GPencilData();
-//   ~GPencilData();
-// };
+class GPDataRuntime {
+ public:
+  /* Runtime Data */
+  /* void *stroke_painting_buffer; */
+};
 
-struct bGPdata {
-  ID id;
-  /* Animation data (must be immediately after id). */
-  struct AnimData *adt;
+class GPencilData : blender::dna::gpencil::GPData {
+ public:
+  GPencilData();
+  ~GPencilData();
+};
+
+}  // namespace blender::bke::gpencil
+
+namespace blender::dna::gpencil {
+
+#ifdef __cplusplus
+class GPDataRuntime;
+using GPDataRuntimeHandle = blender::bke::gpencil::GPDataRuntime;
+#else
+typedef struct GPDataRuntimeHandle GPDataRuntimeHandle;
+#endif
+
+typedef struct GPLayerGroup {
+  struct GPLayerGroup *children;
+  int children_size;
+
+  int *layer_indices;
+  int layer_indices_size;
+
+  char name[128];
+} GPLayerGroup;
 
+typedef struct GPLayer {
+  char name[128];
+  int flag;
+} GPLayer;
+
+typedef struct GPData {
   CurvesGeometry *frames;
   int frames_size;
   CustomData frame_data;
+  int active_frame_index;
+
+  GPLayer *layers;
+  int layers_size;
+  CustomData layer_data;
+  int active_layer_index;
+
+  GPLayerGroup default_group;
+
+  GPDataRuntimeHandle *runtime;
+} GPData;
+
+typedef struct GreasePencil {
+  ID id;
+  /* Animation data (must be immediately after id). */
+  struct AnimData *adt;
+
+  /**/
+  GPData grease_pencil_data;
 
+  int flag;
 
   /** Materials array. */
   struct Material **mat;
   /** Total materials. */
   short totcol;
-};
 
-namespace tests {
+  /* ... */
+} GreasePencil;
+
+}  // namespace blender::dna::gpencil
+
+namespace blender::bke::gpencil::tests {
 
-TEST(gpencil_proposal, Foo) {
+TEST(gpencil_proposal, Foo)
+{
   using namespace blender::bke::gpencil;
   GPencilFrame my_frame;
   float3 min, max;
   EXPECT_FALSE(my_frame.bounds_min_max(min, max));
 }
 
-} // namespace tests
-} // namespace blender::bke::gpencil
\ No newline at end of file
+}  // namespace blender::bke::gpencil::tests
\ No newline at end of file

___
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] [9693aeb0034] gpencil-new-data-proposal: WIP: Add new proposal test file

2022-05-10 Thread Falk David
Commit: 9693aeb0034af23e18453370943e7318566acb09
Author: Falk David
Date:   Sun Apr 10 11:57:06 2022 +0200
Branches: gpencil-new-data-proposal
https://developer.blender.org/rB9693aeb0034af23e18453370943e7318566acb09

WIP: Add new proposal test file

===

M   source/blender/blenkernel/CMakeLists.txt
A   source/blender/blenkernel/intern/gpencil_new_proposal_test.cc

===

diff --git a/source/blender/blenkernel/CMakeLists.txt 
b/source/blender/blenkernel/CMakeLists.txt
index aca8cdf916e..ea37513ba7f 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -819,6 +819,7 @@ if(WITH_GTESTS)
 intern/cryptomatte_test.cc
 intern/curves_geometry_test.cc
 intern/fcurve_test.cc
+intern/gpencil_new_proposal_test.cc
 intern/idprop_serialize_test.cc
 intern/image_partial_update_test.cc
 intern/image_test.cc
diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc 
b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
new file mode 100644
index 000..8d690bd0f15
--- /dev/null
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
@@ -0,0 +1,64 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+/** \file
+ * \ingroup bke
+ */
+
+#include "BKE_curves.hh"
+
+#include "testing/testing.h"
+
+namespace blender::bke::gpencil {
+
+typedef struct bGPdata bGPdata;
+
+class GPencilFrame : public CurvesGeometry {
+  public:
+  GPencilFrame() {};
+  ~GPencilFrame() = default;
+
+  CurvesGeometry _curves_geometry()
+  {
+CurvesGeometry *geometry = reinterpret_cast(this);
+return *geometry;
+  }
+
+  bool bounds_min_max(float3 , float3 ) 
+  {
+return as_curves_geometry().bounds_min_max(min, max);
+  }
+};
+
+// class GPencilData : bGPdata {
+// public:
+//   GPencilData();
+//   ~GPencilData();
+// };
+
+struct bGPdata {
+  ID id;
+  /* Animation data (must be immediately after id). */
+  struct AnimData *adt;
+
+  CurvesGeometry *frames;
+  int frames_size;
+  CustomData frame_data;
+
+
+  /** Materials array. */
+  struct Material **mat;
+  /** Total materials. */
+  short totcol;
+};
+
+namespace tests {
+
+TEST(gpencil_proposal, Foo) {
+  using namespace blender::bke::gpencil;
+  GPencilFrame my_frame;
+  float3 min, max;
+  EXPECT_FALSE(my_frame.bounds_min_max(min, max));
+}
+
+} // namespace tests
+} // namespace blender::bke::gpencil
\ No newline at end of file

___
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] [a74a2677677] master: Cleanup: Move mesh primitive cube to the geometry module

2022-05-10 Thread Hans Goudey
Commit: a74a267767706f57583ab1b3431f640570801784
Author: Hans Goudey
Date:   Tue May 10 10:21:30 2022 +0200
Branches: master
https://developer.blender.org/rBa74a267767706f57583ab1b3431f640570801784

Cleanup: Move mesh primitive cube to the geometry module

This allows easy reuse elsewhere in Blender.

===

M   source/blender/geometry/CMakeLists.txt
A   source/blender/geometry/GEO_mesh_primitive_cuboid.hh
A   source/blender/geometry/intern/mesh_primitive_cuboid.cc
M   source/blender/nodes/geometry/node_geometry_util.hh
M   source/blender/nodes/geometry/nodes/node_geo_bounding_box.cc
M   source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cube.cc

===

diff --git a/source/blender/geometry/CMakeLists.txt 
b/source/blender/geometry/CMakeLists.txt
index 9dcacb13536..cf89426bfc4 100644
--- a/source/blender/geometry/CMakeLists.txt
+++ b/source/blender/geometry/CMakeLists.txt
@@ -7,6 +7,7 @@ set(INC
   ../blenlib
   ../blentranslation
   ../functions
+  ../guardedalloc
   ../makesdna
   ../makesrna
   ../../../intern/eigen
@@ -16,6 +17,7 @@ set(INC
 
 set(SRC
   intern/mesh_merge_by_distance.cc
+  intern/mesh_primitive_cuboid.cc
   intern/mesh_to_curve_convert.cc
   intern/point_merge_by_distance.cc
   intern/realize_instances.cc
@@ -23,6 +25,7 @@ set(SRC
   intern/uv_parametrizer.c
 
   GEO_mesh_merge_by_distance.hh
+  GEO_mesh_primitive_cuboid.hh
   GEO_mesh_to_curve.hh
   GEO_point_merge_by_distance.hh
   GEO_realize_instances.hh
diff --git a/source/blender/geometry/GEO_mesh_primitive_cuboid.hh 
b/source/blender/geometry/GEO_mesh_primitive_cuboid.hh
new file mode 100644
index 000..d8f16065e2b
--- /dev/null
+++ b/source/blender/geometry/GEO_mesh_primitive_cuboid.hh
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+#pragma once
+
+struct Mesh;
+struct float3;
+namespace blender {
+namespace bke {
+class AttributeIDRef;
+}
+}  // namespace blender
+
+namespace blender::geometry {
+
+Mesh *create_cuboid_mesh(
+const float3 , int verts_x, int verts_y, int verts_z, const 
bke::AttributeIDRef _id);
+
+}  // namespace blender::geometry
diff --git 
a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cube.cc 
b/source/blender/geometry/intern/mesh_primitive_cuboid.cc
similarity index 77%
copy from source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cube.cc
copy to source/blender/geometry/intern/mesh_primitive_cuboid.cc
index 636ecb8ab41..e41516d0486 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cube.cc
+++ b/source/blender/geometry/intern/mesh_primitive_cuboid.cc
@@ -1,14 +1,19 @@
 /* SPDX-License-Identifier: GPL-2.0-or-later */
 
+#include "BLI_index_range.hh"
+#include "BLI_math_vector.h"
+#include "BLI_math_vector.hh"
+
 #include "DNA_mesh_types.h"
 #include "DNA_meshdata_types.h"
 
-#include "BKE_material.h"
+#include "BKE_attribute_access.hh"
+#include "BKE_geometry_set.hh"
 #include "BKE_mesh.h"
 
-#include "node_geometry_util.hh"
+#include "GEO_mesh_primitive_cuboid.hh"
 
-namespace blender::nodes {
+namespace blender::geometry {
 
 struct CuboidConfig {
   float3 size;
@@ -315,12 +320,12 @@ static void calculate_polys(const CuboidConfig ,
   }
 }
 
-static void calculate_uvs(const CuboidConfig , Mesh *mesh)
+static void calculate_uvs(const CuboidConfig , Mesh *mesh, const 
bke::AttributeIDRef _id)
 {
   MeshComponent mesh_component;
   mesh_component.replace(mesh, GeometryOwnershipType::Editable);
-  OutputAttribute_Typed uv_attribute =
-  mesh_component.attribute_try_get_for_output_only("uv_map", 
ATTR_DOMAIN_CORNER);
+  bke::OutputAttribute_Typed uv_attribute =
+  mesh_component.attribute_try_get_for_output_only(uv_id, 
ATTR_DOMAIN_CORNER);
   MutableSpan uvs = uv_attribute.as_span();
 
   int loop_index = 0;
@@ -392,128 +397,27 @@ static void calculate_uvs(const CuboidConfig , 
Mesh *mesh)
   uv_attribute.save();
 }
 
-Mesh *create_cuboid_mesh(const float3 size,
+Mesh *create_cuboid_mesh(const float3 ,
  const int verts_x,
  const int verts_y,
- const int verts_z)
+ const int verts_z,
+ const bke::AttributeIDRef _id)
 {
   const CuboidConfig config(size, verts_x, verts_y, verts_z);
 
   Mesh *mesh = BKE_mesh_new_nomain(
   config.vertex_count, 0, 0, config.loop_count, config.poly_count);
-  BKE_id_material_eval_ensure_default_slot(>id);
 
   calculate_vertices(config, {mesh->mvert, mesh->totvert});
 
   calculate_polys(config, {mesh->mpoly, mesh->totpoly}, {mesh->mloop, 
mesh->totloop});
   BKE_mesh_calc_edges(mesh, false, false);
 
-  calculate_uvs(config, mesh);
-
-  return mesh;
-}
-
-}  // namespace blender::nodes
-
-namespace blender::nodes::node_geo_mesh_primitive_cube_cc {
-
-static void node_declare(NodeDeclarationBuilder )
-{
-  

[Bf-blender-cvs] [77c0e798053] master: Merge branch 'blender-v3.2-release'

2022-05-10 Thread Jeroen Bakker
Commit: 77c0e79805350ef8d99f0a6bb82a71b57aad72e3
Author: Jeroen Bakker
Date:   Tue May 10 10:01:10 2022 +0200
Branches: master
https://developer.blender.org/rB77c0e79805350ef8d99f0a6bb82a71b57aad72e3

Merge branch 'blender-v3.2-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] [2a2e47b20c8] master: Curves: Add disabled message for add empty hair operator

2022-05-10 Thread Hans Goudey
Commit: 2a2e47b20c88657c18dddbba6e44158a6ce114b0
Author: Hans Goudey
Date:   Tue May 10 09:40:40 2022 +0200
Branches: master
https://developer.blender.org/rB2a2e47b20c88657c18dddbba6e44158a6ce114b0

Curves: Add disabled message for add empty hair operator

Ref 2ba081f59bc62f1fc7f59a6391c

===

M   source/blender/editors/object/object_add.cc

===

diff --git a/source/blender/editors/object/object_add.cc 
b/source/blender/editors/object/object_add.cc
index 820f500d172..b7deade5146 100644
--- a/source/blender/editors/object/object_add.cc
+++ b/source/blender/editors/object/object_add.cc
@@ -2126,6 +2126,7 @@ static bool object_curves_empty_hair_add_poll(bContext *C)
   }
   Object *ob = CTX_data_active_object(C);
   if (ob == nullptr || ob->type != OB_MESH) {
+CTX_wm_operator_poll_msg_set(C, "No active mesh object");
 return false;
   }
   return 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] [2f1843401cb] cycles_oneapi: Merge branch 'master' into cycles_oneapi

2022-05-10 Thread Werner, Stefan
Commit: 2f1843401cb9e8a0a77d80daa6cb6a8b87e5ffeb
Author: Werner, Stefan
Date:   Tue May 10 09:05:25 2022 +0200
Branches: cycles_oneapi
https://developer.blender.org/rB2f1843401cb9e8a0a77d80daa6cb6a8b87e5ffeb

Merge branch 'master' into cycles_oneapi

===



===



___
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] [439f86ac89b] temp-T97272: Fix T97272: Lag when resizing viewports.

2022-05-10 Thread Jeroen Bakker
Commit: 439f86ac89bdd649aa9ccfe258c5f80474788449
Author: Jeroen Bakker
Date:   Tue May 10 08:10:46 2022 +0200
Branches: temp-T97272
https://developer.blender.org/rB439f86ac89bdd649aa9ccfe258c5f80474788449

Fix T97272: Lag when resizing viewports.

Viewports where cleared explicitly due to compatibility reasons with Intel 
iGPUs.
This slowed down other platforms as well, this wasn't noticeable on all 
platforms.

This patch will be more selective when to enable the workaround.
Currently only for iGPUs on Mac + Linux.

===

M   source/blender/gpu/GPU_capabilities.h
M   source/blender/gpu/intern/gpu_capabilities.cc
M   source/blender/gpu/intern/gpu_capabilities_private.hh
M   source/blender/gpu/intern/gpu_viewport.c
M   source/blender/gpu/opengl/gl_backend.cc

===

diff --git a/source/blender/gpu/GPU_capabilities.h 
b/source/blender/gpu/GPU_capabilities.h
index 0d0542aa528..aedac168a01 100644
--- a/source/blender/gpu/GPU_capabilities.h
+++ b/source/blender/gpu/GPU_capabilities.h
@@ -40,6 +40,7 @@ bool GPU_mip_render_workaround(void);
 bool GPU_depth_blitting_workaround(void);
 bool GPU_use_main_context_workaround(void);
 bool GPU_use_hq_normals_workaround(void);
+bool GPU_clear_viewport_workaround(void);
 bool GPU_crappy_amd_driver(void);
 
 bool GPU_compute_shader_support(void);
diff --git a/source/blender/gpu/intern/gpu_capabilities.cc 
b/source/blender/gpu/intern/gpu_capabilities.cc
index b750dacaca6..72b62b3de3d 100644
--- a/source/blender/gpu/intern/gpu_capabilities.cc
+++ b/source/blender/gpu/intern/gpu_capabilities.cc
@@ -142,6 +142,11 @@ bool GPU_use_hq_normals_workaround()
   return GCaps.use_hq_normals_workaround;
 }
 
+bool GPU_clear_viewport_workaround()
+{
+  return GCaps.clear_viewport_workaround;
+}
+
 bool GPU_compute_shader_support()
 {
   return GCaps.compute_shader_support;
diff --git a/source/blender/gpu/intern/gpu_capabilities_private.hh 
b/source/blender/gpu/intern/gpu_capabilities_private.hh
index 4a951eb8458..611c2d6973c 100644
--- a/source/blender/gpu/intern/gpu_capabilities_private.hh
+++ b/source/blender/gpu/intern/gpu_capabilities_private.hh
@@ -51,6 +51,7 @@ struct GPUCapabilities {
   bool use_main_context_workaround = false;
   bool broken_amd_driver = false;
   bool use_hq_normals_workaround = false;
+  bool clear_viewport_workaround = false;
   /* Vulkan related workarounds. */
 
   /* Metal related workarounds. */
diff --git a/source/blender/gpu/intern/gpu_viewport.c 
b/source/blender/gpu/intern/gpu_viewport.c
index a0efe12f523..d528160797d 100644
--- a/source/blender/gpu/intern/gpu_viewport.c
+++ b/source/blender/gpu/intern/gpu_viewport.c
@@ -21,6 +21,7 @@
 #include "DNA_userdef_types.h"
 #include "DNA_vec_types.h"
 
+#include "GPU_capabilities.h"
 #include "GPU_framebuffer.h"
 #include "GPU_immediate.h"
 #include "GPU_matrix.h"
@@ -126,19 +127,23 @@ static void gpu_viewport_textures_create(GPUViewport 
*viewport)
   if (viewport->color_render_tx[0] == NULL) {
 viewport->color_render_tx[0] = GPU_texture_create_2d(
 "dtxl_color", UNPACK2(size), 1, GPU_RGBA16F, NULL);
-GPU_texture_clear(viewport->color_render_tx[0], GPU_DATA_FLOAT, 
empty_pixel);
 viewport->color_overlay_tx[0] = GPU_texture_create_2d(
 "dtxl_color_overlay", UNPACK2(size), 1, GPU_SRGB8_A8, NULL);
-GPU_texture_clear(viewport->color_overlay_tx[0], GPU_DATA_FLOAT, 
empty_pixel);
+if (GPU_clear_viewport_workaround()) {
+  GPU_texture_clear(viewport->color_render_tx[0], GPU_DATA_FLOAT, 
empty_pixel);
+  GPU_texture_clear(viewport->color_overlay_tx[0], GPU_DATA_FLOAT, 
empty_pixel);
+}
   }
 
   if ((viewport->flag & GPU_VIEWPORT_STEREO) != 0 && 
viewport->color_render_tx[1] == NULL) {
 viewport->color_render_tx[1] = GPU_texture_create_2d(
 "dtxl_color_stereo", UNPACK2(size), 1, GPU_RGBA16F, NULL);
-GPU_texture_clear(viewport->color_render_tx[1], GPU_DATA_FLOAT, 
empty_pixel);
 viewport->color_overlay_tx[1] = GPU_texture_create_2d(
 "dtxl_color_overlay_stereo", UNPACK2(size), 1, GPU_SRGB8_A8, NULL);
-GPU_texture_clear(viewport->color_overlay_tx[1], GPU_DATA_FLOAT, 
empty_pixel);
+if (GPU_clear_viewport_workaround()) {
+  GPU_texture_clear(viewport->color_render_tx[1], GPU_DATA_FLOAT, 
empty_pixel);
+  GPU_texture_clear(viewport->color_overlay_tx[1], GPU_DATA_FLOAT, 
empty_pixel);
+}
   }
 
   /* Can be shared with GPUOffscreen. */
diff --git a/source/blender/gpu/opengl/gl_backend.cc 
b/source/blender/gpu/opengl/gl_backend.cc
index 610fd5d980f..0ce01d80a77 100644
--- a/source/blender/gpu/opengl/gl_backend.cc
+++ b/source/blender/gpu/opengl/gl_backend.cc
@@ -419,6 +419,13 @@ static void detect_workarounds()
 GCaps.shader_storage_buffer_objects_support = false;
   }
 
+  /* Certain Intel based platforms don't clear the viewport textures. Always 
clearing leads to
+   * 

[Bf-blender-cvs] [08a39d32a98] master: Merge branch 'blender-v3.2-release'

2022-05-10 Thread Jeroen Bakker
Commit: 08a39d32a988347d2e2ff42a4afa2f8ca9977467
Author: Jeroen Bakker
Date:   Tue May 10 08:30:56 2022 +0200
Branches: master
https://developer.blender.org/rB08a39d32a988347d2e2ff42a4afa2f8ca9977467

Merge branch 'blender-v3.2-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] [11aa237858d] blender-v3.2-release: Eevee: Fix GLSL compilation error.

2022-05-10 Thread Jeroen Bakker
Commit: 11aa237858d4a2f12db43bac97793606eda7f542
Author: Jeroen Bakker
Date:   Tue May 10 08:30:21 2022 +0200
Branches: blender-v3.2-release
https://developer.blender.org/rB11aa237858d4a2f12db43bac97793606eda7f542

Eevee: Fix GLSL compilation error.

Introduced by {35594f4b92fa4cbb5b848f447b7a3323e572b676}.
Some platforms do not support temp variables to be used as inout parameter.

Detected on Mac with Intel iGPU.

===

M   
source/blender/gpu/shaders/material/gpu_shader_material_eevee_specular.glsl
M   source/blender/gpu/shaders/material/gpu_shader_material_principled.glsl

===

diff --git 
a/source/blender/gpu/shaders/material/gpu_shader_material_eevee_specular.glsl 
b/source/blender/gpu/shaders/material/gpu_shader_material_eevee_specular.glsl
index c81880184e3..530907859e9 100644
--- 
a/source/blender/gpu/shaders/material/gpu_shader_material_eevee_specular.glsl
+++ 
b/source/blender/gpu/shaders/material/gpu_shader_material_eevee_specular.glsl
@@ -64,6 +64,8 @@ void node_eevee_specular(vec4 diffuse,
   else {
 result = closure_eval(diffuse_data, reflection_data);
   }
-  result = closure_add(result, closure_eval(emission_data));
-  result = closure_add(result, closure_eval(transparency_data));
+  Closure emission_cl = closure_eval(emission_data);
+  Closure transparency_cl = closure_eval(transparency_data);
+  result = closure_add(result, emission_cl);
+  result = closure_add(result, transparency_cl);
 }
diff --git 
a/source/blender/gpu/shaders/material/gpu_shader_material_principled.glsl 
b/source/blender/gpu/shaders/material/gpu_shader_material_principled.glsl
index 033dc05c57d..2e695fa3e14 100644
--- a/source/blender/gpu/shaders/material/gpu_shader_material_principled.glsl
+++ b/source/blender/gpu/shaders/material/gpu_shader_material_principled.glsl
@@ -169,6 +169,8 @@ void node_bsdf_principled(vec4 base_color,
 /* Un-optimized case. */
 result = closure_eval(diffuse_data, reflection_data, clearcoat_data, 
refraction_data);
   }
-  result = closure_add(result, closure_eval(emission_data));
-  result = closure_add(result, closure_eval(transparency_data));
+  Closure emission_cl = closure_eval(emission_data);
+  Closure transparency_cl = closure_eval(transparency_data);
+  result = closure_add(result, emission_cl);
+  result = closure_add(result, transparency_cl);
 }

___
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