[Bf-blender-cvs] [abc46d5aeb4] master: Fix: Timeline marker names are not correctly clipped in some cases

2022-08-02 Thread Colin Basnett
Commit: abc46d5aeb49a71ad537c86daa3d78451f63e6d3
Author: Colin Basnett
Date:   Tue Aug 2 20:59:44 2022 -0700
Branches: master
https://developer.blender.org/rBabc46d5aeb49a71ad537c86daa3d78451f63e6d3

Fix: Timeline marker names are not correctly clipped in some cases

Timeline marker names are now correctly clipped instead of messily
overlapping each other and being unreadable. This change affects all
the animation editors (graph editor, NLA, action editor etc.) as well
as the VSE.

This also makes a change to when text is elevated. In the previous
behavior, a marker's text would be elevated if it was selected or if
the current frame was <= 4 frames away from the marker. This seems
like a completely arbitrary thing (probably added in to alleviate text
overlapping for markers that the user would be interested in). This
patch changes the behavior such that the marker's text will be elevated
if it is either selected or it is the last marker encountered relative
to the current frame.

===

M   source/blender/editors/animation/anim_markers.c

===

diff --git a/source/blender/editors/animation/anim_markers.c 
b/source/blender/editors/animation/anim_markers.c
index 3608140a29d..e7c7f679b16 100644
--- a/source/blender/editors/animation/anim_markers.c
+++ b/source/blender/editors/animation/anim_markers.c
@@ -402,6 +402,7 @@ static void draw_marker_name(const uchar *text_color,
  const uiFontStyle *fstyle,
  TimeMarker *marker,
  float marker_x,
+ float xmax,
  float text_y)
 {
   const char *name = marker->name;
@@ -419,8 +420,16 @@ static void draw_marker_name(const uchar *text_color,
   }
 #endif
 
-  int name_x = marker_x + UI_DPI_ICON_SIZE * 0.6;
-  UI_fontstyle_draw_simple(fstyle, name_x, text_y, name, final_text_color);
+  const int icon_half_width = UI_DPI_ICON_SIZE * 0.6;
+  const struct uiFontStyleDraw_Params fs_params = {.align = 
UI_STYLE_TEXT_LEFT, .word_wrap = 0};
+  const struct rcti rect = {
+  .xmin = marker_x + icon_half_width,
+  .xmax = xmax - icon_half_width,
+  .ymin = text_y,
+  .ymax = text_y,
+  };
+
+  UI_fontstyle_draw(fstyle, , name, strlen(name), final_text_color, 
_params);
 }
 
 static void draw_marker_line(const uchar *color, int xpos, int ymin, int ymax)
@@ -462,8 +471,13 @@ static int marker_get_icon_id(TimeMarker *marker, int flag)
   return (marker->flag & SELECT) ? ICON_MARKER_HLT : ICON_MARKER;
 }
 
-static void draw_marker(
-const uiFontStyle *fstyle, TimeMarker *marker, int cfra, int xpos, int 
flag, int region_height)
+static void draw_marker(const uiFontStyle *fstyle,
+TimeMarker *marker,
+int xpos,
+int xmax,
+int flag,
+int region_height,
+bool is_elevated)
 {
   uchar line_color[4], text_color[4];
 
@@ -479,12 +493,11 @@ static void draw_marker(
   GPU_blend(GPU_BLEND_NONE);
 
   float name_y = UI_DPI_FAC * 18;
-  /* Give an offset to the marker name when selected,
-   * or when near the current frame (5 frames range, starting from the current 
one). */
-  if ((marker->flag & SELECT) || (cfra - 4 <= marker->frame && marker->frame 
<= cfra)) {
+  /* Give an offset to the marker that is elevated. */
+  if (is_elevated) {
 name_y += UI_DPI_FAC * 10;
   }
-  draw_marker_name(text_color, fstyle, marker, xpos, name_y);
+  draw_marker_name(text_color, fstyle, marker, xpos, xmax, name_y);
 }
 
 static void draw_markers_background(rctf *rect)
@@ -532,6 +545,14 @@ static void get_marker_clip_frame_range(View2D *v2d, float 
xscale, int r_range[2
   r_range[1] = v2d->cur.xmax + font_width_max;
 }
 
+static int markers_frame_sort(const void *a, const void *b)
+{
+  const TimeMarker *marker_a = a;
+  const TimeMarker *marker_b = b;
+
+  return marker_a->frame > marker_b->frame;
+}
+
 void ED_markers_draw(const bContext *C, int flag)
 {
   ListBase *markers = ED_context_get_markers(C);
@@ -561,22 +582,69 @@ void ED_markers_draw(const bContext *C, int flag)
 
   const uiFontStyle *fstyle = UI_FSTYLE_WIDGET;
 
-  /* Separate loops in order to draw selected markers on top */
-  LISTBASE_FOREACH (TimeMarker *, marker, markers) {
-if ((marker->flag & SELECT) == 0) {
-  if (marker_is_in_frame_range(marker, clip_frame_range)) {
-draw_marker(fstyle, marker, cfra, marker->frame * xscale, flag, 
region->winy);
-  }
+  /* Markers are not stored by frame order, so we need to sort it here. */
+  ListBase sorted_markers;
+
+  BLI_duplicatelist(_markers, markers);
+  BLI_listbase_sort(_markers, markers_frame_sort);
+
+  /**
+   * Set a temporary bit in the marker's flag to indicate that it should be 
elevated.
+   * This bit will be flipped back at 

[Bf-blender-cvs] [529f5e95d7d] refactor-mesh-hide-generic: Fix compile warning

2022-08-02 Thread Hans Goudey
Commit: 529f5e95d7d989d1e53e283dbccd13e52709a1ce
Author: Hans Goudey
Date:   Tue Aug 2 22:46:19 2022 -0500
Branches: refactor-mesh-hide-generic
https://developer.blender.org/rB529f5e95d7d989d1e53e283dbccd13e52709a1ce

Fix compile warning

===

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

===

diff --git a/source/blender/editors/space_view3d/view3d_select.c 
b/source/blender/editors/space_view3d/view3d_select.c
index 7bdcc45b126..0baf7fd0dae 100644
--- a/source/blender/editors/space_view3d/view3d_select.c
+++ b/source/blender/editors/space_view3d/view3d_select.c
@@ -364,7 +364,6 @@ static bool edbm_backbuf_check_and_select_faces_obmode(Mesh 
*me,
const eSelectOp sel_op)
 {
   MPoly *mpoly = me->mpoly;
-  uint index;
   bool changed = false;
 
   const BLI_bitmap *select_bitmap = esel->select_bitmap;

___
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] [e278c5879fb] refactor-mesh-hide-generic: Merge master

2022-08-02 Thread Hans Goudey
Commit: e278c5879fba64310c0b38872cad76b27cc9ef9c
Author: Hans Goudey
Date:   Tue Aug 2 22:24:38 2022 -0500
Branches: refactor-mesh-hide-generic
https://developer.blender.org/rBe278c5879fba64310c0b38872cad76b27cc9ef9c

Merge master

===

M   source/blender/blenkernel/intern/pbvh.c
M   source/blender/gpu/GPU_buffers.h
M   source/blender/gpu/intern/gpu_buffers.c

===

diff --git a/source/blender/blenkernel/intern/pbvh.c 
b/source/blender/blenkernel/intern/pbvh.c
index d3ba53fc310..ba859127240 100644
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@ -1358,7 +1358,8 @@ static void pbvh_update_draw_buffer_cb(void *__restrict 
userdata,
  CustomData_get_layer(pbvh->pdata, 
CD_SCULPT_FACE_SETS),
  pbvh->face_sets_color_seed,
  pbvh->face_sets_color_default,
- update_flags);
+ update_flags,
+ pbvh->vert_normals);
 break;
   }
   case PBVH_BMESH:
diff --git a/source/blender/gpu/GPU_buffers.h b/source/blender/gpu/GPU_buffers.h
index 647917e21ca..6dc49ff494d 100644
--- a/source/blender/gpu/GPU_buffers.h
+++ b/source/blender/gpu/GPU_buffers.h
@@ -96,7 +96,8 @@ void GPU_pbvh_mesh_buffers_update(PBVHGPUFormat *vbo_id,
   const int *sculpt_face_sets,
   const int face_sets_color_seed,
   const int face_sets_color_default,
-  const int update_flags);
+  const int update_flags,
+  const float (*vert_normals)[3]);
 
 bool GPU_pbvh_attribute_names_update(PBVHType pbvh_type,
  PBVHGPUFormat *vbo_id,
diff --git a/source/blender/gpu/intern/gpu_buffers.c 
b/source/blender/gpu/intern/gpu_buffers.c
index 0b954dbec5e..bfa30f74f11 100644
--- a/source/blender/gpu/intern/gpu_buffers.c
+++ b/source/blender/gpu/intern/gpu_buffers.c
@@ -227,7 +227,8 @@ void GPU_pbvh_mesh_buffers_update(PBVHGPUFormat *vbo_id,
   const int *sculpt_face_sets,
   int face_sets_color_seed,
   int face_sets_color_default,
-  int update_flags)
+  int update_flags,
+  const float (*vert_normals)[3])
 {
   GPUAttrRef vcol_refs[MAX_GPU_ATTR];
   GPUAttrRef cd_uvs[MAX_GPU_ATTR];

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

2022-08-02 Thread Hans Goudey
Commit: d9683a5937fe6e55c309df06a47b9d551902d5bc
Author: Hans Goudey
Date:   Tue Aug 2 22:17:46 2022 -0500
Branches: refactor-mesh-hide-generic
https://developer.blender.org/rBd9683a5937fe6e55c309df06a47b9d551902d5bc

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

===



===

diff --cc source/blender/blenkernel/intern/pbvh.c
index e5bcac6b1d7,dae9788d21c..d3ba53fc310
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@@ -3225,27 -3207,6 +3211,27 @@@ const float (*BKE_pbvh_get_vert_normals
return pbvh->vert_normals;
  }
  
 +const bool *BKE_pbvh_get_vert_hide(const PBVH *pbvh)
 +{
-   BLI_assert(pbvh->type == PBVH_FACES);
++  BLI_assert(pbvh->header.type == PBVH_FACES);
 +  return pbvh->hide_vert;
 +}
 +
 +bool *BKE_pbvh_get_vert_hide_for_write(PBVH *pbvh)
 +{
-   BLI_assert(pbvh->type == PBVH_FACES);
++  BLI_assert(pbvh->header.type == PBVH_FACES);
 +  if (pbvh->hide_vert) {
 +return pbvh->hide_vert;
 +  }
 +  pbvh->hide_vert = CustomData_get_layer_named(>mesh->vdata, 
CD_PROP_BOOL, ".hide_vert");
 +  if (pbvh->hide_vert) {
 +return pbvh->hide_vert;
 +  }
 +  pbvh->hide_vert = (bool *)CustomData_add_layer_named(
 +  >mesh->vdata, CD_PROP_BOOL, CD_CALLOC, NULL, pbvh->mesh->totvert, 
".hide_vert");
 +  return pbvh->hide_vert;
 +}
 +
  void BKE_pbvh_subdiv_cgg_set(PBVH *pbvh, SubdivCCG *subdiv_ccg)
  {
pbvh->subdiv_ccg = subdiv_ccg;
diff --cc source/blender/gpu/intern/gpu_buffers.c
index 33322fe7988,9e8e75be23b..0b954dbec5e
--- a/source/blender/gpu/intern/gpu_buffers.c
+++ b/source/blender/gpu/intern/gpu_buffers.c
@@@ -235,14 -233,11 +232,14 @@@ void GPU_pbvh_mesh_buffers_update(PBVHG
GPUAttrRef vcol_refs[MAX_GPU_ATTR];
GPUAttrRef cd_uvs[MAX_GPU_ATTR];
  
-   Mesh me_query;
-   BKE_id_attribute_copy_domains_temp(ID_ME, vdata, NULL, ldata, NULL, NULL, 
_query.id);
++  const bool *hide_vert = (bool *)CustomData_get_layer_named(
++  >vdata, CD_PROP_BOOL, ".hide_vert");
 +
-   CustomDataLayer *actcol = BKE_id_attributes_active_color_get(_query.id);
-   eAttrDomain actcol_domain = actcol ? BKE_id_attribute_domain(_query.id, 
actcol) :
+   const CustomDataLayer *actcol = 
BKE_id_attributes_active_color_get(>id);
+   eAttrDomain actcol_domain = actcol ? BKE_id_attribute_domain(>id, 
actcol) :
 ATTR_DOMAIN_AUTO;
  
-   CustomDataLayer *rendercol = 
BKE_id_attributes_render_color_get(_query.id);
+   const CustomDataLayer *rendercol = 
BKE_id_attributes_render_color_get(>id);
  
int totcol;
  
@@@ -471,8 -464,11 +466,14 @@@ GPU_PBVH_Buffers *GPU_pbvh_mesh_buffers
int i, tottri;
int tot_real_edges = 0;
  
+   const MPoly *mpoly = mesh->mpoly;
+   const MLoop *mloop = mesh->mloop;
+ 
buffers = MEM_callocN(sizeof(GPU_PBVH_Buffers), "GPU_Buffers");
  
++  const bool *hide_vert = (bool *)CustomData_get_layer_named(
++  >vdata, CD_PROP_BOOL, ".hide_vert");
++
/* smooth or flat for all */
buffers->smooth = mpoly[looptri[face_indices[0]].poly].flag & ME_SMOOTH;

___
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] [f1cb3ebbe64] soc-2022-many-lights-sampling: Cycles: use light sample for weighting heuristic

2022-08-02 Thread Jeffrey Liu
Commit: f1cb3ebbe6465c86536dc4ecfc7e79ceb19b3112
Author: Jeffrey Liu
Date:   Tue Aug 2 23:10:35 2022 -0400
Branches: soc-2022-many-lights-sampling
https://developer.blender.org/rBf1cb3ebbe6465c86536dc4ecfc7e79ceb19b3112

Cycles: use light sample for weighting heuristic

===

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

===

diff --git a/intern/cycles/kernel/light/light_tree.h 
b/intern/cycles/kernel/light/light_tree.h
index 8e84d5a6fdb..decf7db8fe8 100644
--- a/intern/cycles/kernel/light/light_tree.h
+++ b/intern/cycles/kernel/light/light_tree.h
@@ -82,10 +82,51 @@ ccl_device float light_tree_node_importance(const float3 P,
 
 /* This is uniformly sampling the reservoir for now. */
 ccl_device float light_tree_emitter_reservoir_weight(KernelGlobals kg,
+ const float randu,
+ const float randv,
+ const float time,
  const float3 P,
  const float3 N,
+ const int bounce,
+ const uint32_t path_flag,
  int emitter_index)
 {
+  LightSample ls ccl_optional_struct_init;
+  ccl_global const KernelLightTreeEmitter *kemitter = 
_data_fetch(light_tree_emitters,
+ 
emitter_index);
+  bool sampled = true;
+  const int prim = kemitter->prim_id;
+  if (prim >= 0) {
+/* Mesh light. */
+const int object = kemitter->mesh_light.object_id;
+
+/* Exclude synthetic meshes from shadow catcher pass. */
+if ((path_flag & PATH_RAY_SHADOW_CATCHER_PASS) &&
+!(kernel_data_fetch(object_flag, object) & SD_OBJECT_SHADOW_CATCHER)) {
+  return 0.0f;
+}
+
+const int shader_flag = kemitter->mesh_light.shader_flag;
+triangle_light_sample(kg, prim, object, randu, randv, time, , P);
+ls.shader |= shader_flag;
+
+sampled = ls.pdf > 0.0f;
+  }
+  else {
+const int lamp = -prim - 1;
+
+if (UNLIKELY(light_select_reached_max_bounces(kg, lamp, bounce))) {
+  return 0.0f;
+}
+
+sampled = light_sample(kg, lamp, randu, randv, P, path_flag, );
+  }
+
+  
+  if (sampled == 0.0f) {
+return 0.0f;
+  }
+
   return 1.0f;
 }
 
@@ -114,10 +155,18 @@ ccl_device float 
light_tree_emitter_importance(KernelGlobals kg,
 
 /* to-do: this is using a lot of the same calculations as the cluster 
importance,
  * so it may be better to compute these once and then hold on to it somewhere. 
*/
-ccl_device float light_tree_should_split(KernelGlobals kg,
+ccl_device bool light_tree_should_split(KernelGlobals kg,
  const float3 P,
  const ccl_global KernelLightTreeNode 
*knode)
 {
+  const float splitting_threshold = kernel_data.integrator.splitting_threshold;
+  if (splitting_threshold == 0.0f) {
+return false;
+  }
+  else if (splitting_threshold == 1.0f) {
+return true;
+  }
+  
   const float3 bbox_min = make_float3(
   knode->bounding_box_min[0], knode->bounding_box_min[1], 
knode->bounding_box_min[2]);
   const float3 bbox_max = make_float3(
@@ -143,7 +192,7 @@ ccl_device float light_tree_should_split(KernelGlobals kg,
 
   const float total_variance = V_e * V_g + V_e * E_g * E_g + E_e * E_e * V_g;
   const float normalized_variance = sqrt(sqrt(1.0f / (1.0f + 
sqrt(total_variance;
-  return (normalized_variance < kernel_data.integrator.splitting_threshold);
+  return (normalized_variance < splitting_threshold);
 }
 
 ccl_device float light_tree_cluster_importance(KernelGlobals kg,
@@ -253,7 +302,8 @@ ccl_device bool light_tree_sample(KernelGlobals kg,
 continue;
   }
 
-  const float light_weight = light_tree_emitter_reservoir_weight(kg, P, N, 
selected_light);
+  const float light_weight = light_tree_emitter_reservoir_weight(
+  kg, time, *randu, randv, P, N, bounce, path_flag, selected_light);
   if (light_weight == 0.0f) {
 stack_index--;
 continue;

___
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] [749ea10e057] soc-2022-many-lights-sampling: Merge branch 'master' into soc-2022-many-lights-sampling

2022-08-02 Thread Jeffrey Liu
Commit: 749ea10e05722cf6bd0b2bfb56e0c4b890b06fc4
Author: Jeffrey Liu
Date:   Tue Aug 2 23:11:07 2022 -0400
Branches: soc-2022-many-lights-sampling
https://developer.blender.org/rB749ea10e05722cf6bd0b2bfb56e0c4b890b06fc4

Merge branch 'master' into soc-2022-many-lights-sampling

===



===



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

2022-08-02 Thread Chris Blackbourn
Commit: 84b160719698c6ff57c8b3dde170cbc03bdd2ee7
Author: Chris Blackbourn
Date:   Wed Aug 3 13:27:13 2022 +1200
Branches: master
https://developer.blender.org/rB84b160719698c6ff57c8b3dde170cbc03bdd2ee7

Cleanup: make format

===

M   release/scripts/modules/gpu_extras/presets.py

===

diff --git a/release/scripts/modules/gpu_extras/presets.py 
b/release/scripts/modules/gpu_extras/presets.py
index 222d9032cfd..eba8d6c161d 100644
--- a/release/scripts/modules/gpu_extras/presets.py
+++ b/release/scripts/modules/gpu_extras/presets.py
@@ -24,7 +24,7 @@ def draw_circle_2d(position, color, radius, *, segments=None):
 )
 
 if segments is None:
-max_pixel_error = 0.25 # TODO: multiply 0.5 by display dpi
+max_pixel_error = 0.25  # TODO: multiply 0.5 by display dpi
 segments = int(ceil(pi / acos(1.0 - max_pixel_error / radius)))
 segments = max(segments, 8)
 segments = min(segments, 1000)

___
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] [68c1eb86a6b] master: Fix unreported: Add tie-break conditions for udim search with integers

2022-08-02 Thread Chris Blackbourn
Commit: 68c1eb86a6b809975d7cc8b08deb8f847d8e4586
Author: Chris Blackbourn
Date:   Mon Aug 1 17:00:10 2022 +1200
Branches: master
https://developer.blender.org/rB68c1eb86a6b809975d7cc8b08deb8f847d8e4586

Fix unreported: Add tie-break conditions for udim search with integers

When searching for closest UDIM with integer co-ordinates, several UDIMs
can be equidistant. Previously, of all closest UDIMs, the one which was
earliest in the list would be used. Now, "half-open interval" rules are
used to break the tie.

Motivated by 0fcc04e7bfe1

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

===

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

===

diff --git a/source/blender/blenkernel/intern/image.cc 
b/source/blender/blenkernel/intern/image.cc
index ae5eead2547..c6e711a33e0 100644
--- a/source/blender/blenkernel/intern/image.cc
+++ b/source/blender/blenkernel/intern/image.cc
@@ -863,37 +863,89 @@ void BKE_image_get_tile_uv(const Image *ima, const int 
tile_number, float r_uv[2
   }
 }
 
+/* Linear distance between #x and the unit interval. */
+static float distance_to_unit_interval(float x)
+{
+  /* The unit interval is between 0 and 1.
+  Within the interval, return 0.
+  Outside the interval, return the distance to the nearest boundary.
+  Intuitively, the function looks like:
+   \ |   | /
+  __\|___|/__
+ 0   1
+  */
+
+  if (x <= 0.0f) {
+return -x; /* Distance to left border. */
+  }
+  if (x <= 1.0f) {
+return 0.0f; /* Inside unit interval. */
+  }
+  return x - 1.0f; /* Distance to right border. */
+}
+
+/* Distance squared between #co and the unit square with lower-left starting 
at #udim. */
+static float distance_squared_to_udim(const float co[2], const float udim[2])
+{
+  float delta[2];
+  sub_v2_v2v2(delta, co, udim);
+  delta[0] = distance_to_unit_interval(delta[0]);
+  delta[1] = distance_to_unit_interval(delta[1]);
+  return len_squared_v2(delta);
+}
+
+static bool nearest_udim_tile_tie_break(const float best_dist_sq,
+const float best_uv[2],
+const float dist_sq,
+const float uv[2])
+{
+  if (best_dist_sq == dist_sq) {   /* Exact same distance? Tie-break. */
+if (best_uv[0] == uv[0]) { /* Exact same U? Tie-break. */
+  return (uv[1] > best_uv[1]); /* Higher than previous candidate? */
+}
+return (uv[0] > best_uv[0]); /* Further right than previous candidate? */
+  }
+  return (dist_sq < best_dist_sq); /* Closer than previous candidate? */
+}
+
+/* Finds the nearest tile and offset to #co.
+ * If the co-ordinates are integers, take special care to break ties. */
 int BKE_image_find_nearest_tile_with_offset(const Image *image,
 const float co[2],
 float r_uv_offset[2])
 {
-  /* Distance squared to the closest UDIM tile. */
-  float dist_best_sq = FLT_MAX;
-  float uv_offset_best[2] = {0, 0};
+  zero_v2(r_uv_offset);
   int tile_number_best = -1;
 
-  const float co_offset[2] = {co[0] - 0.5f, co[1] - 0.5f};
+  if (!image || image->source != IMA_SRC_TILED) {
+return tile_number_best;
+  }
+
+  /* Distance squared to the closest UDIM tile. */
+  float dist_best_sq = FLT_MAX;
 
   LISTBASE_FOREACH (const ImageTile *, tile, >tiles) {
 float uv_offset[2];
 BKE_image_get_tile_uv(image, tile->tile_number, uv_offset);
 
-/* Distance squared between co[2] and center of UDIM tile. */
-const float dist_sq = len_squared_v2v2(uv_offset, co_offset);
+/* Distance squared between #co and closest point on UDIM tile. */
+const float dist_sq = distance_squared_to_udim(co, uv_offset);
 
-if (dist_sq < dist_best_sq) {
+if (dist_sq == 0) { /* Either inside in the UDIM, or on its boundary. */
+  if (floorf(co[0]) == uv_offset[0] && floorf(co[1]) == uv_offset[1]) {
+/* Within the half-open interval of the UDIM. */
+copy_v2_v2(r_uv_offset, uv_offset);
+return tile_number_best;
+  }
+}
+
+if (nearest_udim_tile_tie_break(dist_best_sq, r_uv_offset, dist_sq, 
uv_offset)) {
+  /* Tile is better than previous best, update. */
   dist_best_sq = dist_sq;
+  copy_v2_v2(r_uv_offset, uv_offset);
   tile_number_best = tile->tile_number;
-  copy_v2_v2(uv_offset_best, uv_offset);
-
-  if (dist_best_sq < 0.5f * 0.5f) {
-break; /* No other tile can be closer. */
-  }
 }
   }
-  if (tile_number_best != -1) {
-copy_v2_v2(r_uv_offset, uv_offset_best);
-  }
   return tile_number_best;
 }

___
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] [43918ec28d1] master: Geometry Nodes: Speed up reading attribute with different type

2022-08-02 Thread Hans Goudey
Commit: 43918ec28d12124cfa32b3e84ead1bfb65501f6f
Author: Hans Goudey
Date:   Tue Aug 2 19:22:10 2022 -0500
Branches: master
https://developer.blender.org/rB43918ec28d12124cfa32b3e84ead1bfb65501f6f

Geometry Nodes: Speed up reading attribute with different type

The virtual array created by the implicit conversions had a lot of
overhead when converting many values. Implement "materialize"
functions to avoid a virtual function call for every element.
This gave me a 20x improvement when copying the values
from a float attribute as a boolean, though I doubt there are
any real world situations where it's that noticible.

===

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

===

diff --git a/source/blender/blenkernel/intern/type_conversions.cc 
b/source/blender/blenkernel/intern/type_conversions.cc
index 0b5d6ad7b10..a01f5d19088 100644
--- a/source/blender/blenkernel/intern/type_conversions.cc
+++ b/source/blender/blenkernel/intern/type_conversions.cc
@@ -367,20 +367,38 @@ void DataTypeConversions::convert_to_uninitialized(const 
CPPType _type,
   functions->convert_single_to_uninitialized(from_value, to_value);
 }
 
+static void call_convert_to_uninitialized_fn(const GVArray ,
+ const fn::MultiFunction ,
+ const IndexMask mask,
+ GMutableSpan to)
+{
+  fn::MFParamsBuilder params{fn, from.size()};
+  params.add_readonly_single_input(from);
+  params.add_uninitialized_single_output(to);
+  fn::MFContextBuilder context;
+  fn.call_auto(mask, params, context);
+}
+
+static void call_convert_to_uninitialized_fn(const GVArray ,
+ const fn::MultiFunction ,
+ GMutableSpan to)
+{
+  call_convert_to_uninitialized_fn(from, fn, IndexMask(from.size()), to);
+}
+
 void DataTypeConversions::convert_to_initialized_n(GSpan from_span, 
GMutableSpan to_span) const
 {
   const CPPType _type = from_span.type();
   const CPPType _type = to_span.type();
+
   BLI_assert(from_span.size() == to_span.size());
   BLI_assert(this->is_convertible(from_type, to_type));
+
   const fn::MultiFunction *fn = this->get_conversion_multi_function(
   MFDataType::ForSingle(from_type), MFDataType::ForSingle(to_type));
-  fn::MFParamsBuilder params{*fn, from_span.size()};
-  params.add_readonly_single_input(from_span);
+
   to_type.destruct_n(to_span.data(), to_span.size());
-  params.add_uninitialized_single_output(to_span);
-  fn::MFContextBuilder context;
-  fn->call_auto(IndexRange(from_span.size()), params, context);
+  call_convert_to_uninitialized_fn(GVArray::ForSpan(from_span), *fn, to_span);
 }
 
 class GVArray_For_ConvertedGVArray : public GVArrayImpl {
@@ -414,6 +432,20 @@ class GVArray_For_ConvertedGVArray : public GVArrayImpl {
 old_to_new_conversions_.convert_single_to_uninitialized(buffer, r_value);
 from_type_.destruct(buffer);
   }
+
+  void materialize(const IndexMask mask, void *dst) const override
+  {
+type_->destruct_n(dst, mask.min_array_size());
+this->materialize_to_uninitialized(mask, dst);
+  }
+
+  void materialize_to_uninitialized(const IndexMask mask, void *dst) const 
override
+  {
+call_convert_to_uninitialized_fn(varray_,
+ *old_to_new_conversions_.multi_function,
+ mask,
+ {this->type(), dst, 
mask.min_array_size()});
+  }
 };
 
 class GVMutableArray_For_ConvertedGVMutableArray : public GVMutableArrayImpl {
@@ -458,6 +490,20 @@ class GVMutableArray_For_ConvertedGVMutableArray : public 
GVMutableArrayImpl {
 new_to_old_conversions_.convert_single_to_uninitialized(value, buffer);
 varray_.set_by_relocate(index, buffer);
   }
+
+  void materialize(const IndexMask mask, void *dst) const override
+  {
+type_->destruct_n(dst, mask.min_array_size());
+this->materialize_to_uninitialized(mask, dst);
+  }
+
+  void materialize_to_uninitialized(const IndexMask mask, void *dst) const 
override
+  {
+call_convert_to_uninitialized_fn(varray_,
+ *old_to_new_conversions_.multi_function,
+ mask,
+ {this->type(), dst, 
mask.min_array_size()});
+  }
 };
 
 GVArray DataTypeConversions::try_convert(GVArray varray, const CPPType 
_type) const
@@ -495,9 +541,8 @@ fn::GField DataTypeConversions::try_convert(fn::GField 
field, const CPPType _
   if (!this->is_convertible(from_type, to_type)) {
 return {};
   }
-  const fn::MultiFunction  =
-  *bke::get_implicit_type_conversions().get_conversion_multi_function(
-  fn::MFDataType::ForSingle(from_type), 
fn::MFDataType::ForSingle(to_type));
+  const fn::MultiFunction  = 

[Bf-blender-cvs] [8e8d9779b79] temp-sculpt-brush-channel: temp-sculpt-brush-channel: Brush channel system

2022-08-02 Thread Joseph Eagar
Commit: 8e8d9779b799bd3a6cd02b0c7f64983e87c3e9b7
Author: Joseph Eagar
Date:   Tue Aug 2 16:40:26 2022 -0700
Branches: temp-sculpt-brush-channel
https://developer.blender.org/rB8e8d9779b799bd3a6cd02b0c7f64983e87c3e9b7

temp-sculpt-brush-channel: Brush channel system

This branch is slimmed down version of sculpt-dev's
BrushChannel API.  The main differences are:

* BrushChannel wraps RNA properties instead of
  being a fully-formed property system on its
  own.  The exception are BrushCurve properties which
  don't exist in RNA.
* The brush command queue has been removed.
* BrushChannels still store data (so the .fvalue
  .ivalue .vector .curve members are still there),
  but except for curves these are mere runtime
  caches filled in from RNA.
* brush_channel_define.h still exists but no longer has
  all the property definitions; instead it merely defines
  which RNA properties are brush properties.
* There is no global CurveMapping cache, that's really
  only needed for the command queue sytem.
* Got rid of the awkward BRUSHSET_ macros.  Instead,
  brush channel API methods that takes channel names
  are prefixed with _ and wrapped in unprefixed versions
  that do the compile-time name checking.

Note that this is a work in progress

===

M   source/blender/CMakeLists.txt
M   source/blender/blenkernel/BKE_brush.h
A   source/blender/blenkernel/BKE_brush_channel.h
M   source/blender/blenkernel/CMakeLists.txt
M   source/blender/blenkernel/intern/brush.cc
A   source/blender/blenkernel/intern/brush_channel.cc
A   source/blender/blenkernel/intern/brush_channel_define.h
A   source/blender/makesdna/DNA_brush_channel_types.h
M   source/blender/makesdna/DNA_brush_types.h
M   source/blender/makesdna/DNA_scene_types.h
M   source/blender/makesrna/intern/CMakeLists.txt
M   source/blender/makesrna/intern/makesrna.c
M   source/blender/makesrna/intern/rna_brush.c
A   source/blender/makesrna/intern/rna_brush_channels.c
M   source/blender/makesrna/intern/rna_internal.h

===

diff --git a/source/blender/CMakeLists.txt b/source/blender/CMakeLists.txt
index 8ba6e7318bb..91f58474eb5 100644
--- a/source/blender/CMakeLists.txt
+++ b/source/blender/CMakeLists.txt
@@ -87,6 +87,7 @@ set(SRC_DNA_INC
   ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_workspace_types.h
   ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_world_types.h
   ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_xr_types.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_brush_channel_types.h
 )
 
 set(SRC_DNA_DEFAULTS_INC
diff --git a/source/blender/blenkernel/BKE_brush.h 
b/source/blender/blenkernel/BKE_brush.h
index 4d728002c87..a904b4d00ad 100644
--- a/source/blender/blenkernel/BKE_brush.h
+++ b/source/blender/blenkernel/BKE_brush.h
@@ -97,7 +97,11 @@ float BKE_brush_curve_strength_clamped(const struct Brush 
*br, float p, float le
  * Uses the brush curve control to find a strength value.
  */
 float BKE_brush_curve_strength(const struct Brush *br, float p, float len);
-
+float BKE_brush_curve_strength_ex(int curve_preset,
+  const struct CurveMapping *curve,
+  float p,
+  const float len,
+  const bool invert);
 /* Sampling. */
 
 /**
diff --git a/source/blender/blenkernel/BKE_brush_channel.h 
b/source/blender/blenkernel/BKE_brush_channel.h
new file mode 100644
index 000..44ecc85ffca
--- /dev/null
+++ b/source/blender/blenkernel/BKE_brush_channel.h
@@ -0,0 +1,203 @@
+#pragma once
+#pragma once
+
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup bke
+ * \brief New brush engine for sculpt
+ */
+
+#include "RNA_types.h"
+
+/*
+The new brush engine is based on command lists.  These lists
+will eventually be created by a node editor.
+
+Key is the concept of BrushChannels.  A brush channel is
+a logical parameter with a type, input settings (e.g. pen),
+a falloff curve, etc.
+
+Brush channels have a concept of inheritance.  There is a
+BrushChannelSet (collection of 

[Bf-blender-cvs] [fc1a53eb7b9] master: Cleanup: Remove unused function `uv_poly_copy_aspect`

2022-08-02 Thread Chris Blackbourn
Commit: fc1a53eb7b975d831bfb4fa783d52570e90044f7
Author: Chris Blackbourn
Date:   Wed Aug 3 09:51:55 2022 +1200
Branches: master
https://developer.blender.org/rBfc1a53eb7b975d831bfb4fa783d52570e90044f7

Cleanup: Remove unused function `uv_poly_copy_aspect`

===

M   source/blender/editors/uvedit/uvedit_intern.h
M   source/blender/editors/uvedit/uvedit_ops.c

===

diff --git a/source/blender/editors/uvedit/uvedit_intern.h 
b/source/blender/editors/uvedit/uvedit_intern.h
index 04128cf378c..434bfbc64f9 100644
--- a/source/blender/editors/uvedit/uvedit_intern.h
+++ b/source/blender/editors/uvedit/uvedit_intern.h
@@ -14,9 +14,6 @@ struct Scene;
 struct SpaceImage;
 struct wmOperatorType;
 
-/* geometric utilities */
-void uv_poly_copy_aspect(float uv_orig[][2], float uv[][2], float aspx, float 
aspy, int len);
-
 /* find nearest */
 
 typedef struct UvNearestHit {
diff --git a/source/blender/editors/uvedit/uvedit_ops.c 
b/source/blender/editors/uvedit/uvedit_ops.c
index 74a9989f550..5ebdfcec294 100644
--- a/source/blender/editors/uvedit/uvedit_ops.c
+++ b/source/blender/editors/uvedit/uvedit_ops.c
@@ -189,15 +189,6 @@ void uvedit_live_unwrap_update(SpaceImage *sima, Scene 
*scene, Object *obedit)
 /** \name Geometric Utilities
  * \{ */
 
-void uv_poly_copy_aspect(float uv_orig[][2], float uv[][2], float aspx, float 
aspy, int len)
-{
-  int i;
-  for (i = 0; i < len; i++) {
-uv[i][0] = uv_orig[i][0] * aspx;
-uv[i][1] = uv_orig[i][1] * aspy;
-  }
-}
-
 bool ED_uvedit_minmax_multi(
 const Scene *scene, Object **objects_edit, uint objects_len, float 
r_min[2], float r_max[2])
 {

___
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] [18377c4f5e4] master: UI: Improve circle drawing of cursor for uv sculpting

2022-08-02 Thread Chris Blackbourn
Commit: 18377c4f5e4727f6f0b58bd0bae7a5a5686ea0a0
Author: Chris Blackbourn
Date:   Wed Aug 3 09:38:51 2022 +1200
Branches: master
https://developer.blender.org/rB18377c4f5e4727f6f0b58bd0bae7a5a5686ea0a0

UI: Improve circle drawing of cursor for uv sculpting

Calculate segments based on radius.

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

===

M   release/scripts/modules/gpu_extras/presets.py
M   release/scripts/startup/bl_ui/space_toolsystem_toolbar.py

===

diff --git a/release/scripts/modules/gpu_extras/presets.py 
b/release/scripts/modules/gpu_extras/presets.py
index ac9fd3cc1ff..222d9032cfd 100644
--- a/release/scripts/modules/gpu_extras/presets.py
+++ b/release/scripts/modules/gpu_extras/presets.py
@@ -1,6 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0-or-later
 
-def draw_circle_2d(position, color, radius, *, segments=32):
+def draw_circle_2d(position, color, radius, *, segments=None):
 """
 Draw a circle.
 
@@ -11,10 +11,11 @@ def draw_circle_2d(position, color, radius, *, segments=32):
 :arg radius: Radius of the circle.
 :type radius: float
 :arg segments: How many segments will be used to draw the circle.
-Higher values give besser results but the drawing will take longer.
-:type segments: int
+Higher values give better results but the drawing will take longer.
+If None or not specified, an automatic value will be calculated.
+:type segments: int or None
 """
-from math import sin, cos, pi
+from math import sin, cos, pi, ceil, acos
 import gpu
 from gpu.types import (
 GPUBatch,
@@ -22,6 +23,12 @@ def draw_circle_2d(position, color, radius, *, segments=32):
 GPUVertFormat,
 )
 
+if segments is None:
+max_pixel_error = 0.25 # TODO: multiply 0.5 by display dpi
+segments = int(ceil(pi / acos(1.0 - max_pixel_error / radius)))
+segments = max(segments, 8)
+segments = min(segments, 1000)
+
 if segments <= 0:
 raise ValueError("Amount of segments must be greater than 0.")
 
diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py 
b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
index 470b78ae558..2e4c0e69e61 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
@@ -1889,7 +1889,7 @@ class _defs_image_uv_sculpt:
 if brush is None:
 return
 radius = brush.size
-draw_circle_2d(xy, (1.0,) * 4, radius, segments=32)
+draw_circle_2d(xy, (1.0,) * 4, radius)
 
 return generate_from_enum_ex(
 context,

___
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] [8081a05015f] master: Tests: Remove deprecated/removed operators from tests

2022-08-02 Thread Hans Goudey
Commit: 8081a05015f620db1d5759f80d9724699bbcd289
Author: Hans Goudey
Date:   Tue Aug 2 16:23:21 2022 -0500
Branches: master
https://developer.blender.org/rB8081a05015f620db1d5759f80d9724699bbcd289

Tests: Remove deprecated/removed operators from tests

44aa9e40ffe40c0b222c2f4675545a5777e27059

===

M   tests/python/bl_run_operators.py
M   tests/python/operators.py

===

diff --git a/tests/python/bl_run_operators.py b/tests/python/bl_run_operators.py
index a2478bd7547..ccb0814e5eb 100644
--- a/tests/python/bl_run_operators.py
+++ b/tests/python/bl_run_operators.py
@@ -317,7 +317,6 @@ def ctx_editmode_mesh_extra():
 bpy.ops.object.shape_key_add(from_mix=False)
 bpy.ops.object.shape_key_add(from_mix=True)
 bpy.ops.mesh.uv_texture_add()
-bpy.ops.mesh.vertex_color_add()
 bpy.ops.object.material_slot_add()
 # editmode last!
 bpy.ops.object.mode_set(mode='EDIT')
diff --git a/tests/python/operators.py b/tests/python/operators.py
index 3933fc1cd1c..fc2e8e39d4f 100644
--- a/tests/python/operators.py
+++ b/tests/python/operators.py
@@ -563,24 +563,6 @@ def main():
 )],
 ),
 
-# Vertex Colors
-SpecMeshTest(
-"VertexColorAdd", "testCubeColorAdd", "expectedCubeColorAdd",
-[OperatorSpecEditMode("vertex_color_add", {}, "VERT", {})],
-),
-SpecMeshTest(
-"VertexColorRemove", "testCubeColorRemove", 
"expectedCubeColorRemove",
-[OperatorSpecEditMode("vertex_color_remove", {}, "VERT", {})],
-),
-SpecMeshTest(
-"VertexColorSculptAdd", "testCubeSculptAdd", 
"expectedCubeSculptAdd",
-[OperatorSpecEditMode("sculpt_vertex_color_add", {}, "VERT", {})],
-),
-SpecMeshTest(
-"VertexColorSculptRemove", "testCubeSculptRemove", 
"expectedCubeSculptRemove",
-[OperatorSpecEditMode("sculpt_vertex_color_remove", {}, "VERT", 
{})],
-),
-
 # Laplacian Smooth
 SpecMeshTest(
 "LaplacianSmoothDefault", "testSphereLaplacianSmoothDefault", 
"expectedSphereLaplacianSmoothDefault",

___
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] [c5b361335aa] master: Cleanup: Simplify functions for adding and removing color attributes

2022-08-02 Thread Hans Goudey
Commit: c5b361335aaa1552627d3c217251461eb5f384a5
Author: Hans Goudey
Date:   Tue Aug 2 14:43:36 2022 -0500
Branches: master
https://developer.blender.org/rBc5b361335aaa1552627d3c217251461eb5f384a5

Cleanup: Simplify functions for adding and removing color attributes

The specific functions for vertex colors and and sculpt vertex colors
can be replaced by more generic attribute functions internally.
Also remove a paramter from one function.

===

M   source/blender/editors/include/ED_mesh.h
M   source/blender/editors/mesh/mesh_data.cc
M   source/blender/editors/physics/dynamicpaint_ops.c
M   source/blender/makesrna/intern/rna_mesh.c

===

diff --git a/source/blender/editors/include/ED_mesh.h 
b/source/blender/editors/include/ED_mesh.h
index d469c29945d..1981b069011 100644
--- a/source/blender/editors/include/ED_mesh.h
+++ b/source/blender/editors/include/ED_mesh.h
@@ -552,14 +552,10 @@ void ED_mesh_uv_loop_reset_ex(struct Mesh *me, int 
layernum);
 bool ED_mesh_color_ensure(struct Mesh *me, const char *name);
 int ED_mesh_color_add(
 struct Mesh *me, const char *name, bool active_set, bool do_init, struct 
ReportList *reports);
-bool ED_mesh_color_remove_index(struct Mesh *me, int n);
-bool ED_mesh_color_remove_active(struct Mesh *me);
-bool ED_mesh_color_remove_named(struct Mesh *me, const char *name);
-
-int ED_mesh_sculpt_color_add(
-struct Mesh *me, const char *name, bool active_set, bool do_init, struct 
ReportList *reports);
-bool ED_mesh_sculpt_color_remove_index(struct Mesh *me, int n);
-bool ED_mesh_sculpt_color_remove_named(struct Mesh *me, const char *name);
+int ED_mesh_sculpt_color_add(struct Mesh *me,
+ const char *name,
+ bool do_init,
+ struct ReportList *reports);
 
 void ED_mesh_report_mirror(struct wmOperator *op, int totmirr, int totfail);
 void ED_mesh_report_mirror_ex(struct wmOperator *op, int totmirr, int totfail, 
char selectmode);
diff --git a/source/blender/editors/mesh/mesh_data.cc 
b/source/blender/editors/mesh/mesh_data.cc
index 66e9b1ed673..971fab1508e 100644
--- a/source/blender/editors/mesh/mesh_data.cc
+++ b/source/blender/editors/mesh/mesh_data.cc
@@ -444,44 +444,6 @@ bool ED_mesh_color_ensure(Mesh *me, const char *name)
   return (layer != nullptr);
 }
 
-bool ED_mesh_color_remove_index(Mesh *me, const int n)
-{
-  CustomData *ldata = GET_CD_DATA(me, ldata);
-  CustomDataLayer *cdl;
-  int index;
-
-  index = CustomData_get_layer_index_n(ldata, CD_PROP_BYTE_COLOR, n);
-  cdl = (index == -1) ? nullptr : >layers[index];
-
-  if (!cdl) {
-return false;
-  }
-
-  delete_customdata_layer(me, cdl);
-  DEG_id_tag_update(>id, 0);
-  WM_main_add_notifier(NC_GEOM | ND_DATA, me);
-
-  return true;
-}
-bool ED_mesh_color_remove_active(Mesh *me)
-{
-  CustomData *ldata = GET_CD_DATA(me, ldata);
-  const int n = CustomData_get_active_layer(ldata, CD_PROP_BYTE_COLOR);
-  if (n != -1) {
-return ED_mesh_color_remove_index(me, n);
-  }
-  return false;
-}
-bool ED_mesh_color_remove_named(Mesh *me, const char *name)
-{
-  CustomData *ldata = GET_CD_DATA(me, ldata);
-  const int n = CustomData_get_named_layer(ldata, CD_PROP_BYTE_COLOR, name);
-  if (n != -1) {
-return ED_mesh_color_remove_index(me, n);
-  }
-  return false;
-}
-
 /*** General poll /
 
 static bool layers_poll(bContext *C)
@@ -494,8 +456,7 @@ static bool layers_poll(bContext *C)
 
 /*** Sculpt Vertex colors operators 
/
 
-int ED_mesh_sculpt_color_add(
-Mesh *me, const char *name, const bool active_set, const bool do_init, 
ReportList *reports)
+int ED_mesh_sculpt_color_add(Mesh *me, const char *name, const bool do_init, 
ReportList *reports)
 {
   /* NOTE: keep in sync with #ED_mesh_uv_add. */
 
@@ -519,7 +480,7 @@ int ED_mesh_sculpt_color_add(
   const int layernum_dst = CustomData_get_active_layer(>bm->vdata, 
CD_PROP_COLOR);
   BM_data_layer_copy(em->bm, >bm->vdata, CD_PROP_COLOR, layernum_dst, 
layernum);
 }
-if (active_set || layernum == 0) {
+if (layernum == 0) {
   CustomData_set_layer_active(>bm->vdata, CD_PROP_COLOR, layernum);
 }
   }
@@ -542,7 +503,7 @@ int ED_mesh_sculpt_color_add(
   >vdata, CD_PROP_COLOR, CD_DEFAULT, nullptr, me->totvert, name);
 }
 
-if (active_set || layernum == 0) {
+if (layernum == 0) {
   CustomData_set_layer_active(>vdata, CD_PROP_COLOR, layernum);
 }
 
@@ -555,35 +516,6 @@ int ED_mesh_sculpt_color_add(
   return layernum;
 }
 
-bool ED_mesh_sculpt_color_remove_index(Mesh *me, const int n)
-{
-  CustomData *vdata = GET_CD_DATA(me, vdata);
-  CustomDataLayer *cdl;
-  int index;
-
-  index = CustomData_get_layer_index_n(vdata, CD_PROP_COLOR, n);
-  cdl = (index == -1) ? nullptr : >layers[index];
-
-  

[Bf-blender-cvs] [44aa9e40ffe] master: Cleanup: Remove unused sculpt and vertex color operators

2022-08-02 Thread Hans Goudey
Commit: 44aa9e40ffe40c0b222c2f4675545a5777e27059
Author: Hans Goudey
Date:   Tue Aug 2 14:17:20 2022 -0500
Branches: master
https://developer.blender.org/rB44aa9e40ffe40c0b222c2f4675545a5777e27059

Cleanup: Remove unused sculpt and vertex color operators

The "Color Attributes" system from f7bbc7cdbb6cb0d2850 has replaced
both "Sculpt Vertex Colors" and "Vertex Colors" in the UI. The Operators
for adding and removing them are unused now.

This commit does not break backwards compatibility with the Python
API, it only removes the operators, which generally aren't used by
addons anyway. The mesh RNA properties will be removed in 4.0 (T100153).

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

===

M   source/blender/editors/include/ED_mesh.h
M   source/blender/editors/mesh/mesh_data.cc
M   source/blender/editors/mesh/mesh_intern.h
M   source/blender/editors/mesh/mesh_ops.c
M   source/blender/editors/sculpt_paint/sculpt_ops.c

===

diff --git a/source/blender/editors/include/ED_mesh.h 
b/source/blender/editors/include/ED_mesh.h
index b73b62d5a9d..d469c29945d 100644
--- a/source/blender/editors/include/ED_mesh.h
+++ b/source/blender/editors/include/ED_mesh.h
@@ -556,11 +556,9 @@ bool ED_mesh_color_remove_index(struct Mesh *me, int n);
 bool ED_mesh_color_remove_active(struct Mesh *me);
 bool ED_mesh_color_remove_named(struct Mesh *me, const char *name);
 
-bool ED_mesh_sculpt_color_ensure(struct Mesh *me, const char *name);
 int ED_mesh_sculpt_color_add(
 struct Mesh *me, const char *name, bool active_set, bool do_init, struct 
ReportList *reports);
 bool ED_mesh_sculpt_color_remove_index(struct Mesh *me, int n);
-bool ED_mesh_sculpt_color_remove_active(struct Mesh *me);
 bool ED_mesh_sculpt_color_remove_named(struct Mesh *me, const char *name);
 
 void ED_mesh_report_mirror(struct wmOperator *op, int totmirr, int totfail);
diff --git a/source/blender/editors/mesh/mesh_data.cc 
b/source/blender/editors/mesh/mesh_data.cc
index 67834bf05ce..66e9b1ed673 100644
--- a/source/blender/editors/mesh/mesh_data.cc
+++ b/source/blender/editors/mesh/mesh_data.cc
@@ -494,23 +494,6 @@ static bool layers_poll(bContext *C)
 
 /*** Sculpt Vertex colors operators 
/
 
-static bool sculpt_vertex_color_remove_poll(bContext *C)
-{
-  if (!layers_poll(C)) {
-return false;
-  }
-
-  Object *ob = ED_object_context(C);
-  Mesh *me = static_cast(ob->data);
-  CustomData *vdata = GET_CD_DATA(me, vdata);
-  const int active = CustomData_get_active_layer(vdata, CD_PROP_COLOR);
-  if (active != -1) {
-return true;
-  }
-
-  return false;
-}
-
 int ED_mesh_sculpt_color_add(
 Mesh *me, const char *name, const bool active_set, const bool do_init, 
ReportList *reports)
 {
@@ -572,20 +555,6 @@ int ED_mesh_sculpt_color_add(
   return layernum;
 }
 
-bool ED_mesh_sculpt_color_ensure(Mesh *me, const char *name)
-{
-  BLI_assert(me->edit_mesh == nullptr);
-
-  if (me->totvert && !CustomData_has_layer(>vdata, CD_PROP_COLOR)) {
-CustomData_add_layer_named(>vdata, CD_PROP_COLOR, CD_DEFAULT, nullptr, 
me->totvert, name);
-BKE_mesh_update_customdata_pointers(me, true);
-  }
-
-  DEG_id_tag_update(>id, 0);
-
-  return (me->mloopcol != nullptr);
-}
-
 bool ED_mesh_sculpt_color_remove_index(Mesh *me, const int n)
 {
   CustomData *vdata = GET_CD_DATA(me, vdata);
@@ -605,15 +574,6 @@ bool ED_mesh_sculpt_color_remove_index(Mesh *me, const int 
n)
 
   return true;
 }
-bool ED_mesh_sculpt_color_remove_active(Mesh *me)
-{
-  CustomData *vdata = GET_CD_DATA(me, vdata);
-  const int n = CustomData_get_active_layer(vdata, CD_PROP_COLOR);
-  if (n != -1) {
-return ED_mesh_sculpt_color_remove_index(me, n);
-  }
-  return false;
-}
 bool ED_mesh_sculpt_color_remove_named(Mesh *me, const char *name)
 {
   CustomData *vdata = GET_CD_DATA(me, vdata);
@@ -709,135 +669,6 @@ void MESH_OT_uv_texture_remove(wmOperatorType *ot)
   ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 }
 
-/*** vertex color operators /
-
-static bool vertex_color_remove_poll(bContext *C)
-{
-  if (!layers_poll(C)) {
-return false;
-  }
-
-  Object *ob = ED_object_context(C);
-  Mesh *me = static_cast(ob->data);
-  CustomData *ldata = GET_CD_DATA(me, ldata);
-  const int active = CustomData_get_active_layer(ldata, CD_PROP_BYTE_COLOR);
-  if (active != -1) {
-return true;
-  }
-
-  return false;
-}
-
-static int mesh_vertex_color_add_exec(bContext *C, wmOperator *op)
-{
-  Object *ob = ED_object_context(C);
-  Mesh *me = static_cast(ob->data);
-
-  if (ED_mesh_color_add(me, nullptr, true, true, op->reports) == -1) {
-return OPERATOR_CANCELLED;
-  }
-
-  return OPERATOR_FINISHED;
-}
-
-void MESH_OT_vertex_color_add(wmOperatorType *ot)
-{
-  /* identifiers */
-  ot->name = "Add Vertex Color";
-  ot->description = "Add vertex 

[Bf-blender-cvs] [a48e5c53a54] master: Cleanup: Simplify const cast in virtual array construction

2022-08-02 Thread Hans Goudey
Commit: a48e5c53a546cd5e493a9e816ce9ed71f0e61a8b
Author: Hans Goudey
Date:   Tue Aug 2 13:44:07 2022 -0500
Branches: master
https://developer.blender.org/rBa48e5c53a546cd5e493a9e816ce9ed71f0e61a8b

Cleanup: Simplify const cast in virtual array construction

===

M   source/blender/blenlib/BLI_virtual_array.hh

===

diff --git a/source/blender/blenlib/BLI_virtual_array.hh 
b/source/blender/blenlib/BLI_virtual_array.hh
index 438fcc4b8f7..7eab960b302 100644
--- a/source/blender/blenlib/BLI_virtual_array.hh
+++ b/source/blender/blenlib/BLI_virtual_array.hh
@@ -315,6 +315,12 @@ template class VArrayImpl_For_Span_final final 
: public VArrayImpl_F
  public:
   using VArrayImpl_For_Span::VArrayImpl_For_Span;
 
+  VArrayImpl_For_Span_final(const Span data)
+  /* Cast const away, because the implementation for const and non const 
spans is shared. */
+  : VArrayImpl_For_Span({const_cast(data.data()), data.size()})
+  {
+  }
+
  private:
   CommonVArrayInfo common_info() const final
   {
@@ -898,10 +904,7 @@ template class VArray : public VArrayCommon 
{
 
   VArray(varray_tag::span /* tag */, Span span)
   {
-/* Cast const away, because the virtual array implementation for const and 
non const spans is
- * shared. */
-MutableSpan mutable_span{const_cast(span.data()), span.size()};
-this->template emplace>(mutable_span);
+this->template emplace>(span);
   }
 
   VArray(varray_tag::single /* tag */, T value, const 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] [2ba2efc2969] master: Cleanup: Simplify arguments to sculpt draw functions

2022-08-02 Thread Hans Goudey
Commit: 2ba2efc29691762d3fb2002f54adafd536b2c37b
Author: Hans Goudey
Date:   Tue Aug 2 13:32:25 2022 -0500
Branches: master
https://developer.blender.org/rB2ba2efc29691762d3fb2002f54adafd536b2c37b

Cleanup: Simplify arguments to sculpt draw functions

Instead of passing pointers to specific mesh data, rely on
retrieving that data from the mesh internally. This makes
it easier to support retrieving additional data from Mesh
(like active attribute names in D15101 or D15169). It also makes
the functions simpler conceptually, because they're drawing
a mesh with an acceleration strcture on top.

The BKE_id_attribute_copy_domains_temp call was unnecessary
because the GPU_pbvh_mesh_buffers_update function was only
called when Mesh/PBVH_FACES is used in the first place.

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

===

M   source/blender/blenkernel/intern/pbvh.c
M   source/blender/gpu/GPU_buffers.h
M   source/blender/gpu/intern/gpu_buffers.c

===

diff --git a/source/blender/blenkernel/intern/pbvh.c 
b/source/blender/blenkernel/intern/pbvh.c
index ac3eac70c39..dae9788d21c 100644
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@ -1303,17 +1303,6 @@ static void pbvh_update_draw_buffer_cb(void *__restrict 
userdata,
   PBVH *pbvh = data->pbvh;
   PBVHNode *node = data->nodes[n];
 
-  CustomData *vdata, *ldata;
-
-  if (!pbvh->header.bm) {
-vdata = pbvh->vdata;
-ldata = pbvh->ldata;
-  }
-  else {
-vdata = >header.bm->vdata;
-ldata = >header.bm->ldata;
-  }
-
   if (node->flag & PBVH_RebuildDrawBuffers) {
 switch (pbvh->header.type) {
   case PBVH_GRIDS: {
@@ -1326,14 +1315,12 @@ static void pbvh_update_draw_buffer_cb(void *__restrict 
userdata,
   }
   case PBVH_FACES:
 node->draw_buffers = GPU_pbvh_mesh_buffers_build(
-pbvh->mpoly,
-pbvh->mloop,
-pbvh->looptri,
+pbvh->mesh,
 pbvh->verts,
-node->prim_indices,
+pbvh->looptri,
 CustomData_get_layer(pbvh->pdata, CD_SCULPT_FACE_SETS),
-node->totprim,
-pbvh->mesh);
+node->prim_indices,
+node->totprim);
 break;
   case PBVH_BMESH:
 node->draw_buffers = GPU_pbvh_bmesh_buffers_build(pbvh->flags &
@@ -1360,11 +1347,12 @@ static void pbvh_update_draw_buffer_cb(void *__restrict 
userdata,
  update_flags);
 break;
   case PBVH_FACES: {
+/* Pass vertices separately because they may be not be the same as the 
mesh's vertices,
+ * and pass normals separately because they are managed by the PBVH. */
 GPU_pbvh_mesh_buffers_update(pbvh->vbo_id,
  node->draw_buffers,
+ pbvh->mesh,
  pbvh->verts,
- vdata,
- ldata,
  CustomData_get_layer(pbvh->vdata, 
CD_PAINT_MASK),
  CustomData_get_layer(pbvh->pdata, 
CD_SCULPT_FACE_SETS),
  pbvh->face_sets_color_seed,
diff --git a/source/blender/gpu/GPU_buffers.h b/source/blender/gpu/GPU_buffers.h
index 89473ac0fe0..6dc49ff494d 100644
--- a/source/blender/gpu/GPU_buffers.h
+++ b/source/blender/gpu/GPU_buffers.h
@@ -22,6 +22,7 @@ struct CCGKey;
 struct DMFlagMat;
 struct GSet;
 struct TableGSet;
+struct Mesh;
 struct MLoop;
 struct MLoopCol;
 struct MLoopTri;
@@ -46,14 +47,12 @@ typedef struct GPU_PBVH_Buffers GPU_PBVH_Buffers;
  *
  * Threaded: do not call any functions that use OpenGL calls!
  */
-GPU_PBVH_Buffers *GPU_pbvh_mesh_buffers_build(const struct MPoly *mpoly,
-  const struct MLoop *mloop,
+GPU_PBVH_Buffers *GPU_pbvh_mesh_buffers_build(const struct Mesh *mesh,
+  const struct MVert *vertices,
   const struct MLoopTri *looptri,
-  const struct MVert *mvert,
-  const int *face_indices,
   const int *sculpt_face_sets,
-  int face_indices_len,
-  const struct Mesh *mesh);
+  const int *face_indices,
+  int face_indices_len);
 
 /**
  * Threaded: do not call any functions that use OpenGL calls!
@@ -91,9 +90,8 @@ enum {
  */
 void GPU_pbvh_mesh_buffers_update(PBVHGPUFormat *vbo_id,
   GPU_PBVH_Buffers *buffers,
+ 

[Bf-blender-cvs] [0a65e1a8e7a] blender-v2.93-release: Release cycle: Blender 2.93.10 release.

2022-08-02 Thread Thomas Dinges
Commit: 0a65e1a8e7a95544cb36755a7a661cb86afafa64
Author: Thomas Dinges
Date:   Tue Aug 2 20:21:24 2022 +0200
Branches: blender-v2.93-release
https://developer.blender.org/rB0a65e1a8e7a95544cb36755a7a661cb86afafa64

Release cycle: Blender 2.93.10 release.

===

M   source/blender/blenkernel/BKE_blender_version.h

===

diff --git a/source/blender/blenkernel/BKE_blender_version.h 
b/source/blender/blenkernel/BKE_blender_version.h
index d9173a1b04c..c31701eba4f 100644
--- a/source/blender/blenkernel/BKE_blender_version.h
+++ b/source/blender/blenkernel/BKE_blender_version.h
@@ -35,7 +35,7 @@ extern "C" {
 /* Blender patch version for bugfix releases. */
 #define BLENDER_VERSION_PATCH 10
 /** Blender release cycle stage: alpha/beta/rc/release. */
-#define BLENDER_VERSION_CYCLE rc
+#define BLENDER_VERSION_CYCLE release
 
 /* Blender file format version. */
 #define BLENDER_FILE_VERSION BLENDER_VERSION

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


[Bf-blender-cvs] [bcfdb14560e] blender-v3.2-release: Release cycle: Blender 3.2.2 release

2022-08-02 Thread Thomas Dinges
Commit: bcfdb14560e77891d674c2701a5071a7c07baba3
Author: Thomas Dinges
Date:   Tue Aug 2 20:15:17 2022 +0200
Branches: blender-v3.2-release
https://developer.blender.org/rBbcfdb14560e77891d674c2701a5071a7c07baba3

Release cycle: Blender 3.2.2 release

===

M   source/blender/blenkernel/BKE_blender_version.h

===

diff --git a/source/blender/blenkernel/BKE_blender_version.h 
b/source/blender/blenkernel/BKE_blender_version.h
index 6dceeef5312..3285d45a291 100644
--- a/source/blender/blenkernel/BKE_blender_version.h
+++ b/source/blender/blenkernel/BKE_blender_version.h
@@ -21,7 +21,7 @@ extern "C" {
 /* Blender patch version for bugfix releases. */
 #define BLENDER_VERSION_PATCH 2
 /** Blender release cycle stage: alpha/beta/rc/release. */
-#define BLENDER_VERSION_CYCLE rc
+#define BLENDER_VERSION_CYCLE release
 
 /* Blender file format version. */
 #define BLENDER_FILE_VERSION BLENDER_VERSION

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


[Bf-blender-cvs] [cd800656865] blender-v3.2-release: Fix T100049: Crash when render finishes

2022-08-02 Thread Richard Antalik
Commit: cd800656865e6feed6a4f72d6bf5b33a67cbad40
Author: Richard Antalik
Date:   Tue Aug 2 17:52:40 2022 +0200
Branches: blender-v3.2-release
https://developer.blender.org/rBcd800656865e6feed6a4f72d6bf5b33a67cbad40

Fix T100049: Crash when render finishes

Caused by NULL dereference of `Editing` before NULL check was done.

===

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

===

diff --git a/source/blender/sequencer/intern/utils.c 
b/source/blender/sequencer/intern/utils.c
index 0cf47420d8f..751cf680651 100644
--- a/source/blender/sequencer/intern/utils.c
+++ b/source/blender/sequencer/intern/utils.c
@@ -384,14 +384,15 @@ void seq_open_anim_file(Scene *scene, Sequence *seq, bool 
openfile)
 const Sequence *SEQ_get_topmost_sequence(const Scene *scene, int frame)
 {
   Editing *ed = scene->ed;
-  ListBase *channels = SEQ_channels_displayed_get(ed);
-  const Sequence *seq, *best_seq = NULL;
-  int best_machine = -1;
 
   if (!ed) {
 return NULL;
   }
 
+  ListBase *channels = SEQ_channels_displayed_get(ed);
+  const Sequence *seq, *best_seq = NULL;
+  int best_machine = -1;
+
   for (seq = ed->seqbasep->first; seq; seq = seq->next) {
 if (SEQ_render_is_muted(channels, seq) || 
!SEQ_time_strip_intersects_frame(seq, frame)) {
   continue;

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

2022-08-02 Thread Aras Pranckevicius
Commit: 5ddaf2fa7b878e8c6299033e9f9392a0a174dde5
Author: Aras Pranckevicius
Date:   Tue Aug 2 21:01:54 2022 +0300
Branches: master
https://developer.blender.org/rB5ddaf2fa7b878e8c6299033e9f9392a0a174dde5

Merge branch 'blender-v3.3-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] [ead8260a49d] blender-v3.3-release: Object: move collection resync after empty duplicate early-out

2022-08-02 Thread Aras Pranckevicius
Commit: ead8260a49debaeb69967b2b4d2b62bf9728
Author: Aras Pranckevicius
Date:   Tue Aug 2 21:01:09 2022 +0300
Branches: blender-v3.3-release
https://developer.blender.org/rBead8260a49debaeb69967b2b4d2b62bf9728

Object: move collection resync after empty duplicate early-out

As pointed out in rB02b1a209be88 comment, the BKE_main_collection_sync
should be after "nothing to duplicate" early-out.

===

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 55366348f38..acd7a8e3c13 100644
--- a/source/blender/editors/object/object_add.cc
+++ b/source/blender/editors/object/object_add.cc
@@ -3715,14 +3715,15 @@ static int duplicate_exec(bContext *C, wmOperator *op)
 }
   }
   CTX_DATA_END;
-  /* Sync the collection now, after everything is duplicated. */
   BKE_layer_collection_resync_allow();
-  BKE_main_collection_sync(bmain);
 
   if (source_bases_new_objects.is_empty()) {
 return OPERATOR_CANCELLED;
   }
 
+  /* Sync the collection now, after everything is duplicated. */
+  BKE_main_collection_sync(bmain);
+
   /* After sync we can get to the new Base data, process it here. */
   for (const auto  : source_bases_new_objects) {
 Object *ob_new = item.second;

___
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] [b010985e4ac] master: Fix T99255: Strips inserting incorrectly

2022-08-02 Thread Sebastian Parborg
Commit: b010985e4ac49a98e12802567efdf6b38f7b5bf2
Author: Sebastian Parborg
Date:   Tue Aug 2 19:36:42 2022 +0200
Branches: master
https://developer.blender.org/rBb010985e4ac49a98e12802567efdf6b38f7b5bf2

Fix T99255: Strips inserting incorrectly

When dropping file to sequencer timeline, coordinates for strip position
and overlap handling are used even if not set.

Reset internal state in on_drag_start callback and set is_modal
variable only if coordinates are updated. This way when dragging file
from external file browser, strip is added at current frame as before
modal operator was implemented.

Reviewed By: Richard Antalik

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

===

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

===

diff --git a/source/blender/editors/space_sequencer/sequencer_drag_drop.c 
b/source/blender/editors/space_sequencer/sequencer_drag_drop.c
index f6561cf07b9..4796d80b3a0 100644
--- a/source/blender/editors/space_sequencer/sequencer_drag_drop.c
+++ b/source/blender/editors/space_sequencer/sequencer_drag_drop.c
@@ -51,7 +51,9 @@
 typedef struct SeqDropCoords {
   float start_frame, channel;
   int strip_len, channel_len;
+  float playback_rate;
   bool in_use;
+  bool has_read_mouse_pos;
   bool is_intersecting;
   bool use_snapping;
   float snap_point_x;
@@ -63,7 +65,7 @@ typedef struct SeqDropCoords {
  * preloading data on drag start.
  * Therefore we will for now use a global variable for this.
  */
-static SeqDropCoords g_drop_coords = {.in_use = false};
+static SeqDropCoords g_drop_coords = {.in_use = false, .has_read_mouse_pos = 
false};
 
 static void generic_poll_operations(const wmEvent *event, uint8_t type)
 {
@@ -82,31 +84,134 @@ static bool image_drop_poll(bContext *UNUSED(C), wmDrag 
*drag, const wmEvent *ev
 }
   }
 
-  return WM_drag_is_ID_type(drag, ID_IM);
+  if (WM_drag_is_ID_type(drag, ID_IM)) {
+generic_poll_operations(event, TH_SEQ_IMAGE);
+return true;
+  }
+
+  return false;
 }
 
-static bool movie_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent 
*event)
+static bool is_movie(wmDrag *drag)
 {
   if (drag->type == WM_DRAG_PATH) {
-if (ELEM(drag->icon, 0, ICON_FILE_MOVIE, ICON_FILE_BLANK)) { /* Rule might 
not work? */
-  generic_poll_operations(event, TH_SEQ_MOVIE);
+if (ELEM(drag->icon, ICON_FILE_MOVIE, ICON_FILE_BLANK)) { /* Rule might 
not work? */
   return true;
 }
   }
+  if (WM_drag_is_ID_type(drag, ID_MC)) {
+return true;
+  }
+  return false;
+}
+
+static bool movie_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent 
*event)
+{
+  if (is_movie(drag)) {
+generic_poll_operations(event, TH_SEQ_MOVIE);
+return true;
+  }
 
-  return WM_drag_is_ID_type(drag, ID_MC);
+  return false;
 }
 
-static bool sound_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent 
*event)
+static bool is_sound(wmDrag *drag)
 {
   if (drag->type == WM_DRAG_PATH) {
 if (ELEM(drag->icon, ICON_FILE_SOUND, ICON_FILE_BLANK)) { /* Rule might 
not work? */
-  generic_poll_operations(event, TH_SEQ_AUDIO);
   return true;
 }
   }
+  if (WM_drag_is_ID_type(drag, ID_SO)) {
+return true;
+  }
+  return false;
+}
 
-  return WM_drag_is_ID_type(drag, ID_SO);
+static bool sound_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent 
*event)
+{
+  if (is_sound(drag)) {
+generic_poll_operations(event, TH_SEQ_AUDIO);
+return true;
+  }
+
+  return false;
+}
+
+static float update_overlay_strip_position_data(bContext *C, const int mval[2])
+{
+  SeqDropCoords *coords = _drop_coords;
+  ARegion *region = CTX_wm_region(C);
+  Scene *scene = CTX_data_scene(C);
+  int hand;
+  View2D *v2d = >v2d;
+
+  /* Update the position were we would place the strip if we complete the drag 
and drop action.
+   */
+  UI_view2d_region_to_view(v2d, mval[0], mval[1], >start_frame, 
>channel);
+  coords->start_frame = roundf(coords->start_frame);
+  if (coords->channel < 1.0f) {
+coords->channel = 1;
+  }
+
+  float start_frame = coords->start_frame;
+  float end_frame;
+  float strip_len;
+
+  if (coords->playback_rate != 0.0f) {
+float scene_playback_rate = (float)scene->r.frs_sec / 
scene->r.frs_sec_base;
+strip_len = coords->strip_len / (coords->playback_rate / 
scene_playback_rate);
+  }
+  else {
+strip_len = coords->strip_len;
+  }
+
+  end_frame = coords->start_frame + strip_len;
+
+  if (coords->use_snapping) {
+/* Do snapping via the existing transform code. */
+int snap_delta;
+float snap_frame;
+bool valid_snap;
+
+valid_snap = ED_transform_snap_sequencer_to_closest_strip_calc(
+scene, region, start_frame, end_frame, _delta, _frame);
+
+if (valid_snap) {
+  /* We snapped onto something! */
+  start_frame += snap_delta;
+  coords->start_frame = start_frame;
+  end_frame = start_frame + 

[Bf-blender-cvs] [41fb4bedb81] refactor-mesh-hide-generic: Skip legacy conversion when reading and writing undo steps

2022-08-02 Thread Hans Goudey
Commit: 41fb4bedb81603956d8a8f1b61614fd6f920a71a
Author: Hans Goudey
Date:   Tue Aug 2 11:57:00 2022 -0500
Branches: refactor-mesh-hide-generic
https://developer.blender.org/rB41fb4bedb81603956d8a8f1b61614fd6f920a71a

Skip legacy conversion when reading and writing undo steps

===

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

===

diff --git a/source/blender/blenkernel/intern/mesh.cc 
b/source/blender/blenkernel/intern/mesh.cc
index bc9f29572bd..74b8f811e30 100644
--- a/source/blender/blenkernel/intern/mesh.cc
+++ b/source/blender/blenkernel/intern/mesh.cc
@@ -251,7 +251,9 @@ static void mesh_blend_write(BlendWriter *writer, ID *id, 
const void *id_address
 CustomData_blend_write_prepare(mesh->pdata, poly_layers);
   }
 
-  BKE_mesh_legacy_convert_hide_layers_to_flags(mesh);
+  if (!BLO_write_is_undo(writer)) {
+BKE_mesh_legacy_convert_hide_layers_to_flags(mesh);
+  }
 
   BLO_write_id_struct(writer, Mesh, id_address, >id);
   BKE_id_blend_write(writer, >id);
@@ -329,7 +331,9 @@ static void mesh_blend_read_data(BlendDataReader *reader, 
ID *id)
 }
   }
 
-  BKE_mesh_legacy_convert_flags_to_hide_layers(mesh);
+  if (!BLO_read_data_is_undo(reader)) {
+BKE_mesh_legacy_convert_flags_to_hide_layers(mesh);
+  }
 
   /* We don't expect to load normals from files, since they are derived data. 
*/
   BKE_mesh_normals_tag_dirty(mesh);

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


[Bf-blender-cvs] [8ac6bb57380] refactor-mesh-bevel-weight-generic: Fix python API

2022-08-02 Thread Hans Goudey
Commit: 8ac6bb573804b2addac67af6da137140b080e2ec
Author: Hans Goudey
Date:   Tue Aug 2 11:35:50 2022 -0500
Branches: refactor-mesh-bevel-weight-generic
https://developer.blender.org/rB8ac6bb573804b2addac67af6da137140b080e2ec

Fix python API

===

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

===

diff --git a/source/blender/makesrna/intern/rna_mesh.c 
b/source/blender/makesrna/intern/rna_mesh.c
index ae42fa927dc..c2107462169 100644
--- a/source/blender/makesrna/intern/rna_mesh.c
+++ b/source/blender/makesrna/intern/rna_mesh.c
@@ -352,6 +352,9 @@ static void rna_Mesh_update_positions_tag(Main *bmain, 
Scene *scene, PointerRNA
 /** \name Property get/set Callbacks
  * \{ */
 
+static int rna_MeshVertex_index_get(PointerRNA *ptr);
+static int rna_MeshEdge_index_get(PointerRNA *ptr);
+
 static void rna_MeshVertex_normal_get(PointerRNA *ptr, float *value)
 {
   Mesh *mesh = rna_mesh(ptr);
@@ -367,33 +370,33 @@ static void rna_MeshVertex_normal_get(PointerRNA *ptr, 
float *value)
 static float rna_MeshVertex_bevel_weight_get(PointerRNA *ptr)
 {
   const Mesh *mesh = rna_mesh(ptr);
-  const MVert *vert = (const MVert *)ptr->data;
+  const int index = rna_MeshVertex_index_get(ptr);
   const float *values = CustomData_get_layer(>vdata, CD_BWEIGHT);
-  return values[vert - mesh->mvert];
+  return values == NULL ? 0.0f : values[index];
 }
 
 static void rna_MeshVertex_bevel_weight_set(PointerRNA *ptr, float value)
 {
-  const Mesh *mesh = rna_mesh(ptr);
-  MVert *vert = (MVert *)ptr->data;
-  float *values = CustomData_get_layer(>vdata, CD_BWEIGHT);
-  values[vert - mesh->mvert] = clamp_f(value, 0.0f, 1.0f);
+  Mesh *mesh = rna_mesh(ptr);
+  const int index = rna_MeshVertex_index_get(ptr);
+  float *values = CustomData_add_layer(>vdata, CD_BWEIGHT, CD_CALLOC, 
NULL, mesh->totvert);
+  values[index] = clamp_f(value, 0.0f, 1.0f);
 }
 
 static float rna_MEdge_bevel_weight_get(PointerRNA *ptr)
 {
   const Mesh *mesh = rna_mesh(ptr);
-  const MEdge *edge = (const MEdge *)ptr->data;
+  const int index = rna_MeshEdge_index_get(ptr);
   const float *values = CustomData_get_layer(>edata, CD_BWEIGHT);
-  return values[edge - mesh->medge];
+  return values == NULL ? 0.0f : values[index];
 }
 
 static void rna_MEdge_bevel_weight_set(PointerRNA *ptr, float value)
 {
   Mesh *mesh = rna_mesh(ptr);
-  const MEdge *edge = (const MEdge *)ptr->data;
-  float *values = CustomData_get_layer(>edata, CD_BWEIGHT);
-  values[edge - mesh->medge] = clamp_f(value, 0.0f, 1.0f);
+  const int index = rna_MeshEdge_index_get(ptr);
+  float *values = CustomData_add_layer(>edata, CD_BWEIGHT, CD_CALLOC, 
NULL, mesh->totedge);
+  values[index] = clamp_f(value, 0.0f, 1.0f);
 }
 
 static float rna_MEdge_crease_get(PointerRNA *ptr)

___
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] [01bb6863922] refactor-mesh-bevel-weight-generic: Skip legacy conversion in undo reading and writing

2022-08-02 Thread Hans Goudey
Commit: 01bb68639229b765fbc633feba166bc4b8d351e0
Author: Hans Goudey
Date:   Tue Aug 2 11:47:00 2022 -0500
Branches: refactor-mesh-bevel-weight-generic
https://developer.blender.org/rB01bb68639229b765fbc633feba166bc4b8d351e0

Skip legacy conversion in undo reading and writing

===

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

===

diff --git a/source/blender/blenkernel/intern/mesh.cc 
b/source/blender/blenkernel/intern/mesh.cc
index b777642368c..5775d29479e 100644
--- a/source/blender/blenkernel/intern/mesh.cc
+++ b/source/blender/blenkernel/intern/mesh.cc
@@ -252,7 +252,9 @@ static void mesh_blend_write(BlendWriter *writer, ID *id, 
const void *id_address
 CustomData_blend_write_prepare(mesh->pdata, poly_layers);
   }
 
-  BKE_mesh_legacy_bevel_weight_from_layers(mesh);
+  if (!BLO_write_is_undo(writer)) {
+BKE_mesh_legacy_bevel_weight_from_layers(mesh);
+  }
 
   BLO_write_id_struct(writer, Mesh, id_address, >id);
   BKE_id_blend_write(writer, >id);
@@ -330,7 +332,9 @@ static void mesh_blend_read_data(BlendDataReader *reader, 
ID *id)
 }
   }
 
-  BKE_mesh_legacy_bevel_weight_to_layers(mesh);
+  if (!BLO_read_data_is_undo(reader)) {
+BKE_mesh_legacy_bevel_weight_to_layers(mesh);
+  }
 
   /* We don't expect to load normals from files, since they are derived data. 
*/
   BKE_mesh_normals_tag_dirty(mesh);

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


[Bf-blender-cvs] [2282b7c6d96] refactor-mesh-bevel-weight-generic: Add comments on MVert and MEdge

2022-08-02 Thread Hans Goudey
Commit: 2282b7c6d96ba5a69738a57e02d5311e55d40be8
Author: Hans Goudey
Date:   Tue Aug 2 11:46:30 2022 -0500
Branches: refactor-mesh-bevel-weight-generic
https://developer.blender.org/rB2282b7c6d96ba5a69738a57e02d5311e55d40be8

Add comments on MVert and MEdge

===

M   source/blender/makesdna/DNA_meshdata_types.h

===

diff --git a/source/blender/makesdna/DNA_meshdata_types.h 
b/source/blender/makesdna/DNA_meshdata_types.h
index e724436c3cf..c8081c49ca4 100644
--- a/source/blender/makesdna/DNA_meshdata_types.h
+++ b/source/blender/makesdna/DNA_meshdata_types.h
@@ -26,6 +26,9 @@ extern "C" {
 typedef struct MVert {
   float co[3];
   char flag;
+  /**
+   * Deprecated bevel weight storage, now located in #CD_BWEIGHT, except for 
file read and write.
+   */
   char bweight DNA_DEPRECATED;
   char _pad[2];
 } MVert;
@@ -45,6 +48,9 @@ typedef struct MEdge {
   /** Un-ordered vertex indices (cannot match). */
   unsigned int v1, v2;
   char crease;
+  /**
+   * Deprecated bevel weight storage, now located in #CD_BWEIGHT, except for 
file read and write.
+   */
   char bweight DNA_DEPRECATED;
   short flag;
 } MEdge;

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

2022-08-02 Thread Hans Goudey
Commit: c810c3c3a511c5dc2612bf1002af6de1d340f3a5
Author: Hans Goudey
Date:   Tue Aug 2 11:19:59 2022 -0500
Branches: refactor-mesh-bevel-weight-generic
https://developer.blender.org/rBc810c3c3a511c5dc2612bf1002af6de1d340f3a5

Merge branch 'master' into refactor-mesh-bevel-weight-generic

===



===



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


[Bf-blender-cvs] [475d5a38eed] refactor-mesh-hide-generic: Merge branch 'master' into refactor-mesh-hide-generic

2022-08-02 Thread Hans Goudey
Commit: 475d5a38eed7a679c1a3cb10714cb7ab88c265a7
Author: Hans Goudey
Date:   Tue Aug 2 11:17:31 2022 -0500
Branches: refactor-mesh-hide-generic
https://developer.blender.org/rB475d5a38eed7a679c1a3cb10714cb7ab88c265a7

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

===



===

diff --cc source/blender/editors/sculpt_paint/sculpt.c
index 20cc48f3d83,17acf8d884e..85cc1b526ab
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@@ -344,12 -344,9 +344,11 @@@ int SCULPT_active_face_set_get(SculptSe
  void SCULPT_vertex_visible_set(SculptSession *ss, PBVHVertRef vertex, bool 
visible)
  {
switch (BKE_pbvh_type(ss->pbvh)) {
 -case PBVH_FACES:
 -  SET_FLAG_FROM_TEST(ss->mvert[vertex.i].flag, !visible, ME_HIDE);
 +case PBVH_FACES: {
 +  bool *hide_vert = BKE_pbvh_get_vert_hide_for_write(ss->pbvh);
 +  hide_vert[vertex.i] = visible;
-   BKE_pbvh_vert_mark_update(ss->pbvh, vertex);
break;
 +}
  case PBVH_BMESH: {
BMVert *v = (BMVert *)vertex.i;
BM_elem_flag_set(v, BM_ELEM_HIDDEN, !visible);
diff --cc source/blender/editors/sculpt_paint/sculpt_undo.c
index eca663d21b9,85778f4f00a..99f6a45ce1a
--- a/source/blender/editors/sculpt_paint/sculpt_undo.c
+++ b/source/blender/editors/sculpt_paint/sculpt_undo.c
@@@ -312,14 -346,15 +346,14 @@@ static bool sculpt_undo_restore_hidden(
SculptSession *ss = ob->sculpt;
SubdivCCG *subdiv_ccg = ss->subdiv_ccg;
  
 -  if (unode->maxvert) {
 -MVert *mvert = ss->mvert;
 +  bool *hide_vert = BKE_pbvh_get_vert_hide_for_write(ss->pbvh);
  
 +  if (unode->maxvert) {
  for (int i = 0; i < unode->totvert; i++) {
 -  MVert *v = [unode->index[i]];
 -  if ((BLI_BITMAP_TEST(unode->vert_hidden, i) != 0) != ((v->flag & 
ME_HIDE) != 0)) {
 +  if ((BLI_BITMAP_TEST(unode->vert_hidden, i) != 0) != hide_vert[i]) {
  BLI_BITMAP_FLIP(unode->vert_hidden, i);
- hide_vert[i] = !hide_vert[i];
- BKE_pbvh_vert_mark_update(ss->pbvh, 
BKE_pbvh_make_vref(unode->index[i]));
 -v->flag ^= ME_HIDE;
++hide_vert[unode->index[i]] = !hide_vert[i];
+ modified_vertices[unode->index[i]] = 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] [2d4498e457d] master: Merge branch 'blender-v3.3-release'

2022-08-02 Thread Hans Goudey
Commit: 2d4498e457d308d29b4617ba681f332262bc8ddf
Author: Hans Goudey
Date:   Tue Aug 2 11:09:22 2022 -0500
Branches: master
https://developer.blender.org/rB2d4498e457d308d29b4617ba681f332262bc8ddf

Merge branch 'blender-v3.3-release'

===



===

diff --cc source/blender/blenkernel/BKE_pbvh.h
index 2f4618e6f7a,5641ff0ba34..af7effe806c
--- a/source/blender/blenkernel/BKE_pbvh.h
+++ b/source/blender/blenkernel/BKE_pbvh.h
@@@ -427,7 -308,7 +427,7 @@@ void BKE_pbvh_node_fully_unmasked_set(P
  bool BKE_pbvh_node_fully_unmasked_get(PBVHNode *node);
  
  void BKE_pbvh_mark_rebuild_pixels(PBVH *pbvh);
- void BKE_pbvh_vert_mark_update(PBVH *pbvh, PBVHVertRef vertex);
 -void BKE_pbvh_vert_tag_update_normal(PBVH *pbvh, int index);
++void BKE_pbvh_vert_tag_update_normal(PBVH *pbvh, PBVHVertRef vertex);
  
  void BKE_pbvh_node_get_grids(PBVH *pbvh,
   PBVHNode *node,
diff --cc source/blender/blenkernel/intern/pbvh.c
index 0ec7a79f890,8c1f19f0909..ac3eac70c39
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@@ -1953,10 -1964,10 +1953,10 @@@ bool BKE_pbvh_node_fully_unmasked_get(P
return (node->flag & PBVH_Leaf) && (node->flag & PBVH_FullyUnmasked);
  }
  
- void BKE_pbvh_vert_mark_update(PBVH *pbvh, PBVHVertRef index)
 -void BKE_pbvh_vert_tag_update_normal(PBVH *pbvh, int index)
++void BKE_pbvh_vert_tag_update_normal(PBVH *pbvh, PBVHVertRef vertex)
  {
 -  BLI_assert(pbvh->type == PBVH_FACES);
 -  pbvh->vert_bitmap[index] = true;
 +  BLI_assert(pbvh->header.type == PBVH_FACES);
-   pbvh->vert_bitmap[index.i] = true;
++  pbvh->vert_bitmap[vertex.i] = true;
  }
  
  void BKE_pbvh_node_get_loops(PBVH *pbvh,
@@@ -2112,9 -2123,9 +2112,9 @@@ void BKE_pbvh_node_get_bm_orco_data(PBV
*r_orco_coords = node->bm_orco;
  }
  
- bool BKE_pbvh_node_vert_update_check_any(PBVH *pbvh, PBVHNode *node)
+ bool BKE_pbvh_node_has_vert_with_normal_update_tag(PBVH *pbvh, PBVHNode *node)
  {
 -  BLI_assert(pbvh->type == PBVH_FACES);
 +  BLI_assert(pbvh->header.type == PBVH_FACES);
const int *verts = node->vert_indices;
const int totvert = node->uniq_verts + node->face_verts;
  
@@@ -2980,7 -2991,7 +2980,7 @@@ void BKE_pbvh_vert_coords_apply(PBVH *p
/* no need for float comparison here (memory is exactly equal or not) */
if (memcmp(mvert->co, vertCos[a], sizeof(float[3])) != 0) {
  copy_v3_v3(mvert->co, vertCos[a]);
- BKE_pbvh_vert_mark_update(pbvh, BKE_pbvh_make_vref(a));
 -BKE_pbvh_vert_tag_update_normal(pbvh, a);
++BKE_pbvh_vert_tag_update_normal(pbvh, BKE_pbvh_make_vref(a));
}
  }
  
diff --cc source/blender/editors/sculpt_paint/paint_mask.c
index a5389f7fd83,b861d0c84da..2e57886fd95
--- a/source/blender/editors/sculpt_paint/paint_mask.c
+++ b/source/blender/editors/sculpt_paint/paint_mask.c
@@@ -1439,7 -1437,7 +1439,7 @@@ static void project_line_gesture_apply_
  }
  add_v3_v3(vd.co, disp);
  if (vd.mvert) {
-   BKE_pbvh_vert_mark_update(sgcontext->ss->pbvh, vd.vertex);
 -  BKE_pbvh_vert_tag_update_normal(sgcontext->ss->pbvh, vd.index);
++  BKE_pbvh_vert_tag_update_normal(sgcontext->ss->pbvh, vd.vertex);
  }
  any_updated = true;
}
diff --cc source/blender/editors/sculpt_paint/sculpt.c
index 2366089cefb,4b902b7fca9..17acf8d884e
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@@ -345,14 -342,12 +345,13 @@@ void SCULPT_vertex_visible_set(SculptSe
  {
switch (BKE_pbvh_type(ss->pbvh)) {
  case PBVH_FACES:
 -  SET_FLAG_FROM_TEST(ss->mvert[index].flag, !visible, ME_HIDE);
 -  BKE_pbvh_vert_tag_update_normal(ss->pbvh, index);
 +  SET_FLAG_FROM_TEST(ss->mvert[vertex.i].flag, !visible, ME_HIDE);
-   BKE_pbvh_vert_mark_update(ss->pbvh, vertex);
break;
 -case PBVH_BMESH:
 -  BM_elem_flag_set(BM_vert_at_index(ss->bm, index), BM_ELEM_HIDDEN, 
!visible);
 +case PBVH_BMESH: {
 +  BMVert *v = (BMVert *)vertex.i;
 +  BM_elem_flag_set(v, BM_ELEM_HIDDEN, !visible);
break;
 +}
  case PBVH_GRIDS:
break;
}
@@@ -1444,17 -1407,16 +1442,16 @@@ static void paint_mesh_restore_co_task_
else {
  copy_v3_v3(vd.fno, orig_data.no);
}
+   if (vd.mvert) {
 -BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.index);
++BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
+   }
  }
  else if (orig_data.unode->type == SCULPT_UNDO_MASK) {
*vd.mask = orig_data.mask;
  }
  else if (orig_data.unode->type == SCULPT_UNDO_COLOR) {
 -  SCULPT_vertex_color_set(ss, vd.index, orig_data.col);
 +  SCULPT_vertex_color_set(ss, vd.vertex, orig_data.col);
  }
- 
- if (vd.mvert) {
-   BKE_pbvh_vert_mark_update(ss->pbvh, vd.vertex);
- }
}

[Bf-blender-cvs] [efe0e2b1837] blender-v3.3-release: Fix T96810: Invalid sculpt normals after some operations

2022-08-02 Thread Hans Goudey
Commit: efe0e2b18370972c14383e809719c2b606abc414
Author: Hans Goudey
Date:   Tue Aug 2 11:00:38 2022 -0500
Branches: blender-v3.3-release
https://developer.blender.org/rBefe0e2b18370972c14383e809719c2b606abc414

Fix T96810: Invalid sculpt normals after some operations

Mask and color brushes were using the existing PBVH vertex "update tag"
to mark their modifications. This was mostly unnecessary, and causes
unnecessary calculation of normals. It also caused errors though,
because they didn't tag the corresponding PBVH node for normal
recalculation, causing problems on the borders of nodes, since one
node might accumulate into another's vertex normals, but the other
node wouldn't also accumulate and normalize the normals.

The solution is to only use the update tag for tagging deformed
vertices that need recalculated normals. Everything else is handled at
the PBVH node level (which was already the case, but it wasn't clear).

The update tag was also used for undo to tag the nodes corresponding to
changed vertices. This was wrong though, because normals and visibility
would also be recalculated for just color or mask undo steps. Instead,
just use local arrays to map from vertices to nodes.

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

===

M   source/blender/blenkernel/BKE_pbvh.h
M   source/blender/blenkernel/intern/pbvh.c
M   source/blender/editors/sculpt_paint/paint_mask.c
M   source/blender/editors/sculpt_paint/sculpt.c
M   source/blender/editors/sculpt_paint/sculpt_boundary.c
M   source/blender/editors/sculpt_paint/sculpt_brush_types.c
M   source/blender/editors/sculpt_paint/sculpt_cloth.c
M   source/blender/editors/sculpt_paint/sculpt_expand.c
M   source/blender/editors/sculpt_paint/sculpt_face_set.c
M   source/blender/editors/sculpt_paint/sculpt_filter_color.c
M   source/blender/editors/sculpt_paint/sculpt_filter_mask.c
M   source/blender/editors/sculpt_paint/sculpt_filter_mesh.c
M   source/blender/editors/sculpt_paint/sculpt_mask_expand.c
M   source/blender/editors/sculpt_paint/sculpt_multiplane_scrape.c
M   source/blender/editors/sculpt_paint/sculpt_ops.c
M   source/blender/editors/sculpt_paint/sculpt_paint_color.c
M   source/blender/editors/sculpt_paint/sculpt_pose.c
M   source/blender/editors/sculpt_paint/sculpt_smooth.c
M   source/blender/editors/sculpt_paint/sculpt_transform.c
M   source/blender/editors/sculpt_paint/sculpt_undo.c

===

diff --git a/source/blender/blenkernel/BKE_pbvh.h 
b/source/blender/blenkernel/BKE_pbvh.h
index f517ff3a949..5641ff0ba34 100644
--- a/source/blender/blenkernel/BKE_pbvh.h
+++ b/source/blender/blenkernel/BKE_pbvh.h
@@ -308,7 +308,7 @@ void BKE_pbvh_node_fully_unmasked_set(PBVHNode *node, int 
fully_masked);
 bool BKE_pbvh_node_fully_unmasked_get(PBVHNode *node);
 
 void BKE_pbvh_mark_rebuild_pixels(PBVH *pbvh);
-void BKE_pbvh_vert_mark_update(PBVH *pbvh, int index);
+void BKE_pbvh_vert_tag_update_normal(PBVH *pbvh, int index);
 
 void BKE_pbvh_node_get_grids(PBVH *pbvh,
  PBVHNode *node,
@@ -526,7 +526,7 @@ void BKE_pbvh_node_get_bm_orco_data(PBVHNode *node,
  * however this is important to avoid having to recalculate bound-box & sync 
the buffers to the
  * GPU (which is far more expensive!) See: T47232.
  */
-bool BKE_pbvh_node_vert_update_check_any(PBVH *pbvh, PBVHNode *node);
+bool BKE_pbvh_node_has_vert_with_normal_update_tag(PBVH *pbvh, PBVHNode *node);
 
 // void BKE_pbvh_node_BB_reset(PBVHNode *node);
 // void BKE_pbvh_node_BB_expand(PBVHNode *node, float co[3]);
diff --git a/source/blender/blenkernel/intern/pbvh.c 
b/source/blender/blenkernel/intern/pbvh.c
index 6cebcdfea4e..8c1f19f0909 100644
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@ -1964,7 +1964,7 @@ bool BKE_pbvh_node_fully_unmasked_get(PBVHNode *node)
   return (node->flag & PBVH_Leaf) && (node->flag & PBVH_FullyUnmasked);
 }
 
-void BKE_pbvh_vert_mark_update(PBVH *pbvh, int index)
+void BKE_pbvh_vert_tag_update_normal(PBVH *pbvh, int index)
 {
   BLI_assert(pbvh->type == PBVH_FACES);
   pbvh->vert_bitmap[index] = true;
@@ -2123,7 +2123,7 @@ void BKE_pbvh_node_get_bm_orco_data(PBVHNode *node,
   *r_orco_coords = node->bm_orco;
 }
 
-bool BKE_pbvh_node_vert_update_check_any(PBVH *pbvh, PBVHNode *node)
+bool BKE_pbvh_node_has_vert_with_normal_update_tag(PBVH *pbvh, PBVHNode *node)
 {
   BLI_assert(pbvh->type == PBVH_FACES);
   const int *verts = node->vert_indices;
@@ -2991,7 +2991,7 @@ void BKE_pbvh_vert_coords_apply(PBVH *pbvh, const float 
(*vertCos)[3], const int
   /* no need for float comparison here (memory is exactly equal or not) */
   if (memcmp(mvert->co, vertCos[a], sizeof(float[3])) != 0) {
 copy_v3_v3(mvert->co, vertCos[a]);
-BKE_pbvh_vert_mark_update(pbvh, a);
+ 

[Bf-blender-cvs] [ac9d9c993ad] master: Merge branch 'blender-v3.3-release'

2022-08-02 Thread Richard Antalik
Commit: ac9d9c993ad1610881828e89f131dc7e9bf8e8c2
Author: Richard Antalik
Date:   Tue Aug 2 17:57:12 2022 +0200
Branches: master
https://developer.blender.org/rBac9d9c993ad1610881828e89f131dc7e9bf8e8c2

Merge branch 'blender-v3.3-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] [97b226ac511] blender-v3.3-release: Fix T100049: Crash when render finishes

2022-08-02 Thread Richard Antalik
Commit: 97b226ac51188ce1f4ab8bee7820c7dd296c7012
Author: Richard Antalik
Date:   Tue Aug 2 17:52:40 2022 +0200
Branches: blender-v3.3-release
https://developer.blender.org/rB97b226ac51188ce1f4ab8bee7820c7dd296c7012

Fix T100049: Crash when render finishes

Caused by NULL dereference of `Editing` before NULL check was done.

===

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

===

diff --git a/source/blender/sequencer/intern/utils.c 
b/source/blender/sequencer/intern/utils.c
index 2026e322763..e6c641a5532 100644
--- a/source/blender/sequencer/intern/utils.c
+++ b/source/blender/sequencer/intern/utils.c
@@ -338,14 +338,15 @@ void seq_open_anim_file(Scene *scene, Sequence *seq, bool 
openfile)
 const Sequence *SEQ_get_topmost_sequence(const Scene *scene, int frame)
 {
   Editing *ed = scene->ed;
-  ListBase *channels = SEQ_channels_displayed_get(ed);
-  const Sequence *seq, *best_seq = NULL;
-  int best_machine = -1;
 
   if (!ed) {
 return NULL;
   }
 
+  ListBase *channels = SEQ_channels_displayed_get(ed);
+  const Sequence *seq, *best_seq = NULL;
+  int best_machine = -1;
+
   for (seq = ed->seqbasep->first; seq; seq = seq->next) {
 if (SEQ_render_is_muted(channels, seq) ||
 !SEQ_time_strip_intersects_frame(scene, seq, frame)) {

___
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] SVN commit: bf-blender [62989] trunk/lib/tests/render/light: Add test for parametric coordinates on light, fixed in T100119

2022-08-02 Thread Sergey Sharybin
Revision: 62989
  https://developer.blender.org/rBL62989
Author:   sergey
Date: 2022-08-02 17:37:44 +0200 (Tue, 02 Aug 2022)
Log Message:
---
Add test for parametric coordinates on light, fixed in T100119

Added Paths:
---
trunk/lib/tests/render/light/area_light_uv.blend
trunk/lib/tests/render/light/cycles_renders/area_light_uv.png

Added: trunk/lib/tests/render/light/area_light_uv.blend
===
(Binary files differ)

Index: trunk/lib/tests/render/light/area_light_uv.blend
===
--- trunk/lib/tests/render/light/area_light_uv.blend2022-07-28 14:20:36 UTC 
(rev 62988)
+++ trunk/lib/tests/render/light/area_light_uv.blend2022-08-02 15:37:44 UTC 
(rev 62989)

Property changes on: trunk/lib/tests/render/light/area_light_uv.blend
___
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Added: trunk/lib/tests/render/light/cycles_renders/area_light_uv.png
===
(Binary files differ)

Index: trunk/lib/tests/render/light/cycles_renders/area_light_uv.png
===
--- trunk/lib/tests/render/light/cycles_renders/area_light_uv.png   
2022-07-28 14:20:36 UTC (rev 62988)
+++ trunk/lib/tests/render/light/cycles_renders/area_light_uv.png   
2022-08-02 15:37:44 UTC (rev 62989)

Property changes on: 
trunk/lib/tests/render/light/cycles_renders/area_light_uv.png
___
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
___
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] [09ac5f97a7e] master: GPencil: Fix compiler warning

2022-08-02 Thread Antonio Vazquez
Commit: 09ac5f97a7ef0381618f1e144795659b285da130
Author: Antonio Vazquez
Date:   Tue Aug 2 17:03:25 2022 +0200
Branches: master
https://developer.blender.org/rB09ac5f97a7ef0381618f1e144795659b285da130

GPencil: Fix compiler warning

The variable can never be NULL and the comparison was wrong.

===

M   source/blender/io/gpencil/intern/gpencil_io_import_base.cc

===

diff --git a/source/blender/io/gpencil/intern/gpencil_io_import_base.cc 
b/source/blender/io/gpencil/intern/gpencil_io_import_base.cc
index 18cbbceda0b..6d4439243fd 100644
--- a/source/blender/io/gpencil/intern/gpencil_io_import_base.cc
+++ b/source/blender/io/gpencil/intern/gpencil_io_import_base.cc
@@ -35,7 +35,7 @@ Object *GpencilImporter::create_object()
 
   Object *ob_gpencil = ED_object_add_type(params_.C,
   OB_GPENCIL,
-  (params_.filename != nullptr) ? 
params_.filename :
+  (params_.filename[0] != '\0') ? 
params_.filename :
   
nullptr,
   cur_loc,
   rot,

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

2022-08-02 Thread Hans Goudey
Commit: dadfdc822673ec9857e616759892b66a2ed6d8b3
Author: Hans Goudey
Date:   Tue Aug 2 09:51:08 2022 -0500
Branches: master
https://developer.blender.org/rBdadfdc822673ec9857e616759892b66a2ed6d8b3

Merge branch 'blender-v3.3-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] [d3eef4d22a0] blender-v3.3-release: Fix: Use evaluated materials in OBJ exporter

2022-08-02 Thread Hans Goudey
Commit: d3eef4d22a021bf71c5e6cac492139cab397e4d2
Author: Hans Goudey
Date:   Tue Aug 2 09:49:51 2022 -0500
Branches: blender-v3.3-release
https://developer.blender.org/rBd3eef4d22a021bf71c5e6cac492139cab397e4d2

Fix: Use evaluated materials in OBJ exporter

Since 1a81d268a19f2f140, materials on object data can change during
evaluation. But a different function is necessary to retrieve materials
taking that into account.

Solves part of T96721.

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

===

M   source/blender/io/wavefront_obj/exporter/obj_export_mesh.cc

===

diff --git a/source/blender/io/wavefront_obj/exporter/obj_export_mesh.cc 
b/source/blender/io/wavefront_obj/exporter/obj_export_mesh.cc
index e2ecda32717..9460746630d 100644
--- a/source/blender/io/wavefront_obj/exporter/obj_export_mesh.cc
+++ b/source/blender/io/wavefront_obj/exporter/obj_export_mesh.cc
@@ -219,13 +219,13 @@ void OBJMesh::calc_poly_order()
 const Material *OBJMesh::get_object_material(const int16_t mat_nr) const
 {
   /**
-   * The const_cast is safe here because BKE_object_material_get won't change 
the object
+   * The const_cast is safe here because #BKE_object_material_get_eval won't 
change the object
* but it is a big can of worms to fix the declaration of that function 
right now.
*
* The call uses "+ 1" as material getter needs one-based indices.
*/
   Object *obj = const_cast(_object_eval_);
-  const Material *r_mat = BKE_object_material_get(obj, mat_nr + 1);
+  const Material *r_mat = BKE_object_material_get_eval(obj, mat_nr + 1);
   return r_mat;
 }

___
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] [074ce49de01] master: Automated testing: Add operators tests

2022-08-02 Thread Pratik Borhade
Commit: 074ce49de014641f05f12e3b196d8eb7c4d1f733
Author: Pratik Borhade
Date:   Tue Aug 2 16:43:42 2022 +0200
Branches: master
https://developer.blender.org/rB074ce49de014641f05f12e3b196d8eb7c4d1f733

Automated testing: Add operators tests

Part of {T84999}
This patch adds test for
- `dissolve_limited`
- `dissolve_mode`
- `merge_normals`

Updated blend file:
{F13162744}

Reviewed By: zazizizou, mont29

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

===

M   tests/python/operators.py

===

diff --git a/tests/python/operators.py b/tests/python/operators.py
index 548a2b50b05..3933fc1cd1c 100644
--- a/tests/python/operators.py
+++ b/tests/python/operators.py
@@ -115,6 +115,18 @@ def main():
 [OperatorSpecEditMode("dissolve_faces", {}, "VERT", {5, 34, 47, 
49, 83, 91, 95})],
 ),
 
+# dissolve limited
+SpecMeshTest(
+"SphereDissolveLimited", "testSphereDissolveLimited", 
"expectedSphereDissolveLimited",
+[OperatorSpecEditMode("dissolve_limited", {"angle_limit": 
0.610865}, "FACE", {20, 23, 26, 29, 32})],
+),
+
+# dissolve mode
+SpecMeshTest(
+"PlaneDissolveMode", "testPlaneDissolveMode", 
"expectedPlaneDissolveMode",
+[OperatorSpecEditMode("dissolve_mode", {"use_verts": True}, 
"FACE", {0, 1, 2, 10, 12, 13})],
+),
+
 # dissolve verts
 SpecMeshTest(
 "CubeDissolveVerts", "testCubeDissolveVerts", 
"expectedCubeDissolveVerts",
@@ -332,6 +344,12 @@ def main():
 [OperatorSpecEditMode("mark_seam", {}, "EDGE", {1})],
 ),
 
+# merge normals
+SpecMeshTest(
+"CubeMergeNormals", "testCubeMergeNormals", 
"expectedCubeMergeNormals",
+[OperatorSpecEditMode("merge_normals", {}, "FACE", {3, 5})],
+),
+
 # select all
 SpecMeshTest(
 "CircleSelectAll", "testCircleSelectAll", 
"expectedCircleSelectAll",

___
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] [977a5bbee12] blender-v2.93-release: Fix T99820: missing 'no more mising' tagging on reloaded libraries.

2022-08-02 Thread Bastien Montagne
Commit: 977a5bbee1261bcaa0a6b3fba95c483da01f1398
Author: Bastien Montagne
Date:   Tue Aug 2 15:11:06 2022 +0200
Branches: blender-v2.93-release
https://developer.blender.org/rB977a5bbee1261bcaa0a6b3fba95c483da01f1398

Fix T99820: missing 'no more mising' tagging on reloaded libraries.

Backport of rB4d8018948ddb for 2.93 LTS.

===

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

===

diff --git a/source/blender/windowmanager/intern/wm_files_link.c 
b/source/blender/windowmanager/intern/wm_files_link.c
index 840debad01b..219f008f0d0 100644
--- a/source/blender/windowmanager/intern/wm_files_link.c
+++ b/source/blender/windowmanager/intern/wm_files_link.c
@@ -261,7 +261,8 @@ static void wm_link_do(WMLinkAppendData *lapp_data,
 mainl = BLO_library_link_begin(, libname, _params);
 lib = mainl->curlib;
 BLI_assert(lib);
-UNUSED_VARS_NDEBUG(lib);
+/* In case lib was already existing but not found originally, see T99820. 
*/
+lib->id.tag &= ~LIB_TAG_MISSING;
 
 if (mainl->versionfile < 250) {
   BKE_reportf(reports,

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

2022-08-02 Thread Bastien Montagne
Commit: 84aa8b85a2732baacfa5169badc17857c8849e6a
Author: Bastien Montagne
Date:   Tue Aug 2 15:07:54 2022 +0200
Branches: master
https://developer.blender.org/rB84aa8b85a2732baacfa5169badc17857c8849e6a

Merge branch 'blender-v3.3-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] [2a7e83ce18e] blender-v3.3-release: LibOverride: Expose in public API the utils to get actual override data.

2022-08-02 Thread Bastien Montagne
Commit: 2a7e83ce18e838e12526529130ad31dd1b50cbbd
Author: Bastien Montagne
Date:   Tue Aug 2 15:03:11 2022 +0200
Branches: blender-v3.3-release
https://developer.blender.org/rB2a7e83ce18e838e12526529130ad31dd1b50cbbd

LibOverride: Expose in public API the utils to get actual override data.

This is useful when input ID is a 'non-override' one (like embedded IDs
or shapekeys), to get override data and 'owner' ID pointer.

===

M   source/blender/blenkernel/BKE_lib_override.h
M   source/blender/blenkernel/intern/lib_override.cc

===

diff --git a/source/blender/blenkernel/BKE_lib_override.h 
b/source/blender/blenkernel/BKE_lib_override.h
index b2162e651fd..9ad5a32e6f0 100644
--- a/source/blender/blenkernel/BKE_lib_override.h
+++ b/source/blender/blenkernel/BKE_lib_override.h
@@ -59,6 +59,19 @@ void BKE_lib_override_library_clear(struct IDOverrideLibrary 
*override, bool do_
  */
 void BKE_lib_override_library_free(struct IDOverrideLibrary **override, bool 
do_id_user);
 
+/**
+ * Return the actual #IDOverrideLibrary data 'controlling' the given `id`, and 
the acutal ID owning
+ * it.
+ *
+ * \note This is especially useful when `id` is a non-real override (e.g. 
embedded ID like a master
+ * collection or root node tree, or a shape key).
+ *
+ * \param r_owner_id If given, will be set with the actual ID owning the 
return liboverride data.
+ */
+IDOverrideLibrary *BKE_lib_override_library_get(struct Main *bmain,
+struct ID *id,
+struct ID **r_owner_id);
+
 /**
  * Check if given ID has some override rules that actually indicate the user 
edited it.
  */
diff --git a/source/blender/blenkernel/intern/lib_override.cc 
b/source/blender/blenkernel/intern/lib_override.cc
index 4ad8d26cd2a..febc91716dd 100644
--- a/source/blender/blenkernel/intern/lib_override.cc
+++ b/source/blender/blenkernel/intern/lib_override.cc
@@ -91,9 +91,9 @@ BLI_INLINE void lib_override_object_posemode_transfer(ID 
*id_dst, ID *id_src)
 }
 
 /** Get override data for a given ID. Needed because of our beloved shape keys 
snowflake. */
-BLI_INLINE const IDOverrideLibrary *lib_override_get(const Main *bmain,
- const ID *id,
- const ID **r_owner_id)
+BLI_INLINE const IDOverrideLibrary *BKE_lib_override_library_get(const Main 
*bmain,
+ const ID *id,
+ const ID 
**r_owner_id)
 {
   if (r_owner_id != nullptr) {
 *r_owner_id = id;
@@ -114,13 +114,14 @@ BLI_INLINE const IDOverrideLibrary 
*lib_override_get(const Main *bmain,
   return id->override_library;
 }
 
-BLI_INLINE IDOverrideLibrary *lib_override_get(Main *bmain, ID *id, ID 
**r_owner_id)
+IDOverrideLibrary *BKE_lib_override_library_get(Main *bmain, ID *id, ID 
**r_owner_id)
 {
   /* Reuse the implementation of the const access function, which does not 
change the arguments.
* Add const explicitly to make it clear to the compiler to avoid just 
calling this function. */
-  return const_cast(lib_override_get(const_cast(bmain),
-  const_cast(id),
-  const_cast(r_owner_id)));
+  return const_cast(
+  BKE_lib_override_library_get(const_cast(bmain),
+   const_cast(id),
+   const_cast(r_owner_id)));
 }
 
 IDOverrideLibrary *BKE_lib_override_library_init(ID *local_id, ID 
*reference_id)
@@ -317,7 +318,7 @@ bool BKE_lib_override_library_is_system_defined(const Main 
*bmain, const ID *id)
 {
   if (ID_IS_OVERRIDE_LIBRARY(id)) {
 const ID *override_owner_id;
-lib_override_get(bmain, id, _owner_id);
+BKE_lib_override_library_get(bmain, id, _owner_id);
 return (override_owner_id->override_library->flag & 
IDOVERRIDE_LIBRARY_FLAG_SYSTEM_DEFINED) !=
0;
   }
@@ -1084,8 +1085,9 @@ static void 
lib_override_overrides_group_tag_recursive(LibOverrideGroupTagData *
   continue;
 }
 
-const Library *reference_lib = lib_override_get(bmain, id_owner, 
nullptr)->reference->lib;
-const ID *to_id_reference = lib_override_get(bmain, to_id, 
nullptr)->reference;
+const Library *reference_lib =
+BKE_lib_override_library_get(bmain, id_owner, nullptr)->reference->lib;
+const ID *to_id_reference = BKE_lib_override_library_get(bmain, to_id, 
nullptr)->reference;
 if (to_id_reference->lib != reference_lib) {
   /* We do not override data-blocks from other libraries, nor do we 
process them. */
   continue;
@@ -1433,7 +1435,7 @@ static ID *lib_override_root_find(Main *bmain, ID *id, 
const int curr_level, int

[Bf-blender-cvs] [e4dd644d6be] blender-v3.3-release: LibOverride: Add 'editable/clear' toggle to ID template.

2022-08-02 Thread Bastien Montagne
Commit: e4dd644d6be04b6479d4a9f845e7d1ba43ceb332
Author: Bastien Montagne
Date:   Tue Aug 2 15:04:11 2022 +0200
Branches: blender-v3.3-release
https://developer.blender.org/rBe4dd644d6be04b6479d4a9f845e7d1ba43ceb332

LibOverride: Add 'editable/clear' toggle to ID template.

Now when an ID template is set to an override ID, `Shift-Click` on the
right button toggles between making it user-editable (if it's a system
override), or clearing any user edit and setting it back to system override.

===

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

===

diff --git a/source/blender/editors/interface/interface_templates.c 
b/source/blender/editors/interface/interface_templates.c
index 14da5a7cd62..fa3c12e158d 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -659,6 +659,27 @@ static void 
template_id_liboverride_hierarchy_create(bContext *C,
   ID *id = idptr->data;
   ID *owner_id = template_ui->ptr.owner_id;
 
+  /* If this is called on an already local override, 'toggle' between 
user-editable state, and
+   * system override with reset. */
+  if (!ID_IS_LINKED(id) && ID_IS_OVERRIDE_LIBRARY(id)) {
+if (!ID_IS_OVERRIDE_LIBRARY_REAL(id)) {
+  BKE_lib_override_library_get(bmain, id, );
+}
+if (id->override_library->flag & IDOVERRIDE_LIBRARY_FLAG_SYSTEM_DEFINED) {
+  id->override_library->flag &= ~IDOVERRIDE_LIBRARY_FLAG_SYSTEM_DEFINED;
+  *r_undo_push_label = "Make Library Override Hierarchy Editable";
+}
+else {
+  BKE_lib_override_library_id_reset(bmain, id, true);
+  *r_undo_push_label = "Clear Library Override Hierarchy";
+}
+
+WM_event_add_notifier(C, NC_WM | ND_DATACHANGED, NULL);
+WM_event_add_notifier(C, NC_WM | ND_LIB_OVERRIDE_CHANGED, NULL);
+WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+return;
+  }
+
   /* Attempt to perform a hierarchy override, based on contextual data 
available.
* NOTE: do not attempt to perform such hierarchy override at all cost, if 
there is not enough
* context, better to abort than create random overrides all over the place. 
*/
@@ -918,12 +939,19 @@ static void template_id_cb(bContext *C, void *arg_litem, 
void *arg_event)
   break;
 case UI_ID_OVERRIDE:
   if (id && ID_IS_OVERRIDE_LIBRARY(id)) {
-BKE_lib_override_library_make_local(id);
-/* Reassign to get proper updates/notifiers. */
-idptr = RNA_property_pointer_get(_ui->ptr, template_ui->prop);
-RNA_property_pointer_set(_ui->ptr, template_ui->prop, idptr, 
NULL);
-RNA_property_update(C, _ui->ptr, template_ui->prop);
-undo_push_label = "Make Local";
+Main *bmain = CTX_data_main(C);
+if (CTX_wm_window(C)->eventstate->modifier & KM_SHIFT) {
+  template_id_liboverride_hierarchy_create(
+  C, bmain, template_ui, , _push_label);
+}
+else {
+  BKE_lib_override_library_make_local(id);
+  /* Reassign to get proper updates/notifiers. */
+  idptr = RNA_property_pointer_get(_ui->ptr, 
template_ui->prop);
+  RNA_property_pointer_set(_ui->ptr, template_ui->prop, 
idptr, NULL);
+  RNA_property_update(C, _ui->ptr, template_ui->prop);
+  undo_push_label = "Make Local";
+}
   }
   break;
 case UI_ID_ALONE:

___
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] [0830320a7ce] master: CMake: Check if freetype is compiled with brotli support

2022-08-02 Thread Sebastian Parborg
Commit: 0830320a7ce8da31dec7c1efd97a7481784b6445
Author: Sebastian Parborg
Date:   Tue Aug 2 14:48:05 2022 +0200
Branches: master
https://developer.blender.org/rB0830320a7ce8da31dec7c1efd97a7481784b6445

CMake: Check if freetype is compiled with brotli support

Because of the recent changes to our core fonts,
Freetype has to support Woff2 fonts or Blender will segfault on startup.

This adds an explicit check for this to inform people compiling Blender
about this requirement.

===

M   build_files/cmake/platform/platform_unix.cmake

===

diff --git a/build_files/cmake/platform/platform_unix.cmake 
b/build_files/cmake/platform/platform_unix.cmake
index f6e233a0c86..406748b7ff0 100644
--- a/build_files/cmake/platform/platform_unix.cmake
+++ b/build_files/cmake/platform/platform_unix.cmake
@@ -96,6 +96,18 @@ find_package_wrapper(PNG REQUIRED)
 find_package_wrapper(ZLIB REQUIRED)
 find_package_wrapper(Zstd REQUIRED)
 
+function(check_freetype_for_brotli)
+  include(CheckSymbolExists)
+  set(CMAKE_REQUIRED_INCLUDES ${FREETYPE_INCLUDE_DIRS})
+  check_symbol_exists(FT_CONFIG_OPTION_USE_BROTLI
+  "freetype/config/ftconfig.h" HAVE_BROTLI)
+  if(NOT HAVE_BROTLI)
+unset(HAVE_BROTLI CACHE)
+message(FATAL_ERROR "Freetype needs to be compiled with brotli support!")
+  endif()
+  unset(HAVE_BROTLI CACHE)
+endfunction()
+
 if(NOT WITH_SYSTEM_FREETYPE)
   # FreeType compiled with Brotli compression for woff2.
   find_package_wrapper(Freetype REQUIRED)
@@ -110,6 +122,7 @@ if(NOT WITH_SYSTEM_FREETYPE)
 #   ${BROTLI_LIBRARIES}
 # )
   endif()
+  check_freetype_for_brotli()
 endif()
 
 if(WITH_PYTHON)
@@ -587,6 +600,7 @@ if(WITH_SYSTEM_FREETYPE)
   if(NOT FREETYPE_FOUND)
 message(FATAL_ERROR "Failed finding system FreeType version!")
   endif()
+  check_freetype_for_brotli()
 endif()
 
 if(WITH_LZO AND WITH_SYSTEM_LZO)

___
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] [25a0124bc89] master: Fix T100119: Light object's parametric vector distorted in blender 3.4

2022-08-02 Thread Sergey Sharybin
Commit: 25a0124bc890a3390ef7738707f218f50a8d8ac3
Author: Sergey Sharybin
Date:   Mon Aug 1 16:07:10 2022 +0200
Branches: master
https://developer.blender.org/rB25a0124bc890a3390ef7738707f218f50a8d8ac3

Fix T100119: Light object's parametric vector distorted in blender 3.4

Caused by 38af5b050100.

Adjust barycentric coordinates used for intersection result in the
ray-to-rectangle intersection check.

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

===

M   intern/cycles/util/math_intersect.h

===

diff --git a/intern/cycles/util/math_intersect.h 
b/intern/cycles/util/math_intersect.h
index 37bdc5f1ccf..cc07cbe7745 100644
--- a/intern/cycles/util/math_intersect.h
+++ b/intern/cycles/util/math_intersect.h
@@ -209,10 +209,13 @@ ccl_device bool ray_quad_intersect(float3 ray_P,
 *isect_P = hit;
   if (isect_t != NULL)
 *isect_t = t;
+
+  /* NOTE: Return barycentric coordinates in the same notation as Embree and 
OptiX. */
   if (isect_u != NULL)
-*isect_u = u + 0.5f;
+*isect_u = v + 0.5f;
   if (isect_v != NULL)
-*isect_v = v + 0.5f;
+*isect_v = -u - v;
+
   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] [588791df637] master: Fix compilation error after recent DNA changes

2022-08-02 Thread Sergey Sharybin
Commit: 588791df637a078aae20250022bc5fcd1fc07d1a
Author: Sergey Sharybin
Date:   Tue Aug 2 14:15:23 2022 +0200
Branches: master
https://developer.blender.org/rB588791df637a078aae20250022bc5fcd1fc07d1a

Fix compilation error after recent DNA changes

Apparently, Clang allows to specify underlying enum type in C
but onot GCC. The latter one is actually closer to the standard.

===

M   source/blender/makesdna/DNA_ID.h

===

diff --git a/source/blender/makesdna/DNA_ID.h b/source/blender/makesdna/DNA_ID.h
index 7ba2b426fcf..0dc7d75e744 100644
--- a/source/blender/makesdna/DNA_ID.h
+++ b/source/blender/makesdna/DNA_ID.h
@@ -763,7 +763,7 @@ enum {
 };
 
 /* Tag given ID for an update in all the dependency graphs. */
-typedef enum IDRecalcFlag : unsigned int {
+typedef enum IDRecalcFlag {
   /***
* Individual update tags, this is what ID gets tagged for update with. */

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

2022-08-02 Thread Jeroen Bakker
Commit: 4e2af28bc72795aa146d6a5c4339ecad7bccfef6
Author: Jeroen Bakker
Date:   Tue Aug 2 13:42:14 2022 +0200
Branches: master
https://developer.blender.org/rB4e2af28bc72795aa146d6a5c4339ecad7bccfef6

Merge branch 'blender-v3.3-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] [78ad9ebed3a] blender-v3.3-release: Fix T99715: Only force optimal display during on cage editing.

2022-08-02 Thread Jeroen Bakker
Commit: 78ad9ebed3a55138c0a576c4200ab0fd6d8e3712
Author: Jeroen Bakker
Date:   Tue Aug 2 13:38:34 2022 +0200
Branches: blender-v3.3-release
https://developer.blender.org/rB78ad9ebed3a55138c0a576c4200ab0fd6d8e3712

Fix T99715: Only force optimal display during on cage editing.

This loosens the current implementation a bit to only force optimal
display when editing on cage. It used to be any editing mode.

Brings GPU based subdivision closer to the CPU version.

===

M   source/blender/draw/intern/draw_cache_impl_mesh.cc
M   source/blender/draw/intern/draw_cache_impl_subdivision.cc
M   source/blender/draw/intern/draw_subdivision.h

===

diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.cc 
b/source/blender/draw/intern/draw_cache_impl_mesh.cc
index d3d9db13005..d1eb937d711 100644
--- a/source/blender/draw/intern/draw_cache_impl_mesh.cc
+++ b/source/blender/draw/intern/draw_cache_impl_mesh.cc
@@ -1893,6 +1893,7 @@ void DRW_mesh_batch_cache_create_requested(struct 
TaskGraph *task_graph,
ob->obmat,
true,
false,
+   do_cage,
ts,
use_hide);
   }
diff --git a/source/blender/draw/intern/draw_cache_impl_subdivision.cc 
b/source/blender/draw/intern/draw_cache_impl_subdivision.cc
index cde2b59ea23..2f8a2540776 100644
--- a/source/blender/draw/intern/draw_cache_impl_subdivision.cc
+++ b/source/blender/draw/intern/draw_cache_impl_subdivision.cc
@@ -2019,6 +2019,7 @@ static bool draw_subdiv_create_requested_buffers(Object 
*ob,
  const float obmat[4][4],
  const bool do_final,
  const bool do_uvedit,
+ const bool do_cage,
  const ToolSettings *ts,
  const bool use_hide,
  OpenSubdiv_EvaluatorCache 
*evaluator_cache)
@@ -2062,9 +2063,8 @@ static bool draw_subdiv_create_requested_buffers(Object 
*ob,
 return false;
   }
 
-  /* Edges which do not come from coarse edges should not be drawn in edit 
mode, only in object
-   * mode when optimal display in turned off. */
-  const bool optimal_display = runtime_data->use_optimal_display || 
is_editmode;
+  /* Edges which do not come from coarse edges should not be drawn in edit 
cage mode. */
+  const bool optimal_display = runtime_data->use_optimal_display || 
(is_editmode && !do_cage);
 
   draw_cache->bm = bm;
   draw_cache->mesh = mesh_eval;
@@ -2216,6 +2216,7 @@ void DRW_create_subdivision(Object *ob,
 const float obmat[4][4],
 const bool do_final,
 const bool do_uvedit,
+const bool do_cage,
 const ToolSettings *ts,
 const bool use_hide)
 {
@@ -2239,6 +2240,7 @@ void DRW_create_subdivision(Object *ob,
 obmat,
 do_final,
 do_uvedit,
+do_cage,
 ts,
 use_hide,
 g_evaluator_cache)) {
diff --git a/source/blender/draw/intern/draw_subdivision.h 
b/source/blender/draw/intern/draw_subdivision.h
index ef580fc116a..37b025e761d 100644
--- a/source/blender/draw/intern/draw_subdivision.h
+++ b/source/blender/draw/intern/draw_subdivision.h
@@ -199,6 +199,7 @@ void DRW_create_subdivision(struct Object *ob,
 const float obmat[4][4],
 const bool do_final,
 const bool do_uvedit,
+const bool do_cage,
 const ToolSettings *ts,
 const bool use_hide);

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

2022-08-02 Thread Bastien Montagne
Commit: 33e4ecc7509ced4b9499c4005114ca5865717b7b
Author: Bastien Montagne
Date:   Tue Aug 2 12:55:29 2022 +0200
Branches: master
https://developer.blender.org/rB33e4ecc7509ced4b9499c4005114ca5865717b7b

Merge branch 'blender-v3.3-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] [33d0b7c5bdd] blender-v3.3-release: Fix T100133: Crash when linking an evaluated object to a collection.

2022-08-02 Thread Bastien Montagne
Commit: 33d0b7c5bdd8bdbde0a3fd6e7982440c151e321b
Author: Bastien Montagne
Date:   Tue Aug 2 12:52:35 2022 +0200
Branches: blender-v3.3-release
https://developer.blender.org/rB33d0b7c5bdd8bdbde0a3fd6e7982440c151e321b

Fix T100133: Crash when linking an evaluated object to a collection.

Note that ideally, we should have a protection mechnism at global RNA
level, making e.g. any evaluated data read-only... But for now, give
better (and more consistent) protection for the collections' link/unlink
of children collections  and objects.

===

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

===

diff --git a/source/blender/makesrna/intern/rna_collection.c 
b/source/blender/makesrna/intern/rna_collection.c
index 4657f7e9a9f..84ddea368e7 100644
--- a/source/blender/makesrna/intern/rna_collection.c
+++ b/source/blender/makesrna/intern/rna_collection.c
@@ -39,6 +39,7 @@ const EnumPropertyItem rna_enum_collection_color_items[] = {
 
 #  include "DEG_depsgraph.h"
 #  include "DEG_depsgraph_build.h"
+#  include "DEG_depsgraph_query.h"
 
 #  include "BKE_collection.h"
 #  include "BKE_global.h"
@@ -79,26 +80,45 @@ static PointerRNA 
rna_Collection_objects_get(CollectionPropertyIterator *iter)
   return rna_pointer_inherit_refine(>parent, _Object, cob->ob);
 }
 
-static void rna_Collection_objects_link(Collection *collection,
-Main *bmain,
-ReportList *reports,
-Object *object)
+static bool rna_collection_objects_edit_check(Collection *collection,
+  ReportList *reports,
+  Object *object)
 {
+  if (!DEG_is_original_id(>id)) {
+BKE_reportf(
+reports, RPT_ERROR, "Collection '%s' is not an original ID", 
collection->id.name + 2);
+return false;
+  }
+  if (!DEG_is_original_id(>id)) {
+BKE_reportf(reports, RPT_ERROR, "Collection '%s' is not an original ID", 
object->id.name + 2);
+return false;
+  }
   /* Currently this should not be allowed (might be supported in the future 
though...). */
   if (ID_IS_OVERRIDE_LIBRARY(>id)) {
 BKE_reportf(reports,
 RPT_ERROR,
-"Could not link the object '%s' because the collection '%s' is 
overridden",
+"Could not (un)link the object '%s' because the collection 
'%s' is overridden",
 object->id.name + 2,
 collection->id.name + 2);
-return;
+return false;
   }
   if (ID_IS_LINKED(>id)) {
 BKE_reportf(reports,
 RPT_ERROR,
-"Could not link the object '%s' because the collection '%s' is 
linked",
+"Could not (un)link the object '%s' because the collection 
'%s' is linked",
 object->id.name + 2,
 collection->id.name + 2);
+return false;
+  }
+  return true;
+}
+
+static void rna_Collection_objects_link(Collection *collection,
+Main *bmain,
+ReportList *reports,
+Object *object)
+{
+  if (!rna_collection_objects_edit_check(collection, reports, object)) {
 return;
   }
   if (!BKE_collection_object_add(bmain, collection, object)) {
@@ -120,6 +140,9 @@ static void rna_Collection_objects_unlink(Collection 
*collection,
   ReportList *reports,
   Object *object)
 {
+  if (!rna_collection_objects_edit_check(collection, reports, object)) {
+return;
+  }
   if (!BKE_collection_object_remove(bmain, collection, object, false)) {
 BKE_reportf(reports,
 RPT_ERROR,
@@ -204,11 +227,47 @@ static PointerRNA 
rna_Collection_children_get(CollectionPropertyIterator *iter)
   return rna_pointer_inherit_refine(>parent, _Collection, 
child->collection);
 }
 
+static bool rna_collection_children_edit_check(Collection *collection,
+   ReportList *reports,
+   Collection *child)
+{
+  if (!DEG_is_original_id(>id)) {
+BKE_reportf(
+reports, RPT_ERROR, "Collection '%s' is not an original ID", 
collection->id.name + 2);
+return false;
+  }
+  if (!DEG_is_original_id(>id)) {
+BKE_reportf(reports, RPT_ERROR, "Collection '%s' is not an original ID", 
child->id.name + 2);
+return false;
+  }
+  /* Currently this should not be allowed (might be supported in the future 
though...). */
+  if (ID_IS_OVERRIDE_LIBRARY(>id)) {
+BKE_reportf(reports,
+RPT_ERROR,
+"Could not (un)link the collection '%s' because the collection 
'%s' is overridden",
+child->id.name + 2,
+collection->id.name + 2);
+ 

[Bf-blender-cvs] [1c90ab7bf25] master: Depsgraph: Make naming and recalc flag sign consistent

2022-08-02 Thread Sergey Sharybin
Commit: 1c90ab7bf252ba008e0f61f37886ab58c75f5c7b
Author: Sergey Sharybin
Date:   Tue Aug 2 10:54:44 2022 +0200
Branches: master
https://developer.blender.org/rB1c90ab7bf252ba008e0f61f37886ab58c75f5c7b

Depsgraph: Make naming and recalc flag sign consistent

Always use unsigned int for the recalc flags. This allows to use
all 32 bit of integer for the flags without worrying about the
sign. Use full notation of `unsigned int` instead of short `uint`
to avoid pulling more headers in.

Whenever depsgraph API allows passing combined recalc flags call
the variable `flags` and use `unsigned int` type for it. For a
single flag use `IDRecalcFlag` flag.

No functional changes expected.

===

M   source/blender/depsgraph/DEG_depsgraph.h
M   source/blender/depsgraph/intern/depsgraph_tag.cc
M   source/blender/depsgraph/intern/depsgraph_tag.h
M   source/blender/makesdna/DNA_ID.h

===

diff --git a/source/blender/depsgraph/DEG_depsgraph.h 
b/source/blender/depsgraph/DEG_depsgraph.h
index 00efa779c4d..a8b21e4c153 100644
--- a/source/blender/depsgraph/DEG_depsgraph.h
+++ b/source/blender/depsgraph/DEG_depsgraph.h
@@ -125,13 +125,13 @@ void DEG_tag_on_visible_update(struct Main *bmain, bool 
do_time);
 const char *DEG_update_tag_as_string(IDRecalcFlag flag);
 
 /** Tag given ID for an update in all the dependency graphs. */
-void DEG_id_tag_update(struct ID *id, int flag);
-void DEG_id_tag_update_ex(struct Main *bmain, struct ID *id, int flag);
+void DEG_id_tag_update(struct ID *id, unsigned int flags);
+void DEG_id_tag_update_ex(struct Main *bmain, struct ID *id, unsigned int 
flags);
 
 void DEG_graph_id_tag_update(struct Main *bmain,
  struct Depsgraph *depsgraph,
  struct ID *id,
- int flag);
+ unsigned int flags);
 
 /** Tag all dependency graphs when time has changed. */
 void DEG_time_tag_update(struct Main *bmain);
diff --git a/source/blender/depsgraph/intern/depsgraph_tag.cc 
b/source/blender/depsgraph/intern/depsgraph_tag.cc
index 9cd5980d8fe..7a2904e3766 100644
--- a/source/blender/depsgraph/intern/depsgraph_tag.cc
+++ b/source/blender/depsgraph/intern/depsgraph_tag.cc
@@ -224,13 +224,13 @@ void depsgraph_tag_to_component_opcode(const ID *id,
 }
 
 void id_tag_update_ntree_special(
-Main *bmain, Depsgraph *graph, ID *id, int flag, eUpdateSource 
update_source)
+Main *bmain, Depsgraph *graph, ID *id, unsigned int flags, eUpdateSource 
update_source)
 {
   bNodeTree *ntree = ntreeFromID(id);
   if (ntree == nullptr) {
 return;
   }
-  graph_id_tag_update(bmain, graph, >id, flag, update_source);
+  graph_id_tag_update(bmain, graph, >id, flags, update_source);
 }
 
 void depsgraph_update_editors_tag(Main *bmain, Depsgraph *graph, ID *id)
@@ -407,13 +407,13 @@ string stringify_append_bit(const string , 
IDRecalcFlag tag)
   return result;
 }
 
-string stringify_update_bitfield(int flag)
+string stringify_update_bitfield(unsigned int flags)
 {
-  if (flag == 0) {
+  if (flags == 0) {
 return "LEGACY_0";
   }
   string result;
-  int current_flag = flag;
+  unsigned int current_flag = flags;
   /* Special cases to avoid ALL flags form being split into
* individual bits. */
   if ((current_flag & ID_RECALC_PSYS_ALL) == ID_RECALC_PSYS_ALL) {
@@ -421,7 +421,7 @@ string stringify_update_bitfield(int flag)
   }
   /* Handle all the rest of the flags. */
   while (current_flag != 0) {
-IDRecalcFlag tag = (IDRecalcFlag)(1 << 
bitscan_forward_clear_i(_flag));
+IDRecalcFlag tag = (IDRecalcFlag)(1 << 
bitscan_forward_clear_uint(_flag));
 result = stringify_append_bit(result, tag);
   }
   return result;
@@ -449,7 +449,7 @@ int deg_recalc_flags_for_legacy_zero()
ID_RECALC_SOURCE | ID_RECALC_EDITORS);
 }
 
-int deg_recalc_flags_effective(Depsgraph *graph, int flags)
+int deg_recalc_flags_effective(Depsgraph *graph, unsigned int flags)
 {
   if (graph != nullptr) {
 if (!graph->is_active) {
@@ -520,12 +520,12 @@ void graph_tag_ids_for_visible_update(Depsgraph *graph)
* No need bother with it to tag or anything. */
   continue;
 }
-int flag = 0;
+unsigned int flags = 0;
 if (!deg::deg_copy_on_write_is_expanded(id_node->id_cow)) {
-  flag |= ID_RECALC_COPY_ON_WRITE;
+  flags |= ID_RECALC_COPY_ON_WRITE;
   if (do_time) {
 if (BKE_animdata_from_id(id_node->id_orig) != nullptr) {
-  flag |= ID_RECALC_ANIMATION;
+  flags |= ID_RECALC_ANIMATION;
 }
   }
 }
@@ -542,9 +542,9 @@ void graph_tag_ids_for_visible_update(Depsgraph *graph)
  *
  * TODO(sergey): Need to generalize this somehow. */
 if (id_type == ID_OB) {
-  flag |= ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY;
+  flags |= ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY;
 }
-  

[Bf-blender-cvs] [bb7747e7cae] master: Fix undefined behavior in dependency graph tagging

2022-08-02 Thread Sergey Sharybin
Commit: bb7747e7caee59a8c98cd7d9abc9cd1e9b0e0762
Author: Sergey Sharybin
Date:   Tue Aug 2 11:10:40 2022 +0200
Branches: master
https://developer.blender.org/rBbb7747e7caee59a8c98cd7d9abc9cd1e9b0e0762

Fix undefined behavior in dependency graph tagging

The tagging code was iterating over bits set in the ID_RECALC_ALL and
was casting the flag to IDRecalcFlag. This was triggering an undefined
behavior warning in Clang since the bit might not have a corresponding
value in the enumerator.

The solution is to pre-define all reacalc flags for all bits. While
this seems a bit annoying this seems to be the least fragile solution
from all suggested ones.

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

===

M   source/blender/depsgraph/intern/depsgraph_tag.cc
M   source/blender/makesdna/DNA_ID.h

===

diff --git a/source/blender/depsgraph/intern/depsgraph_tag.cc 
b/source/blender/depsgraph/intern/depsgraph_tag.cc
index 7a2904e3766..d95e871d6c7 100644
--- a/source/blender/depsgraph/intern/depsgraph_tag.cc
+++ b/source/blender/depsgraph/intern/depsgraph_tag.cc
@@ -220,6 +220,15 @@ void depsgraph_tag_to_component_opcode(const ID *id,
   *component_type = NodeType::NTREE_OUTPUT;
   *operation_code = OperationCode::NTREE_OUTPUT;
   break;
+
+case ID_RECALC_PROVISION_26:
+case ID_RECALC_PROVISION_27:
+case ID_RECALC_PROVISION_28:
+case ID_RECALC_PROVISION_29:
+case ID_RECALC_PROVISION_30:
+case ID_RECALC_PROVISION_31:
+  BLI_assert_msg(0, "Should not happen");
+  break;
   }
 }
 
@@ -741,6 +750,15 @@ const char *DEG_update_tag_as_string(IDRecalcFlag flag)
   return "TAG_FOR_UNDO";
 case ID_RECALC_NTREE_OUTPUT:
   return "ID_RECALC_NTREE_OUTPUT";
+
+case ID_RECALC_PROVISION_26:
+case ID_RECALC_PROVISION_27:
+case ID_RECALC_PROVISION_28:
+case ID_RECALC_PROVISION_29:
+case ID_RECALC_PROVISION_30:
+case ID_RECALC_PROVISION_31:
+  BLI_assert_msg(0, "Should not happen");
+  return nullptr;
   }
   return nullptr;
 }
diff --git a/source/blender/makesdna/DNA_ID.h b/source/blender/makesdna/DNA_ID.h
index 8b99345e237..7ba2b426fcf 100644
--- a/source/blender/makesdna/DNA_ID.h
+++ b/source/blender/makesdna/DNA_ID.h
@@ -870,6 +870,17 @@ typedef enum IDRecalcFlag : unsigned int {
   /* The node tree has changed in a way that affects its output nodes. */
   ID_RECALC_NTREE_OUTPUT = (1 << 25),
 
+  /* Provisioned flags.
+   *
+   * Not for actual use. The idea of them is to have all bits of the 
`IDRecalcFlag` defined to a
+   * known value, silencing sanitizer warnings when checkign bits of the 
ID_RECALC_ALL. */
+  ID_RECALC_PROVISION_26 = (1 << 26),
+  ID_RECALC_PROVISION_27 = (1 << 27),
+  ID_RECALC_PROVISION_28 = (1 << 28),
+  ID_RECALC_PROVISION_29 = (1 << 29),
+  ID_RECALC_PROVISION_30 = (1 << 30),
+  ID_RECALC_PROVISION_31 = (1u << 31),
+
   /***
* Pseudonyms, to have more semantic meaning in the actual code without
* using too much low-level and implementation specific tags. */

___
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] [fdf34666f00] blender-v3.3-release: Fix Unreported : add F-curves only filter to functions only appliable to F-curves channels.

2022-08-02 Thread Amelie Fondevilla
Commit: fdf34666f00fc0995507b46e30a0e732812cd05e
Author: Amelie Fondevilla
Date:   Tue Aug 2 12:24:30 2022 +0200
Branches: blender-v3.3-release
https://developer.blender.org/rBfdf34666f00fc0995507b46e30a0e732812cd05e

Fix Unreported : add F-curves only filter to functions only appliable to 
F-curves channels.

The filter was missing in some places that are using channel data as if it was 
f-curve channel.
There seems to be no related issue or bug, but still it would be best to have 
them there.

Reviewed By: sybren

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

===

M   source/blender/editors/animation/anim_channels_edit.c
M   source/blender/editors/animation/keyframes_edit.c
M   source/blender/editors/animation/keyframes_keylist.cc
M   source/blender/editors/include/ED_anim_api.h
M   source/blender/editors/space_graph/space_graph.c

===

diff --git a/source/blender/editors/animation/anim_channels_edit.c 
b/source/blender/editors/animation/anim_channels_edit.c
index f371591c3a8..1c7b3496723 100644
--- a/source/blender/editors/animation/anim_channels_edit.c
+++ b/source/blender/editors/animation/anim_channels_edit.c
@@ -1640,7 +1640,8 @@ static void animchannels_group_channels(bAnimContext *ac,
 int filter;
 
 /* find selected F-Curves to re-group */
-filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | 
ANIMFILTER_SEL);
+filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | 
ANIMFILTER_SEL |
+  ANIMFILTER_FCURVESONLY);
 ANIM_animdata_filter(ac, _data, filter, adt_ref, ANIMCONT_CHANNEL);
 
 if (anim_data.first) {
@@ -1754,7 +1755,7 @@ static int animchannels_ungroup_exec(bContext *C, 
wmOperator *UNUSED(op))
 
   /* just selected F-Curves... */
   filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL 
|
-ANIMFILTER_NODUPLIS);
+ANIMFILTER_NODUPLIS | ANIMFILTER_FCURVESONLY);
   ANIM_animdata_filter(, _data, filter, ac.data, ac.datatype);
 
   for (ale = anim_data.first; ale; ale = ale->next) {
@@ -2454,7 +2455,7 @@ static int animchannels_enable_exec(bContext *C, 
wmOperator *UNUSED(op))
   }
 
   /* filter data */
-  filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_NODUPLIS);
+  filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_NODUPLIS | 
ANIMFILTER_FCURVESONLY);
   ANIM_animdata_filter(, _data, filter, ac.data, ac.datatype);
 
   /* loop through filtered data and clean curves */
@@ -3454,7 +3455,8 @@ static bool select_anim_channel_keys(bAnimContext *ac, 
int channel_index, bool e
 
   /* get the channel that was clicked on */
   /* filter channels */
-  filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | 
ANIMFILTER_LIST_CHANNELS);
+  filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | 
ANIMFILTER_LIST_CHANNELS |
+ANIMFILTER_FCURVESONLY);
   ANIM_animdata_filter(ac, _data, filter, ac->data, ac->datatype);
 
   /* get channel from index */
diff --git a/source/blender/editors/animation/keyframes_edit.c 
b/source/blender/editors/animation/keyframes_edit.c
index 706db498a82..63bd5665459 100644
--- a/source/blender/editors/animation/keyframes_edit.c
+++ b/source/blender/editors/animation/keyframes_edit.c
@@ -218,7 +218,7 @@ static short ob_keyframes_loop(KeyframeEditData *ked,
   ac.datatype = ANIMCONT_CHANNEL;
 
   /* get F-Curves to take keyframes from */
-  filter = ANIMFILTER_DATA_VISIBLE; /* curves only */
+  filter = ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FCURVESONLY;
   ANIM_animdata_filter(, _data, filter, ac.data, ac.datatype);
 
   /* Loop through each F-Curve, applying the operation as required,
@@ -267,7 +267,7 @@ static short scene_keyframes_loop(KeyframeEditData *ked,
   ac.datatype = ANIMCONT_CHANNEL;
 
   /* get F-Curves to take keyframes from */
-  filter = ANIMFILTER_DATA_VISIBLE; /* curves only */
+  filter = ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FCURVESONLY;
   ANIM_animdata_filter(, _data, filter, ac.data, ac.datatype);
 
   /* Loop through each F-Curve, applying the operation as required,
diff --git a/source/blender/editors/animation/keyframes_keylist.cc 
b/source/blender/editors/animation/keyframes_keylist.cc
index 8dc598e6e2d..da266dd4253 100644
--- a/source/blender/editors/animation/keyframes_keylist.cc
+++ b/source/blender/editors/animation/keyframes_keylist.cc
@@ -943,7 +943,8 @@ void scene_to_keylist(bDopeSheet *ads, Scene *sce, 
AnimKeylist *keylist, const i
   ac.datatype = ANIMCONT_CHANNEL;
 
   /* get F-Curves to take keyframes from */
-  const eAnimFilter_Flags filter = ANIMFILTER_DATA_VISIBLE; /* curves only */
+  const eAnimFilter_Flags filter = ANIMFILTER_DATA_VISIBLE | 
ANIMFILTER_FCURVESONLY;
+
   ANIM_animdata_filter(
   , _data, filter, ac.data, 
static_cast(ac.datatype));
 
@@ -980,7 +981,7 @@ void ob_to_keylist(bDopeSheet *ads, Object *ob, AnimKeylist 
*keylist, const int
   

[Bf-blender-cvs] [80d193c51b4] blender-v3.2-release: Fix T100040: Crash when transform applied on multi-user image

2022-08-02 Thread Pratik Borhade
Commit: 80d193c51b460cff30266efb4530bef6b6fd
Author: Pratik Borhade
Date:   Mon Aug 1 17:07:56 2022 +0200
Branches: blender-v3.2-release
https://developer.blender.org/rB80d193c51b460cff30266efb4530bef6b6fd

Fix T100040: Crash when transform applied on multi-user image

Affected by rB8621fdb10dc4
Crash if single-user data is created when we apply transform
on multi-user image data. Crash occurs because creation of new copy
was not handled in `single_obdata_users` for empty objects (image for example)

Reviewed By: dfelinto, mont29

Maniphest Tasks: T100040

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

===

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

===

diff --git a/source/blender/editors/object/object_relations.c 
b/source/blender/editors/object/object_relations.c
index 111f3b6bf92..7df9f084640 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -1822,6 +1822,11 @@ static void single_obdata_users(
 DEG_id_tag_update(>id, ID_RECALC_GEOMETRY);
 
 switch (ob->type) {
+  case OB_EMPTY:
+ob->data = ID_NEW_SET(
+ob->data,
+BKE_id_copy_ex(bmain, ob->data, NULL, LIB_ID_COPY_DEFAULT | 
LIB_ID_COPY_ACTIONS));
+break;
   case OB_LAMP:
 ob->data = la = ID_NEW_SET(
 ob->data,

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


[Bf-blender-cvs] [ae459317974] blender-v3.2-release: Python: restrict name-space access for restricted evaluation

2022-08-02 Thread Campbell Barton
Commit: ae4593179745d55e93036902d3fd15045933a253
Author: Campbell Barton
Date:   Tue Aug 2 11:32:25 2022 +0200
Branches: blender-v3.2-release
https://developer.blender.org/rBae4593179745d55e93036902d3fd15045933a253

Python: restrict name-space access for restricted evaluation

From [0], restrict namsepace access to anything with an underscore
prefix since these may be undocumented.

[0]: 00c7e760b323e5fa46703d0e4769c8f1d9c35f2e

===

M   source/blender/python/intern/bpy_driver.c

===

diff --git a/source/blender/python/intern/bpy_driver.c 
b/source/blender/python/intern/bpy_driver.c
index a9cc0019783..1712213b612 100644
--- a/source/blender/python/intern/bpy_driver.c
+++ b/source/blender/python/intern/bpy_driver.c
@@ -359,6 +359,7 @@ static bool bpy_driver_secure_bytecode_validate(PyObject 
*expr_code, PyObject *d
   {
 for (int i = 0; i < PyTuple_GET_SIZE(py_code->co_names); i++) {
   PyObject *name = PyTuple_GET_ITEM(py_code->co_names, i);
+  const char *name_str = PyUnicode_AsUTF8(name);
 
   bool contains_name = false;
   for (int j = 0; dict_arr[j]; j++) {
@@ -368,11 +369,11 @@ static bool bpy_driver_secure_bytecode_validate(PyObject 
*expr_code, PyObject *d
 }
   }
 
-  if (contains_name == false) {
+  if ((contains_name == false) || (name_str[0] == '_')) {
 fprintf(stderr,
 "\tBPY_driver_eval() - restricted access disallows name '%s', "
 "enable auto-execution to support\n",
-PyUnicode_AsUTF8(name));
+name_str);
 return false;
   }
 }

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


[Bf-blender-cvs] [d03a5fab7a4] blender-v2.93-release: Python: restrict name-space access for restricted evaluation

2022-08-02 Thread Campbell Barton
Commit: d03a5fab7a4d0462091c93be52638015240f1afd
Author: Campbell Barton
Date:   Tue Aug 2 10:42:39 2022 +0200
Branches: blender-v2.93-release
https://developer.blender.org/rBd03a5fab7a4d0462091c93be52638015240f1afd

Python: restrict name-space access for restricted evaluation

From [0], restrict namsepace access to anything with an underscore
prefix since these may be undocumented.

[0]: 00c7e760b323e5fa46703d0e4769c8f1d9c35f2e

===

M   source/blender/python/intern/bpy_driver.c

===

diff --git a/source/blender/python/intern/bpy_driver.c 
b/source/blender/python/intern/bpy_driver.c
index 33162fdc35c..6c078e4228c 100644
--- a/source/blender/python/intern/bpy_driver.c
+++ b/source/blender/python/intern/bpy_driver.c
@@ -350,6 +350,7 @@ static bool bpy_driver_secure_bytecode_validate(PyObject 
*expr_code, PyObject *d
   {
 for (int i = 0; i < PyTuple_GET_SIZE(py_code->co_names); i++) {
   PyObject *name = PyTuple_GET_ITEM(py_code->co_names, i);
+  const char *name_str = PyUnicode_AsUTF8(name);
 
   bool contains_name = false;
   for (int j = 0; dict_arr[j]; j++) {
@@ -359,11 +360,11 @@ static bool bpy_driver_secure_bytecode_validate(PyObject 
*expr_code, PyObject *d
 }
   }
 
-  if (contains_name == false) {
+  if ((contains_name == false) || (name_str[0] == '_')) {
 fprintf(stderr,
 "\tBPY_driver_eval() - restricted access disallows name '%s', "
 "enable auto-execution to support\n",
-PyUnicode_AsUTF8(name));
+name_str);
 return false;
   }
 }

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


[Bf-blender-cvs] [ddffd1bc9f5] blender-v2.93-release: Fix (studio-reported) crash in some rare cases in blendfile read code.

2022-08-02 Thread Bastien Montagne
Commit: ddffd1bc9f52eb461f433e355bc8ec2bd5dc148f
Author: Bastien Montagne
Date:   Tue Aug 2 10:33:29 2022 +0200
Branches: blender-v2.93-release
https://developer.blender.org/rBddffd1bc9f52eb461f433e355bc8ec2bd5dc148f

Fix (studio-reported) crash in some rare cases in blendfile read code.

Crash would happen when a linked ID would become missing, that was
'pre-declared' and used only once as a 'weak link' in another library
stored before the one it came from.

In that case, the place-holder generated in read code would be freed in
read_library_clear_weak_links, when handling its 'owner' library, but
since all previous libraries in the list had already been 'lib_linked'
and their filedata (and related libmap) freed, the update of the libmaps
in read_library_clear_weak_links would not apply to data from those
previous libraries, leading to ID pointers there pointing to freed
memory.

This fix should also be backported to 2.93.

===

M   source/blender/blenloader/intern/readfile.c

===

diff --git a/source/blender/blenloader/intern/readfile.c 
b/source/blender/blenloader/intern/readfile.c
index 19ae0014bb8..a40029d4e08 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -5541,11 +5541,15 @@ static void read_libraries(FileData *basefd, ListBase 
*mainlist)
 }
   }
 
-  Main *main_newid = BKE_main_new();
   for (Main *mainptr = mainl->next; mainptr; mainptr = mainptr->next) {
-/* Drop weak links for which no data-block was found. */
+/* Drop weak links for which no data-block was found.
+ * Since this can remap pointers in `libmap` of all libraries, it needs to 
be performed in its
+ * own loop, before any call to `lib_link_all` (and the freeing of the 
libraries' filedata). */
 read_library_clear_weak_links(basefd, mainlist, mainptr);
+  }
 
+  Main *main_newid = BKE_main_new();
+  for (Main *mainptr = mainl->next; mainptr; mainptr = mainptr->next) {
 /* Do versioning for newly added linked data-locks. If no data-locks
  * were read from a library versionfile will still be zero and we can
  * skip it. */

___
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] [bc9d461ab0e] blender-v2.93-release: Fix Python SystemExit exceptions silently exiting

2022-08-02 Thread Campbell Barton
Commit: bc9d461ab0e178c45f681ee4154b97e94fa45156
Author: Campbell Barton
Date:   Tue Aug 2 10:16:44 2022 +0200
Branches: blender-v2.93-release
https://developer.blender.org/rBbc9d461ab0e178c45f681ee4154b97e94fa45156

Fix Python SystemExit exceptions silently exiting

Any script that raised a SystemExit called by --python, --python-expr
command line args or by executing the text block would exit without
printing a message. This caused the error from T99966 to be hidden.

Add explicit handling for SystemExit to ensure the message is always
shown before exiting.

More details noted in code-comments.

===

M   source/blender/python/generic/py_capi_utils.c

===

diff --git a/source/blender/python/generic/py_capi_utils.c 
b/source/blender/python/generic/py_capi_utils.c
index 9824d5f17c4..44293759672 100644
--- a/source/blender/python/generic/py_capi_utils.c
+++ b/source/blender/python/generic/py_capi_utils.c
@@ -591,6 +591,36 @@ void PyC_Err_PrintWithFunc(PyObject *py_func)
 /** \name Exception Buffer Access
  * \{ */
 
+static void pyc_exception_buffer_handle_system_exit(PyObject *error_type,
+PyObject *error_value,
+PyObject *error_traceback)
+{
+  if (!PyErr_GivenExceptionMatches(error_type, PyExc_SystemExit)) {
+return;
+  }
+  /* Inspecting, follow Python's logic in #_Py_HandleSystemExit & treat as a 
regular exception. */
+  if (_Py_GetConfig()->inspect) {
+return;
+  }
+
+  /* NOTE(@campbellbarton): A `SystemExit` exception will exit immediately 
(unless inspecting).
+   * So print the error and exit now. This is necessary as the call to 
#PyErr_Print exits,
+   * the temporary `sys.stderr` assignment causes the output to be suppressed, 
failing silently.
+   * Instead, restore the error and print it. If Python changes it's behavior 
and doesn't exit in
+   * the future - continue to create the exception buffer, see: T99966.
+   *
+   * Arguably accessing a `SystemExit` exception as a buffer should be 
supported without exiting.
+   * (by temporarily enabling inspection for example) however - it's not 
obvious exactly when this
+   * should be enabled and complicates the Python API by introducing different 
kinds of execution.
+   * Since the rule of thumb is for Blender's embedded Python to match 
stand-alone Python,
+   * favor exiting when a `SystemExit` is raised.
+   * Especially since this exception more likely to be used for 
background/batch-processing
+   * utilities where exiting immediately makes sense, the possibility of this 
being called
+   * indirectly from python-drivers or modal-operators is less of a concern. */
+  PyErr_Restore(error_type, error_value, error_traceback);
+  PyErr_Print();
+}
+
 /* returns the exception string as a new PyUnicode object, depends on external 
traceback module */
 #  if 0
 
@@ -641,6 +671,8 @@ PyObject *PyC_ExceptionBuffer(void)
 
   PyErr_Fetch(_type, _value, _traceback);
 
+  pyc_exception_buffer_handle_system_exit(error_type, error_value, 
error_traceback);
+
   PyErr_Clear();
 
   /* import io
@@ -713,6 +745,11 @@ PyObject *PyC_ExceptionBuffer_Simple(void)
 return NULL;
   }
 
+  /* Since #PyErr_Print is not called it's not essential that `SystemExit` 
exceptions are handled.
+   * Do this to match the behavior of #PyC_ExceptionBuffer since requesting a 
brief exception
+   * shouldn't result in completely different behavior. */
+  pyc_exception_buffer_handle_system_exit(error_type, error_value, 
error_traceback);
+
   if (PyErr_GivenExceptionMatches(error_type, PyExc_SyntaxError)) {
 /* Special exception for syntax errors,
  * in these cases the full error is verbose and not very useful,

___
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] [41689bb3104] blender-v2.93-release: Fix: Incorrect coordinates used in BLI_rct*_isect_segment functions

2022-08-02 Thread Siddhartha Jejurkar
Commit: 41689bb310469d85d9eae59ca578f4a15dc0e80b
Author: Siddhartha Jejurkar
Date:   Tue Jul 12 19:27:48 2022 +1000
Branches: blender-v2.93-release
https://developer.blender.org/rB41689bb310469d85d9eae59ca578f4a15dc0e80b

Fix: Incorrect coordinates used in BLI_rct*_isect_segment functions

Ref D15330.

===

M   source/blender/blenlib/intern/rct.c

===

diff --git a/source/blender/blenlib/intern/rct.c 
b/source/blender/blenlib/intern/rct.c
index 35e24ecc785..8b6e6abc713 100644
--- a/source/blender/blenlib/intern/rct.c
+++ b/source/blender/blenlib/intern/rct.c
@@ -294,7 +294,7 @@ bool BLI_rcti_isect_segment(const rcti *rect, const int 
s1[2], const int s2[2])
   /* diagonal: [/] */
   tvec1[0] = rect->xmin;
   tvec1[1] = rect->ymin;
-  tvec2[0] = rect->xmin;
+  tvec2[0] = rect->xmax;
   tvec2[1] = rect->ymax;
   if (isect_segments_i(s1, s2, tvec1, tvec2)) {
 return true;
@@ -340,7 +340,7 @@ bool BLI_rctf_isect_segment(const rctf *rect, const float 
s1[2], const float s2[
   /* diagonal: [/] */
   tvec1[0] = rect->xmin;
   tvec1[1] = rect->ymin;
-  tvec2[0] = rect->xmin;
+  tvec2[0] = rect->xmax;
   tvec2[1] = rect->ymax;
   if (isect_segments_fl(s1, s2, tvec1, tvec2)) {
 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] [670ced97589] master: GPencil: Allow import several SVG at time

2022-08-02 Thread Antonio Vazquez
Commit: 670ced97589d3fc29feafb32e96d08541aa7b32e
Author: Antonio Vazquez
Date:   Tue Aug 2 09:46:32 2022 +0200
Branches: master
https://developer.blender.org/rB670ced97589d3fc29feafb32e96d08541aa7b32e

GPencil: Allow import several SVG at time

For SVG is very convenient to be able to import several SVG in one operation. 
Each SVG is imported as a new Grease Pencil object.

Also, now the SVG file name is used as Object name.

Important: As all SVG imported are converted to Grease Pencil object in the 
same location of the 3D cursor, the SVG imported are not moved and the result 
may require a manual fix of location. The same is applied for depth order, the 
files are imported in alphabetic order according to the File list.

Reviewed By: mendio, pepeland

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

===

M   source/blender/editors/io/io_gpencil_import.c
M   source/blender/io/gpencil/gpencil_io.h
M   source/blender/io/gpencil/intern/gpencil_io_import_base.cc

===

diff --git a/source/blender/editors/io/io_gpencil_import.c 
b/source/blender/editors/io/io_gpencil_import.c
index 9ac64407dcf..b6fecfaf94e 100644
--- a/source/blender/editors/io/io_gpencil_import.c
+++ b/source/blender/editors/io/io_gpencil_import.c
@@ -9,6 +9,8 @@
 
 #  include "BLI_path_util.h"
 
+#  include "MEM_guardedalloc.h"
+
 #  include "DNA_gpencil_types.h"
 #  include "DNA_space_types.h"
 
@@ -63,7 +65,8 @@ static int wm_gpencil_import_svg_exec(bContext *C, wmOperator 
*op)
 {
   Scene *scene = CTX_data_scene(C);
 
-  if (!RNA_struct_property_is_set(op->ptr, "filepath")) {
+  if (!RNA_struct_property_is_set(op->ptr, "filepath") ||
+  !(RNA_struct_find_property(op->ptr, "directory"))) {
 BKE_report(op->reports, RPT_ERROR, "No filename given");
 return OPERATOR_CANCELLED;
   }
@@ -75,9 +78,6 @@ static int wm_gpencil_import_svg_exec(bContext *C, wmOperator 
*op)
   }
   View3D *v3d = get_invoke_view3d(C);
 
-  char filename[FILE_MAX];
-  RNA_string_get(op->ptr, "filepath", filename);
-
   /* Set flags. */
   int flag = 0;
 
@@ -101,13 +101,31 @@ static int wm_gpencil_import_svg_exec(bContext *C, 
wmOperator *op)
   .resolution = resolution,
   };
 
-  /* Do Import. */
-  WM_cursor_wait(1);
-  const bool done = gpencil_io_import(filename, );
-  WM_cursor_wait(0);
-
-  if (!done) {
-BKE_report(op->reports, RPT_WARNING, "Unable to import SVG");
+  /* Loop all selected files to import them. All SVG imported shared the same 
import
+   * parameters, but they are created in separated grease pencil objects. */
+  PropertyRNA *prop;
+  if ((prop = RNA_struct_find_property(op->ptr, "directory"))) {
+char *directory = RNA_string_get_alloc(op->ptr, "directory", NULL, 0, 
NULL);
+
+if ((prop = RNA_struct_find_property(op->ptr, "files"))) {
+  char file_path[FILE_MAX];
+  RNA_PROP_BEGIN (op->ptr, itemptr, prop) {
+char *filename = RNA_string_get_alloc(, "name", NULL, 0, NULL);
+BLI_join_dirfile(file_path, sizeof(file_path), directory, filename);
+MEM_freeN(filename);
+
+/* Do Import. */
+WM_cursor_wait(1);
+RNA_string_get(, "name", params.filename);
+const bool done = gpencil_io_import(file_path, );
+WM_cursor_wait(0);
+if (!done) {
+  BKE_reportf(op->reports, RPT_WARNING, "Unable to import '%s'", 
file_path);
+}
+  }
+  RNA_PROP_END;
+}
+MEM_freeN(directory);
   }
 
   return OPERATOR_FINISHED;
@@ -149,10 +167,11 @@ void WM_OT_gpencil_import_svg(wmOperatorType *ot)
   ot->check = wm_gpencil_import_svg_common_check;
 
   WM_operator_properties_filesel(ot,
- FILE_TYPE_OBJECT_IO,
+ FILE_TYPE_FOLDER | FILE_TYPE_OBJECT_IO,
  FILE_BLENDER,
  FILE_OPENFILE,
- WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH | 
WM_FILESEL_SHOW_PROPS,
+ WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH | 
WM_FILESEL_SHOW_PROPS |
+ WM_FILESEL_DIRECTORY | WM_FILESEL_FILES,
  FILE_DEFAULTDISPLAY,
  FILE_SORT_DEFAULT);
 
diff --git a/source/blender/io/gpencil/gpencil_io.h 
b/source/blender/io/gpencil/gpencil_io.h
index 215891e3e48..eb811fa2de8 100644
--- a/source/blender/io/gpencil/gpencil_io.h
+++ b/source/blender/io/gpencil/gpencil_io.h
@@ -35,6 +35,8 @@ typedef struct GpencilIOParams {
   /** Stroke sampling factor. */
   float stroke_sample;
   int32_t resolution;
+  /** Filename to be used in new objects. */
+  char filename[128];
 } GpencilIOParams;
 
 /* GpencilIOParams->flag. */
diff --git a/source/blender/io/gpencil/intern/gpencil_io_import_base.cc 
b/source/blender/io/gpencil/intern/gpencil_io_import_base.cc

[Bf-blender-cvs] [f263334529a] master: Merge branch 'blender-v3.3-release'

2022-08-02 Thread Aras Pranckevicius
Commit: f263334529a56381adcebe8d55d829502db2c717
Author: Aras Pranckevicius
Date:   Tue Aug 2 09:28:38 2022 +0300
Branches: master
https://developer.blender.org/rBf263334529a56381adcebe8d55d829502db2c717

Merge branch 'blender-v3.3-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] [02b1a209be8] blender-v3.3-release: Fix T100118: Crash after Shift+D with nothing selected and then making new object

2022-08-02 Thread Aras Pranckevicius
Commit: 02b1a209be88dc58cb635b79f4d4b300a86733e9
Author: Aras Pranckevicius
Date:   Tue Aug 2 09:28:17 2022 +0300
Branches: blender-v3.3-release
https://developer.blender.org/rB02b1a209be88dc58cb635b79f4d4b300a86733e9

Fix T100118: Crash after Shift+D with nothing selected and then making new 
object

Regression from rB2d041fc46823, the "nothing to do, return" code path
was not re-enabling layer collection sync. Fixes T100118.

===

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 e9abf8c1441..55366348f38 100644
--- a/source/blender/editors/object/object_add.cc
+++ b/source/blender/editors/object/object_add.cc
@@ -3715,13 +3715,13 @@ static int duplicate_exec(bContext *C, wmOperator *op)
 }
   }
   CTX_DATA_END;
+  /* Sync the collection now, after everything is duplicated. */
+  BKE_layer_collection_resync_allow();
+  BKE_main_collection_sync(bmain);
 
   if (source_bases_new_objects.is_empty()) {
 return OPERATOR_CANCELLED;
   }
-  /* Sync the collection now, after everything is duplicated. */
-  BKE_layer_collection_resync_allow();
-  BKE_main_collection_sync(bmain);
 
   /* After sync we can get to the new Base data, process it here. */
   for (const auto  : source_bases_new_objects) {

___
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