[Bf-blender-cvs] [2b4bafeac68] master: UV: add "similar object" and "similar winding" to uv "select similar"

2023-01-26 Thread Chris Blackbourn
Commit: 2b4bafeac68ea6fbb7b42760c9fc864d094d67f8
Author: Chris Blackbourn
Date:   Fri Jan 27 17:52:31 2023 +1300
Branches: master
https://developer.blender.org/rB2b4bafeac68ea6fbb7b42760c9fc864d094d67f8

UV: add "similar object" and "similar winding" to uv "select similar"

Adds new options to UV Face selection in the UV Editor, with UV > Select > 
Select Similar

In multi object edit mode, "Similar Object" selects faces which have the same 
object.

"Similar Winding" will select faces which have the same winding, i.e. are they
facing upwards or downwards.

Resolves: T103975
Differential Revision: https://developer.blender.org/D17125

===

M   source/blender/bmesh/intern/bmesh_polygon.c
M   source/blender/bmesh/intern/bmesh_polygon.h
M   source/blender/editors/uvedit/uvedit_select.c

===

diff --git a/source/blender/bmesh/intern/bmesh_polygon.c 
b/source/blender/bmesh/intern/bmesh_polygon.c
index a2aecf80456..8b185b17a3a 100644
--- a/source/blender/bmesh/intern/bmesh_polygon.c
+++ b/source/blender/bmesh/intern/bmesh_polygon.c
@@ -225,20 +225,26 @@ float BM_face_calc_area_with_mat3(const BMFace *f, const 
float mat3[3][3])
   return len_v3(n) * 0.5f;
 }
 
-float BM_face_calc_area_uv(const BMFace *f, int cd_loop_uv_offset)
+float BM_face_calc_area_uv_signed(const BMFace *f, int cd_loop_uv_offset)
 {
   /* inline 'area_poly_v2' logic, avoid creating a temp array */
   const BMLoop *l_iter, *l_first;
 
   l_iter = l_first = BM_FACE_FIRST_LOOP(f);
-  /* The Trapezium Area Rule */
+  /* Green's theorem applied to area of a polygon.
+   * TODO: `cross` should be of type `double` to reduce rounding error. */
   float cross = 0.0f;
   do {
 const float *luv = BM_ELEM_CD_GET_FLOAT_P(l_iter, cd_loop_uv_offset);
 const float *luv_next = BM_ELEM_CD_GET_FLOAT_P(l_iter->next, 
cd_loop_uv_offset);
 cross += (luv_next[0] - luv[0]) * (luv_next[1] + luv[1]);
   } while ((l_iter = l_iter->next) != l_first);
-  return fabsf(cross * 0.5f);
+  return cross * 0.5f;
+}
+
+float BM_face_calc_area_uv(const BMFace *f, int cd_loop_uv_offset)
+{
+  return fabsf(BM_face_calc_area_uv_signed(f, cd_loop_uv_offset));
 }
 
 float BM_face_calc_perimeter(const BMFace *f)
diff --git a/source/blender/bmesh/intern/bmesh_polygon.h 
b/source/blender/bmesh/intern/bmesh_polygon.h
index 6262f185eca..bff1d1d587d 100644
--- a/source/blender/bmesh/intern/bmesh_polygon.h
+++ b/source/blender/bmesh/intern/bmesh_polygon.h
@@ -73,7 +73,12 @@ float BM_face_calc_area(const BMFace *f) 
ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
 float BM_face_calc_area_with_mat3(const BMFace *f, const float mat3[3][3]) 
ATTR_WARN_UNUSED_RESULT
 ATTR_NONNULL();
 /**
- * get the area of UV face
+ * Calculate the signed area of UV face.
+ */
+float BM_face_calc_area_uv_signed(const BMFace *f, int cd_loop_uv_offset) 
ATTR_WARN_UNUSED_RESULT
+ATTR_NONNULL();
+/**
+ * Calculate the area of UV face.
  */
 float BM_face_calc_area_uv(const BMFace *f, int cd_loop_uv_offset) 
ATTR_WARN_UNUSED_RESULT
 ATTR_NONNULL();
diff --git a/source/blender/editors/uvedit/uvedit_select.c 
b/source/blender/editors/uvedit/uvedit_select.c
index 50185049fe1..99ee1ca0002 100644
--- a/source/blender/editors/uvedit/uvedit_select.c
+++ b/source/blender/editors/uvedit/uvedit_select.c
@@ -87,9 +87,11 @@ typedef enum {
   UV_SSIM_FACE,
   UV_SSIM_LENGTH_UV,
   UV_SSIM_LENGTH_3D,
-  UV_SSIM_SIDES,
-  UV_SSIM_PIN,
   UV_SSIM_MATERIAL,
+  UV_SSIM_OBJECT,
+  UV_SSIM_PIN,
+  UV_SSIM_SIDES,
+  UV_SSIM_WINDING,
 } eUVSelectSimilar;
 
 /*  */
@@ -4633,6 +4635,7 @@ static float get_uv_edge_needle(const eUVSelectSimilar 
type,
 
 static float get_uv_face_needle(const eUVSelectSimilar type,
 BMFace *face,
+int ob_index,
 const float ob_m3[3][3],
 const BMUVOffsets offsets)
 {
@@ -4646,6 +4649,8 @@ static float get_uv_face_needle(const eUVSelectSimilar 
type,
   return BM_face_calc_area_with_mat3(face, ob_m3);
 case UV_SSIM_SIDES:
   return face->len;
+case UV_SSIM_OBJECT:
+  return ob_index;
 case UV_SSIM_PIN: {
   BMLoop *l;
   BMIter liter;
@@ -4657,6 +4662,8 @@ static float get_uv_face_needle(const eUVSelectSimilar 
type,
 } break;
 case UV_SSIM_MATERIAL:
   return face->mat_nr;
+case UV_SSIM_WINDING:
+  return signum_i(BM_face_calc_area_uv_signed(face, offsets.uv));
 default:
   BLI_assert_unreachable();
   return false;
@@ -4966,7 +4973,7 @@ static int uv_select_similar_face_exec(bContext *C, 
wmOperator *op)
 continue;
   }
 
-  float needle = get_uv_face_needle(type, face, ob_m3, offsets);
+  float needle = get_uv_face_needle(type, face, ob_index, ob_m3, offsets);
   if (tree_1d) 

[Bf-blender-cvs] [6c0c339da97] sculpt-dev: sculpt-dev: fix error from merge

2023-01-26 Thread Joseph Eagar
Commit: 6c0c339da972ba067819ffeac08c93d9be9ee20d
Author: Joseph Eagar
Date:   Thu Jan 26 20:31:25 2023 -0800
Branches: sculpt-dev
https://developer.blender.org/rB6c0c339da972ba067819ffeac08c93d9be9ee20d

sculpt-dev: fix error from merge

===

M   source/blender/bmesh/intern/bmesh_mesh_convert.cc

===

diff --git a/source/blender/bmesh/intern/bmesh_mesh_convert.cc 
b/source/blender/bmesh/intern/bmesh_mesh_convert.cc
index fde4fc430d9..41a1363b060 100644
--- a/source/blender/bmesh/intern/bmesh_mesh_convert.cc
+++ b/source/blender/bmesh/intern/bmesh_mesh_convert.cc
@@ -437,9 +437,9 @@ void BM_mesh_bm_from_me(Object *ob,
  * At the moment it's simplest to assume all original meshes use the 
key-block and meshes
  * that are evaluated (through the modifier stack for example) use 
custom-data layers.
  */
-BLI_assert(!CustomData_has_layer(>vdata, CD_SHAPEKEY));
+BLI_assert(!CustomData_has_layer(_vdata, CD_SHAPEKEY));
   }
-  if (is_new == false && CustomData_has_layer(>vdata, CD_SHAPEKEY)) {
+  if (is_new == false && CustomData_has_layer(>vdata, CD_SHAPEKEY)) {
 tot_shape_keys = min_ii(tot_shape_keys, 
CustomData_number_of_layers(>vdata, CD_SHAPEKEY));
   }
   const float(**shape_key_table)[3] = tot_shape_keys ? (const 
float(**)[3])BLI_array_alloca(
@@ -1580,8 +1580,10 @@ void BM_mesh_bm_to_me(
 CustomData_copy(>pdata, >pdata, mask.pmask, CD_SET_DEFAULT, 
me->totpoly);
   }
 
-  CustomData_add_layer_named(
-  >vdata, CD_PROP_FLOAT3, CD_CONSTRUCT, nullptr, me->totvert, 
"position");
+  if (CustomData_get_named_layer_index(>vdata, CD_PROP_FLOAT3, "position") 
== -1) {
+CustomData_add_layer_named(
+>vdata, CD_PROP_FLOAT3, CD_CONSTRUCT, nullptr, me->totvert, 
"position");
+  }
   CustomData_add_layer(>edata, CD_MEDGE, CD_SET_DEFAULT, nullptr, 
me->totedge);
   CustomData_add_layer(>ldata, CD_MLOOP, CD_SET_DEFAULT, nullptr, 
me->totloop);
   CustomData_add_layer(>pdata, CD_MPOLY, CD_SET_DEFAULT, nullptr, 
me->totpoly);
@@ -1601,8 +1603,6 @@ void BM_mesh_bm_to_me(
 
   i = 0;
   BM_ITER_MESH (v, , bm, BM_VERTS_OF_MESH) {
-copy_v3_v3(positions[i], v->co);
-
 if (BM_elem_flag_test(v, BM_ELEM_HIDDEN)) {
   need_hide_vert = true;
 }
@@ -1615,6 +1615,8 @@ void BM_mesh_bm_to_me(
 /* Copy over custom-data. */
 CustomData_from_bmesh_block(>vdata, >vdata, v->head.data, i);
 
+copy_v3_v3(positions[i], v->co);
+
 i++;
 
 BM_CHECK_ELEMENT(v);

___
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] [71bce6d8e87] sculpt-dev: Merge branch 'master' into sculpt-dev

2023-01-26 Thread Joseph Eagar
Commit: 71bce6d8e87df59febac3bae37369573b711a3a4
Author: Joseph Eagar
Date:   Thu Jan 26 20:13:46 2023 -0800
Branches: sculpt-dev
https://developer.blender.org/rB71bce6d8e87df59febac3bae37369573b711a3a4

Merge branch 'master' into sculpt-dev

===



===

diff --cc CMakeLists.txt
index abe0b08ccf5,9dfb962a57e..fe4b245b381
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@@ -753,13 -751,6 +758,8 @@@ if("${CMAKE_GENERATOR}" MATCHES "Ninja"
mark_as_advanced(WITH_NINJA_POOL_JOBS)
  endif()
  
- if(UNIX AND NOT APPLE)
-   option(WITH_CXX11_ABI "Use native C++11 ABI of compiler" ON)
-   mark_as_advanced(WITH_CXX11_ABI)
- endif()
- 
 +option(WITH_INSTANT_MESHES, "Instant Meshes Quadrangulator" ON)
 +
  # Installation process.
  set(POSTINSTALL_SCRIPT "" CACHE FILEPATH "Run given CMake script after 
installation process")
  mark_as_advanced(POSTINSTALL_SCRIPT)
diff --cc intern/guardedalloc/intern/mallocn_lockfree_impl.c
index 2338012246b,2c4761c74f0..84f9f8dfa74
--- a/intern/guardedalloc/intern/mallocn_lockfree_impl.c
+++ b/intern/guardedalloc/intern/mallocn_lockfree_impl.c
@@@ -111,12 -87,9 +109,11 @@@ void MEM_lockfree_freeN(void *vmemh
}
  
MemHead *memh = MEMHEAD_FROM_PTR(vmemh);
 +  MEM_UNPOISON_MEMHEAD(vmemh);
 +
size_t len = MEMHEAD_LEN(memh);
  
-   atomic_sub_and_fetch_u(, 1);
-   atomic_sub_and_fetch_z(_in_use, len);
+   memory_usage_block_free(len);
  
if (UNLIKELY(malloc_debug_memset && len)) {
  memset(memh + 1, 255, len);
@@@ -271,11 -209,8 +268,9 @@@ void *MEM_lockfree_callocN(size_t len, 
  
if (LIKELY(memh)) {
  memh->len = len;
- atomic_add_and_fetch_u(, 1);
- atomic_add_and_fetch_z(_in_use, len);
- update_maximum(_mem, mem_in_use);
+ memory_usage_block_alloc(len);
  
 +MEM_POISON_MEMHEAD(PTR_FROM_MEMHEAD(memh));
  return PTR_FROM_MEMHEAD(memh);
}
print_error("Calloc returns null: len=" SIZET_FORMAT " in %s, total %u\n",
@@@ -317,12 -252,8 +312,10 @@@ void *MEM_lockfree_mallocN(size_t len, 
  }
  
  memh->len = len;
- atomic_add_and_fetch_u(, 1);
- atomic_add_and_fetch_z(_in_use, len);
- update_maximum(_mem, mem_in_use);
+ memory_usage_block_alloc(len);
  
 +MEM_POISON_MEMHEAD(PTR_FROM_MEMHEAD(memh));
 +
  return PTR_FROM_MEMHEAD(memh);
}
print_error("Malloc returns null: len=" SIZET_FORMAT " in %s, total %u\n",
@@@ -390,12 -321,8 +383,10 @@@ void *MEM_lockfree_mallocN_aligned(size
  
  memh->len = len | (size_t)MEMHEAD_ALIGN_FLAG;
  memh->alignment = (short)alignment;
- atomic_add_and_fetch_u(, 1);
- atomic_add_and_fetch_z(_in_use, len);
- update_maximum(_mem, mem_in_use);
+ memory_usage_block_alloc(len);
  
 +MEM_POISON_MEMHEAD(PTR_FROM_MEMHEAD(memh));
 +
  return PTR_FROM_MEMHEAD(memh);
}
print_error("Malloc returns null: len=" SIZET_FORMAT " in %s, total %u\n",
diff --cc release/scripts/presets/keyconfig/keymap_data/blender_default.py
index 6da898dc306,19a93e0882a..6b24452131d
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@@ -5098,14 -5047,22 +5095,25 @@@ def km_sculpt(params)
   {"properties": [("mode", 'INVERT')]}),
  ("sculpt.brush_stroke", {"type": 'LEFTMOUSE', "value": 'PRESS', 
"shift": True},
   {"properties": [("mode", 'SMOOTH')]}),
 +# Face Set by Topology
 +("sculpt.face_set_by_topology", {"type": 'W', "value": 'PRESS', 
"ctrl": True},
 + {"properties": [("mode", "POLY_LOOP"), ("repeat_previous", True)]}),
  # Expand
  ("sculpt.expand", {"type": 'A', "value": 'PRESS', "shift": True},
-  {"properties": [("target", "MASK"), ("falloff_type", "GEODESIC"), 
("invert", True)]}),
+  {"properties": [
+  ("target", "MASK"),
+  ("falloff_type", "GEODESIC"),
+  ("invert", True),
+  ("use_auto_mask", False),
+  ("use_mask_preserve", True),
+  ]}),
  ("sculpt.expand", {"type": 'A', "value": 'PRESS', "shift": True, 
"alt": True},
-  {"properties": [("target", "MASK"), ("falloff_type", "NORMALS"), 
("invert", False)]}),
+  {"properties": [
+  ("target", "MASK"),
+  ("falloff_type", "NORMALS"),
+  ("invert", False),
+  ("use_mask_preserve", True),
+  ]}),
  ("sculpt.expand", {"type": 'W', "value": 'PRESS', "shift": True},
   {"properties": [
   ("target", "FACE_SETS"),
@@@ -5117,15 -5076,9 +5127,16 @@@
   ("target", "FACE_SETS"),
   ("falloff_type", "BOUNDARY_FACE_SET"),
   ("invert", False),
+  ("use_mask_preserve", False),
   ("use_modify_active", True),
   ]}),
 +("sculpt.expand", {"type": 'W', "value": 'PRESS', 

[Bf-blender-cvs] [a5bddb43645] sculpt-dev: Sculpt-dev: Cleanup of edge collapse

2023-01-26 Thread Joseph Eagar
Commit: a5bddb436455d8dc84b5e853d5eec1f3236bb947
Author: Joseph Eagar
Date:   Tue Dec 20 02:54:34 2022 -0800
Branches: sculpt-dev
https://developer.blender.org/rBa5bddb436455d8dc84b5e853d5eec1f3236bb947

Sculpt-dev: Cleanup of edge collapse

Still a work in progress.

===

M   source/blender/blenkernel/intern/dyntopo.cc
M   source/blender/blenkernel/intern/paint.cc
M   source/blender/bmesh/intern/bmesh_construct.c
M   source/blender/bmesh/intern/bmesh_core.c
M   source/blender/bmesh/intern/bmesh_log.c
M   source/blender/editors/sculpt_paint/sculpt_dyntopo.c

===

diff --git a/source/blender/blenkernel/intern/dyntopo.cc 
b/source/blender/blenkernel/intern/dyntopo.cc
index baab7497ec9..36d3ec26657 100644
--- a/source/blender/blenkernel/intern/dyntopo.cc
+++ b/source/blender/blenkernel/intern/dyntopo.cc
@@ -2263,6 +2263,8 @@ static bool check_face_is_tri(PBVH *pbvh, BMFace *f)
 
 ATTR_NO_OPT static bool destroy_nonmanifold_fins(PBVH *pbvh, BMEdge *e_root)
 {
+  return false;
+
   bm_logstack_push();
 
   static int max_faces = 64;
@@ -2270,8 +2272,7 @@ ATTR_NO_OPT static bool destroy_nonmanifold_fins(PBVH 
*pbvh, BMEdge *e_root)
 
   BMLoop *l = e_root->l;
   Vector ls;
-  Vector fs;
-  int minfs = INT_MAX;
+  Vector minfs;
 
   if (!l) {
 bm_logstack_pop();
@@ -2309,7 +2310,7 @@ ATTR_NO_OPT static bool destroy_nonmanifold_fins(PBVH 
*pbvh, BMEdge *e_root)
 void **val = nullptr;
 BMFace *f2 = l->radial_next->f;
 
-if (!visit.lookup_key_or_add(f2)) {
+if (visit.add(f2)) {
   if (fs2.size() > max_faces) {
 bad = true;
 break;
@@ -2325,17 +2326,8 @@ ATTR_NO_OPT static bool destroy_nonmanifold_fins(PBVH 
*pbvh, BMEdge *e_root)
   }
 }
 
-if (!bad && fs2.size() < minfs) {
-#if 0
-  if (fs2.size() > 0) {
-fs.resize(fs2.size());
-memcpy((void *)[0], (void *)[0], sizeof(void *) * fs2.size());
-  } else {
-fs.clear();
-  }
-#endif
-  fs = fs2;
-  minfs = fs.size();
+if (!bad && fs2.size() && (minfs.size() == 0 || fs2.size() < 
minfs.size())) {
+  minfs = fs2;
 }
   }
 
@@ -2343,19 +2335,28 @@ ATTR_NO_OPT static bool destroy_nonmanifold_fins(PBVH 
*pbvh, BMEdge *e_root)
 PBVH_UpdateTriAreas;
   nupdateflag = nupdateflag | PBVH_UpdateNormals | PBVH_UpdateTris | 
PBVH_RebuildDrawBuffers;
 
-  if (!fs.size()) {
+  if (!minfs.size()) {
 bm_logstack_pop();
 return false;
   }
 
-  printf("manifold fin size: %d\n", fs.size());
+  printf("manifold fin size: %d\n", minfs.size());
   const int tag = BM_ELEM_TAG_ALT;
 
-  for (int i = 0; i < fs.size(); i++) {
-BMFace *f = fs[i];
+  for (int i = 0; i < minfs.size(); i++) {
+BMFace *f = minfs[i];
 
 BMLoop *l = f->l_first;
 do {
+  BMLoop *l2 = l;
+  do {
+BMLoop *l3 = l2;
+do {
+  l3->v->head.hflag &= ~tag;
+  l3->e->head.hflag &= ~tag;
+} while ((l3 = l3->next) != l2);
+  } while ((l2 = l2->radial_next) != l);
+
   l->v->head.hflag &= ~tag;
   l->e->head.hflag &= ~tag;
 } while ((l = l->next) != f->l_first);
@@ -2364,8 +2365,8 @@ ATTR_NO_OPT static bool destroy_nonmanifold_fins(PBVH 
*pbvh, BMEdge *e_root)
   Vector vs;
   Vector es;
 
-  for (int i = 0; i < fs.size(); i++) {
-BMFace *f = fs[i];
+  for (int i = 0; i < minfs.size(); i++) {
+BMFace *f = minfs[i];
 
 BMLoop *l = f->l_first;
 do {
@@ -2381,17 +2382,17 @@ ATTR_NO_OPT static bool destroy_nonmanifold_fins(PBVH 
*pbvh, BMEdge *e_root)
 } while ((l = l->next) != f->l_first);
   }
 
-  for (int i = 0; i < minfs; i++) {
-for (int j = 0; j < minfs; j++) {
-  if (i != j && fs[i] == fs[j]) {
+  for (int i = 0; i < minfs.size(); i++) {
+for (int j = 0; j < minfs.size(); j++) {
+  if (i != j && minfs[i] == minfs[j]) {
 printf("%s: duplicate faces\n", __func__);
 continue;
   }
 }
   }
 
-  for (int i = 0; i < minfs; i++) {
-BMFace *f = fs[i];
+  for (int i = 0; i < minfs.size(); i++) {
+BMFace *f = minfs[i];
 
 if (f->head.htype != BM_FACE) {
   printf("%s: corruption!\n", __func__);
@@ -3167,6 +3168,7 @@ static bool 
bm_edge_collapse_is_degenerate_topology(BMEdge *e_first)
 typedef struct TraceData {
   PBVH *pbvh;
   SmallHash visit;
+  blender::Set visit2;
   BMEdge *e;
 } TraceData;
 
@@ -3240,6 +3242,10 @@ ATTR_NO_OPT void col_on_vert_add(BMesh *bm, BMVert *v, 
void *userdata)
   TraceData *data = (TraceData *)userdata;
   PBVH *pbvh = data->pbvh;
 
+  if (!data->visit2.add(static_cast(v))) {
+// return;
+  }
+
   pbvh_boundary_update_bmesh(pbvh, v);
 
   MSculptVert *mv = (MSculptVert *)BM_ELEM_CD_GET_VOID_P(v, 
data->pbvh->cd_sculpt_vert);
@@ -3254,6 +3260,10 @@ ATTR_NO_OPT void col_on_edge_add(BMesh *bm, BMEdge *e, 
void *userdata)
   TraceData *data = 

[Bf-blender-cvs] [abc1b0ce41b] sculpt-dev: sculpt-dev: Update submodule refs ahead of merge

2023-01-26 Thread Joseph Eagar
Commit: abc1b0ce41bd60715e110867f1d9fe081de5c7b5
Author: Joseph Eagar
Date:   Fri Jan 13 20:37:39 2023 -0800
Branches: sculpt-dev
https://developer.blender.org/rBabc1b0ce41bd60715e110867f1d9fe081de5c7b5

sculpt-dev: Update submodule refs ahead of merge

===

M   release/datafiles/locale
M   release/scripts/addons
M   release/scripts/addons_contrib
M   source/tools

===

diff --git a/release/datafiles/locale b/release/datafiles/locale
index fe221a8bc93..7084c4ecd97 16
--- a/release/datafiles/locale
+++ b/release/datafiles/locale
@@ -1 +1 @@
-Subproject commit fe221a8bc934385d9f302c46a5c7cbeacddafe3b
+Subproject commit 7084c4ecd97d93459d9d23fd90f81589b09be5df
diff --git a/release/scripts/addons b/release/scripts/addons
index fdfd24de034..a9d4443c244 16
--- a/release/scripts/addons
+++ b/release/scripts/addons
@@ -1 +1 @@
-Subproject commit fdfd24de034d4bba4fb67731d0aae81dc4940239
+Subproject commit a9d4443c244f89399ec4bcc427e05a07950528cc
diff --git a/release/scripts/addons_contrib b/release/scripts/addons_contrib
index c43c0b2bcf0..bdcfdd47ec3 16
--- a/release/scripts/addons_contrib
+++ b/release/scripts/addons_contrib
@@ -1 +1 @@
-Subproject commit c43c0b2bcf08c34d933c3b56f096c9a23c8eff68
+Subproject commit bdcfdd47ec3451822b21d1cff2ea2db751093c9a
diff --git a/source/tools b/source/tools
index dfa16042bf7..e1744b9bd82 16
--- a/source/tools
+++ b/source/tools
@@ -1 +1 @@
-Subproject commit dfa16042bf7149475ad318d29a8202d969982abb
+Subproject commit e1744b9bd82527cf7e8af63362b61bd309b5711b

___
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] [6c8db7c22ba] master: Fix T103868: render uv transform gizmo even if it has zero area

2023-01-26 Thread Chris Blackbourn
Commit: 6c8db7c22ba48c49df0de0ab655b79342d866281
Author: Chris Blackbourn
Date:   Fri Jan 27 17:05:15 2023 +1300
Branches: master
https://developer.blender.org/rB6c8db7c22ba48c49df0de0ab655b79342d866281

Fix T103868: render uv transform gizmo even if it has zero area

Change the 2D Gizmo drawing function to provide a usable transform matrix,
if it would otherwise be degenerate.

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

===

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

===

diff --git a/source/blender/editors/transform/transform_gizmo_2d.c 
b/source/blender/editors/transform/transform_gizmo_2d.c
index a6eb25975e9..b99a650c3c0 100644
--- a/source/blender/editors/transform/transform_gizmo_2d.c
+++ b/source/blender/editors/transform/transform_gizmo_2d.c
@@ -604,8 +604,11 @@ static void gizmo2d_xform_draw_prepare(const bContext *C, 
wmGizmoGroup *gzgroup)
   UI_view2d_view_to_region_m4(>v2d, ggd->cage->matrix_space);
   /* Define the bounding box of the gizmo in the offset transform matrix. */
   unit_m4(ggd->cage->matrix_offset);
-  ggd->cage->matrix_offset[0][0] = (ggd->max[0] - ggd->min[0]);
-  ggd->cage->matrix_offset[1][1] = (ggd->max[1] - ggd->min[1]);
+  const float min_gizmo_pixel_size = 0.001f; /* Draw Gizmo larger than this 
many pixels. */
+  const float min_scale_axis_x = min_gizmo_pixel_size / 
ggd->cage->matrix_space[0][0];
+  const float min_scale_axis_y = min_gizmo_pixel_size / 
ggd->cage->matrix_space[1][1];
+  ggd->cage->matrix_offset[0][0] = max_ff(min_scale_axis_x, ggd->max[0] - 
ggd->min[0]);
+  ggd->cage->matrix_offset[1][1] = max_ff(min_scale_axis_y, ggd->max[1] - 
ggd->min[1]);
 
   ScrArea *area = CTX_wm_area(C);

___
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] [34a6591a073] master: Fix T98594: missing uv editor redraw with geometry nodes modifier

2023-01-26 Thread Chris Blackbourn
Commit: 34a6591a073f90620b6bcff458a407368b5dd02f
Author: Chris Blackbourn
Date:   Fri Jan 27 16:38:12 2023 +1300
Branches: master
https://developer.blender.org/rB34a6591a073f90620b6bcff458a407368b5dd02f

Fix T98594: missing uv editor redraw with geometry nodes modifier

If an object has a geometry nodes modifier, the UVs on that object might change
in response to any change on any other object.

Now we will redraw the UV editor on any object change, not just the active 
object.

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

===

M   source/blender/editors/space_image/space_image.c

===

diff --git a/source/blender/editors/space_image/space_image.c 
b/source/blender/editors/space_image/space_image.c
index 53e1bc0a1e5..fd8c161687e 100644
--- a/source/blender/editors/space_image/space_image.c
+++ b/source/blender/editors/space_image/space_image.c
@@ -405,7 +405,10 @@ static void image_listener(const wmSpaceTypeListenerParams 
*params)
   ViewLayer *view_layer = WM_window_get_active_view_layer(win);
   BKE_view_layer_synced_ensure(scene, view_layer);
   Object *ob = BKE_view_layer_active_object_get(view_layer);
-  if (ob && (ob == wmn->reference) && (ob->mode & OB_MODE_EDIT)) {
+  /* \note With a geometry nodes modifier, the UVs on `ob` can change 
in response to
+   * any change on `wmn->reference`. If we could track the upstream 
dependencies,
+   * unnecessary redraws could be reduced. Until then, just redraw. 
See T98594. */
+  if (ob && (ob->mode & OB_MODE_EDIT)) {
 if (sima->lock && (sima->flag & SI_DRAWSHADOW)) {
   ED_area_tag_refresh(area);
   ED_area_tag_redraw(area);

___
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] [d76004f48f4] master: Sculpt: Fix sculpt expand not switching falloff types properly

2023-01-26 Thread Joseph Eagar
Commit: d76004f48f46164a73b107a11f115d3c45e312ad
Author: Joseph Eagar
Date:   Thu Jan 26 17:53:32 2023 -0800
Branches: master
https://developer.blender.org/rBd76004f48f46164a73b107a11f115d3c45e312ad

Sculpt: Fix sculpt expand not switching falloff types properly

===

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

===

diff --git a/source/blender/editors/sculpt_paint/sculpt_expand.cc 
b/source/blender/editors/sculpt_paint/sculpt_expand.cc
index a125545c010..b6a71a69287 100644
--- a/source/blender/editors/sculpt_paint/sculpt_expand.cc
+++ b/source/blender/editors/sculpt_paint/sculpt_expand.cc
@@ -388,11 +388,11 @@ static BLI_bitmap 
*sculpt_expand_boundary_from_enabled(SculptSession *ss,
   return boundary_verts;
 }
 
-static void sculpt_expand_check_topology_islands(Object *ob)
+static void sculpt_expand_check_topology_islands(Object *ob, 
eSculptExpandFalloffType falloff_type)
 {
   SculptSession *ss = ob->sculpt;
 
-  ss->expand_cache->check_islands = ELEM(ss->expand_cache->falloff_type,
+  ss->expand_cache->check_islands = ELEM(falloff_type,
  SCULPT_EXPAND_FALLOFF_GEODESIC,
  SCULPT_EXPAND_FALLOFF_TOPOLOGY,
  
SCULPT_EXPAND_FALLOFF_TOPOLOGY_DIAGONALS,
@@ -1865,8 +1865,7 @@ static int sculpt_expand_modal(bContext *C, wmOperator 
*op, const wmEvent *event
 return OPERATOR_FINISHED;
   }
   case SCULPT_EXPAND_MODAL_FALLOFF_GEODESIC: {
-expand_cache->falloff_gradient = true;
-sculpt_expand_check_topology_islands(ob);
+sculpt_expand_check_topology_islands(ob, 
SCULPT_EXPAND_FALLOFF_GEODESIC);
 
 sculpt_expand_falloff_factors_from_vertex_and_symm_create(
 expand_cache,
@@ -1877,8 +1876,7 @@ static int sculpt_expand_modal(bContext *C, wmOperator 
*op, const wmEvent *event
 break;
   }
   case SCULPT_EXPAND_MODAL_FALLOFF_TOPOLOGY: {
-expand_cache->falloff_gradient = SCULPT_EXPAND_FALLOFF_TOPOLOGY;
-sculpt_expand_check_topology_islands(ob);
+sculpt_expand_check_topology_islands(ob, 
SCULPT_EXPAND_FALLOFF_TOPOLOGY);
 
 sculpt_expand_falloff_factors_from_vertex_and_symm_create(
 expand_cache,
@@ -1889,8 +1887,7 @@ static int sculpt_expand_modal(bContext *C, wmOperator 
*op, const wmEvent *event
 break;
   }
   case SCULPT_EXPAND_MODAL_FALLOFF_TOPOLOGY_DIAGONALS: {
-expand_cache->falloff_gradient = true;
-sculpt_expand_check_topology_islands(ob);
+sculpt_expand_check_topology_islands(ob, 
SCULPT_EXPAND_FALLOFF_TOPOLOGY_DIAGONALS);
 
 sculpt_expand_falloff_factors_from_vertex_and_symm_create(
 expand_cache,
@@ -2247,7 +2244,7 @@ static int sculpt_expand_invoke(bContext *C, wmOperator 
*op, const wmEvent *even
   sculpt_expand_falloff_factors_from_vertex_and_symm_create(
   ss->expand_cache, sd, ob, ss->expand_cache->initial_active_vertex, 
falloff_type);
 
-  sculpt_expand_check_topology_islands(ob);
+  sculpt_expand_check_topology_islands(ob, falloff_type);
 
   /* Initial mesh data update, resets all target data in the sculpt mesh. */
   sculpt_expand_update_for_vertex(C, ob, 
ss->expand_cache->initial_active_vertex);

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


[Bf-blender-cvs] [742c2e46bb1] master: Cleanup: format

2023-01-26 Thread Chris Blackbourn
Commit: 742c2e46bb1eee2d874b137e973658db57683f78
Author: Chris Blackbourn
Date:   Fri Jan 27 14:45:37 2023 +1300
Branches: master
https://developer.blender.org/rB742c2e46bb1eee2d874b137e973658db57683f78

Cleanup: format

===

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

===

diff --git a/source/blender/io/usd/intern/usd_reader_stage.cc 
b/source/blender/io/usd/intern/usd_reader_stage.cc
index 3ee5e666d38..393d8acba4a 100644
--- a/source/blender/io/usd/intern/usd_reader_stage.cc
+++ b/source/blender/io/usd/intern/usd_reader_stage.cc
@@ -355,7 +355,8 @@ void USDStageReader::fake_users_for_unused_materials()
 {
   /* Iterate over the imported materials and set a fake user for any unused
* materials. */
-  for (const std::pair _mat_pair : 
settings_.usd_path_to_mat_name) {
+  for (const std::pair _mat_pair :
+   settings_.usd_path_to_mat_name) {
 
 std::map::iterator mat_it = 
settings_.mat_name_to_mat.find(
 path_mat_pair.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] [e735bf02cb5] master: Fix linux/mac compiler warning.

2023-01-26 Thread Michael Kowalski
Commit: e735bf02cb5d73f7ab96f6ef4032ab758d890b60
Author: Michael Kowalski
Date:   Thu Jan 26 20:16:07 2023 -0500
Branches: master
https://developer.blender.org/rBe735bf02cb5d73f7ab96f6ef4032ab758d890b60

Fix linux/mac compiler warning.

===

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

===

diff --git a/source/blender/io/usd/intern/usd_reader_stage.cc 
b/source/blender/io/usd/intern/usd_reader_stage.cc
index 0c179ceae48..3ee5e666d38 100644
--- a/source/blender/io/usd/intern/usd_reader_stage.cc
+++ b/source/blender/io/usd/intern/usd_reader_stage.cc
@@ -355,7 +355,7 @@ void USDStageReader::fake_users_for_unused_materials()
 {
   /* Iterate over the imported materials and set a fake user for any unused
* materials. */
-  for (const std::pair _mat_pair : 
settings_.usd_path_to_mat_name) {
+  for (const std::pair _mat_pair : 
settings_.usd_path_to_mat_name) {
 
 std::map::iterator mat_it = 
settings_.mat_name_to_mat.find(
 path_mat_pair.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] [647cffc0016] master: Sculpt: Add numpad aliases for number keymap entries in expand modal map

2023-01-26 Thread Joseph Eagar
Commit: 647cffc0016374088dcd8decbc065d7799028939
Author: Joseph Eagar
Date:   Thu Jan 26 16:57:28 2023 -0800
Branches: master
https://developer.blender.org/rB647cffc0016374088dcd8decbc065d7799028939

Sculpt: Add numpad aliases for number keymap entries in expand modal map

===

M   release/scripts/presets/keyconfig/keymap_data/blender_default.py

===

diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py 
b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index ec89b61d47c..9f25d421c9d 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -6281,6 +6281,8 @@ def km_sculpt_expand_modal(_params):
 ("MOVE_TOGGLE", {"type": 'SPACE', "value": 'ANY', "any": True}, None),
 *((e, {"type": NUMBERS_1[i], "value": 'PRESS', "any": True}, None) for 
i, e in enumerate(
 ("FALLOFF_GEODESICS", "FALLOFF_TOPOLOGY", 
"FALLOFF_TOPOLOGY_DIAGONALS", "FALLOFF_SPHERICAL"))),
+*((e, {"type": "NUMPAD_%i" % (i+1), "value": 'PRESS', "any": True}, 
None) for i, e in enumerate(
+("FALLOFF_GEODESICS", "FALLOFF_TOPOLOGY", 
"FALLOFF_TOPOLOGY_DIAGONALS", "FALLOFF_SPHERICAL"))),
 ("SNAP_TOGGLE", {"type": 'LEFT_CTRL', "value": 'ANY'}, None),
 ("SNAP_TOGGLE", {"type": 'RIGHT_CTRL', "value": 'ANY'}, None),
 ("LOOP_COUNT_INCREASE", {"type": 'W', "value": 'PRESS', "any": True, 
"repeat": True}, None),

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


[Bf-blender-cvs] [3e903909187] master: Sculpt: Resolve `Shift R` shortcut conflicts

2023-01-26 Thread Aaron Carlisle
Commit: 3e903909187002d40e122993597793ca3c7afa28
Author: Aaron Carlisle
Date:   Thu Jan 26 16:55:03 2023 -0800
Branches: master
https://developer.blender.org/rB3e903909187002d40e122993597793ca3c7afa28

Sculpt: Resolve `Shift R` shortcut conflicts

Based on T99607:
- Existing Angle Control shortcuts are removed
- Voxel, Dyntopo and Hair resolution shortcuts are remapped to `R`

Since voxel remeshing is not compatible with dyntopo, each can use the shortcut 
`R` for the remeshing resolution without causing a conflict.
The shortcut `R` is not currently used for anything important.
The angle control menu is commonly not used.
And sculpt mode is only coincidentally inheriting the rotate operator shortcut 
on `R` because nothing else is mapped to the key.

Reviewed By: Julien Kaspar and Hans Goudey and Joseph Eagar
Differential Revision: https://developer.blender.org/D16511
Ref D16511

===

M   release/scripts/addons
M   release/scripts/presets/keyconfig/keymap_data/blender_default.py
M   
release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
M   release/scripts/startup/bl_ui/space_view3d.py

===

diff --git a/release/scripts/addons b/release/scripts/addons
index 9958ddb8799..d887a4ea6b2 16
--- a/release/scripts/addons
+++ b/release/scripts/addons
@@ -1 +1 @@
-Subproject commit 9958ddb879934718cc2b379b556f0bc3b861bee5
+Subproject commit d887a4ea6b2a9d64b926034d4e78ecf7a48ca979
diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py 
b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index 8f659449315..ec89b61d47c 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -4913,7 +4913,6 @@ def km_image_paint(params):
  {"properties": [("data_path", 
'image_paint_object.data.use_paint_mask')]}),
 ("wm.context_toggle", {"type": 'S', "value": 'PRESS', "shift": True},
  {"properties": [("data_path", 
'tool_settings.image_paint.brush.use_smooth_stroke')]}),
-op_menu("VIEW3D_MT_angle_control", {"type": 'R', "value": 'PRESS'}),
 ("wm.context_menu_enum", {"type": 'E', "value": 'PRESS'},
  {"properties": [("data_path", 
'tool_settings.image_paint.brush.stroke_method')]}),
 *_template_items_context_panel("VIEW3D_PT_paint_texture_context_menu", 
params.context_menu_event),
@@ -4962,7 +4961,6 @@ def km_vertex_paint(params):
  {"properties": [("data_path", 
'vertex_paint_object.data.use_paint_mask')]}),
 ("wm.context_toggle", {"type": 'S', "value": 'PRESS', "shift": True},
  {"properties": [("data_path", 
'tool_settings.vertex_paint.brush.use_smooth_stroke')]}),
-op_menu("VIEW3D_MT_angle_control", {"type": 'R', "value": 'PRESS'}),
 ("wm.context_menu_enum", {"type": 'E', "value": 'PRESS'},
  {"properties": [("data_path", 
'tool_settings.vertex_paint.brush.stroke_method')]}),
 ("paint.face_vert_reveal", {"type": 'H', "value": 'PRESS', "alt": 
True}, None),
@@ -5108,11 +5106,11 @@ def km_sculpt(params):
  {"properties": [("data_path", 
'scene.tool_settings.sculpt.show_mask')]}),
 # Dynamic topology
 ("sculpt.dynamic_topology_toggle", {"type": 'D', "value": 'PRESS', 
"ctrl": True}, None),
-("sculpt.dyntopo_detail_size_edit", {"type": 'D', "value": 'PRESS', 
"shift": True}, None),
+("sculpt.dyntopo_detail_size_edit", {"type": 'R', "value": 'PRESS'}, 
None),
 ("sculpt.set_detail_size", {"type": 'D', "value": 'PRESS', "shift": 
True, "alt": True}, None),
 # Remesh
 ("object.voxel_remesh", {"type": 'R', "value": 'PRESS', "ctrl": True}, 
None),
-("object.voxel_size_edit", {"type": 'R', "value": 'PRESS', "shift": 
True}, None),
+("object.voxel_size_edit", {"type": 'R', "value": 'PRESS'}, None),
 ("object.quadriflow_remesh", {"type": 'R', "value": 'PRESS', "ctrl": 
True, "alt": True}, None),
 # Color
 ("sculpt.sample_color", {"type": 'S', "value": 'PRESS'}, None),
@@ -5163,7 +5161,6 @@ def km_sculpt(params):
  {"properties": [("data_path", 
'tool_settings.sculpt.brush.stroke_method')]}),
 ("wm.context_toggle", {"type": 'S', "value": 'PRESS', "shift": True},
  {"properties": [("data_path", 
'tool_settings.sculpt.brush.use_smooth_stroke')]}),
-op_menu("VIEW3D_MT_angle_control", {"type": 'R', "value": 'PRESS'}),
 op_menu_pie("VIEW3D_MT_sculpt_mask_edit_pie", {"type": 'A', "value": 
'PRESS'}),
 op_menu_pie("VIEW3D_MT_sculpt_automasking_pie", {"type": 'A', "alt": 
True, "value": 'PRESS'}),
 op_menu_pie("VIEW3D_MT_sculpt_face_sets_edit_pie", {"type": 'W', 
"value": 'PRESS'}),
@@ -5643,7 +5640,7 @@ def km_sculpt_curves(params):
 ("curves.set_selection_domain", {"type": 

[Bf-blender-cvs] [ebccb23bba6] tmp-mak-012623: Fix linux/mac warnings.

2023-01-26 Thread Michael Kowalski
Commit: ebccb23bba6b8ba3a74bbd078b1d3622032fe778
Author: Michael Kowalski
Date:   Thu Jan 26 19:45:00 2023 -0500
Branches: tmp-mak-012623
https://developer.blender.org/rBebccb23bba6b8ba3a74bbd078b1d3622032fe778

Fix linux/mac warnings.

===

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

===

diff --git a/source/blender/io/usd/intern/usd_reader_stage.cc 
b/source/blender/io/usd/intern/usd_reader_stage.cc
index 0c179ceae48..3ee5e666d38 100644
--- a/source/blender/io/usd/intern/usd_reader_stage.cc
+++ b/source/blender/io/usd/intern/usd_reader_stage.cc
@@ -355,7 +355,7 @@ void USDStageReader::fake_users_for_unused_materials()
 {
   /* Iterate over the imported materials and set a fake user for any unused
* materials. */
-  for (const std::pair _mat_pair : 
settings_.usd_path_to_mat_name) {
+  for (const std::pair _mat_pair : 
settings_.usd_path_to_mat_name) {
 
 std::map::iterator mat_it = 
settings_.mat_name_to_mat.find(
 path_mat_pair.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] [cdef135f6f6] master: USD import: Support importing USDZ.

2023-01-26 Thread Michael Kowalski
Commit: cdef135f6f651c669f526a931a3cfd996d1e8cbd
Author: Michael Kowalski
Date:   Thu Jan 26 18:08:45 2023 -0500
Branches: master
https://developer.blender.org/rBcdef135f6f651c669f526a931a3cfd996d1e8cbd

USD import: Support importing USDZ.

This addressed feature request T99811.

Added the following features to fully support importing USDZ archives:

- Added .usdz to the list of supported extensions.
- Added new USD import options to copy textures from USDZ archives. The
textures may be imported as packed data (the default) or to a directory
on disk.
- Extended the USD material import logic to handle package-relative texture
assets paths by invoking the USD asset resolver to copy the textures from
the USDZ archive to a directory on disk. When importing in Packed mode,
the textures are first saved to Blender's temporary session directory
prior to packing.

The new USD import options are

- Import Textures: Behavior when importing textures from a USDZ archive
- Textures Directory: Path to the directory where imported textures will
be copied
- File Name Collision: Behavior when the name of an imported texture file
conflicts with an existing file

Import Textures menu options:

- None: Don't import textures
- Packed: Import textures as packed data (the default)
- Copy: Copy files to Textures Directory

File Name Collision menu options:

- Use Existing: If a file with the same name already exists, use that
instead of copying (the default)
- Overwrite: Overwrite existing files

Reviewed by: Bastien

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

===

M   release/scripts/startup/bl_ui/space_topbar.py
M   source/blender/blenkernel/intern/cachefile.c
M   source/blender/editors/io/io_usd.c
M   source/blender/editors/space_file/filelist.cc
M   source/blender/io/usd/CMakeLists.txt
A   source/blender/io/usd/intern/usd_asset_utils.cc
A   source/blender/io/usd/intern/usd_asset_utils.h
M   source/blender/io/usd/intern/usd_reader_material.cc
M   source/blender/io/usd/usd.h

===

diff --git a/release/scripts/startup/bl_ui/space_topbar.py 
b/release/scripts/startup/bl_ui/space_topbar.py
index 97f8a1bfad1..50bb1e42602 100644
--- a/release/scripts/startup/bl_ui/space_topbar.py
+++ b/release/scripts/startup/bl_ui/space_topbar.py
@@ -468,7 +468,7 @@ class TOPBAR_MT_file_import(Menu):
 self.layout.operator("wm.alembic_import", text="Alembic (.abc)")
 if bpy.app.build_options.usd:
 self.layout.operator(
-"wm.usd_import", text="Universal Scene Description (.usd, 
.usdc, .usda)")
+"wm.usd_import", text="Universal Scene Description (.usd*)")
 
 if bpy.app.build_options.io_gpencil:
 self.layout.operator("wm.gpencil_import_svg", text="SVG as Grease 
Pencil")
diff --git a/source/blender/blenkernel/intern/cachefile.c 
b/source/blender/blenkernel/intern/cachefile.c
index 5d19db323f8..5968a6b7296 100644
--- a/source/blender/blenkernel/intern/cachefile.c
+++ b/source/blender/blenkernel/intern/cachefile.c
@@ -366,7 +366,7 @@ void BKE_cachefile_eval(Main *bmain, Depsgraph *depsgraph, 
CacheFile *cache_file
   }
 #endif
 #ifdef WITH_USD
-  if (BLI_path_extension_check_glob(filepath, "*.usd;*.usda;*.usdc")) {
+  if (BLI_path_extension_check_glob(filepath, "*.usd;*.usda;*.usdc;*.usdz")) {
 cache_file->type = CACHEFILE_TYPE_USD;
 cache_file->handle = USD_create_handle(bmain, filepath, 
_file->object_paths);
 BLI_strncpy(cache_file->handle_filepath, filepath, FILE_MAX);
diff --git a/source/blender/editors/io/io_usd.c 
b/source/blender/editors/io/io_usd.c
index 99d4e84cfd4..e6426732584 100644
--- a/source/blender/editors/io/io_usd.c
+++ b/source/blender/editors/io/io_usd.c
@@ -72,6 +72,23 @@ const EnumPropertyItem 
rna_enum_usd_mtl_name_collision_mode_items[] = {
 {0, NULL, 0, NULL, NULL},
 };
 
+const EnumPropertyItem rna_enum_usd_tex_import_mode_items[] = {
+{USD_TEX_IMPORT_NONE, "IMPORT_NONE", 0, "None", "Don't import textures"},
+{USD_TEX_IMPORT_PACK, "IMPORT_PACK", 0, "Packed", "Import textures as 
packed data"},
+{USD_TEX_IMPORT_COPY, "IMPORT_COPY", 0, "Copy", "Copy files to Textures 
Directory"},
+{0, NULL, 0, NULL, NULL},
+};
+
+const EnumPropertyItem rna_enum_usd_tex_name_collision_mode_items[] = {
+{USD_TEX_NAME_COLLISION_USE_EXISTING,
+ "USE_EXISTING",
+ 0,
+ "Use Existing",
+ "If a file with the same name already exists, use that instead of 
copying"},
+{USD_TEX_NAME_COLLISION_OVERWRITE, "OVERWRITE", 0, "Overwrite", "Overwrite 
existing files"},
+{0, NULL, 0, NULL, NULL},
+};
+
 /* Stored in the wmOperator's customdata field to indicate it should run as a 
background job.
  * This is set when the operator is invoked, and not set when it is only 
executed. */
 enum { AS_BACKGROUND_JOB = 1 };
@@ -405,6 +422,14 @@ static 

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

2023-01-26 Thread Hans Goudey
Commit: 5ce6c617bbe9a3b2cd95e84020e5b3b5b2c8aff2
Author: Hans Goudey
Date:   Thu Jan 26 16:14:50 2023 -0600
Branches: refactor-mesh-sharp-face-generic
https://developer.blender.org/rB5ce6c617bbe9a3b2cd95e84020e5b3b5b2c8aff2

Merge branch 'master' into refactor-mesh-sharp-face-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] [7ea1b5a5e45] refactor-mesh-corners-generic: Merge branch 'master' into refactor-mesh-corners-generic

2023-01-26 Thread Hans Goudey
Commit: 7ea1b5a5e453ecde1eceb6010f7bd5cde4dc825a
Author: Hans Goudey
Date:   Thu Jan 26 15:52:23 2023 -0600
Branches: refactor-mesh-corners-generic
https://developer.blender.org/rB7ea1b5a5e453ecde1eceb6010f7bd5cde4dc825a

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

===



===

diff --cc source/blender/blenkernel/intern/cdderivedmesh.cc
index 720c78d283e,9cf5f7ecedf..580cd6966d8
--- a/source/blender/blenkernel/intern/cdderivedmesh.cc
+++ b/source/blender/blenkernel/intern/cdderivedmesh.cc
@@@ -234,12 -223,12 +231,14 @@@ static DerivedMesh *cdDM_from_mesh_ex(M
/* Though this may be an unnecessary calculation, simply retrieving the 
layer may return nothing
 * or dirty normals. */
cddm->vert_normals = BKE_mesh_vertex_normals_ensure(mesh);
-   cddm->medge = CustomData_get_layer_for_write(>edgeData, CD_MEDGE, 
mesh->totedge);
-   cddm->corner_verts = CustomData_get_layer_named_for_write(
-   >loopData, CD_PROP_INT32, ".corner_vert", mesh->totloop);
-   cddm->corner_edges = CustomData_get_layer_named_for_write(
-   >loopData, CD_PROP_INT32, ".corner_edge", mesh->totloop);
-   cddm->mpoly = CustomData_get_layer_for_write(>polyData, CD_MPOLY, 
mesh->totpoly);
+   cddm->medge = static_cast(
+   CustomData_get_layer_for_write(>edgeData, CD_MEDGE, mesh->totedge));
 -  cddm->mloop = static_cast(
 -  CustomData_get_layer_for_write(>loopData, CD_MLOOP, mesh->totloop));
++  cddm->corner_verts = static_cast(CustomData_get_layer_named_for_write(
++  >loopData, CD_PROP_INT32, ".corner_vert", mesh->totloop));
++  cddm->corner_edges = static_cast(CustomData_get_layer_named_for_write(
++  >loopData, CD_PROP_INT32, ".corner_edge", mesh->totloop));
+   cddm->mpoly = static_cast(
+   CustomData_get_layer_for_write(>polyData, CD_MPOLY, mesh->totpoly));
  #if 0
cddm->mface = CustomData_get_layer(>faceData, CD_MFACE);
  #else
diff --cc source/blender/blenkernel/intern/deform.cc
index 103f5afdb98,dda4d098126..988a757b126
--- a/source/blender/blenkernel/intern/deform.cc
+++ b/source/blender/blenkernel/intern/deform.cc
@@@ -1106,8 -1103,8 +1101,8 @@@ void BKE_defvert_extract_vgroup_to_loop
  void BKE_defvert_extract_vgroup_to_polyweights(const MDeformVert *dvert,
 const int defgroup,
 const int verts_num,
 -   const MLoop *loops,
 +   const int *corner_verts,
-const int UNUSED(loops_num),
+const int /*loops_num*/,
 const MPoly *polys,
 const int polys_num,
 const bool invert_vgroup,
@@@ -1126,10 -1124,10 +1122,10 @@@
int j = mp->totloop;
float w = 0.0f;
  
 -  for (; j--; ml++) {
 -w += tmp_weights[ml->v];
 +  for (; j--; corner_vert++) {
 +w += tmp_weights[*corner_vert];
}
-   r_weights[i] = w / (float)mp->totloop;
+   r_weights[i] = w / float(mp->totloop);
  }
  
  MEM_freeN(tmp_weights);
diff --cc source/blender/blenkernel/intern/dynamicpaint.cc
index 79a8db6648b,9b30d34aabb..f4a8a2baf2f
--- a/source/blender/blenkernel/intern/dynamicpaint.cc
+++ b/source/blender/blenkernel/intern/dynamicpaint.cc
@@@ -1464,10 -1476,10 +1476,10 @@@ static void dynamicPaint_initAdjacencyD
MEM_freeN(temp_data);
  }
  
- typedef struct DynamicPaintSetInitColorData {
+ struct DynamicPaintSetInitColorData {
const DynamicPaintSurface *surface;
  
 -  const MLoop *mloop;
 +  const int *corner_verts;
const float (*mloopuv)[2];
const MLoopTri *mlooptri;
const MLoopCol *mloopcol;
@@@ -1484,10 -1497,10 +1497,10 @@@ static void dynamic_paint_set_init_colo
const PaintSurfaceData *sData = data->surface->data;
PaintPoint *pPoint = (PaintPoint *)sData->type_data;
  
 -  const MLoop *mloop = data->mloop;
 +  const int *corner_verts = data->corner_verts;
const MLoopTri *mlooptri = data->mlooptri;
const float(*mloopuv)[2] = data->mloopuv;
-   struct ImagePool *pool = data->pool;
+   ImagePool *pool = data->pool;
Tex *tex = data->surface->init_texture;
  
const bool scene_color_manage = data->scene_color_manage;
@@@ -1627,14 -1642,14 +1642,14 @@@ static void dynamicPaint_setInitialColo
  if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX) {
struct ImagePool *pool = BKE_image_pool_new();
  
-   DynamicPaintSetInitColorData data = {
-   .surface = surface,
-   .corner_verts = corner_verts,
-   .mlooptri = mlooptri,
-   .mloopuv = mloopuv,
-   .pool = pool,
-   .scene_color_manage = scene_color_manage,
-   

[Bf-blender-cvs] [95915484f2b] refactor-mesh-corners-generic: Cleanup: Use C++ accessor functions

2023-01-26 Thread Hans Goudey
Commit: 95915484f2b1be03bb5829c2abcca474431defb7
Author: Hans Goudey
Date:   Thu Jan 26 16:09:58 2023 -0600
Branches: refactor-mesh-corners-generic
https://developer.blender.org/rB95915484f2b1be03bb5829c2abcca474431defb7

Cleanup: Use C++ accessor functions

===

M   source/blender/blenkernel/intern/dynamicpaint.cc
M   source/blender/blenkernel/intern/fluid.cc
M   source/blender/blenloader/intern/versioning_290.cc
M   source/blender/editors/armature/meshlaplacian.cc
M   source/blender/editors/object/object_bake_api.cc
M   source/blender/editors/space_view3d/drawobject.cc
M   source/blender/editors/uvedit/uvedit_unwrap_ops.cc

===

diff --git a/source/blender/blenkernel/intern/dynamicpaint.cc 
b/source/blender/blenkernel/intern/dynamicpaint.cc
index f4a8a2baf2f..2d98c0e86f7 100644
--- a/source/blender/blenkernel/intern/dynamicpaint.cc
+++ b/source/blender/blenkernel/intern/dynamicpaint.cc
@@ -1416,7 +1416,7 @@ static void 
dynamicPaint_initAdjacencyData(DynamicPaintSurface *surface, const b
 int numOfPolys = mesh->totpoly;
 const MEdge *edges = BKE_mesh_edges(mesh);
 const MPoly *polys = BKE_mesh_polys(mesh);
-const int *corner_verts = BKE_mesh_corner_verts(mesh);
+const blender::Span corner_verts = mesh->corner_verts();
 
 /* count number of edges per vertex */
 for (int i = 0; i < numOfEdges; i++) {
@@ -1618,7 +1618,7 @@ static void dynamicPaint_setInitialColor(const Scene 
*scene, DynamicPaintSurface
   else if (surface->init_color_type == MOD_DPAINT_INITIAL_TEXTURE) {
 Tex *tex = surface->init_texture;
 
-const int *corner_verts = BKE_mesh_corner_verts(mesh);
+const blender::Span corner_verts = mesh->corner_verts();
 const MLoopTri *mlooptri = BKE_mesh_runtime_looptri_ensure(mesh);
 const int tottri = BKE_mesh_runtime_looptri_len(mesh);
 
@@ -1644,7 +1644,7 @@ static void dynamicPaint_setInitialColor(const Scene 
*scene, DynamicPaintSurface
 
   DynamicPaintSetInitColorData data{};
   data.surface = surface;
-  data.corner_verts = corner_verts;
+  data.corner_verts = corner_verts.data();
   data.mlooptri = mlooptri;
   data.mloopuv = mloopuv;
   data.pool = pool;
@@ -1676,7 +1676,7 @@ static void dynamicPaint_setInitialColor(const Scene 
*scene, DynamicPaintSurface
 
 /* For vertex surface, just copy colors from #MLoopCol. */
 if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX) {
-  const int *corner_verts = BKE_mesh_corner_verts(mesh);
+  const blender::Span corner_verts = mesh->corner_verts();
   const int totloop = mesh->totloop;
   const MLoopCol *col = static_cast(
   CustomData_get_layer_named(>ldata, CD_PROP_BYTE_COLOR, 
surface->init_layername));
@@ -1930,7 +1930,7 @@ static Mesh 
*dynamicPaint_Modifier_apply(DynamicPaintModifierData *pmd, Object *
 
   /* vertex color paint */
   if (surface->type == MOD_DPAINT_SURFACE_T_PAINT) {
-const int *corner_verts = BKE_mesh_corner_verts(result);
+const blender::Span corner_verts = mesh->corner_verts();
 const int totloop = result->totloop;
 const MPoly *mpoly = BKE_mesh_polys(result);
 const int totpoly = result->totpoly;
@@ -1982,7 +1982,7 @@ static Mesh 
*dynamicPaint_Modifier_apply(DynamicPaintModifierData *pmd, Object *
 }
 
 data.ob = ob;
-data.corner_verts = corner_verts;
+data.corner_verts = corner_verts.data();
 data.mpoly = mpoly;
 data.mloopcol = mloopcol;
 data.mloopcol_wet = mloopcol_wet;
@@ -2837,7 +2837,7 @@ int dynamicPaint_createUVSurface(Scene *scene,
 return setError(canvas, N_("Cannot bake non-'image sequence' formats"));
   }
 
-  const int *corner_verts = BKE_mesh_corner_verts(mesh);
+  const blender::Span corner_verts = mesh->corner_verts();
   mlooptri = BKE_mesh_runtime_looptri_ensure(mesh);
   const int tottri = BKE_mesh_runtime_looptri_len(mesh);
 
@@ -2925,7 +2925,7 @@ int dynamicPaint_createUVSurface(Scene *scene,
 data.tempWeights = tempWeights;
 data.mlooptri = mlooptri;
 data.mloopuv = mloopuv;
-data.corner_verts = corner_verts;
+data.corner_verts = corner_verts.data();
 data.tottri = tottri;
 data.faceBB = faceBB;
 
@@ -2984,7 +2984,7 @@ int dynamicPaint_createUVSurface(Scene *scene,
  mesh->totvert,
  mlooptri,
  tottri,
- corner_verts,
+ corner_verts.data(),
  mesh->totloop);
 
 int total_border = 0;
@@ -4298,7 +4298,7 @@ static bool dynamicPaint_paintMesh(Depsgraph *depsgraph,
 float(*positions)[3] = 

[Bf-blender-cvs] [f55d6816ecd] cycles_path_guiding: Guiding: Added roughness-based MIS guiding type and fixed sss bug with RIS

2023-01-26 Thread Sebastian Herholz
Commit: f55d6816ecd463b4d9ad5d3848a8ecc53723e083
Author: Sebastian Herholz
Date:   Thu Jan 26 19:50:20 2023 +0100
Branches: cycles_path_guiding
https://developer.blender.org/rBf55d6816ecd463b4d9ad5d3848a8ecc53723e083

Guiding: Added roughness-based MIS guiding type and fixed sss bug with RIS

===

M   intern/cycles/kernel/integrator/shade_surface.h
M   intern/cycles/kernel/integrator/surface_shader.h
M   intern/cycles/kernel/light/visibility.h

===

diff --git a/intern/cycles/kernel/integrator/shade_surface.h 
b/intern/cycles/kernel/integrator/shade_surface.h
index cc81dae8af0..8a52ab74a2a 100644
--- a/intern/cycles/kernel/integrator/shade_surface.h
+++ b/intern/cycles/kernel/integrator/shade_surface.h
@@ -372,7 +372,9 @@ ccl_device_forceinline int 
integrate_surface_bsdf_bssrdf_bounce(
 #if defined(__PATH_GUIDING__) && PATH_GUIDING_LEVEL >= 4
   if (kernel_data.integrator.use_surface_guiding) {
 if (kernel_data.integrator.guiding_directional_sampling_type ==
-GUIDING_DIRECTIONAL_SAMPLING_TYPE_PRODUCT) {
+GUIDING_DIRECTIONAL_SAMPLING_TYPE_PRODUCT ||
+kernel_data.integrator.guiding_directional_sampling_type ==
+GUIDING_DIRECTIONAL_SAMPLING_TYPE_ROUGHNESS) {
   label = surface_shader_bsdf_guided_sample_closure_mis(kg,
 state,
 sd,
diff --git a/intern/cycles/kernel/integrator/surface_shader.h 
b/intern/cycles/kernel/integrator/surface_shader.h
index 56707523f33..60eaed2c4ee 100644
--- a/intern/cycles/kernel/integrator/surface_shader.h
+++ b/intern/cycles/kernel/integrator/surface_shader.h
@@ -26,6 +26,24 @@ CCL_NAMESPACE_BEGIN
 /* Guiding */
 
 #ifdef __PATH_GUIDING__
+
+ccl_device float 
surface_shader_average_sample_weight_squared_roughness(ccl_private const 
ShaderData *sd){
+  float avg_roughness = 0.0f;
+  float sum_sample_weight = 0.0f;
+  for (int i = 0; i < sd->num_closure; i++) {
+ccl_private const ShaderClosure *sc = >closure[i];
+
+if (!CLOSURE_IS_BSDF_OR_BSSRDF(sc->type)) {
+  continue;
+}
+avg_roughness += sc->sample_weight * 
bsdf_get_specular_roughness_squared(sc);
+sum_sample_weight += sc->sample_weight;
+  }
+
+  avg_roughness = avg_roughness > 0.f ? avg_roughness / sum_sample_weight : 
0.f;
+  return avg_roughness;
+}
+
 ccl_device_inline void surface_shader_prepare_guiding(KernelGlobals kg,
   IntegratorState state,
   ccl_private ShaderData 
*sd,
@@ -38,6 +56,8 @@ ccl_device_inline void 
surface_shader_prepare_guiding(KernelGlobals kg,
   }
 
   const float surface_guiding_probability = 
kernel_data.integrator.surface_guiding_probability;
+  const int guiding_directional_sampling_type =
+  kernel_data.integrator.guiding_directional_sampling_type;
   float rand_bsdf_guiding = path_state_rng_1D(kg, rng_state, 
PRNG_SURFACE_BSDF_GUIDING);
 
   /* Compute proportion of diffuse BSDF and BSSRDFs .*/
@@ -45,6 +65,8 @@ ccl_device_inline void 
surface_shader_prepare_guiding(KernelGlobals kg,
   float bssrdf_sampling_fraction = 0.0f;
   float bsdf_bssrdf_sampling_sum = 0.0f;
 
+  bool fully_opaque = true;
+
   for (int i = 0; i < sd->num_closure; i++) {
 ShaderClosure *sc = >closure[i];
 if (CLOSURE_IS_BSDF_OR_BSSRDF(sc->type)) {
@@ -58,6 +80,10 @@ ccl_device_inline void 
surface_shader_prepare_guiding(KernelGlobals kg,
   if (CLOSURE_IS_BSSRDF(sc->type)) {
 bssrdf_sampling_fraction += sweight;
   }
+
+  if (CLOSURE_IS_BSDF_TRANSPARENT(sc->type) || 
CLOSURE_IS_BSDF_TRANSMISSION(sc->type)) {
+fully_opaque = false;
+  }
 }
   }
 
@@ -66,16 +92,31 @@ ccl_device_inline void 
surface_shader_prepare_guiding(KernelGlobals kg,
 bssrdf_sampling_fraction /= bsdf_bssrdf_sampling_sum;
   }
 
+  float avg_roughness = 
surface_shader_average_sample_weight_squared_roughness(sd);
+ 
   /* Init guiding (diffuse BSDFs only for now). */
-  if (!(diffuse_sampling_fraction > 0.0f &&
-guiding_bsdf_init(kg, state, sd->P, sd->N, rand_bsdf_guiding))) {
+  if (!fully_opaque || avg_roughness <= 0.05f ||
+  ((guiding_directional_sampling_type == 
GUIDING_DIRECTIONAL_SAMPLING_TYPE_PRODUCT) &&
+   (diffuse_sampling_fraction <= 0.f)) ||
+  !guiding_bsdf_init(kg, state, sd->P, sd->N, rand_bsdf_guiding)) {
 state->guiding.use_surface_guiding = false;
+state->guiding.surface_guiding_sampling_prob = 0.0f;
 return;
   }
 
   state->guiding.use_surface_guiding = true;
-  state->guiding.surface_guiding_sampling_prob = surface_guiding_probability *
- diffuse_sampling_fraction;
+  if (kernel_data.integrator.guiding_directional_sampling_type ==
+  

[Bf-blender-cvs] [1a27728dc8c] cycles_path_guiding: Guiding: fixing RIS sampling

2023-01-26 Thread Sebastian Herholz
Commit: 1a27728dc8c54db6a9bfeb66ee9ee2800258ed3b
Author: Sebastian Herholz
Date:   Mon Jan 23 17:25:49 2023 +0100
Branches: cycles_path_guiding
https://developer.blender.org/rB1a27728dc8c54db6a9bfeb66ee9ee2800258ed3b

Guiding: fixing RIS sampling

===

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

===

diff --git a/intern/cycles/kernel/integrator/surface_shader.h 
b/intern/cycles/kernel/integrator/surface_shader.h
index 23e30c3e3f4..56707523f33 100644
--- a/intern/cycles/kernel/integrator/surface_shader.h
+++ b/intern/cycles/kernel/integrator/surface_shader.h
@@ -21,7 +21,7 @@
 
 CCL_NAMESPACE_BEGIN
 
-//#define RIS_COSINE
+#define RIS_COSINE
 
 /* Guiding */
 
@@ -571,18 +571,22 @@ ccl_device int 
surface_shader_bsdf_guided_sample_closure_ris(KernelGlobals kg,
 rand_guiding_bsdf_ris[0] = path_state_rng_2D(kg, rng_state, 
PRNG_SURFACE_RIS_GUIDING_0);
 rand_guiding_bsdf_ris[1] = path_state_rng_2D(kg, rng_state, 
PRNG_SURFACE_RIS_GUIDING_1);
 
+float pi_factor = 2.0f;
+
 float2 sampled_rougness_ris[2];
 float eta_ris[2];
 int label_ris[2];
 
 float3 omega_in_ris[2];
-float ris_pdfs[2];
-float guide_pdfs[2];
-float bsdf_pdfs[2];
-float cosines[2];
+float ris_pdfs[2] = {0.f, 0.f};
+float guide_pdfs[2] = {0.f, 0.f};
+float bsdf_pdfs[2] = {0.f, 0.f};
+float cosines[2] = {0.f, 0.f};
 BsdfEval bsdf_evals[2];
-float avg_bsdf_evals[2];
-Spectrum evals[2];
+float avg_bsdf_evals[2] = {0.f, 0.f};
+Spectrum evals[2] = {zero_spectrum(), zero_spectrum()};
+
+int ris_idx = 0;
 
 // RIS0 - sample BSDF
 label_ris[0] = bsdf_sample(kg,
@@ -597,18 +601,20 @@ ccl_device int 
surface_shader_bsdf_guided_sample_closure_ris(KernelGlobals kg,
_ris[0]);
 
 bsdf_eval_init(_evals[0], sc->type, evals[0] * sc->weight);
-cosines[0] = max(0.01f, fabsf(dot(sd->N, omega_in_ris[0])));
-if (sd->num_closure > 1) {
-  float sweight = sc->sample_weight;
-  bsdf_pdfs[0] = _surface_shader_bsdf_eval_mis(
-  kg, sd, omega_in_ris[0], sc, _evals[0], (bsdf_pdfs[0]) * 
sweight, sweight, 0);
-  kernel_assert(reduce_min(bsdf_eval_sum(_evals[0])) >= 0.0f);
+if(bsdf_pdfs[0] > 0.f)
+{
+  cosines[0] = max(0.01f, fabsf(dot(sd->N, omega_in_ris[0])));
+  if (sd->num_closure > 1) {
+float sweight = sc->sample_weight;
+bsdf_pdfs[0] = _surface_shader_bsdf_eval_mis(
+kg, sd, omega_in_ris[0], sc, _evals[0], (bsdf_pdfs[0]) * 
sweight, sweight, 0);
+kernel_assert(reduce_min(bsdf_eval_sum(_evals[0])) >= 0.0f);
+  }
+  avg_bsdf_evals[0] = (bsdf_evals[0].sum[0] + bsdf_evals[0].sum[1] + 
bsdf_evals[0].sum[2]) /
+  3.0f;
+  guide_pdfs[0] = guiding_bsdf_pdf(kg, state, omega_in_ris[0]);
+  bsdf_pdfs[0] = max(0.f, bsdf_pdfs[0]);
 }
-avg_bsdf_evals[0] = (bsdf_evals[0].sum[0] + bsdf_evals[0].sum[1] + 
bsdf_evals[0].sum[2]) /
-3.0f;
-guide_pdfs[0] = guiding_bsdf_pdf(kg, state, omega_in_ris[0]);
-bsdf_pdfs[0] = max(0.f, bsdf_pdfs[0]);
-
 // assert(bsdf_pdfs[0] >= 1e-20f);
 // assert(guide_pdfs[0] >= 1e-20f);
 
@@ -635,12 +641,12 @@ ccl_device int 
surface_shader_bsdf_guided_sample_closure_ris(KernelGlobals kg,
 if (avg_bsdf_evals[0] > 0.f && bsdf_pdfs[0] > 1e-10f && guide_pdfs[0] > 
0.f) {
 #  ifdef RIS_COSINE
   ris_pdfs[0] = (avg_bsdf_evals[0] / cosines[0] *
- (0.5f * ((1.0f / (4.0f * float(M_PI))) + guide_pdfs[0]))) 
/
+ (0.5f * ((1.0f / (pi_factor * float(M_PI))) + 
guide_pdfs[0]))) /
 (0.5f * (bsdf_pdfs[0] + guide_pdfs[0]));
   //(0.5f * (bsdf_pdfs[0] + bsdf_pdfs[0]));
 #  else
   ris_pdfs[0] = (avg_bsdf_evals[0] *
- (0.5f * ((1.0f / (4.0f * float(M_PI))) + guide_pdfs[0]))) 
/
+ (0.5f * ((1.0f / (pi_factor * float(M_PI))) + 
guide_pdfs[0]))) /
 (0.5f * (bsdf_pdfs[0] + guide_pdfs[0]));
 #  endif
   sum_ris_pdfs += ris_pdfs[0];
@@ -650,15 +656,15 @@ ccl_device int 
surface_shader_bsdf_guided_sample_closure_ris(KernelGlobals kg,
   ris_pdfs[0] = 0.f;
 }
 assert(sum_ris_pdfs >= 0.f);
-/* */
+
 if (avg_bsdf_evals[1] > 0.f && bsdf_pdfs[1] > 1e-10f && guide_pdfs[1] > 
0.f) {
 #  ifdef RIS_COSINE
   ris_pdfs[1] = (avg_bsdf_evals[1] / cosines[1] *
- (0.5f * ((1.0f / (4.0f * float(M_PI))) + guide_pdfs[1]))) 
/
+ (0.5f * ((1.0f / (pi_factor * float(M_PI))) + 
guide_pdfs[1]))) /
 (0.5f * (bsdf_pdfs[1] + guide_pdfs[1]));
 #  else
   ris_pdfs[1] = (avg_bsdf_evals[1] *
- (0.5f * ((1.0f / (4.0f * float(M_PI))) + guide_pdfs[1]))) 
/
+ (0.5f * ((1.0f / (pi_factor * float(M_PI))) + 
guide_pdfs[1]))) /

[Bf-blender-cvs] [77b2ceaa1f0] cycles_path_guiding: BSDF: init all eval and samples with zeros

2023-01-26 Thread Sebastian Herholz
Commit: 77b2ceaa1f0cc9d46fc64c46641ae785a7c576de
Author: Sebastian Herholz
Date:   Thu Jan 26 20:14:08 2023 +0100
Branches: cycles_path_guiding
https://developer.blender.org/rB77b2ceaa1f0cc9d46fc64c46641ae785a7c576de

BSDF: init all eval and samples with zeros

===

M   intern/cycles/kernel/closure/bsdf.h

===

diff --git a/intern/cycles/kernel/closure/bsdf.h 
b/intern/cycles/kernel/closure/bsdf.h
index b0d01c427de..42865991134 100644
--- a/intern/cycles/kernel/closure/bsdf.h
+++ b/intern/cycles/kernel/closure/bsdf.h
@@ -120,7 +120,9 @@ ccl_device_inline int bsdf_sample(KernelGlobals kg,
 {
   /* For curves use the smooth normal, particularly for ribbons the geometric
* normal gives too much darkening otherwise. */
-  int label;
+  *eval = zero_spectrum();
+  *pdf = 0.f;
+  int label = LABEL_NONE;
   const float3 Ng = (sd->type & PRIMITIVE_CURVE) ? sc->N : sd->Ng;
 
   switch (sc->type) {
@@ -526,6 +528,7 @@ ccl_device_inline
   ccl_private float *pdf)
 {
   Spectrum eval = zero_spectrum();
+  *pdf = 0.f;
 
   switch (sc->type) {
 case CLOSURE_BSDF_DIFFUSE_ID:

___
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] [a71930fa42b] cycles_path_guiding: Guiding: Adding ui switches to select the directional sampling type for guiding

2023-01-26 Thread Sebastian Herholz
Commit: a71930fa42b8ab2a231c586c75776e2d41fe1aa9
Author: Sebastian Herholz
Date:   Fri Jan 20 16:28:58 2023 +0100
Branches: cycles_path_guiding
https://developer.blender.org/rBa71930fa42b8ab2a231c586c75776e2d41fe1aa9

Guiding: Adding ui switches to select the directional sampling type for guiding

===

M   intern/cycles/blender/addon/properties.py
M   intern/cycles/blender/addon/ui.py
M   intern/cycles/blender/sync.cpp
M   intern/cycles/integrator/guiding.h
M   intern/cycles/kernel/data_template.h
M   intern/cycles/kernel/types.h
M   intern/cycles/scene/integrator.cpp
M   intern/cycles/scene/integrator.h

===

diff --git a/intern/cycles/blender/addon/properties.py 
b/intern/cycles/blender/addon/properties.py
index eed51eed95f..a90fd60a711 100644
--- a/intern/cycles/blender/addon/properties.py
+++ b/intern/cycles/blender/addon/properties.py
@@ -208,6 +208,11 @@ enum_guiding_distribution = (
 ('VMM', "VMM", "Use von Mises-Fisher models as directional distribution", 
2),
 )
 
+enum_guiding_directional_sampling_types = (
+('PRODUCT', "Diffuse Product", "Guided diffuse BSDF component based on the 
incoming light distribution and the cosine product (closed form product)", 0),
+('RIS', "Re-sampled Importance Sampling", "Perform RIS sampling to guided 
based on the product of the incoming light distribution and the BSDF", 1),
+('ROUGHNESS', "Roughness-based", "Adjust the guiding probability based on 
the roughness of the material components", 2),
+)
 
 def enum_openimagedenoise_denoiser(self, context):
 import _cycles
@@ -567,6 +572,13 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
 default='PARALLAX_AWARE_VMM',
 )
 
+guiding_directional_sampling_type: EnumProperty(
+name="Directional Sampling Type",
+description="Type of the directional sampling used for guiding",
+items=enum_guiding_directional_sampling_types,
+default='PRODUCT',
+)
+
 use_surface_guiding: BoolProperty(
 name="Surface Guiding",
 description="Use guiding when sampling directions on a surface",
diff --git a/intern/cycles/blender/addon/ui.py 
b/intern/cycles/blender/addon/ui.py
index 81f940529d1..b75e2a0cc1b 100644
--- a/intern/cycles/blender/addon/ui.py
+++ b/intern/cycles/blender/addon/ui.py
@@ -316,6 +316,8 @@ class 
CYCLES_RENDER_PT_sampling_path_guiding(CyclesButtonsPanel, Panel):
 
 layout.prop(cscene, "guiding_training_samples")
 
+layout.prop(cscene, "guiding_directional_sampling_type", 
text="Directional Sampling Type")
+
 col = layout.column(align=True)
 col.prop(cscene, "use_surface_guiding", text="Surface")
 col.prop(cscene, "use_volume_guiding", text="Volume")
diff --git a/intern/cycles/blender/sync.cpp b/intern/cycles/blender/sync.cpp
index 7df2a8cf30f..68ab3ad3cb4 100644
--- a/intern/cycles/blender/sync.cpp
+++ b/intern/cycles/blender/sync.cpp
@@ -441,6 +441,9 @@ void BlenderSync::sync_integrator(BL::ViewLayer 
_view_layer, bool background)
 GuidingDistributionType guiding_distribution_type = 
(GuidingDistributionType)get_enum(
 cscene, "guiding_distribution_type", GUIDING_NUM_TYPES, 
GUIDING_TYPE_PARALLAX_AWARE_VMM);
 integrator->set_guiding_distribution_type(guiding_distribution_type);
+GuidingDirectionalSamplingType guiding_directional_sampling_type = 
(GuidingDirectionalSamplingType)get_enum(
+cscene, "guiding_directional_sampling_type", 
GUIDING_DIRECTIONAL_SAMPLING_NUM_TYPES, 
GUIDING_DIRECTIONAL_SAMPLING_TYPE_PRODUCT);
+
integrator->set_guiding_directional_sampling_type(guiding_directional_sampling_type);
   }
 
   DenoiseParams denoise_params = get_denoise_params(b_scene, b_view_layer, 
background);
diff --git a/intern/cycles/integrator/guiding.h 
b/intern/cycles/integrator/guiding.h
index b7d7e2fe51e..fa918d4ea4b 100644
--- a/intern/cycles/integrator/guiding.h
+++ b/intern/cycles/integrator/guiding.h
@@ -15,6 +15,7 @@ struct GuidingParams {
   bool use_volume_guiding = false;
 
   GuidingDistributionType type = GUIDING_TYPE_PARALLAX_AWARE_VMM;
+  GuidingDirectionalSamplingType sampling_type = 
GUIDING_DIRECTIONAL_SAMPLING_TYPE_PRODUCT;
   int training_samples = 128;
   bool deterministic = false;
 
@@ -24,7 +25,7 @@ struct GuidingParams {
   {
 return !((use == other.use) && (use_surface_guiding == 
other.use_surface_guiding) &&
  (use_volume_guiding == other.use_volume_guiding) && (type == 
other.type) &&
- (training_samples == other.training_samples) &&
+ (sampling_type == other.sampling_type) && (training_samples == 
other.training_samples) &&
  (deterministic == other.deterministic));
   }
 };
diff --git a/intern/cycles/kernel/data_template.h 
b/intern/cycles/kernel/data_template.h
index fd25644e56b..93a1db64087 100644
--- 

[Bf-blender-cvs] [2fe4e806486] cycles_path_guiding: Guiding: Adding first implementation of RIS directional guiding

2023-01-26 Thread Sebastian Herholz
Commit: 2fe4e806486debc9029f0ae8d3d4d7f754249164
Author: Sebastian Herholz
Date:   Fri Jan 20 16:27:38 2023 +0100
Branches: cycles_path_guiding
https://developer.blender.org/rB2fe4e806486debc9029f0ae8d3d4d7f754249164

Guiding: Adding first implementation of RIS directional guiding

===

M   intern/cycles/blender/addon/properties.py
M   intern/cycles/blender/sync.cpp
M   intern/cycles/integrator/guiding.h
M   intern/cycles/kernel/data_template.h
M   intern/cycles/kernel/integrator/shade_surface.h
M   intern/cycles/kernel/integrator/surface_shader.h
M   intern/cycles/kernel/types.h
M   intern/cycles/scene/integrator.cpp

===

diff --git a/intern/cycles/blender/addon/properties.py 
b/intern/cycles/blender/addon/properties.py
index a90fd60a711..e0d7e1028de 100644
--- a/intern/cycles/blender/addon/properties.py
+++ b/intern/cycles/blender/addon/properties.py
@@ -209,11 +209,21 @@ enum_guiding_distribution = (
 )
 
 enum_guiding_directional_sampling_types = (
-('PRODUCT', "Diffuse Product", "Guided diffuse BSDF component based on the 
incoming light distribution and the cosine product (closed form product)", 0),
-('RIS', "Re-sampled Importance Sampling", "Perform RIS sampling to guided 
based on the product of the incoming light distribution and the BSDF", 1),
-('ROUGHNESS', "Roughness-based", "Adjust the guiding probability based on 
the roughness of the material components", 2),
+('PRODUCT',
+ "Diffuse Product",
+ "Guided diffuse BSDF component based on the incoming light distribution 
and the cosine product (closed form product)",
+ 0),
+('RIS',
+ "Re-sampled Importance Sampling",
+ "Perform RIS sampling to guided based on the product of the incoming 
light distribution and the BSDF",
+ 1),
+('ROUGHNESS',
+ "Roughness-based",
+ "Adjust the guiding probability based on the roughness of the material 
components",
+ 2),
 )
 
+
 def enum_openimagedenoise_denoiser(self, context):
 import _cycles
 if _cycles.with_openimagedenoise:
diff --git a/intern/cycles/blender/sync.cpp b/intern/cycles/blender/sync.cpp
index 68ab3ad3cb4..37e1cd55c46 100644
--- a/intern/cycles/blender/sync.cpp
+++ b/intern/cycles/blender/sync.cpp
@@ -441,8 +441,11 @@ void BlenderSync::sync_integrator(BL::ViewLayer 
_view_layer, bool background)
 GuidingDistributionType guiding_distribution_type = 
(GuidingDistributionType)get_enum(
 cscene, "guiding_distribution_type", GUIDING_NUM_TYPES, 
GUIDING_TYPE_PARALLAX_AWARE_VMM);
 integrator->set_guiding_distribution_type(guiding_distribution_type);
-GuidingDirectionalSamplingType guiding_directional_sampling_type = 
(GuidingDirectionalSamplingType)get_enum(
-cscene, "guiding_directional_sampling_type", 
GUIDING_DIRECTIONAL_SAMPLING_NUM_TYPES, 
GUIDING_DIRECTIONAL_SAMPLING_TYPE_PRODUCT);
+GuidingDirectionalSamplingType guiding_directional_sampling_type =
+(GuidingDirectionalSamplingType)get_enum(cscene,
+ 
"guiding_directional_sampling_type",
+ 
GUIDING_DIRECTIONAL_SAMPLING_NUM_TYPES,
+ 
GUIDING_DIRECTIONAL_SAMPLING_TYPE_PRODUCT);
 
integrator->set_guiding_directional_sampling_type(guiding_directional_sampling_type);
   }
 
diff --git a/intern/cycles/integrator/guiding.h 
b/intern/cycles/integrator/guiding.h
index fa918d4ea4b..8aa61e3371d 100644
--- a/intern/cycles/integrator/guiding.h
+++ b/intern/cycles/integrator/guiding.h
@@ -25,7 +25,8 @@ struct GuidingParams {
   {
 return !((use == other.use) && (use_surface_guiding == 
other.use_surface_guiding) &&
  (use_volume_guiding == other.use_volume_guiding) && (type == 
other.type) &&
- (sampling_type == other.sampling_type) && (training_samples == 
other.training_samples) &&
+ (sampling_type == other.sampling_type) &&
+ (training_samples == other.training_samples) &&
  (deterministic == other.deterministic));
   }
 };
diff --git a/intern/cycles/kernel/data_template.h 
b/intern/cycles/kernel/data_template.h
index 93a1db64087..29bb98c99b6 100644
--- a/intern/cycles/kernel/data_template.h
+++ b/intern/cycles/kernel/data_template.h
@@ -211,7 +211,7 @@ KERNEL_STRUCT_MEMBER(integrator, int, 
use_guiding_direct_light)
 KERNEL_STRUCT_MEMBER(integrator, int, use_guiding_mis_weights)
 
 /* Padding. */
-//KERNEL_STRUCT_MEMBER(integrator, int, pad1)
+// KERNEL_STRUCT_MEMBER(integrator, int, pad1)
 KERNEL_STRUCT_END(KernelIntegrator)
 
 /* SVM. For shader specialization. */
diff --git a/intern/cycles/kernel/integrator/shade_surface.h 
b/intern/cycles/kernel/integrator/shade_surface.h
index 548867c7551..cc81dae8af0 100644
--- a/intern/cycles/kernel/integrator/shade_surface.h
+++ 

[Bf-blender-cvs] [05b342c0a3e] cycles_path_guiding: Fix T103977: Cycles handling ray visibility inconsistent for forward and nee

2023-01-26 Thread Sebastian Herholz
Commit: 05b342c0a3e5a396103caed88ce62b380175977f
Author: Sebastian Herholz
Date:   Fri Jan 20 18:32:41 2023 +0100
Branches: cycles_path_guiding
https://developer.blender.org/rB05b342c0a3e5a396103caed88ce62b380175977f

Fix T103977: Cycles handling ray visibility inconsistent for forward and nee

===

M   intern/cycles/kernel/CMakeLists.txt
M   intern/cycles/kernel/integrator/shade_background.h
M   intern/cycles/kernel/integrator/shade_light.h
M   intern/cycles/kernel/integrator/shade_surface.h
M   intern/cycles/kernel/integrator/state_template.h
M   intern/cycles/kernel/integrator/surface_shader.h
A   intern/cycles/kernel/light/visibility.h

===

diff --git a/intern/cycles/kernel/CMakeLists.txt 
b/intern/cycles/kernel/CMakeLists.txt
index 78bd71988c0..48e9bd7b1ba 100644
--- a/intern/cycles/kernel/CMakeLists.txt
+++ b/intern/cycles/kernel/CMakeLists.txt
@@ -294,6 +294,7 @@ set(SRC_KERNEL_LIGHT_HEADERS
   light/spot.h
   light/tree.h
   light/triangle.h
+  light/visibility.h
 )
 
 set(SRC_KERNEL_SAMPLE_HEADERS
diff --git a/intern/cycles/kernel/integrator/shade_background.h 
b/intern/cycles/kernel/integrator/shade_background.h
index 3c01a162d01..dde7284847b 100644
--- a/intern/cycles/kernel/integrator/shade_background.h
+++ b/intern/cycles/kernel/integrator/shade_background.h
@@ -11,6 +11,7 @@
 
 #include "kernel/light/light.h"
 #include "kernel/light/sample.h"
+#include "kernel/light/visibility.h"
 
 CCL_NAMESPACE_BEGIN
 
@@ -22,20 +23,18 @@ ccl_device Spectrum 
integrator_eval_background_shader(KernelGlobals kg,
   const uint32_t path_flag = INTEGRATOR_STATE(state, path, flag);
 
   /* Use visibility flag to skip lights. */
+  Spectrum light_visibility = one_spectrum();
   if (shader & SHADER_EXCLUDE_ANY) {
-if (((shader & SHADER_EXCLUDE_DIFFUSE) && (path_flag & PATH_RAY_DIFFUSE)) 
||
-((shader & SHADER_EXCLUDE_GLOSSY) && ((path_flag & (PATH_RAY_GLOSSY | 
PATH_RAY_REFLECT)) ==
-  (PATH_RAY_GLOSSY | 
PATH_RAY_REFLECT))) ||
-((shader & SHADER_EXCLUDE_TRANSMIT) && (path_flag & 
PATH_RAY_TRANSMIT)) ||
-((shader & SHADER_EXCLUDE_CAMERA) && (path_flag & PATH_RAY_CAMERA)) ||
+if (((shader & SHADER_EXCLUDE_CAMERA) && (path_flag & PATH_RAY_CAMERA)) ||
 ((shader & SHADER_EXCLUDE_SCATTER) && (path_flag & 
PATH_RAY_VOLUME_SCATTER)))
   return zero_spectrum();
+light_visibility_correction(kg, state, shader, _visibility);
   }
 
   /* Use fast constant background color if available. */
   Spectrum L = zero_spectrum();
   if (surface_shader_constant_emission(kg, shader, )) {
-return L;
+return light_visibility * L;
   }
 
   /* Evaluate background shader. */
@@ -57,7 +56,7 @@ ccl_device Spectrum 
integrator_eval_background_shader(KernelGlobals kg,
   surface_shader_eval(
   kg, state, emission_sd, render_buffer, path_flag | PATH_RAY_EMISSION);
 
-  return surface_shader_background(emission_sd);
+  return light_visibility * surface_shader_background(emission_sd);
 }
 
 ccl_device_inline void integrate_background(KernelGlobals kg,
@@ -138,18 +137,14 @@ ccl_device_inline void 
integrate_distant_lights(KernelGlobals kg,
   for (int lamp = 0; lamp < kernel_data.integrator.num_lights; lamp++) {
 if (distant_light_sample_from_intersection(kg, ray_D, lamp, )) {
   /* Use visibility flag to skip lights. */
+  Spectrum light_visibility = one_spectrum();
 #ifdef __PASSES__
   const uint32_t path_flag = INTEGRATOR_STATE(state, path, flag);
-
   if (ls.shader & SHADER_EXCLUDE_ANY) {
-if (((ls.shader & SHADER_EXCLUDE_DIFFUSE) && (path_flag & 
PATH_RAY_DIFFUSE)) ||
-((ls.shader & SHADER_EXCLUDE_GLOSSY) &&
- ((path_flag & (PATH_RAY_GLOSSY | PATH_RAY_REFLECT)) ==
-  (PATH_RAY_GLOSSY | PATH_RAY_REFLECT))) ||
-((ls.shader & SHADER_EXCLUDE_TRANSMIT) && (path_flag & 
PATH_RAY_TRANSMIT)) ||
-((ls.shader & SHADER_EXCLUDE_CAMERA) && (path_flag & 
PATH_RAY_CAMERA)) ||
+if (((ls.shader & SHADER_EXCLUDE_CAMERA) && (path_flag & 
PATH_RAY_CAMERA)) ||
 ((ls.shader & SHADER_EXCLUDE_SCATTER) && (path_flag & 
PATH_RAY_VOLUME_SCATTER)))
   return;
+light_visibility_correction(kg, state, ls.shader, _visibility);
   }
 #endif
 
@@ -168,6 +163,7 @@ ccl_device_inline void 
integrate_distant_lights(KernelGlobals kg,
   ShaderDataTinyStorage emission_sd_storage;
   ccl_private ShaderData *emission_sd = 
AS_SHADER_DATA(_sd_storage);
   Spectrum light_eval = light_sample_shader_eval(kg, state, emission_sd, 
, ray_time);
+  light_eval *= light_visibility;
   if (is_zero(light_eval)) {
 return;
   }
diff --git a/intern/cycles/kernel/integrator/shade_light.h 
b/intern/cycles/kernel/integrator/shade_light.h
index 1f09ac4e6d8..f732961f464 100644
--- 

[Bf-blender-cvs] [69d3e7d95fb] cycles_path_guiding: Merge branch 'master' into cycles_path_guiding

2023-01-26 Thread Sebastian Herholz
Commit: 69d3e7d95fbaf1eeea64c3ceb5a93b8a7db5aa9b
Author: Sebastian Herholz
Date:   Thu Jan 26 20:02:18 2023 +0100
Branches: cycles_path_guiding
https://developer.blender.org/rB69d3e7d95fbaf1eeea64c3ceb5a93b8a7db5aa9b

Merge branch 'master' into cycles_path_guiding

===



===



___
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] [9a4c54e8b0a] master: Fix: Curve to Points node has wrong field interface status

2023-01-26 Thread Iliya Katueshenock
Commit: 9a4c54e8b0a3b6be8360042bc3a755b7adef20fd
Author: Iliya Katueshenock
Date:   Thu Jan 26 13:01:03 2023 -0600
Branches: master
https://developer.blender.org/rB9a4c54e8b0a3b6be8360042bc3a755b7adef20fd

Fix: Curve to Points node has wrong field interface status

In 7536abbe16bd changes make possible to input field as Count field.
But changes of declaration probably was forgotten. So now this input
can take field and node will be work. But input link was red. This
patch resolves this issue.

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

===

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

===

diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc 
b/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc
index ab7a9bef8db..f17c8044995 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc
@@ -25,6 +25,7 @@ static void node_declare(NodeDeclarationBuilder )
   b.add_input(N_("Count"))
   .default_value(10)
   .min(2)
+  .field_on_all()
   .max(10)
   .make_available(
   [](bNode ) { node_storage(node).mode = 
GEO_NODE_CURVE_RESAMPLE_COUNT; });

___
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] [d6c9cd445cb] master: Geometry Nodes: Skip sorting in topology nodes if possible

2023-01-26 Thread Hans Goudey
Commit: d6c9cd445cb41480b40fc7a7c29bbf982a2a6446
Author: Hans Goudey
Date:   Thu Jan 26 12:34:28 2023 -0600
Branches: master
https://developer.blender.org/rBd6c9cd445cb41480b40fc7a7c29bbf982a2a6446

Geometry Nodes: Skip sorting in topology nodes if possible

When the sort weights are a single value, they have no effect,
so sorting the relevant indices for the element will be wasted work.
The sorting is expensive compared to the rest of the node. In my
simple test of the points of curve node, it became 6 times faster
when the weights are a single value.

===

M   
source/blender/nodes/geometry/nodes/node_geo_curve_topology_points_of_curve.cc
M   
source/blender/nodes/geometry/nodes/node_geo_mesh_topology_corners_of_face.cc
M   
source/blender/nodes/geometry/nodes/node_geo_mesh_topology_corners_of_vertex.cc
M   
source/blender/nodes/geometry/nodes/node_geo_mesh_topology_edges_of_vertex.cc

===

diff --git 
a/source/blender/nodes/geometry/nodes/node_geo_curve_topology_points_of_curve.cc
 
b/source/blender/nodes/geometry/nodes/node_geo_curve_topology_points_of_curve.cc
index 0f9c14b0fee..8d9e4a07a76 100644
--- 
a/source/blender/nodes/geometry/nodes/node_geo_curve_topology_points_of_curve.cc
+++ 
b/source/blender/nodes/geometry/nodes/node_geo_curve_topology_points_of_curve.cc
@@ -49,6 +49,8 @@ class PointsOfCurveInput final : public bke::CurvesFieldInput 
{
  const eAttrDomain domain,
  const IndexMask mask) const final
   {
+const OffsetIndices points_by_curve = curves.points_by_curve();
+
 const bke::CurvesFieldContext context{curves, domain};
 fn::FieldEvaluator evaluator{context, };
 evaluator.add(curve_index_);
@@ -62,7 +64,7 @@ class PointsOfCurveInput final : public bke::CurvesFieldInput 
{
 point_evaluator.add(sort_weight_);
 point_evaluator.evaluate();
 const VArray all_sort_weights = 
point_evaluator.get_evaluated(0);
-const OffsetIndices points_by_curve = curves.points_by_curve();
+const bool use_sorting = !all_sort_weights.is_single();
 
 Array point_of_curve(mask.min_array_size());
 threading::parallel_for(mask.index_range(), 256, [&](const IndexRange 
range) {
@@ -77,25 +79,29 @@ class PointsOfCurveInput final : public 
bke::CurvesFieldInput {
   point_of_curve[selection_i] = 0;
   continue;
 }
-
 const IndexRange points = points_by_curve[curve_i];
 
-/* Retrieve the weights for each point. */
-sort_weights.reinitialize(points.size());
-all_sort_weights.materialize_compressed(IndexMask(points), 
sort_weights.as_mutable_span());
-
-/* Sort a separate array of compressed indices corresponding to the 
compressed weights.
- * This allows using `materialize_compressed` to avoid virtual 
function call overhead
- * when accessing values in the sort weights. However, it means a 
separate array of
- * indices within the compressed array is necessary for sorting. */
-sort_indices.reinitialize(points.size());
-std::iota(sort_indices.begin(), sort_indices.end(), 0);
-std::stable_sort(sort_indices.begin(), sort_indices.end(), [&](int a, 
int b) {
-  return sort_weights[a] < sort_weights[b];
-});
-
 const int index_in_sort_wrapped = mod_i(index_in_sort, points.size());
-point_of_curve[selection_i] = 
points[sort_indices[index_in_sort_wrapped]];
+if (use_sorting) {
+  /* Retrieve the weights for each point. */
+  sort_weights.reinitialize(points.size());
+  all_sort_weights.materialize_compressed(IndexMask(points),
+  
sort_weights.as_mutable_span());
+
+  /* Sort a separate array of compressed indices corresponding to the 
compressed weights.
+   * This allows using `materialize_compressed` to avoid virtual 
function call overhead
+   * when accessing values in the sort weights. However, it means a 
separate array of
+   * indices within the compressed array is necessary for sorting. */
+  sort_indices.reinitialize(points.size());
+  std::iota(sort_indices.begin(), sort_indices.end(), 0);
+  std::stable_sort(sort_indices.begin(), sort_indices.end(), [&](int 
a, int b) {
+return sort_weights[a] < sort_weights[b];
+  });
+  point_of_curve[selection_i] = 
points[sort_indices[index_in_sort_wrapped]];
+}
+else {
+  point_of_curve[selection_i] = points[index_in_sort_wrapped];
+}
   }
 });
 
diff --git 
a/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_corners_of_face.cc 
b/source/blender/nodes/geometry/nodes/node_geo_mesh_topology_corners_of_face.cc
index d5b4b4869c1..55c70095236 100644
--- 

[Bf-blender-cvs] [3b4486424a3] master: Fix repeated transform constraint orientations

2023-01-26 Thread Germano Cavalcante
Commit: 3b4486424a3299756dbe7eba923348c83304ca36
Author: Germano Cavalcante
Date:   Thu Jan 26 07:54:04 2023 -0300
Branches: master
https://developer.blender.org/rB3b4486424a3299756dbe7eba923348c83304ca36

Fix repeated transform constraint orientations

On some occasions, as in cases where transform operations are triggered
via gizmos, the constrain orientations that can be toggled with
multiple clicks of X, Y or Z were repeated.

There is no use in maintaining repeated orientations.

===

M   source/blender/editors/transform/transform_constraints.c
M   source/blender/editors/transform/transform_generics.c

===

diff --git a/source/blender/editors/transform/transform_constraints.c 
b/source/blender/editors/transform/transform_constraints.c
index 61adc98c258..f8e116e77b8 100644
--- a/source/blender/editors/transform/transform_constraints.c
+++ b/source/blender/editors/transform/transform_constraints.c
@@ -1001,6 +1001,9 @@ void postSelectConstraint(TransInfo *t)
 
 static void setNearestAxis2d(TransInfo *t)
 {
+  /* Clear any prior constraint flags. */
+  t->con.mode &= ~(CON_AXIS0 | CON_AXIS1 | CON_AXIS2);
+
   /* no correction needed... just use whichever one is lower */
   if (abs(t->mval[0] - t->con.imval[0]) < abs(t->mval[1] - t->con.imval[1])) {
 t->con.mode |= CON_AXIS1;
@@ -1014,6 +1017,9 @@ static void setNearestAxis2d(TransInfo *t)
 
 static void setNearestAxis3d(TransInfo *t)
 {
+  /* Clear any prior constraint flags. */
+  t->con.mode &= ~(CON_AXIS0 | CON_AXIS1 | CON_AXIS2);
+
   float zfac;
   float mvec[3], proj[3];
   float len[3];
@@ -1090,10 +1096,7 @@ static void setNearestAxis3d(TransInfo *t)
 
 void setNearestAxis(TransInfo *t)
 {
-  /* clear any prior constraint flags */
-  t->con.mode &= ~CON_AXIS0;
-  t->con.mode &= ~CON_AXIS1;
-  t->con.mode &= ~CON_AXIS2;
+  eTConstraint mode_prev = t->con.mode;
 
   /* constraint setting - depends on spacetype */
   if (t->spacetype == SPACE_VIEW3D) {
@@ -1105,7 +1108,9 @@ void setNearestAxis(TransInfo *t)
 setNearestAxis2d(t);
   }
 
-  projection_matrix_calc(t, t->con.pmtx);
+  if (mode_prev != t->con.mode) {
+projection_matrix_calc(t, t->con.pmtx);
+  }
 }
 
 /** \} */
diff --git a/source/blender/editors/transform/transform_generics.c 
b/source/blender/editors/transform/transform_generics.c
index 968e2bca5b9..f09c919c8b7 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -440,6 +440,7 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator 
*op, const wmEvent *eve
 
   {
 short orient_types[3];
+short orient_type_apply = O_DEFAULT;
 float custom_matrix[3][3];
 
 int orient_type_scene = V3D_ORIENT_GLOBAL;
@@ -502,14 +503,23 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator 
*op, const wmEvent *eve
 t->is_orient_default_overwrite = true;
   }
 }
-else if (t->con.mode & CON_APPLY) {
-  orient_type_set = orient_type_scene;
-}
-else if (orient_type_scene == V3D_ORIENT_GLOBAL) {
-  orient_type_set = V3D_ORIENT_LOCAL;
+
+if (orient_type_set == -1) {
+  if (orient_type_scene == V3D_ORIENT_GLOBAL) {
+orient_type_set = V3D_ORIENT_LOCAL;
+  }
+  else {
+orient_type_set = V3D_ORIENT_GLOBAL;
+  }
+
+  if (t->con.mode & CON_APPLY) {
+orient_type_apply = O_SCENE;
+  }
 }
 else {
-  orient_type_set = V3D_ORIENT_GLOBAL;
+  if (t->con.mode & CON_APPLY) {
+orient_type_apply = O_SET;
+  }
 }
 
 BLI_assert(!ELEM(-1, orient_type_default, orient_type_set));
@@ -546,7 +556,7 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator 
*op, const wmEvent *eve
   }
 }
 
-transform_orientations_current_set(t, (t->con.mode & CON_APPLY) ? 2 : 0);
+transform_orientations_current_set(t, orient_type_apply);
   }
 
   if (op && ((prop = RNA_struct_find_property(op->ptr, "release_confirm")) &&

___
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] [84ec6527186] temp-angavrilov: Shrinkwrap: fix stability of the Target Normal Project mode.

2023-01-26 Thread Alexander Gavrilov
Commit: 84ec6527186231eaf6987943cdff8d5bb4ba7c9a
Author: Alexander Gavrilov
Date:   Sat Sep 3 17:03:11 2022 +0300
Branches: temp-angavrilov
https://developer.blender.org/rB84ec6527186231eaf6987943cdff8d5bb4ba7c9a

Shrinkwrap: fix stability of the Target Normal Project mode.

This mode works by using an iterative process to solve a system
of equations for each triangle to find a point on its surface that
has the smooth normal pointing at the original point. If a point
within the triangle is not found, the next triangle is searched.

All instability with vertices jumping to the opposite side of
the mesh is caused by incorrectly discarding triangles for various
reasons when the solution is close to the triangle edge.

In order to optimize performance the old code was aggressively
aborting iteration when the local gradient at the edge was
pointing outside domain. However, it is wrong because it can be
caused by a sharp valley diagonal to the domain boundary with
the bottom gently sloping towards a minimum within the domain.

Now iteration is only aborted if the solution deviates
nonsensically far from the domain. Otherwise, the iteration
proceeds as usual, and the final result is checked against
domain borders with epsilon.

In addition, iterations can now be aborted based on the value
of the Jacobian determinant, or the number of linear search
correction steps. Both can signify a singularity, which can
be caused by the lack of a real solution to the equation.

Finally, custom correction clearly has to be done after
the linear search phase of the iterative solver, because the
linear correction math assumes running after a normal Newton
method step, not some kind of custom clamping.

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

===

M   source/blender/blenkernel/intern/shrinkwrap.cc
M   source/blender/blenlib/BLI_math_solvers.h
M   source/blender/blenlib/intern/math_solvers.c

===

diff --git a/source/blender/blenkernel/intern/shrinkwrap.cc 
b/source/blender/blenkernel/intern/shrinkwrap.cc
index 1a0b33ca2b1..5f5f29a1b36 100644
--- a/source/blender/blenkernel/intern/shrinkwrap.cc
+++ b/source/blender/blenkernel/intern/shrinkwrap.cc
@@ -752,6 +752,16 @@ static void target_project_tri_jacobian(void *userdata, 
const float x[3], float
   madd_v3_v3fl(r_jacobian[2], data->n1_minus_n2, x[1]);
 }
 
+/* Retrieve maximum deviation of the barycentric weights outside the triangle. 
*/
+static float target_project_tri_error(float x[3])
+{
+  float error = 0.0f;
+  error = max_ff(error, -x[0]);
+  error = max_ff(error, -x[1]);
+  error = max_ff(error, x[0] + x[1] - 1.0f);
+  return error;
+}
+
 /* Clamp barycentric weights to the triangle. */
 static void target_project_tri_clamp(float x[3])
 {
@@ -773,71 +783,26 @@ static bool target_project_tri_correct(void * 
/*userdata*/,
float step[3],
float x_next[3])
 {
-  /* Insignificant correction threshold */
-  const float epsilon = 1e-5f;
-  /* Dot product threshold for checking if step is 'clearly' pointing outside. 
*/
-  const float dir_epsilon = 0.5f;
-  bool fixed = false, locked = false;
-
-  /* The barycentric coordinate domain is a triangle bounded by
-   * the X and Y axes, plus the x+y=1 diagonal. First, clamp the
-   * movement against the diagonal. Note that step is subtracted. */
-  float sum = x[0] + x[1];
-  float sstep = -(step[0] + step[1]);
-
-  if (sum + sstep > 1.0f) {
-float ldist = 1.0f - sum;
-
-/* If already at the boundary, slide along it. */
-if (ldist < epsilon * float(M_SQRT2)) {
-  float step_len = len_v2(step);
-
-  /* Abort if the solution is clearly outside the domain. */
-  if (step_len > epsilon && sstep > step_len * dir_epsilon * 
float(M_SQRT2)) {
-return false;
-  }
-
-  /* Project the new position onto the diagonal. */
-  add_v2_fl(step, (sum + sstep - 1.0f) * 0.5f);
-  fixed = locked = true;
-}
-else {
-  /* Scale a significant step down to arrive at the boundary. */
-  mul_v3_fl(step, ldist / sstep);
-  fixed = true;
-}
-  }
-
-  /* Weight 0 and 1 boundary checks - along axis. */
-  for (int i = 0; i < 2; i++) {
-if (step[i] > x[i]) {
-  /* If already at the boundary, slide along it. */
-  if (x[i] < epsilon) {
-float step_len = len_v2(step);
-
-/* Abort if the solution is clearly outside the domain. */
-if (step_len > epsilon && (locked || step[i] > step_len * 
dir_epsilon)) {
-  return false;
-}
+  const float error = target_project_tri_error(x_next);
 
-/* Reset precision errors to stay at the boundary. */
-step[i] = x[i];
-fixed = true;
-  }
-  else {
-/* Scale a significant step down to arrive at the boundary. */
-mul_v3_fl(step, 

[Bf-blender-cvs] [9b1b2092c83] temp-angavrilov: Shape Keys: support locking to protect from accidental editing.

2023-01-26 Thread Alexander Gavrilov
Commit: 9b1b2092c83e5f0fdd911557c9e302460621871f
Author: Alexander Gavrilov
Date:   Tue Jan 24 16:53:10 2023 +0200
Branches: temp-angavrilov
https://developer.blender.org/rB9b1b2092c83e5f0fdd911557c9e302460621871f

Shape Keys: support locking to protect from accidental editing.

It is very common for graphical editors with layers to support
locking individual layers to protect them from accidental edits due
to misclicks. Blender itself already supports locking vertex groups.
This adds lock toggles for shape keys, with lock/unlock all operators.

The flags are checked by sculpt brushes, edit mode transform tools,
and Smooth, Propagate and Blend From Shape operators. This selection
aims to cover operations that only deform the mesh, where the shape
key selection matters. Topology changing operations always apply to
all keys, and thus incorrect shape key selection is less impactful.

===

M   release/scripts/startup/bl_ui/properties_data_mesh.py
M   source/blender/blenkernel/BKE_key.h
M   source/blender/blenkernel/intern/key.cc
M   source/blender/editors/include/ED_mesh.h
M   source/blender/editors/mesh/editmesh_tools.c
M   source/blender/editors/mesh/mesh_data.cc
M   source/blender/editors/object/object_intern.h
M   source/blender/editors/object/object_ops.c
M   source/blender/editors/object/object_shapekey.c
M   source/blender/editors/sculpt_paint/sculpt.cc
M   source/blender/editors/transform/transform_convert_curve.c
M   source/blender/editors/transform/transform_convert_lattice.c
M   source/blender/editors/transform/transform_convert_mesh.c
M   source/blender/editors/transform/transform_convert_sculpt.c
M   source/blender/makesdna/DNA_key_types.h
M   source/blender/makesrna/intern/rna_key.c

===

diff --git a/release/scripts/startup/bl_ui/properties_data_mesh.py 
b/release/scripts/startup/bl_ui/properties_data_mesh.py
index 1ff76a73e7e..f65516a34b2 100644
--- a/release/scripts/startup/bl_ui/properties_data_mesh.py
+++ b/release/scripts/startup/bl_ui/properties_data_mesh.py
@@ -70,6 +70,9 @@ class MESH_MT_shape_key_context_menu(Menu):
 op.all = True
 op.apply_mix = True
 layout.separator()
+layout.operator("object.shape_key_lock", icon='LOCKED', text="Lock 
All").action = 'LOCK'
+layout.operator("object.shape_key_lock", icon='UNLOCKED', text="Unlock 
All").action = 'UNLOCK'
+layout.separator()
 layout.operator("object.shape_key_move", icon='TRIA_UP_BAR', 
text="Move to Top").type = 'TOP'
 layout.operator("object.shape_key_move", icon='TRIA_DOWN_BAR', 
text="Move to Bottom").type = 'BOTTOM'
 
@@ -140,6 +143,7 @@ class MESH_UL_shape_keys(UIList):
 else:
 row.label(text="")
 row.prop(key_block, "mute", text="", emboss=False)
+row.prop(key_block, "lock_shape", text="", emboss=False)
 elif self.layout_type == 'GRID':
 layout.alignment = 'CENTER'
 layout.label(text="", icon_value=icon)
diff --git a/source/blender/blenkernel/BKE_key.h 
b/source/blender/blenkernel/BKE_key.h
index d868969f9b9..10c95253f38 100644
--- a/source/blender/blenkernel/BKE_key.h
+++ b/source/blender/blenkernel/BKE_key.h
@@ -87,9 +87,13 @@ struct KeyBlock *BKE_keyblock_add(struct Key *key, const 
char *name);
  */
 struct KeyBlock *BKE_keyblock_add_ctime(struct Key *key, const char *name, 
bool do_force);
 /**
- * Get the appropriate #KeyBlock given an index.
+ * Get the appropriate #KeyBlock given an index, excluding the first (0th) 
key. Key may be null.
  */
 struct KeyBlock *BKE_keyblock_from_key(struct Key *key, int index);
+/**
+ * Get the appropriate #KeyBlock given an index. Key may be null.
+ */
+struct KeyBlock *BKE_keyblock_find_index(struct Key *key, int index);
 /**
  * Get the appropriate #KeyBlock given a name to search for.
  */
diff --git a/source/blender/blenkernel/intern/key.cc 
b/source/blender/blenkernel/intern/key.cc
index 7d835c2464d..b8ff350917e 100644
--- a/source/blender/blenkernel/intern/key.cc
+++ b/source/blender/blenkernel/intern/key.cc
@@ -1899,12 +1899,7 @@ KeyBlock *BKE_keyblock_from_object(Object *ob)
 {
   Key *key = BKE_key_from_object(ob);
 
-  if (key) {
-KeyBlock *kb = static_cast(BLI_findlink(>block, 
ob->shapenr - 1));
-return kb;
-  }
-
-  return nullptr;
+  return BKE_keyblock_find_index(key, ob->shapenr - 1);
 }
 
 KeyBlock *BKE_keyblock_from_object_reference(Object *ob)
@@ -1935,6 +1930,15 @@ KeyBlock *BKE_keyblock_from_key(Key *key, int index)
   return nullptr;
 }
 
+KeyBlock *BKE_keyblock_find_index(Key *key, int index)
+{
+  if (key) {
+return static_cast(BLI_findlink(>block, index));
+  }
+
+  return nullptr;
+}
+
 KeyBlock *BKE_keyblock_find_name(Key *key, const char name[])
 {
   return static_cast(BLI_findstring(>block, name, 

[Bf-blender-cvs] [7faa8c84b35] temp-angavrilov: Subdivision Surface: fix a serious performance hit when mixing CPU & GPU.

2023-01-26 Thread Alexander Gavrilov
Commit: 7faa8c84b35397dee81532c235ebda487d71a8b7
Author: Alexander Gavrilov
Date:   Wed Jan 25 11:34:58 2023 +0200
Branches: temp-angavrilov
https://developer.blender.org/rB7faa8c84b35397dee81532c235ebda487d71a8b7

Subdivision Surface: fix a serious performance hit when mixing CPU & GPU.

Subdivision surface efficiency relies on caching pre-computed topology
data for evaluation between frames. However, while rBeed45d2a239a
introduced a second GPU subdiv evaluator type, it still only kept
one slot for caching this runtime data per mesh.

The result is that if the mesh is also needed on CPU, for instance
due to a modifier on a different object (e.g. shrinkwrap), the two
evaluators are used at the same time and fight over the single slot.
This causes the topology data to be discarded and recomputed twice
per frame.

Since avoiding duplicate evaluation is a complex task, this fix
simply adds a second separate cache slot for the GPU data, so that
the cost is simply running subdivision twice, not recomputing topology
twice.

To help diagnostics, I also add a message to show when GPU evaluation
is actually used to the modifier panel. Two frame counters are used
to suppress flicker in the UI panel.

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

===

M   source/blender/blenkernel/BKE_subdiv_modifier.h
M   source/blender/blenkernel/intern/mesh_wrapper.cc
M   source/blender/blenkernel/intern/subdiv_modifier.cc
M   source/blender/modifiers/intern/MOD_subsurf.cc

===

diff --git a/source/blender/blenkernel/BKE_subdiv_modifier.h 
b/source/blender/blenkernel/BKE_subdiv_modifier.h
index d65df26da77..dd01c4ffd07 100644
--- a/source/blender/blenkernel/BKE_subdiv_modifier.h
+++ b/source/blender/blenkernel/BKE_subdiv_modifier.h
@@ -32,8 +32,13 @@ typedef struct SubsurfRuntimeData {
   SubdivSettings settings;
 
   /* Cached subdivision surface descriptor, with topology and settings. */
-  struct Subdiv *subdiv;
-  bool set_by_draw_code;
+  struct Subdiv *subdiv_cpu;
+  struct Subdiv *subdiv_gpu;
+
+  /* Recent usage markers for UI diagnostics. To avoid UI flicker due to races
+   * between evaluation and UI redraw, they are set to 2 when an evaluator is 
used,
+   * and count down every frame. */
+  char used_cpu, used_gpu;
 
   /* Cached mesh wrapper data, to be used for GPU subdiv or lazy evaluation on 
CPU. */
   bool has_gpu_subdiv;
diff --git a/source/blender/blenkernel/intern/mesh_wrapper.cc 
b/source/blender/blenkernel/intern/mesh_wrapper.cc
index 9c8c36cacb8..3b036274477 100644
--- a/source/blender/blenkernel/intern/mesh_wrapper.cc
+++ b/source/blender/blenkernel/intern/mesh_wrapper.cc
@@ -350,7 +350,7 @@ static Mesh *mesh_wrapper_ensure_subdivision(Mesh *me)
 BKE_mesh_calc_normals_split(subdiv_mesh);
   }
 
-  if (subdiv != runtime_data->subdiv) {
+  if (subdiv != runtime_data->subdiv_cpu && subdiv != 
runtime_data->subdiv_gpu) {
 BKE_subdiv_free(subdiv);
   }
 
diff --git a/source/blender/blenkernel/intern/subdiv_modifier.cc 
b/source/blender/blenkernel/intern/subdiv_modifier.cc
index 3221e43d4e6..60d55af215c 100644
--- a/source/blender/blenkernel/intern/subdiv_modifier.cc
+++ b/source/blender/blenkernel/intern/subdiv_modifier.cc
@@ -49,6 +49,8 @@ bool BKE_subsurf_modifier_runtime_init(SubsurfModifierData 
*smd, const bool use_
  * was already allocated. */
 if (runtime_data) {
   runtime_data->settings = settings;
+
+  runtime_data->used_cpu = runtime_data->used_gpu = 0;
 }
 
 return false;
@@ -162,15 +164,18 @@ Subdiv 
*BKE_subsurf_modifier_subdiv_descriptor_ensure(SubsurfRuntimeData *runtim
   const Mesh *mesh,
   const bool for_draw_code)
 {
-  if (runtime_data->subdiv && runtime_data->set_by_draw_code != for_draw_code) 
{
-BKE_subdiv_free(runtime_data->subdiv);
-runtime_data->subdiv = nullptr;
+  if (for_draw_code) {
+runtime_data->used_gpu = 2; /* countdown in frames */
+
+return runtime_data->subdiv_gpu = BKE_subdiv_update_from_mesh(
+   runtime_data->subdiv_gpu, _data->settings, mesh);
+  }
+  else {
+runtime_data->used_cpu = 2;
+
+return runtime_data->subdiv_cpu = BKE_subdiv_update_from_mesh(
+   runtime_data->subdiv_cpu, _data->settings, mesh);
   }
-  Subdiv *subdiv = BKE_subdiv_update_from_mesh(
-  runtime_data->subdiv, _data->settings, mesh);
-  runtime_data->subdiv = subdiv;
-  runtime_data->set_by_draw_code = for_draw_code;
-  return subdiv;
 }
 
 int BKE_subsurf_modifier_eval_required_mode(bool is_final_render, bool 
is_edit_mode)
diff --git a/source/blender/modifiers/intern/MOD_subsurf.cc 
b/source/blender/modifiers/intern/MOD_subsurf.cc
index 75377f00bb3..7f6a9696b56 100644
--- a/source/blender/modifiers/intern/MOD_subsurf.cc
+++ 

[Bf-blender-cvs] [ee58795cae8] temp-angavrilov: Eevee: implement conditional evaluation of Mix node branches.

2023-01-26 Thread Alexander Gavrilov
Commit: ee58795cae8467edcff8470abc5ae24ce25a8255
Author: Alexander Gavrilov
Date:   Sun Oct 9 21:15:48 2022 +0300
Branches: temp-angavrilov
https://developer.blender.org/rBee58795cae8467edcff8470abc5ae24ce25a8255

Eevee: implement conditional evaluation of Mix node branches.

If the material effectively combines multiple distinct materials
using some kind of mask texture, it is wasteful to evaluate all
of them when the mask fully excludes some. Cycles already supports
this optimization for Mix Shader nodes.

This implements a similar feature for Mix Shader and Mix Color Blend
nodes in Eevee: shader matches Cycles, and mixing colors can be used
for a similar purpose in NPR shaders.

To achieve that, a Conditional node type directly supported by code
generation is added. Shader nodes can add these conditionals as needed,
and the code generator partitions the node graph into a branch tree
and appropriately generates conditionals. Empty conditionals are
automatically eliminated to avoid any performance impact. This
processing is done separately for every sub-graph to minimize
dependency cross-contamination.

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

===

M   source/blender/gpu/GPU_material.h
M   source/blender/gpu/intern/gpu_codegen.cc
M   source/blender/gpu/intern/gpu_node_graph.cc
M   source/blender/gpu/intern/gpu_node_graph.h
M   source/blender/nodes/shader/nodes/node_shader_mix.cc
M   source/blender/nodes/shader/nodes/node_shader_mix_shader.cc

===

diff --git a/source/blender/gpu/GPU_material.h 
b/source/blender/gpu/GPU_material.h
index f9bae39b016..c6e75a78091 100644
--- a/source/blender/gpu/GPU_material.h
+++ b/source/blender/gpu/GPU_material.h
@@ -195,6 +195,51 @@ bool GPU_stack_link(GPUMaterial *mat,
 GPUNodeStack *out,
 ...);
 
+/** Comparison operator for conditionals. */
+typedef enum {
+  GPU_CMP_NE = 0,
+  GPU_CMP_LT,
+  GPU_CMP_LE,
+  GPU_CMP_EQ,
+  GPU_CMP_GE,
+  GPU_CMP_GT,
+} GPUComparisonOp;
+
+/**
+ * Create a runtime ternary conditional, choosing between two inputs based on
+ * comparing a scalar float input with a constant threshold.
+ *
+ * \param cmp_input: Input to compare with the threshold.
+ * \param result_type: Type of value to produce.
+ * \param if_true: Input to use when the condition is true.
+ * \param if_false: Input to use when the condition is false. If null, this 
signifies
+ * the conditional is an optimization hint the input is unused if the 
condition is false.
+ * Depending on context, a valid default value is used, or the conditional may 
be discarded
+ * if it produces no performance benefit.
+ */
+GPUNodeLink *GPU_link_conditional(GPUMaterial *mat,
+  GPUNodeLink *cmp_input,
+  GPUComparisonOp cmp,
+  float threshold,
+  eGPUType result_type,
+  GPUNodeLink *if_true,
+  GPUNodeLink *if_false);
+
+/**
+ * Introduces a predicate for evaluating a stack input only when necessary.
+ * The conditional is only added if both inputs are non-constant.
+ *
+ * \param cmp_input: Input to compare with the threshold.
+ * \param inout_if_true: Stack entry to wrap in the conditional, suppressing 
evaluation when false.
+ * The link field within the entry is updated in place.
+ * \return true if the conditional was actually added.
+ */
+bool GPU_stack_link_conditional(GPUMaterial *mat,
+GPUNodeStack *cmp_input,
+GPUComparisonOp cmp,
+float threshold,
+GPUNodeStack *inout_if_true);
+
 void GPU_material_output_surface(GPUMaterial *material, GPUNodeLink *link);
 void GPU_material_output_volume(GPUMaterial *material, GPUNodeLink *link);
 void GPU_material_output_displacement(GPUMaterial *material, GPUNodeLink 
*link);
diff --git a/source/blender/gpu/intern/gpu_codegen.cc 
b/source/blender/gpu/intern/gpu_codegen.cc
index 465a621e864..f9f43e61291 100644
--- a/source/blender/gpu/intern/gpu_codegen.cc
+++ b/source/blender/gpu/intern/gpu_codegen.cc
@@ -40,6 +40,7 @@
 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -205,9 +206,25 @@ static std::ostream <<(std::ostream , 
const GPUInput *input)
   }
 }
 
-static std::ostream <<(std::ostream , const GPUOutput *output)
+static std::ostream <<(std::ostream , GPUComparisonOp cmp)
 {
-  return stream << SRC_NAME("out", output, outputs, "tmp") << output->id;
+  switch (cmp) {
+case GPU_CMP_NE:
+  return stream << "!=";
+case GPU_CMP_LT:
+  return stream << "<";
+case GPU_CMP_LE:
+  return stream << "<=";
+case GPU_CMP_EQ:
+  return stream << "==";
+case GPU_CMP_GE:
+  return 

[Bf-blender-cvs] [5d7a0461432] temp-angavrilov: Subdivision Surface: add dependency graph tracking when cpu mesh is needed.

2023-01-26 Thread Alexander Gavrilov
Commit: 5d7a04614321c2ecce62a055653b1023ade9a1e7
Author: Alexander Gavrilov
Date:   Wed Jan 25 11:37:40 2023 +0200
Branches: temp-angavrilov
https://developer.blender.org/rB5d7a04614321c2ecce62a055653b1023ade9a1e7

Subdivision Surface: add dependency graph tracking when cpu mesh is needed.

Constraints targeting mesh vertex groups, as well as likely modifiers
now tag their targets with a dependency graph flag to notify that the
fully evaluated mesh is needed on the CPU. This is used to disable GPU
subdiv in those cases.

In addition, the evaluated mesh is used by sculpt and paint modes.

===

M   source/blender/blenkernel/BKE_subdiv_modifier.h
M   source/blender/blenkernel/intern/subdiv_modifier.cc
M   source/blender/depsgraph/DEG_depsgraph.h
M   source/blender/depsgraph/DEG_depsgraph_build.h
M   source/blender/depsgraph/intern/builder/deg_builder_relations.cc
M   source/blender/depsgraph/intern/depsgraph_build.cc
M   source/blender/gpencil_modifiers/intern/MOD_gpencilshrinkwrap.c
M   source/blender/modifiers/intern/MOD_array.cc
M   source/blender/modifiers/intern/MOD_boolean.cc
M   source/blender/modifiers/intern/MOD_datatransfer.cc
M   source/blender/modifiers/intern/MOD_mesh_to_volume.cc
M   source/blender/modifiers/intern/MOD_meshdeform.c
M   source/blender/modifiers/intern/MOD_shrinkwrap.c
M   source/blender/modifiers/intern/MOD_subsurf.cc
M   source/blender/modifiers/intern/MOD_surfacedeform.cc
M   source/blender/modifiers/intern/MOD_weightvgproximity.cc

===

diff --git a/source/blender/blenkernel/BKE_subdiv_modifier.h 
b/source/blender/blenkernel/BKE_subdiv_modifier.h
index dd01c4ffd07..f20e2028b37 100644
--- a/source/blender/blenkernel/BKE_subdiv_modifier.h
+++ b/source/blender/blenkernel/BKE_subdiv_modifier.h
@@ -7,6 +7,7 @@
 
 #pragma once
 
+#include "BKE_DerivedMesh.h"
 #include "BKE_subdiv.h"
 
 #include "BLI_sys_types.h"
@@ -68,12 +69,15 @@ bool BKE_subsurf_modifier_use_custom_loop_normals(const 
struct SubsurfModifierDa
  * and supported by the GPU. It is mainly useful for showing UI messages.
  */
 bool BKE_subsurf_modifier_force_disable_gpu_evaluation_for_mesh(
-const struct SubsurfModifierData *smd, const struct Mesh *mesh);
+const struct Depsgraph *depsgraph,
+const struct Object *ob,
+const struct Mesh *mesh,
+const struct SubsurfModifierData *smd);
 /**
  * \param skip_check_is_last: When true, we assume that the modifier passed is 
the last enabled
  * modifier in the stack.
  */
-bool BKE_subsurf_modifier_can_do_gpu_subdiv(const struct Scene *scene,
+bool BKE_subsurf_modifier_can_do_gpu_subdiv(const struct Depsgraph *depsgraph,
 const struct Object *ob,
 const struct Mesh *mesh,
 const struct SubsurfModifierData 
*smd,
diff --git a/source/blender/blenkernel/intern/subdiv_modifier.cc 
b/source/blender/blenkernel/intern/subdiv_modifier.cc
index 60d55af215c..eb69f8bb5c9 100644
--- a/source/blender/blenkernel/intern/subdiv_modifier.cc
+++ b/source/blender/blenkernel/intern/subdiv_modifier.cc
@@ -14,6 +14,7 @@
 #include "BKE_mesh.h"
 #include "BKE_modifier.h"
 #include "BKE_subdiv.h"
+#include "DEG_depsgraph_query.h"
 
 #include "GPU_capabilities.h"
 #include "GPU_context.h"
@@ -112,8 +113,25 @@ static bool is_subdivision_evaluation_possible_on_gpu()
   return true;
 }
 
-bool BKE_subsurf_modifier_force_disable_gpu_evaluation_for_mesh(const 
SubsurfModifierData *smd,
-const Mesh 
*mesh)
+static bool subsurf_modifier_has_cpu_dependents(const Depsgraph *depsgraph, 
const Object *ob)
+{
+  /* The sculpt mode UI requires the mesh. */
+  if (ob->mode & OB_MODE_ALL_SCULPT) {
+return true;
+  }
+
+  /* Some dependencies request it through depsgraph. */
+  if (DEG_get_eval_flags_for_id(depsgraph, >id) & 
DAG_EVAL_NEED_CPU_SUBSURF) {
+return true;
+  }
+
+  return false;
+}
+
+bool BKE_subsurf_modifier_force_disable_gpu_evaluation_for_mesh(const 
Depsgraph *depsgraph,
+const Object 
*ob,
+const Mesh 
*mesh,
+const 
SubsurfModifierData *smd)
 {
   if ((U.gpu_flag & USER_GPU_FLAG_SUBDIVISION_EVALUATION) == 0) {
 /* GPU subdivision is explicitly disabled, so we don't force it. */
@@ -125,10 +143,11 @@ bool 
BKE_subsurf_modifier_force_disable_gpu_evaluation_for_mesh(const SubsurfMod
 return false;
   }
 
-  return subsurf_modifier_use_autosmooth_or_split_normals(smd, mesh);
+  return subsurf_modifier_use_autosmooth_or_split_normals(smd, mesh) ||
+ 

[Bf-blender-cvs] [85af3685d0f] temp-angavrilov: Bone Overlay: support bone wireframe opacity depth fade.

2023-01-26 Thread Alexander Gavrilov
Commit: 85af3685d0f72af8984e966307ece8e7e2f3ec14
Author: Alexander Gavrilov
Date:   Sat Dec 11 18:04:34 2021 +0300
Branches: temp-angavrilov
https://developer.blender.org/rB85af3685d0f72af8984e966307ece8e7e2f3ec14

Bone Overlay: support bone wireframe opacity depth fade.

Add an option that allows fade based on the depth from the camera,
using exponential decay with the slider specifying the 'half-life'
depth. This is intended as a way to automatically hide bones
in distant parts of the mesh while focused on a specific part.

===

M   release/scripts/startup/bl_ui/space_view3d.py
M   source/blender/blenloader/intern/versioning_300.cc
M   source/blender/draw/CMakeLists.txt
M   source/blender/draw/engines/overlay/overlay_armature.cc
M   source/blender/draw/engines/overlay/overlay_private.hh
M   
source/blender/draw/engines/overlay/shaders/infos/overlay_armature_info.hh
A   
source/blender/draw/engines/overlay/shaders/overlay_armature_alpha_lib.glsl
M   
source/blender/draw/engines/overlay/shaders/overlay_armature_dof_solid_frag.glsl
M   
source/blender/draw/engines/overlay/shaders/overlay_armature_envelope_solid_frag.glsl
M   
source/blender/draw/engines/overlay/shaders/overlay_armature_shape_solid_frag.glsl
M   
source/blender/draw/engines/overlay/shaders/overlay_armature_sphere_solid_frag.glsl
M   
source/blender/draw/engines/overlay/shaders/overlay_armature_stick_frag.glsl
M   
source/blender/draw/engines/overlay/shaders/overlay_armature_wire_frag.glsl
M   source/blender/makesdna/DNA_view3d_defaults.h
M   source/blender/makesdna/DNA_view3d_types.h
M   source/blender/makesrna/intern/rna_space.c

===

diff --git a/release/scripts/startup/bl_ui/space_view3d.py 
b/release/scripts/startup/bl_ui/space_view3d.py
index 2f5b70bb3da..39a40621455 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -6839,6 +6839,12 @@ class VIEW3D_PT_overlay_bones(Panel):
 if VIEW3D_PT_overlay_bones.is_using_wireframe(context):
 col.prop(overlay, "bone_wire_alpha")
 
+row = col.row()
+row.prop(overlay, "bone_wire_use_fade_depth", text="")
+sub = row.row()
+sub.active = overlay.bone_wire_use_fade_depth
+sub.prop(overlay, "bone_wire_fade_depth")
+
 
 class VIEW3D_PT_overlay_texture_paint(Panel):
 bl_space_type = 'VIEW_3D'
diff --git a/source/blender/blenloader/intern/versioning_300.cc 
b/source/blender/blenloader/intern/versioning_300.cc
index 4c45e1433ab..53ce28a057d 100644
--- a/source/blender/blenloader/intern/versioning_300.cc
+++ b/source/blender/blenloader/intern/versioning_300.cc
@@ -3912,5 +3912,19 @@ void blo_do_versions_300(FileData *fd, Library * 
/*lib*/, Main *bmain)
*/
   {
 /* Keep this block, even when empty. */
+
+/* Initialize the bone wireframe opacity depth fade setting. */
+if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "float", 
"bone_wire_fade_depth")) {
+  LISTBASE_FOREACH (bScreen *, screen, >screens) {
+LISTBASE_FOREACH (ScrArea *, area, >areabase) {
+  LISTBASE_FOREACH (SpaceLink *, sl, >spacedata) {
+if (sl->spacetype == SPACE_VIEW3D) {
+  View3D *v3d = (View3D *)sl;
+  v3d->overlay.bone_wire_fade_depth = 1.0f;
+}
+  }
+}
+  }
+}
   }
 }
diff --git a/source/blender/draw/CMakeLists.txt 
b/source/blender/draw/CMakeLists.txt
index d2835639686..7afd4421341 100644
--- a/source/blender/draw/CMakeLists.txt
+++ b/source/blender/draw/CMakeLists.txt
@@ -580,6 +580,7 @@ set(GLSL_SRC
   engines/basic/shaders/basic_depth_frag.glsl
 
   engines/overlay/shaders/overlay_antialiasing_frag.glsl
+  engines/overlay/shaders/overlay_armature_alpha_lib.glsl
   engines/overlay/shaders/overlay_armature_dof_solid_frag.glsl
   engines/overlay/shaders/overlay_armature_dof_vert.glsl
   engines/overlay/shaders/overlay_armature_envelope_outline_vert.glsl
diff --git a/source/blender/draw/engines/overlay/overlay_armature.cc 
b/source/blender/draw/engines/overlay/overlay_armature.cc
index 8c9587e7a9a..b0aea51e590 100644
--- a/source/blender/draw/engines/overlay/overlay_armature.cc
+++ b/source/blender/draw/engines/overlay/overlay_armature.cc
@@ -86,6 +86,8 @@ struct ArmatureDrawContext {
   bool transparent;
   bool show_relations;
 
+  float *p_fade_depth_bias;
+
   const ThemeWireColor *bcolor; /* pchan color */
 };
 
@@ -126,7 +128,14 @@ void OVERLAY_armature_cache_init(OVERLAY_Data *vedata)
draw_ctx->object_pose != nullptr;
 
   const float wire_alpha = pd->overlay.bone_wire_alpha;
-  const bool use_wire_alpha = (wire_alpha < 1.0f);
+  const float wire_fade = (pd->overlay.flag & V3D_OVERLAY_BONE_FADE_DEPTH) ?
+  1 / 

[Bf-blender-cvs] [4c73c394db1] temp-angavrilov: Force Fields: implement new true power and custom falloff options.

2023-01-26 Thread Alexander Gavrilov
Commit: 4c73c394db1fb4390fd0808eb4bb6d0a6bf3d65b
Author: Alexander Gavrilov
Date:   Sun Sep 12 19:35:48 2021 +0300
Branches: temp-angavrilov
https://developer.blender.org/rB4c73c394db1fb4390fd0808eb4bb6d0a6bf3d65b

Force Fields: implement new true power and custom falloff options.

The 'power' falloff option in Blender force fields does not actually
generate a true power falloff function, as pointed out in D2389.
However, that patch adds a special 'gravity' falloff option to Force
fields, without addressing the shortcoming in the common options.

The reason for not using the true curve in the options, as far as
one can tell, is that the power curve goes up to infinity as the
distance is reduced to 0, while the falloff options are designed
so that the maximum value of the curve is 1.

However, in reality forces with a power falloff don't actually go
to infinity, because real objects have a nonzero size, and the force
reaches its maximum at the surface of the object. This can be used
to integrate an option to use a true power falloff with the design
of falloff settings, if it requires a nonzero 'minimum' distance
to be set, and uses a curve that reaches 1 at that distance.

Since this is adding a new feature to the minimum distance value,
it is also a good opportunity to add a feature to the maximum
distance. Specifically, the new options can be used to apply
arbitrary brush-style falloff curves between min and max,
including a fully custom curve option. When used together with
power falloff, the two curves are multiplied together.

While the true power option allows creating more physically
correct forces, the custom curves aid artistic effects.

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

===

M   release/scripts/startup/bl_ui/properties_physics_common.py
M   release/scripts/startup/bl_ui/properties_physics_field.py
M   source/blender/blenkernel/BKE_effect.h
M   source/blender/blenkernel/BKE_particle.h
M   source/blender/blenkernel/intern/effect.c
M   source/blender/blenkernel/intern/object.cc
M   source/blender/blenkernel/intern/particle.cc
M   source/blender/makesdna/DNA_object_force_types.h
M   source/blender/makesrna/intern/rna_object_force.c

===

diff --git a/release/scripts/startup/bl_ui/properties_physics_common.py 
b/release/scripts/startup/bl_ui/properties_physics_common.py
index cae4687faac..8d5a9f3cdda 100644
--- a/release/scripts/startup/bl_ui/properties_physics_common.py
+++ b/release/scripts/startup/bl_ui/properties_physics_common.py
@@ -342,6 +342,10 @@ def basic_force_field_falloff_ui(self, field):
 sub.prop(field, "distance_min", text="")
 row.prop_decorator(field, "distance_min")
 
+col = layout.column()
+col.active = field.use_min_distance and field.distance_min > 0
+col.prop(field, "use_true_power")
+
 col = layout.column(align=False, heading="Max Distance")
 col.use_property_decorate = False
 row = col.row(align=True)
@@ -352,6 +356,13 @@ def basic_force_field_falloff_ui(self, field):
 sub.prop(field, "distance_max", text="")
 row.prop_decorator(field, "distance_max")
 
+col = layout.column()
+col.active = field.use_max_distance and field.distance_max > 
field.distance_min
+col.prop(field, "falloff_curve_type", text="Curve")
+
+if field.falloff_curve_type == 'CUSTOM':
+col.template_curve_mapping(field, "falloff_curve", type='NONE', 
brush=True)
+
 
 classes = (
 PHYSICS_PT_add,
diff --git a/release/scripts/startup/bl_ui/properties_physics_field.py 
b/release/scripts/startup/bl_ui/properties_physics_field.py
index 757ac57c171..6c707814e61 100644
--- a/release/scripts/startup/bl_ui/properties_physics_field.py
+++ b/release/scripts/startup/bl_ui/properties_physics_field.py
@@ -268,20 +268,36 @@ class 
PHYSICS_PT_field_falloff_angular(PhysicButtonsPanel, Panel):
 col = flow.column()
 col.prop(field, "radial_falloff", text="Power")
 
-col = flow.column()
-col.prop(field, "use_radial_min", text="Use Min Angle")
-
-sub = col.column()
+col = layout.column(align=False, heading="Min Angle")
+col.use_property_decorate = False
+row = col.row(align=True)
+sub = row.row(align=True)
+sub.prop(field, "use_radial_min", text="")
+sub = sub.row(align=True)
 sub.active = field.use_radial_min
-sub.prop(field, "radial_min", text="Min Angle")
-
-col = flow.column()
-col.prop(field, "use_radial_max", text="Use Max Angle")
+sub.prop(field, "radial_min", text="")
+row.prop_decorator(field, "radial_min")
 
-sub = col.column()
+col = layout.column()
+col.active = field.use_radial_min and field.radial_min > 0
+col.prop(field, "use_radial_true_power")
+
+col = layout.column(align=False, 

[Bf-blender-cvs] [e39be6c46b0] temp-angavrilov: Depsgraph: connect up drivers on various physics properties.

2023-01-26 Thread Alexander Gavrilov
Commit: e39be6c46b049cf787ef6ad19167142ef3eb38be
Author: Alexander Gavrilov
Date:   Sat Jan 9 21:19:37 2021 +0300
Branches: temp-angavrilov
https://developer.blender.org/rBe39be6c46b049cf787ef6ad19167142ef3eb38be

Depsgraph: connect up drivers on various physics properties.

It seems drivers for physics properties weren't being linked to
evaluation nodes. This connects settings used by modifiers
to Geometry; particle settings and rigid body data to Transform
which seems to contain rigid body evaluation; and force fields
to object Transform, since fields can exist on empties.

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

===

M   source/blender/depsgraph/intern/builder/deg_builder_relations.cc
M   source/blender/depsgraph/intern/builder/deg_builder_rna.cc

===

diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc 
b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
index 0c5dfdf5ced..b8581b16aef 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
@@ -2032,6 +2032,27 @@ void DepsgraphRelationBuilder::build_rigidbody(Scene 
*scene)
 }
 FOREACH_COLLECTION_OBJECT_RECURSIVE_END;
   }
+  /* Constraints. */
+  if (rbw->constraints != nullptr) {
+build_collection(nullptr, nullptr, rbw->constraints);
+FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN (rbw->constraints, object) {
+  if (object->rigidbody_constraint == nullptr) {
+continue;
+  }
+  if (object->rigidbody_object != nullptr) {
+/* Avoid duplicate relations for constraints attached to objects. */
+continue;
+  }
+
+  /* Simulation uses object transformation after parenting and solving 
constraints. */
+  OperationKey object_transform_simulation_init_key(
+  >id, NodeType::TRANSFORM, 
OperationCode::TRANSFORM_SIMULATION_INIT);
+  add_relation(object_transform_simulation_init_key,
+   rb_simulate_key,
+   "Object Transform -> Rigidbody Sim Eval");
+}
+FOREACH_COLLECTION_OBJECT_RECURSIVE_END;
+  }
 }
 
 void DepsgraphRelationBuilder::build_particle_systems(Object *object)
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_rna.cc 
b/source/blender/depsgraph/intern/builder/deg_builder_rna.cc
index 1a4356c4a92..b300490066b 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_rna.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_rna.cc
@@ -283,7 +283,16 @@ RNANodeIdentifier 
RNANodeQuery::construct_node_identifier(const PointerRNA *ptr,
RNA_struct_is_a(ptr->type, _MeshUVLoop) ||
RNA_struct_is_a(ptr->type, _MeshLoopColor) ||
RNA_struct_is_a(ptr->type, _VertexGroupElement) ||
-   RNA_struct_is_a(ptr->type, _ShaderFx)) {
+   RNA_struct_is_a(ptr->type, _ShaderFx) ||
+   ELEM(ptr->type,
+_CollisionSettings,
+_SoftBodySettings,
+_ClothSettings,
+_ClothCollisionSettings,
+_DynamicPaintSurface,
+_DynamicPaintCanvasSettings,
+_DynamicPaintBrushSettings) ||
+   (ELEM(ptr->type, _EffectorWeights) && 
GS(node_identifier.id->name) == ID_OB)) {
 /* When modifier is used as FROM operation this is likely referencing to
  * the property (for example, modifier's influence).
  * But when it's used as TO operation, this is geometry component. */
@@ -383,6 +392,20 @@ RNANodeIdentifier 
RNANodeQuery::construct_node_identifier(const PointerRNA *ptr,
 node_identifier.type = NodeType::GEOMETRY;
 return node_identifier;
   }
+  else if (GS(node_identifier.id->name) == ID_PA &&
+   ELEM(ptr->type, _EffectorWeights, _FieldSettings, 
_ParticleSettings)) {
+node_identifier.type = NodeType::PARTICLE_SETTINGS;
+return node_identifier;
+  }
+  else if (ELEM(ptr->type,
+_EffectorWeights,
+_RigidBodyWorld,
+_FieldSettings,
+_RigidBodyObject,
+_RigidBodyConstraint)) {
+node_identifier.type = NodeType::TRANSFORM;
+return node_identifier;
+  }
   if (prop != nullptr) {
 /* All unknown data effectively falls under "parameter evaluation". */
 node_identifier.type = NodeType::PARAMETERS;

___
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] [f4c958d5ec6] temp-angavrilov: Animation: support filtering for curves that have cycle issues.

2023-01-26 Thread Alexander Gavrilov
Commit: f4c958d5ec6aaf5547ea6bb4443e8221a74b67d3
Author: Alexander Gavrilov
Date:   Mon May 3 17:27:53 2021 +0300
Branches: temp-angavrilov
https://developer.blender.org/rBf4c958d5ec6aaf5547ea6bb4443e8221a74b67d3

Animation: support filtering for curves that have cycle issues.

It is possible to have curves with cyclic extrapolation that
have a mismatch in their end keyframes, causing a jump.

Also, since the looping behavior is defined per curve rather than at
action level, it is possible for curve loop periods to get out of
sync with each other. This commit adds an option to compare curves
against the manual frame range specified in the action, and treat
any mismatches as errors for the purpose of F-Curve filtering.

When enabled, the check verifies that end values of cyclic curves
match, curves within a cyclic action have valid cyclic extrapolation,
and the action period evenly divides by the curve period (since
a curve looping at e.g. half of the action period length still
repeats in sync with the action).

Ref: D11803

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

===

M   release/scripts/startup/bl_ui/space_dopesheet.py
M   source/blender/editors/animation/anim_filter.c
M   source/blender/makesdna/DNA_action_types.h
M   source/blender/makesrna/intern/rna_action.c

===

diff --git a/release/scripts/startup/bl_ui/space_dopesheet.py 
b/release/scripts/startup/bl_ui/space_dopesheet.py
index 99b33840051..f2854440e2a 100644
--- a/release/scripts/startup/bl_ui/space_dopesheet.py
+++ b/release/scripts/startup/bl_ui/space_dopesheet.py
@@ -63,6 +63,12 @@ class DopesheetFilterPopoverBase:
 else:  # graph and dopesheet editors - F-Curves and drivers only
 col.prop(dopesheet, "show_only_errors", icon='NONE')
 
+col.separator()
+
+col2 = col.column(align=True)
+col2.active = dopesheet.show_only_errors
+col2.prop(dopesheet, "show_cycle_errors")
+
 # Name/Membership Filters
 # XXX: Perhaps these should just stay in the headers (exclusively)?
 @classmethod
diff --git a/source/blender/editors/animation/anim_filter.c 
b/source/blender/editors/animation/anim_filter.c
index f619837a3c5..4f5201a6665 100644
--- a/source/blender/editors/animation/anim_filter.c
+++ b/source/blender/editors/animation/anim_filter.c
@@ -63,6 +63,7 @@
 #include "BLI_alloca.h"
 #include "BLI_blenlib.h"
 #include "BLI_ghash.h"
+#include "BLI_math.h"
 #include "BLI_string.h"
 #include "BLI_utildefines.h"
 
@@ -1207,6 +1208,53 @@ static bool skip_fcurve_with_name(
   return true;
 }
 
+/* Check if the F-Curve doesn't cycle properly based on action settings. */
+static bool fcurve_has_cycle_errors(const FCurve *fcu, const bAction *act)
+{
+  /* Check if the curve is cyclic. */
+  const eFCU_Cycle_Type cycle_type = BKE_fcurve_get_cycle_type(fcu);
+
+  if (cycle_type == FCU_CYCLE_NONE) {
+/* Curves in a cyclic action should be cyclic; in an ordinary action 
either way is fine. */
+return BKE_action_is_cyclic(act);
+  }
+
+  /* Check if the curve has enough points. */
+  if (fcu->totvert < 2 || !fcu->bezt) {
+return true;
+  }
+
+  const BezTriple *first = >bezt[0], *last = >bezt[fcu->totvert - 1];
+
+  if (BKE_action_is_cyclic(act)) {
+/* Check that it has a nonzero period length. */
+const float curve_period = last->vec[1][0] - first->vec[1][0];
+
+if (curve_period < 0.1f) {
+  return true;
+}
+
+/* Check that the action period is divisible by the curve period. */
+const float action_period = act->frame_end - act->frame_start;
+const float gap = action_period - roundf(action_period / curve_period) * 
curve_period;
+
+if (fabsf(gap) > 1e-3f) {
+  return true;
+}
+  }
+
+  /* In case of a perfect cycle, check that the start and end values match. */
+  if (cycle_type == FCU_CYCLE_PERFECT) {
+const float magnitude = max_fff(fabsf(first->vec[1][1]), 
fabsf(last->vec[1][1]), 0.01f);
+
+if (fabsf(first->vec[1][1] - last->vec[1][1]) > magnitude * 1e-4f) {
+  return true;
+}
+  }
+
+  return false;
+}
+
 /**
  * Check if F-Curve has errors and/or is disabled
  *
@@ -1253,6 +1301,7 @@ static FCurve *animfilter_fcurve_next(bDopeSheet *ads,
   FCurve *first,
   eAnim_ChannelType channel_type,
   int filter_mode,
+  bAction *act,
   void *owner,
   ID *owner_id)
 {
@@ -1304,7 +1353,9 @@ static FCurve *animfilter_fcurve_next(bDopeSheet *ads,
 /* error-based filtering... */
 if ((ads) && (ads->filterflag & ADS_FILTER_ONLY_ERRORS)) {
   /* skip if no errors... */
-  if (fcurve_has_errors(fcu) == false) 

[Bf-blender-cvs] [27e86f9d84a] temp-angavrilov: Dope Sheet: distinguish Constant and Linear from other interpolation modes.

2023-01-26 Thread Alexander Gavrilov
Commit: 27e86f9d84ac8c9ad0054cdab9db55146f4ddc8b
Author: Alexander Gavrilov
Date:   Sat Feb 5 14:11:29 2022 +0300
Branches: temp-angavrilov
https://developer.blender.org/rB27e86f9d84ac8c9ad0054cdab9db55146f4ddc8b

Dope Sheet: distinguish Constant and Linear from other interpolation modes.

There is an option to display handles and interpolation modes in
the dope sheet, but the only interpolation mode it distinguishes
is Bezier. This adds distinct display for Constant and Linear:

- Constant is drawn as a thicker line.
- Linear is drawn the same as now.
- Other non-Bezier modes are drawn as a double line.

Constant, Linear and Bezier are the most common modes, so it makes
sense to distinguish them from all others.

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

===

M   source/blender/editors/animation/keyframes_draw.c
M   source/blender/editors/animation/keyframes_keylist.cc
M   source/blender/editors/include/ED_keyframes_keylist.h

===

diff --git a/source/blender/editors/animation/keyframes_draw.c 
b/source/blender/editors/animation/keyframes_draw.c
index d0b978b7adf..92bad9f9168 100644
--- a/source/blender/editors/animation/keyframes_draw.c
+++ b/source/blender/editors/animation/keyframes_draw.c
@@ -287,14 +287,30 @@ static void draw_keylist_block_interpolation_line(const 
DrawKeylistUIData *ctx,
   const ActKeyColumn *ab,
   float ypos)
 {
+  float width = ctx->ipo_size;
+  bool fill = true;
+
+  switch (ab->block.ipo) {
+case BEZT_IPO_CONST:
+  width *= 1.7f;
+  break;
+
+case BEZT_IPO_LIN:
+  break;
+
+default:
+  width *= 2.0f;
+  fill = false;
+  }
+
   UI_draw_roundbox_4fv(
   &(const rctf){
   .xmin = ab->cfra,
   .xmax = ab->next->cfra,
-  .ymin = ypos - ctx->ipo_size,
-  .ymax = ypos + ctx->ipo_size,
+  .ymin = ypos - width,
+  .ymax = ypos + width,
   },
-  true,
+  fill,
   3.0f,
   (ab->block.conflict & ACTKEYBLOCK_FLAG_NON_BEZIER) ? ctx->ipo_color_mix 
: ctx->ipo_color);
 }
diff --git a/source/blender/editors/animation/keyframes_keylist.cc 
b/source/blender/editors/animation/keyframes_keylist.cc
index eff12af02d2..56a8fb14876 100644
--- a/source/blender/editors/animation/keyframes_keylist.cc
+++ b/source/blender/editors/animation/keyframes_keylist.cc
@@ -749,6 +749,10 @@ static void compute_keyblock_data(ActKeyBlockInfo *info,
   /* Remember non-bezier interpolation info. */
   if (prev->ipo != BEZT_IPO_BEZ) {
 info->flag |= ACTKEYBLOCK_FLAG_NON_BEZIER;
+info->ipo = prev->ipo;
+  }
+  else {
+info->ipo = -1;
   }
 
   info->sel = BEZT_ISSEL_ANY(prev) || BEZT_ISSEL_ANY(beztn);
@@ -765,6 +769,13 @@ static void add_keyblock_info(ActKeyColumn *col, const 
ActKeyBlockInfo *block)
 col->block.conflict |= (col->block.flag ^ block->flag);
 col->block.flag |= block->flag;
 col->block.sel |= block->sel;
+
+/* Combine interpolations; detect conflicts and use max value. */
+if (col->block.ipo != block->ipo) {
+  col->block.conflict |= ACTKEYBLOCK_FLAG_NON_BEZIER;
+}
+
+col->block.ipo = MAX2(col->block.ipo, block->ipo);
   }
 
   if (block->flag) {
diff --git a/source/blender/editors/include/ED_keyframes_keylist.h 
b/source/blender/editors/include/ED_keyframes_keylist.h
index 7aaeb41572b..171ec3ae7f5 100644
--- a/source/blender/editors/include/ED_keyframes_keylist.h
+++ b/source/blender/editors/include/ED_keyframes_keylist.h
@@ -36,6 +36,9 @@ typedef struct ActKeyBlockInfo {
 
   /* Selection flag. */
   char sel;
+
+  /* Interpolation mode. */
+  signed char ipo;
 } ActKeyBlockInfo;
 
 /* Keyframe Column Struct */

___
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] [f19f50d288e] master: USD export test format fixes.

2023-01-26 Thread Michael Kowalski
Commit: f19f50d288e2751bf36d7d4d1261008c7ea19da5
Author: Michael Kowalski
Date:   Thu Jan 26 10:35:14 2023 -0500
Branches: master
https://developer.blender.org/rBf19f50d288e2751bf36d7d4d1261008c7ea19da5

USD export test format fixes.

===

M   source/blender/io/usd/tests/usd_export_test.cc

===

diff --git a/source/blender/io/usd/tests/usd_export_test.cc 
b/source/blender/io/usd/tests/usd_export_test.cc
index c13da695c87..c34ab7cd6f7 100644
--- a/source/blender/io/usd/tests/usd_export_test.cc
+++ b/source/blender/io/usd/tests/usd_export_test.cc
@@ -25,8 +25,8 @@
 #include "BKE_node.h"
 #include "BLI_fileops.h"
 #include "BLI_math.h"
-#include "BLI_path_util.h"
 #include "BLI_math_vector_types.hh"
+#include "BLI_path_util.h"
 #include "BLO_readfile.h"
 
 #include "BKE_node_runtime.hh"
@@ -45,11 +45,9 @@ const StringRefNull simple_scene_filename = 
"usd/usd_simple_scene.blend";
 const StringRefNull materials_filename = "usd/usd_materials_export.blend";
 const StringRefNull output_filename = "output.usd";
 
-
 static const bNode *find_node_for_type_in_graph(const bNodeTree *nodetree,
 const blender::StringRefNull 
type_idname);
 
-
 class UsdExportTest : public BlendfileLoadingBaseTest {
  protected:
   struct bContext *context = nullptr;
@@ -104,7 +102,9 @@ class UsdExportTest : public BlendfileLoadingBaseTest {
* Loop the sockets on the Blender bNode, and fail if any of their values do
* not match the equivalent Attribtue values on the UsdPrim.
*/
-  const void compare_blender_node_to_usd_prim(const bNode *bsdf_node, const 
pxr::UsdPrim& bsdf_prim) {
+  const void compare_blender_node_to_usd_prim(const bNode *bsdf_node,
+  const pxr::UsdPrim _prim)
+  {
 ASSERT_NE(bsdf_node, nullptr);
 ASSERT_TRUE(bool(bsdf_prim));
 
@@ -155,7 +155,9 @@ class UsdExportTest : public BlendfileLoadingBaseTest {
 }
   }
 
-  const void compare_blender_image_to_usd_image_shader(const bNode 
*image_node, const pxr::UsdPrim& image_prim) {
+  const void compare_blender_image_to_usd_image_shader(const bNode *image_node,
+   const pxr::UsdPrim 
_prim)
+  {
 const Image *image = reinterpret_cast(image_node->id);
 
 const pxr::UsdShadeShader image_shader(image_prim);
@@ -171,14 +173,16 @@ class UsdExportTest : public BlendfileLoadingBaseTest {
 /* The path is expected to be relative, but that means in Blender the
  * path will start with //.
  */
-EXPECT_EQ(BLI_path_cmp_normalized(image->filepath+2, 
image_prim_asset.GetAssetPath().c_str()), 0);
+EXPECT_EQ(
+BLI_path_cmp_normalized(image->filepath + 2, 
image_prim_asset.GetAssetPath().c_str()), 0);
   }
 
   /*
* Determine if a Blender Mesh matches a UsdGeomMesh prim by checking counts
* on vertices, faces, face indices, and normals.
*/
-  const void compare_blender_mesh_to_usd_prim(const Mesh *mesh, const 
pxr::UsdGeomMesh& mesh_prim) {
+  const void compare_blender_mesh_to_usd_prim(const Mesh *mesh, const 
pxr::UsdGeomMesh _prim)
+  {
 pxr::VtIntArray face_indices;
 pxr::VtIntArray face_counts;
 pxr::VtVec3fArray positions;
@@ -196,10 +200,8 @@ class UsdExportTest : public BlendfileLoadingBaseTest {
 EXPECT_EQ(mesh->totloop, face_indices.size());
 EXPECT_EQ(mesh->totloop, normals.size());
   }
-
 };
 
-
 TEST_F(UsdExportTest, usd_export_rain_mesh)
 {
   if (!load_file_and_depsgraph(simple_scene_filename)) {
@@ -239,8 +241,8 @@ TEST_F(UsdExportTest, usd_export_rain_mesh)
   }
 }
 
-
-static const bNode *find_node_for_type_in_graph(const bNodeTree *nodetree, 
const blender::StringRefNull type_idname)
+static const bNode *find_node_for_type_in_graph(const bNodeTree *nodetree,
+const blender::StringRefNull 
type_idname)
 {
   auto found_nodes = nodetree->nodes_by_type(type_idname);
   if (found_nodes.size() == 1) {
@@ -250,7 +252,6 @@ static const bNode *find_node_for_type_in_graph(const 
bNodeTree *nodetree, const
   return nullptr;
 }
 
-
 /*
  * Export Material test-- export a scene with a material, then read it back
  * in and check that the BSDF and Image Texture nodes translated correctly
@@ -269,7 +270,8 @@ TEST_F(UsdExportTest, usd_export_material)
   /* There are two materials because of the Dots Stroke. */
   EXPECT_EQ(BLI_listbase_count(>main->materials), 2);
 
-  Material *material = reinterpret_cast(BKE_libblock_find_name(bfile->main, ID_MA, "Material"));
+  Material *material = reinterpret_cast(
+  BKE_libblock_find_name(bfile->main, ID_MA, "Material"));
 
   EXPECT_TRUE(bool(material));
 
@@ -300,13 +302,13 @@ TEST_F(UsdExportTest, usd_export_material)
   ASSERT_NE(image_node, nullptr);
   ASSERT_NE(image_node->storage, nullptr);
 
-
   const std::string 

[Bf-blender-cvs] [1fd54204b0a] master: Enable commented out code.

2023-01-26 Thread Jeroen Bakker
Commit: 1fd54204b0a1439ef21719d6bfd4efb84e08d27c
Author: Jeroen Bakker
Date:   Thu Jan 26 15:17:37 2023 +0100
Branches: master
https://developer.blender.org/rB1fd54204b0a1439ef21719d6bfd4efb84e08d27c

Enable commented out code.

Code was disabled for debugging purposes.

===

M   source/blender/imbuf/intern/transform.cc

===

diff --git a/source/blender/imbuf/intern/transform.cc 
b/source/blender/imbuf/intern/transform.cc
index fc4d1c3a9e3..198d04cc5f6 100644
--- a/source/blender/imbuf/intern/transform.cc
+++ b/source/blender/imbuf/intern/transform.cc
@@ -526,12 +526,12 @@ class ScanlineProcessor {
*/
   void process(const TransformUserData *user_data, int scanline)
   {
-// if (user_data->subsampling.num > 1) {
-process_with_subsampling(user_data, scanline);
-// }
-// else {
-//   process_one_sample_per_pixel(user_data, scanline);
-// }
+if (user_data->subsampling.num > 1) {
+  process_with_subsampling(user_data, scanline);
+}
+else {
+  process_one_sample_per_pixel(user_data, scanline);
+}
   }
 
  private:

___
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] [c412c38f0de] master: Fix missing code-paths in previous sequence/imbuf commits.

2023-01-26 Thread Jeroen Bakker
Commit: c412c38f0de3fef5496637336576ca15d23ec658
Author: Jeroen Bakker
Date:   Thu Jan 26 15:15:21 2023 +0100
Branches: master
https://developer.blender.org/rBc412c38f0de3fef5496637336576ca15d23ec658

Fix missing code-paths in previous sequence/imbuf commits.

===

M   source/blender/imbuf/intern/transform.cc

===

diff --git a/source/blender/imbuf/intern/transform.cc 
b/source/blender/imbuf/intern/transform.cc
index 23aad5edf1d..fc4d1c3a9e3 100644
--- a/source/blender/imbuf/intern/transform.cc
+++ b/source/blender/imbuf/intern/transform.cc
@@ -474,6 +474,11 @@ class ChannelConverter {
   blend_color_interpolate_byte(
   pixel_pointer.get_pointer(), pixel_pointer.get_pointer(), 
sample.data(), mix_factor);
 }
+else if constexpr (std::is_same_v && SourceNumChannels 
== 4 &&
+   DestinationNumChannels == 4) {
+  blend_color_interpolate_float(
+  pixel_pointer.get_pointer(), pixel_pointer.get_pointer(), 
sample.data(), mix_factor);
+}
 else {
   BLI_assert_unreachable();
 }
@@ -547,20 +552,12 @@ class ScanlineProcessor {
   xi += 1;
 }
 
-/*
- * Draw until we didn't draw for at least 4 pixels.
- */
-int num_output_pixels_skipped = 0;
-const int num_missing_output_pixels_allowed = 4;
-for (; xi < width && num_output_pixels_skipped < 
num_missing_output_pixels_allowed; xi++) {
+for (; xi < width; xi++) {
   if (!discarder.should_discard(*user_data, uv)) {
 typename Sampler::SampleType sample;
 sampler.sample(user_data->src, uv, sample);
 channel_converter.convert_and_store(sample, output);
   }
-  else {
-num_output_pixels_skipped += 1;
-  }
 
   uv += user_data->add_x;
   output.increase_pixel_pointer();
@@ -593,12 +590,7 @@ class ScanlineProcessor {
   xi += 1;
 }
 
-/*
- * Draw until we didn't draw for at least 4 pixels.
- */
-int num_output_pixels_skipped = 0;
-const int num_missing_output_pixels_allowed = 4;
-for (; xi < width && num_output_pixels_skipped < 
num_missing_output_pixels_allowed; xi++) {
+for (; xi < width; xi++) {
   typename Sampler::SampleType sample;
   sample.clear();
   int num_subsamples_added = 0;
@@ -625,9 +617,6 @@ class ScanlineProcessor {
(user_data->subsampling.num * 
user_data->subsampling.num);
 channel_converter.mix_and_store(sample, output, mix_weight);
   }
-  else {
-num_output_pixels_skipped += 1;
-  }
   uv += user_data->add_x;
   output.increase_pixel_pointer();
 }

___
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] [3b17d6c6192] master: Sequencer: Made subsampling a transform option.

2023-01-26 Thread Jeroen Bakker
Commit: 3b17d6c6192fa0c2a3d7f2fff9fe8584f857a926
Author: Jeroen Bakker
Date:   Thu Jan 26 15:03:19 2023 +0100
Branches: master
https://developer.blender.org/rB3b17d6c6192fa0c2a3d7f2fff9fe8584f857a926

Sequencer: Made subsampling a transform option.

There are cases where automatic selection of subsampling doesn't work
This patch move adds a filtering option that
can enable this.

===

M   release/scripts/addons
M   source/blender/makesdna/DNA_sequence_types.h
M   source/blender/makesrna/intern/rna_sequencer.c
M   source/blender/sequencer/intern/render.c

===

diff --git a/release/scripts/addons b/release/scripts/addons
index d887a4ea6b2..9958ddb8799 16
--- a/release/scripts/addons
+++ b/release/scripts/addons
@@ -1 +1 @@
-Subproject commit d887a4ea6b2a9d64b926034d4e78ecf7a48ca979
+Subproject commit 9958ddb879934718cc2b379b556f0bc3b861bee5
diff --git a/source/blender/makesdna/DNA_sequence_types.h 
b/source/blender/makesdna/DNA_sequence_types.h
index d8005b83383..47039c740c1 100644
--- a/source/blender/makesdna/DNA_sequence_types.h
+++ b/source/blender/makesdna/DNA_sequence_types.h
@@ -795,6 +795,7 @@ typedef enum SequenceColorTag {
 enum {
   SEQ_TRANSFORM_FILTER_NEAREST = 0,
   SEQ_TRANSFORM_FILTER_BILINEAR = 1,
+  SEQ_TRANSFORM_FILTER_NEAREST_3x3 = 2,
 };
 
 typedef enum eSeqChannelFlag {
diff --git a/source/blender/makesrna/intern/rna_sequencer.c 
b/source/blender/makesrna/intern/rna_sequencer.c
index eab9f9c26da..7dd13324f88 100644
--- a/source/blender/makesrna/intern/rna_sequencer.c
+++ b/source/blender/makesrna/intern/rna_sequencer.c
@@ -1510,6 +1510,11 @@ static void rna_def_strip_crop(BlenderRNA *brna)
 static const EnumPropertyItem transform_filter_items[] = {
 {SEQ_TRANSFORM_FILTER_NEAREST, "NEAREST", 0, "Nearest", ""},
 {SEQ_TRANSFORM_FILTER_BILINEAR, "BILINEAR", 0, "Bilinear", ""},
+{SEQ_TRANSFORM_FILTER_NEAREST_3x3,
+ "SUBSAMPLING_3x3",
+ 0,
+ "Subsampling (3x3)",
+ "Use nearest with 3x3 subsamples during rendering"},
 {0, NULL, 0, NULL, NULL},
 };
 
diff --git a/source/blender/sequencer/intern/render.c 
b/source/blender/sequencer/intern/render.c
index daca02b4f79..7f73a32a9c3 100644
--- a/source/blender/sequencer/intern/render.c
+++ b/source/blender/sequencer/intern/render.c
@@ -515,16 +515,24 @@ static void sequencer_preprocess_transform_crop(
   const float crop_scale_factor = do_scale_to_render_size ? 
preview_scale_factor : 1.0f;
   sequencer_image_crop_init(seq, in, crop_scale_factor, _crop);
 
-  eIMBInterpolationFilterMode filter;
   const StripTransform *transform = seq->strip->transform;
-  if (transform->filter == SEQ_TRANSFORM_FILTER_NEAREST) {
-filter = IMB_FILTER_NEAREST;
-  }
-  else {
-filter = IMB_FILTER_BILINEAR;
+  eIMBInterpolationFilterMode filter;
+  int num_subsamples = 1;
+  switch (transform->filter) {
+case SEQ_TRANSFORM_FILTER_NEAREST:
+  filter = IMB_FILTER_NEAREST;
+  num_subsamples = 1;
+  break;
+case SEQ_TRANSFORM_FILTER_BILINEAR:
+  filter = IMB_FILTER_BILINEAR;
+  num_subsamples = 1;
+  break;
+case SEQ_TRANSFORM_FILTER_NEAREST_3x3:
+  filter = IMB_FILTER_NEAREST;
+  num_subsamples = G.is_rendering ? 3 : 1;
+  break;
   }
 
-  const int num_subsamples = G.is_rendering ? 3 : 1;
   IMB_transform(in,
 out,
 IMB_TRANSFORM_MODE_CROP_SRC,

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


[Bf-blender-cvs] [f210842a725] master: Sequencer: Improve Image Transform Quality When Exporting.

2023-01-26 Thread Jeroen Bakker
Commit: f210842a725959d09e6dd87c9325c610aabbac00
Author: Jeroen Bakker
Date:   Thu Jan 26 13:38:59 2023 +0100
Branches: master
https://developer.blender.org/rBf210842a725959d09e6dd87c9325c610aabbac00

Sequencer: Improve Image Transform Quality When Exporting.

Image Transform use linear or nearest sampling during editing and exporting.
This gets sampling is fine for images that aren't scaled. When sequencing
however you mostly want use some sort of scaling, that leads to poorer
quality.

This change will use sub-sampling to improve the quality. This is only
enabled when rendering. During editing the subsampling is disabled to
keep the user interface reacting as expected.

Another improvement is that image transform is stopped at the moment
it hadn't sampled at least 4 samples for a scan line. In that case we
expect that there are no further samples that would change to result.

In a future patch this could be replaced by a ray/bounding bo intersection
as that would remove some unneeded loops in both the single sampled and
sub sampled approach.

===

M   source/blender/draw/engines/image/image_drawing_mode.hh
M   source/blender/imbuf/IMB_imbuf.h
M   source/blender/imbuf/intern/transform.cc
M   source/blender/sequencer/intern/render.c

===

diff --git a/source/blender/draw/engines/image/image_drawing_mode.hh 
b/source/blender/draw/engines/image/image_drawing_mode.hh
index 9345be800e8..d389ecd90af 100644
--- a/source/blender/draw/engines/image/image_drawing_mode.hh
+++ b/source/blender/draw/engines/image/image_drawing_mode.hh
@@ -516,6 +516,7 @@ template class 
ScreenSpaceDrawingMode : public AbstractD
   _buffer,
   transform_mode,
   IMB_FILTER_NEAREST,
+  1,
   uv_to_texel.ptr(),
   crop_rect_ptr);
   }
diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h
index a5bb34392b1..79be739a205 100644
--- a/source/blender/imbuf/IMB_imbuf.h
+++ b/source/blender/imbuf/IMB_imbuf.h
@@ -846,6 +846,8 @@ typedef enum eIMBTransformMode {
  * - Only one data type buffer will be used (rect_float has priority over rect)
  * \param mode: Cropping/Wrap repeat effect to apply during transformation.
  * \param filter: Interpolation to use during sampling.
+ * \param num_subsamples: Number of subsamples to use. Increasing this would 
improve the quality,
+ * but reduces the performance.
  * \param transform_matrix: Transformation matrix to use.
  * The given matrix should transform between dst pixel space to src pixel 
space.
  * One unit is one pixel.
@@ -860,6 +862,7 @@ void IMB_transform(const struct ImBuf *src,
struct ImBuf *dst,
eIMBTransformMode mode,
eIMBInterpolationFilterMode filter,
+   const int num_subsamples,
const float transform_matrix[4][4],
const struct rctf *src_crop);
 
diff --git a/source/blender/imbuf/intern/transform.cc 
b/source/blender/imbuf/intern/transform.cc
index 323460f4593..23aad5edf1d 100644
--- a/source/blender/imbuf/intern/transform.cc
+++ b/source/blender/imbuf/intern/transform.cc
@@ -9,6 +9,7 @@
 #include 
 
 #include "BLI_math.h"
+#include "BLI_math_color_blend.h"
 #include "BLI_math_vector.hh"
 #include "BLI_rect.h"
 
@@ -37,6 +38,14 @@ struct TransformUserData {
*/
   double2 add_y;
 
+  struct {
+int num;
+double2 offset_x;
+double2 offset_y;
+double2 add_x;
+double2 add_y;
+  } subsampling;
+
   /**
* \brief Cropping region in source image pixel space.
*/
@@ -45,11 +54,12 @@ struct TransformUserData {
   /**
* \brief Initialize the start_uv, add_x and add_y fields based on the given 
transform matrix.
*/
-  void init(const float transform_matrix[4][4])
+  void init(const float transform_matrix[4][4], const int num_subsamples)
   {
 init_start_uv(transform_matrix);
 init_add_x(transform_matrix);
 init_add_y(transform_matrix);
+init_subsampling(num_subsamples);
   }
 
  private:
@@ -83,6 +93,15 @@ struct TransformUserData {
 mul_v3_m4v3_db(add_y_v3, transform_matrix_double, double3(0.0, height, 
0.0));
 add_y = double2((add_y_v3 - double3(start_uv)) * (1.0 / height));
   }
+
+  void init_subsampling(const int num_subsamples)
+  {
+subsampling.num = max_ii(num_subsamples, 1);
+subsampling.add_x = add_x / (subsampling.num);
+subsampling.add_y = add_y / (subsampling.num);
+subsampling.offset_x = -add_x * 0.5 + subsampling.add_x * 0.5;
+subsampling.offset_y = -add_y * 0.5 + subsampling.add_y * 0.5;
+  }
 };
 
 /**
@@ -257,6 +276,39 @@ class WrapRepeatUV : public BaseUVWrapping {
   }
 };
 
+// TODO: should we use math_vectors for this.
+template
+class Pixel : public std::array {
+ public:
+  void clear()
+  {
+for (int channel_index 

[Bf-blender-cvs] [6d79bc00732] master: ImBuf: Use vector types in transform.cc.

2023-01-26 Thread Jeroen Bakker
Commit: 6d79bc00732a506dbd6495bfe1dbe56d544234b6
Author: Jeroen Bakker
Date:   Thu Jan 26 09:56:32 2023 +0100
Branches: master
https://developer.blender.org/rB6d79bc00732a506dbd6495bfe1dbe56d544234b6

ImBuf: Use vector types in transform.cc.

Replace array types with the vector types. No functional changes.

===

M   source/blender/imbuf/intern/transform.cc

===

diff --git a/source/blender/imbuf/intern/transform.cc 
b/source/blender/imbuf/intern/transform.cc
index 420cad06959..323460f4593 100644
--- a/source/blender/imbuf/intern/transform.cc
+++ b/source/blender/imbuf/intern/transform.cc
@@ -9,6 +9,7 @@
 #include 
 
 #include "BLI_math.h"
+#include "BLI_math_vector.hh"
 #include "BLI_rect.h"
 
 #include "IMB_imbuf.h"
@@ -22,19 +23,19 @@ struct TransformUserData {
   /** \brief Destination image buffer to write to. */
   ImBuf *dst;
   /** \brief UV coordinates at the origin (0,0) in source image space. */
-  double start_uv[2];
+  double2 start_uv;
 
   /**
* \brief delta UV coordinates along the source image buffer, when moving a 
single pixel in the X
* axis of the dst image buffer.
*/
-  double add_x[2];
+  double2 add_x;
 
   /**
* \brief delta UV coordinate along the source image buffer, when moving a 
single pixel in the Y
* axes of the dst image buffer.
*/
-  double add_y[2];
+  double2 add_y;
 
   /**
* \brief Cropping region in source image pixel space.
@@ -54,45 +55,33 @@ struct TransformUserData {
  private:
   void init_start_uv(const float transform_matrix[4][4])
   {
-double start_uv_v3[3];
-double orig[3];
+double3 start_uv_v3;
+double3 orig(0.0);
 double transform_matrix_double[4][4];
 copy_m4d_m4(transform_matrix_double, transform_matrix);
-zero_v3_db(orig);
 mul_v3_m4v3_db(start_uv_v3, transform_matrix_double, orig);
-copy_v2_v2_db(start_uv, start_uv_v3);
+start_uv = double2(start_uv_v3);
   }
 
   void init_add_x(const float transform_matrix[4][4])
   {
 double transform_matrix_double[4][4];
 copy_m4d_m4(transform_matrix_double, transform_matrix);
-const int width = src->x;
-double add_x_v3[3];
-double uv_max_x[3];
-zero_v3_db(uv_max_x);
-uv_max_x[0] = width;
-uv_max_x[1] = 0.0f;
-mul_v3_m4v3_db(add_x_v3, transform_matrix_double, uv_max_x);
-sub_v2_v2_db(add_x_v3, start_uv);
-mul_v3db_db(add_x_v3, 1.0f / width);
-copy_v2_v2_db(add_x, add_x_v3);
+const double width = src->x;
+double3 add_x_v3;
+mul_v3_m4v3_db(add_x_v3, transform_matrix_double, double3(width, 0.0, 
0.0));
+add_x = double2((add_x_v3 - double3(start_uv)) * (1.0 / width));
   }
 
   void init_add_y(const float transform_matrix[4][4])
   {
 double transform_matrix_double[4][4];
 copy_m4d_m4(transform_matrix_double, transform_matrix);
-const int height = src->y;
-double add_y_v3[3];
-double uv_max_y[3];
-zero_v3_db(uv_max_y);
-uv_max_y[0] = 0.0f;
-uv_max_y[1] = height;
-mul_v3_m4v3_db(add_y_v3, transform_matrix_double, uv_max_y);
-sub_v2_v2_db(add_y_v3, start_uv);
-mul_v3db_db(add_y_v3, 1.0f / height);
-copy_v2_v2_db(add_y, add_y_v3);
+const double height = src->y;
+double3 add_y_v3;
+double3 uv_max_y(0.0, height, 0.0);
+mul_v3_m4v3_db(add_y_v3, transform_matrix_double, double3(0.0, height, 
0.0));
+add_y = double2((add_y_v3 - double3(start_uv)) * (1.0 / height));
   }
 };
 
@@ -110,7 +99,7 @@ class BaseDiscard {
   /**
* \brief Should the source pixel at the given uv coordinate be discarded.
*/
-  virtual bool should_discard(const TransformUserData _data, const double 
uv[2]) = 0;
+  virtual bool should_discard(const TransformUserData _data, const 
double2 uv) = 0;
 };
 
 /**
@@ -123,10 +112,10 @@ class CropSource : public BaseDiscard {
*
* Uses user_data.src_crop to determine if the uv coordinate should be 
skipped.
*/
-  bool should_discard(const TransformUserData _data, const double uv[2]) 
override
+  bool should_discard(const TransformUserData _data, const double2 uv) 
override
   {
-return uv[0] < user_data.src_crop.xmin || uv[0] >= user_data.src_crop.xmax 
||
-   uv[1] < user_data.src_crop.ymin || uv[1] >= user_data.src_crop.ymax;
+return uv.x < user_data.src_crop.xmin || uv.x >= user_data.src_crop.xmax ||
+   uv.y < user_data.src_crop.ymin || uv.y >= user_data.src_crop.ymax;
   }
 };
 
@@ -140,7 +129,7 @@ class NoDiscard : public BaseDiscard {
*
* Will never discard any pixels.
*/
-  bool should_discard(const TransformUserData & /*user_data*/, const double 
/*uv*/[2]) override
+  bool should_discard(const TransformUserData & /*user_data*/, const double2 
/*uv*/) override
   {
 return false;
   }
@@ -168,9 +157,10 @@ class PixelPointer {
   StorageType *pointer;
 
  public:
-  void init_pixel_pointer(const ImBuf *image_buffer, int x, 

[Bf-blender-cvs] [f7dd7d54547] master: Python API: add a method for reordering modifiers.

2023-01-26 Thread Alexander Gavrilov
Commit: f7dd7d545472b8571a64ec96eb94eed1aada0523
Author: Alexander Gavrilov
Date:   Tue Jan 10 18:25:58 2023 +0200
Branches: master
https://developer.blender.org/rBf7dd7d545472b8571a64ec96eb94eed1aada0523

Python API: add a method for reordering modifiers.

Add an `object.modifiers.move()` method, similar to the one
for constraints and some other collections. Currently reordering
modifiers requires using operators, which depend on context.

The implementation is straightforward, except for the need to
make the severity of errors reported by the underlying editor
code into a parameter, so that the new Python API function
reports any problems as Python exceptions, and refactoring
the code to allow aborting a blocked move before making any
changes. I also turn the negative index condition from an assert
into an error.

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

===

M   source/blender/editors/include/ED_object.h
M   source/blender/editors/object/object_modifier.cc
M   source/blender/editors/space_outliner/outliner_dragdrop.cc
M   source/blender/makesrna/intern/rna_object.c

===

diff --git a/source/blender/editors/include/ED_object.h 
b/source/blender/editors/include/ED_object.h
index 82f8505509a..baa84b550aa 100644
--- a/source/blender/editors/include/ED_object.h
+++ b/source/blender/editors/include/ED_object.h
@@ -10,6 +10,7 @@
 #include "BLI_compiler_attrs.h"
 #include "DNA_object_enums.h"
 #include "DNA_userdef_enums.h"
+#include "DNA_windowmanager_types.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -558,15 +559,19 @@ bool ED_object_modifier_remove(struct ReportList *reports,
struct ModifierData *md);
 void ED_object_modifier_clear(struct Main *bmain, struct Scene *scene, struct 
Object *ob);
 bool ED_object_modifier_move_down(struct ReportList *reports,
+  eReportType error_type,
   struct Object *ob,
   struct ModifierData *md);
 bool ED_object_modifier_move_up(struct ReportList *reports,
+eReportType error_type,
 struct Object *ob,
 struct ModifierData *md);
 bool ED_object_modifier_move_to_index(struct ReportList *reports,
+  eReportType error_type,
   struct Object *ob,
   struct ModifierData *md,
-  int index);
+  int index,
+  bool allow_partial);
 
 bool ED_object_modifier_convert_psys_to_mesh(struct ReportList *reports,
  struct Main *bmain,
diff --git a/source/blender/editors/object/object_modifier.cc 
b/source/blender/editors/object/object_modifier.cc
index 1bfd156b664..9964d658994 100644
--- a/source/blender/editors/object/object_modifier.cc
+++ b/source/blender/editors/object/object_modifier.cc
@@ -415,83 +415,139 @@ void ED_object_modifier_clear(Main *bmain, Scene *scene, 
Object *ob)
   DEG_relations_tag_update(bmain);
 }
 
-bool ED_object_modifier_move_up(ReportList *reports, Object *ob, ModifierData 
*md)
+static bool object_modifier_check_move_before(ReportList *reports,
+  eReportType error_type,
+  ModifierData *md,
+  ModifierData *md_prev)
 {
-  if (md->prev) {
+  if (md_prev) {
 const ModifierTypeInfo *mti = 
BKE_modifier_get_info((ModifierType)md->type);
 
 if (mti->type != eModifierTypeType_OnlyDeform) {
-  const ModifierTypeInfo *nmti = 
BKE_modifier_get_info((ModifierType)md->prev->type);
+  const ModifierTypeInfo *nmti = 
BKE_modifier_get_info((ModifierType)md_prev->type);
 
   if (nmti->flags & eModifierTypeFlag_RequiresOriginalData) {
-BKE_report(reports, RPT_WARNING, "Cannot move above a modifier 
requiring original data");
+BKE_report(reports, error_type, "Cannot move above a modifier 
requiring original data");
 return false;
   }
 }
-
-BLI_listbase_swaplinks(>modifiers, md, md->prev);
   }
   else {
-BKE_report(reports, RPT_WARNING, "Cannot move modifier beyond the start of 
the list");
+BKE_report(reports, error_type, "Cannot move modifier beyond the start of 
the list");
 return false;
   }
 
   return true;
 }
 
-bool ED_object_modifier_move_down(ReportList *reports, Object *ob, 
ModifierData *md)
+bool ED_object_modifier_move_up(ReportList *reports,
+eReportType error_type,
+Object *ob,
+ModifierData *md)
+{
+  if 

[Bf-blender-cvs] [4a768a7857b] master: Cleanup: remove unused variable

2023-01-26 Thread Jacques Lucke
Commit: 4a768a7857b57cb3ac0274564a510c2cf9fe00a7
Author: Jacques Lucke
Date:   Thu Jan 26 13:31:23 2023 +0100
Branches: master
https://developer.blender.org/rB4a768a7857b57cb3ac0274564a510c2cf9fe00a7

Cleanup: remove unused variable

===

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

===

diff --git a/source/blender/blenkernel/intern/node.cc 
b/source/blender/blenkernel/intern/node.cc
index cb650c038e4..26b1f2f5096 100644
--- a/source/blender/blenkernel/intern/node.cc
+++ b/source/blender/blenkernel/intern/node.cc
@@ -3803,8 +3803,6 @@ void 
BKE_node_instance_hash_remove_untagged(bNodeInstanceHash *hash,
 
 void ntreeUpdateAllNew(Main *main)
 {
-  Vector new_ntrees;
-
   /* Update all new node trees on file read or append, to add/remove sockets
* in groups nodes if the group changed, and handle any update flags that
* might have been set in file reading or versioning. */

___
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] [a42f307915e] master: Shader Nodes: Use layers from evaluated mesh

2023-01-26 Thread Martijn Versteegh
Commit: a42f307915e49500ca7c2e18e2092dcef85f7f6e
Author: Martijn Versteegh
Date:   Mon Jan 23 19:59:46 2023 +0100
Branches: master
https://developer.blender.org/rBa42f307915e49500ca7c2e18e2092dcef85f7f6e

Shader Nodes: Use layers from evaluated mesh

The list was populated from the base (unevaluated) object, but now that
Geometry nodes can generate various layers this is impractical..

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

===

M   source/blender/nodes/shader/nodes/node_shader_normal_map.cc
M   source/blender/nodes/shader/nodes/node_shader_tangent.cc
M   source/blender/nodes/shader/nodes/node_shader_uvmap.cc
M   source/blender/nodes/shader/nodes/node_shader_vertex_color.cc

===

diff --git a/source/blender/nodes/shader/nodes/node_shader_normal_map.cc 
b/source/blender/nodes/shader/nodes/node_shader_normal_map.cc
index 0bc1318a1f6..a29faff2093 100644
--- a/source/blender/nodes/shader/nodes/node_shader_normal_map.cc
+++ b/source/blender/nodes/shader/nodes/node_shader_normal_map.cc
@@ -6,6 +6,8 @@
 #include "BKE_context.h"
 #include "BKE_node_runtime.hh"
 
+#include "DEG_depsgraph_query.h"
+
 #include "UI_interface.h"
 #include "UI_resources.h"
 
@@ -26,7 +28,11 @@ static void node_shader_buts_normal_map(uiLayout *layout, 
bContext *C, PointerRN
 PointerRNA obptr = CTX_data_pointer_get(C, "active_object");
 
 if (obptr.data && RNA_enum_get(, "type") == OB_MESH) {
-  PointerRNA dataptr = RNA_pointer_get(, "data");
+  PointerRNA eval_obptr;
+
+  Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
+  DEG_get_evaluated_rna_pointer(depsgraph, , _obptr);
+  PointerRNA dataptr = RNA_pointer_get(_obptr, "data");
   uiItemPointerR(layout, ptr, "uv_map", , "uv_layers", "", 
ICON_NONE);
 }
 else {
diff --git a/source/blender/nodes/shader/nodes/node_shader_tangent.cc 
b/source/blender/nodes/shader/nodes/node_shader_tangent.cc
index 9b09eb09bba..cb0c3f34e40 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tangent.cc
+++ b/source/blender/nodes/shader/nodes/node_shader_tangent.cc
@@ -5,6 +5,8 @@
 
 #include "BKE_context.h"
 
+#include "DEG_depsgraph_query.h"
+
 #include "UI_interface.h"
 #include "UI_resources.h"
 
@@ -29,7 +31,11 @@ static void node_shader_buts_tangent(uiLayout *layout, 
bContext *C, PointerRNA *
 PointerRNA obptr = CTX_data_pointer_get(C, "active_object");
 
 if (obptr.data && RNA_enum_get(, "type") == OB_MESH) {
-  PointerRNA dataptr = RNA_pointer_get(, "data");
+  PointerRNA eval_obptr;
+
+  Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
+  DEG_get_evaluated_rna_pointer(depsgraph, , _obptr);
+  PointerRNA dataptr = RNA_pointer_get(_obptr, "data");
   uiItemPointerR(row, ptr, "uv_map", , "uv_layers", "", ICON_NONE);
 }
 else {
diff --git a/source/blender/nodes/shader/nodes/node_shader_uvmap.cc 
b/source/blender/nodes/shader/nodes/node_shader_uvmap.cc
index 483e06f1192..de8221e3e97 100644
--- a/source/blender/nodes/shader/nodes/node_shader_uvmap.cc
+++ b/source/blender/nodes/shader/nodes/node_shader_uvmap.cc
@@ -7,6 +7,8 @@
 
 #include "DNA_customdata_types.h"
 
+#include "DEG_depsgraph_query.h"
+
 #include "UI_interface.h"
 #include "UI_resources.h"
 
@@ -25,7 +27,11 @@ static void node_shader_buts_uvmap(uiLayout *layout, 
bContext *C, PointerRNA *pt
 PointerRNA obptr = CTX_data_pointer_get(C, "active_object");
 
 if (obptr.data && RNA_enum_get(, "type") == OB_MESH) {
-  PointerRNA dataptr = RNA_pointer_get(, "data");
+  PointerRNA eval_obptr;
+
+  Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
+  DEG_get_evaluated_rna_pointer(depsgraph, , _obptr);
+  PointerRNA dataptr = RNA_pointer_get(_obptr, "data");
   uiItemPointerR(layout, ptr, "uv_map", , "uv_layers", "", 
ICON_NONE);
 }
   }
diff --git a/source/blender/nodes/shader/nodes/node_shader_vertex_color.cc 
b/source/blender/nodes/shader/nodes/node_shader_vertex_color.cc
index 8f7e30b99df..0e0f9496851 100644
--- a/source/blender/nodes/shader/nodes/node_shader_vertex_color.cc
+++ b/source/blender/nodes/shader/nodes/node_shader_vertex_color.cc
@@ -5,6 +5,8 @@
 
 #include "BKE_context.h"
 
+#include "DEG_depsgraph_query.h"
+
 #include "UI_interface.h"
 #include "UI_resources.h"
 
@@ -20,8 +22,11 @@ static void node_shader_buts_vertex_color(uiLayout *layout, 
bContext *C, Pointer
 {
   PointerRNA obptr = CTX_data_pointer_get(C, "active_object");
   if (obptr.data && RNA_enum_get(, "type") == OB_MESH) {
-PointerRNA dataptr = RNA_pointer_get(, "data");
+PointerRNA eval_obptr;
 
+Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
+DEG_get_evaluated_rna_pointer(depsgraph, , _obptr);
+PointerRNA dataptr = RNA_pointer_get(_obptr, "data");
 uiItemPointerR(layout, ptr, "layer_name", , 

[Bf-blender-cvs] [ef39d85d7c9] master: Fix T104121: Grease pencil clear function in python not updated in viewport

2023-01-26 Thread Amelie Fondevilla
Commit: ef39d85d7c94c28e952683c0ddd0f3b7435b8460
Author: Amelie Fondevilla
Date:   Wed Jan 25 17:00:10 2023 +0100
Branches: master
https://developer.blender.org/rBef39d85d7c94c28e952683c0ddd0f3b7435b8460

Fix T104121: Grease pencil clear function in python not updated in viewport

The clear functions for grease pencil data/frame/layer
was not followed by immediate update in the viewport.
Some notifiers were missing in the rna definition of these functions,
which are added in by this patch.

Reviewed By: Antonio Vazquez

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

===

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

===

diff --git a/source/blender/makesrna/intern/rna_gpencil.c 
b/source/blender/makesrna/intern/rna_gpencil.c
index 544a7f73cab..dd608ce9acb 100644
--- a/source/blender/makesrna/intern/rna_gpencil.c
+++ b/source/blender/makesrna/intern/rna_gpencil.c
@@ -1101,17 +1101,23 @@ static void rna_GPencil_layer_mask_remove(bGPDlayer 
*gpl,
   WM_main_add_notifier(NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
 }
 
-static void rna_GPencil_frame_clear(bGPDframe *frame)
+static void rna_GPencil_frame_clear(ID *id, bGPDframe *frame)
 {
   BKE_gpencil_free_strokes(frame);
 
+  bGPdata *gpd = (bGPdata *)id;
+  DEG_id_tag_update(>id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
+
   WM_main_add_notifier(NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
 }
 
-static void rna_GPencil_layer_clear(bGPDlayer *layer)
+static void rna_GPencil_layer_clear(ID *id, bGPDlayer *layer)
 {
   BKE_gpencil_free_frames(layer);
 
+  bGPdata *gpd = (bGPdata *)id;
+  DEG_id_tag_update(>id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
+
   WM_main_add_notifier(NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
 }
 
@@ -1119,6 +1125,8 @@ static void rna_GPencil_clear(bGPdata *gpd)
 {
   BKE_gpencil_free_layers(>layers);
 
+  DEG_id_tag_update(>id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
+
   WM_main_add_notifier(NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
 }
 
@@ -1841,6 +1849,7 @@ static void rna_def_gpencil_frame(BlenderRNA *brna)
   /* API */
   func = RNA_def_function(srna, "clear", "rna_GPencil_frame_clear");
   RNA_def_function_ui_description(func, "Remove all the grease pencil frame 
data");
+  RNA_def_function_flag(func, FUNC_USE_SELF_ID);
 }
 
 static void rna_def_gpencil_frames_api(BlenderRNA *brna, PropertyRNA *cprop)
@@ -2304,6 +2313,7 @@ static void rna_def_gpencil_layer(BlenderRNA *brna)
   /* Layers API */
   func = RNA_def_function(srna, "clear", "rna_GPencil_layer_clear");
   RNA_def_function_ui_description(func, "Remove all the grease pencil layer 
data");
+  RNA_def_function_flag(func, FUNC_USE_SELF_ID);
 }
 
 static void rna_def_gpencil_layers_api(BlenderRNA *brna, PropertyRNA *cprop)

___
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