[Bf-blender-cvs] [c4b32f1b291] master: Cleanup: Move mesh legacy conversion to a separate file

2022-07-07 Thread Hans Goudey
Commit: c4b32f1b291a3c3447879175225a3664aeb0b7ef
Author: Hans Goudey
Date:   Thu Jul 7 22:33:57 2022 -0500
Branches: master
https://developer.blender.org/rBc4b32f1b291a3c3447879175225a3664aeb0b7ef

Cleanup: Move mesh legacy conversion to a separate file

It's helpful to make the separation of legacy data formats explicit,
because it declutters actively changed code and makes it clear which
areas do not follow Blender's current design. In this case I separated
the `MFace`/"tessface" conversion code into a separate blenkernel
.cc file and header. This also makes refactoring to remove these
functions simpler because they're easier to find.

In the future, conversions to the `MLoopUV` type and `MVert`
can be implemented here for the same reasons (see T95965).

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

===

M   source/blender/blenkernel/BKE_customdata.h
M   source/blender/blenkernel/BKE_mesh.h
A   source/blender/blenkernel/BKE_mesh_legacy_convert.h
M   source/blender/blenkernel/CMakeLists.txt
M   source/blender/blenkernel/intern/customdata.cc
M   source/blender/blenkernel/intern/mesh.cc
M   source/blender/blenkernel/intern/mesh_evaluate.cc
A   source/blender/blenkernel/intern/mesh_legacy_convert.cc
M   source/blender/blenkernel/intern/mesh_tessellate.c
M   source/blender/blenkernel/intern/particle.c
M   source/blender/blenkernel/intern/particle_distribute.c
M   source/blender/blenkernel/intern/particle_system.c
M   source/blender/blenloader/intern/versioning_280.c
M   source/blender/draw/intern/draw_cache_impl_particles.c
M   source/blender/editors/curves/intern/curves_ops.cc
M   source/blender/editors/physics/particle_edit.c
M   source/blender/editors/physics/particle_object.c
M   source/blender/io/alembic/exporter/abc_writer_hair.cc
M   source/blender/io/collada/collada_utils.cpp
M   source/blender/makesrna/intern/rna_particle.c
M   source/blender/modifiers/intern/MOD_explode.c
M   source/blender/modifiers/intern/MOD_particlesystem.cc

===

diff --git a/source/blender/blenkernel/BKE_customdata.h 
b/source/blender/blenkernel/BKE_customdata.h
index a1101c1df44..010fbb27172 100644
--- a/source/blender/blenkernel/BKE_customdata.h
+++ b/source/blender/blenkernel/BKE_customdata.h
@@ -550,33 +550,11 @@ void CustomData_validate_layer_name(const struct 
CustomData *data,
  */
 bool CustomData_verify_versions(struct CustomData *data, int index);
 
-/* BMesh specific custom-data stuff.
- *
- * Needed to convert to/from different face representation (for versioning). */
+/* BMesh specific custom-data stuff. */
 
-void CustomData_to_bmeshpoly(struct CustomData *fdata, struct CustomData 
*ldata, int totloop);
-void CustomData_from_bmeshpoly(struct CustomData *fdata, struct CustomData 
*ldata, int total);
 void CustomData_bmesh_update_active_layers(struct CustomData *fdata, struct 
CustomData *ldata);
-/**
- * Update active indices for active/render/clone/stencil custom data layers
- * based on indices from fdata layers
- * used by do_versions in `readfile.c` when creating pdata and ldata for 
pre-bmesh
- * meshes and needed to preserve active/render/clone/stencil flags set in 
pre-bmesh files.
- */
-void CustomData_bmesh_do_versions_update_active_layers(struct CustomData 
*fdata,
-   struct CustomData 
*ldata);
 void CustomData_bmesh_init_pool(struct CustomData *data, int totelem, char 
htype);
 
-#ifndef NDEBUG
-/**
- * Debug check, used to assert when we expect layers to be in/out of sync.
- *
- * \param fallback: Use when there are no layers to handle,
- * since callers may expect success or failure.
- */
-bool CustomData_from_bmeshpoly_test(CustomData *fdata, CustomData *ldata, bool 
fallback);
-#endif
-
 /**
  * Validate and fix data of \a layer,
  * if possible (needs relevant callback in layer's type to be defined).
diff --git a/source/blender/blenkernel/BKE_mesh.h 
b/source/blender/blenkernel/BKE_mesh.h
index 66e0ff8e81a..ff4f4a8dc9e 100644
--- a/source/blender/blenkernel/BKE_mesh.h
+++ b/source/blender/blenkernel/BKE_mesh.h
@@ -183,14 +183,6 @@ void BKE_mesh_orco_verts_transform(struct Mesh *me, float 
(*orco)[3], int totver
  */
 void BKE_mesh_orco_ensure(struct Object *ob, struct Mesh *mesh);
 
-/**
- * Rotates the vertices of a face in case v[2] or v[3] (vertex index) is = 0.
- * this is necessary to make the if #MFace.v4 check for quads work.
- */
-int BKE_mesh_mface_index_validate(struct MFace *mface,
-  struct CustomData *mfdata,
-  int mfindex,
-  int nr);
 struct Mesh *BKE_mesh_from_object(struct Object *ob);
 void BKE_mesh_assign_object(struct Main *bmain, struct Object *ob, struct Mesh 
*me);
 void BKE_mesh_from_metaball(struct 

[Bf-blender-cvs] [b98a937db64] master: Fix T99364: Unable to select bones when custom shape display is disabled

2022-07-07 Thread Campbell Barton
Commit: b98a937db64c365de889adcc084248716607521d
Author: Campbell Barton
Date:   Fri Jul 8 11:09:47 2022 +1000
Branches: master
https://developer.blender.org/rBb98a937db64c365de889adcc084248716607521d

Fix T99364: Unable to select bones when custom shape display is disabled

Regression in [0] which revealed an error in [1].
Logic for pose channel custom transform ignored ARM_NO_CUSTOM.

[0]: 3267c91b4d5caab7da8aef071a446dd2e86f86a9
[1]: c3fef001ee926fc183255b623f56da9fc5fcbb73

===

M   source/blender/blenkernel/intern/armature.c
M   source/blender/makesdna/DNA_action_types.h

===

diff --git a/source/blender/blenkernel/intern/armature.c 
b/source/blender/blenkernel/intern/armature.c
index 622ecde6a91..f29074c827c 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -2668,20 +2668,21 @@ void BKE_pchan_minmax(const Object *ob,
   float r_max[3])
 {
   const bArmature *arm = ob->data;
-  const bPoseChannel *pchan_tx = (pchan->custom && pchan->custom_tx) ? 
pchan->custom_tx : pchan;
+  Object *ob_custom = (arm->flag & ARM_NO_CUSTOM) ? NULL : pchan->custom;
+  const bPoseChannel *pchan_tx = (ob_custom && pchan->custom_tx) ? 
pchan->custom_tx : pchan;
   const BoundBox *bb_custom = NULL;
   BoundBox bb_custom_buf;
 
-  if ((pchan->custom) && !(arm->flag & ARM_NO_CUSTOM)) {
+  if (ob_custom) {
 float min[3], max[3];
-if (use_empty_drawtype && (pchan->custom->type == OB_EMPTY) &&
-BKE_object_minmax_empty_drawtype(pchan->custom, min, max)) {
+if (use_empty_drawtype && (ob_custom->type == OB_EMPTY) &&
+BKE_object_minmax_empty_drawtype(ob_custom, min, max)) {
   memset(&bb_custom_buf, 0x0, sizeof(bb_custom_buf));
   BKE_boundbox_init_from_minmax(&bb_custom_buf, min, max);
   bb_custom = &bb_custom_buf;
 }
 else {
-  bb_custom = BKE_object_boundbox_get(pchan->custom);
+  bb_custom = BKE_object_boundbox_get(ob_custom);
 }
   }
 
diff --git a/source/blender/makesdna/DNA_action_types.h 
b/source/blender/makesdna/DNA_action_types.h
index 516d3ce94f9..53e87e905b5 100644
--- a/source/blender/makesdna/DNA_action_types.h
+++ b/source/blender/makesdna/DNA_action_types.h
@@ -251,12 +251,18 @@ typedef struct bPoseChannel {
 
   /** Motion path cache for this bone. */
   bMotionPath *mpath;
-  /** Draws custom object instead of default bone shape. */
+  /**
+   * Draws custom object instead of default bone shape.
+   *
+   * \note For the purpose of user interaction (selection, display etc),
+   * it's important this value is treated as NULL when #ARM_NO_CUSTOM is set.
+   */
   struct Object *custom;
   /**
-   * Odd feature, display with another bones transform.
-   * needed in rare cases for advanced rigs,
-   * since the alternative is highly complicated - campbell
+   * This is a specific feature to display with another bones transform.
+   * Needed in rare cases for advanced rigs, since alternative solutions are 
highly complicated.
+   *
+   * \note This depends #bPoseChannel.custom being set and the #ARM_NO_CUSTOM 
flag being unset.
*/
   struct bPoseChannel *custom_tx;
   float custom_scale; /* Deprecated */

___
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] [9ef37369592] master: Cleanup: format

2022-07-07 Thread Campbell Barton
Commit: 9ef37369592ee74a4e675ece6bdd37b9aca3f9ad
Author: Campbell Barton
Date:   Fri Jul 8 09:09:59 2022 +1000
Branches: master
https://developer.blender.org/rB9ef37369592ee74a4e675ece6bdd37b9aca3f9ad

Cleanup: format

===

M   release/scripts/startup/bl_ui/space_outliner.py
M   
source/blender/draw/engines/overlay/shaders/overlay_sculpt_curves_selection_vert.glsl
M   source/blender/editors/space_graph/graph_utils.c

===

diff --git a/release/scripts/startup/bl_ui/space_outliner.py 
b/release/scripts/startup/bl_ui/space_outliner.py
index 18057de6767..011a430a1ec 100644
--- a/release/scripts/startup/bl_ui/space_outliner.py
+++ b/release/scripts/startup/bl_ui/space_outliner.py
@@ -55,7 +55,7 @@ class OUTLINER_HT_header(Header):
 layout.operator("outliner.collection_new", text="", 
icon='COLLECTION_NEW').nested = True
 
 elif display_mode == 'ORPHAN_DATA':
-layout.operator("outliner.orphans_purge", 
text="Purge").do_recursive=True
+layout.operator("outliner.orphans_purge", 
text="Purge").do_recursive = True
 
 elif space.display_mode == 'DATA_API':
 layout.separator()
diff --git 
a/source/blender/draw/engines/overlay/shaders/overlay_sculpt_curves_selection_vert.glsl
 
b/source/blender/draw/engines/overlay/shaders/overlay_sculpt_curves_selection_vert.glsl
index 9ed959b5ea1..7be3c8e6dfb 100644
--- 
a/source/blender/draw/engines/overlay/shaders/overlay_sculpt_curves_selection_vert.glsl
+++ 
b/source/blender/draw/engines/overlay/shaders/overlay_sculpt_curves_selection_vert.glsl
@@ -2,7 +2,6 @@
 #pragma BLENDER_REQUIRE(common_view_clipping_lib.glsl)
 #pragma BLENDER_REQUIRE(common_view_lib.glsl)
 
-
 float retrieve_selection()
 {
   if (is_point_domain) {
diff --git a/source/blender/editors/space_graph/graph_utils.c 
b/source/blender/editors/space_graph/graph_utils.c
index 51af795893f..82067661d57 100644
--- a/source/blender/editors/space_graph/graph_utils.c
+++ b/source/blender/editors/space_graph/graph_utils.c
@@ -81,7 +81,8 @@ void ED_drivers_editor_init(bContext *C, ScrArea *area)
 bAnimListElem *get_active_fcurve_channel(bAnimContext *ac)
 {
   ListBase anim_data = {NULL, NULL};
-  int filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT | 
ANIMFILTER_ACTIVE | ANIMFILTER_FCURVESONLY);
+  int filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT | 
ANIMFILTER_ACTIVE |
+ANIMFILTER_FCURVESONLY);
   size_t items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, 
ac->datatype);
 
   /* We take the first F-Curve only, since some other ones may have had 
'active' flag set

___
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] [03173d63c01] master: Cleanup: spelling in comments

2022-07-07 Thread Campbell Barton
Commit: 03173d63c01aede48f361ce83f53e5e9d8236c05
Author: Campbell Barton
Date:   Fri Jul 8 09:10:30 2022 +1000
Branches: master
https://developer.blender.org/rB03173d63c01aede48f361ce83f53e5e9d8236c05

Cleanup: spelling in comments

Also move mis-placed doc-string.

===

M   source/blender/blenfont/intern/blf_glyph.c
M   source/blender/blenkernel/BKE_armature.h
M   source/blender/blenkernel/BKE_mball.h
M   source/blender/blenkernel/BKE_object.h
M   source/blender/blenkernel/intern/image_save.cc
M   source/blender/blenkernel/intern/mball.c
M   source/blender/editors/space_image/image_ops.c
M   source/blender/makesdna/DNA_windowmanager_types.h
M   source/blender/python/intern/bpy_driver.c

===

diff --git a/source/blender/blenfont/intern/blf_glyph.c 
b/source/blender/blenfont/intern/blf_glyph.c
index 103919e86f2..215f79e6795 100644
--- a/source/blender/blenfont/intern/blf_glyph.c
+++ b/source/blender/blenfont/intern/blf_glyph.c
@@ -908,12 +908,12 @@ static FT_GlyphSlot blf_glyph_render(FontBLF 
*settings_font,
   bool spacing_done = false;
 
   /* 70% of maximum weight results in the same amount of boldness and 
horizontal
-   * expansion as the bold version (DejaVuSans-Bold.ttf) of our default font.
+   * expansion as the bold version `DejaVuSans-Bold.ttf` of our default font.
* Worth reevaluating if we change default font. */
   float weight = (settings_font->flags & BLF_BOLD) ? 0.7f : 
settings_font->char_weight;
 
   /* 37.5% of maximum rightward slant results in 6 degree slope, matching 
italic
-   * version (DejaVuSans-Oblique.ttf) of our current font. But a nice median 
when
+   * version `DejaVuSans-Oblique.ttf` of our current font. But a nice median 
when
* checking others. Worth reevaluating if we change default font. We could 
also
* narrow the glyph slightly as most italics do, but this one does not. */
   float slant = (settings_font->flags & BLF_ITALIC) ? 0.375f : 
settings_font->char_slant;
diff --git a/source/blender/blenkernel/BKE_armature.h 
b/source/blender/blenkernel/BKE_armature.h
index 98f9f8e3588..ee0f41937e2 100644
--- a/source/blender/blenkernel/BKE_armature.h
+++ b/source/blender/blenkernel/BKE_armature.h
@@ -159,7 +159,7 @@ struct BoundBox *BKE_armature_boundbox_get(struct Object 
*ob);
  * Visual elements such as the envelopes radius & bendy-bone spline segments 
are *not* included,
  * making this not so useful for viewport culling.
  *
- * \param use_empty_drawtype: When enabled, the draw type of empty 
custom-objects is tagen into
+ * \param use_empty_drawtype: When enabled, the draw type of empty 
custom-objects is taken into
  * account when calculating the bounds.
  */
 void BKE_pchan_minmax(const struct Object *ob,
diff --git a/source/blender/blenkernel/BKE_mball.h 
b/source/blender/blenkernel/BKE_mball.h
index 5a4988c7a5f..a23d010b51f 100644
--- a/source/blender/blenkernel/BKE_mball.h
+++ b/source/blender/blenkernel/BKE_mball.h
@@ -75,7 +75,8 @@ float *BKE_mball_make_orco(struct Object *ob, struct ListBase 
*dispbase);
  * When some properties (wire-size, threshold, update flags) of meta-ball are 
changed, then this
  * properties are copied to all meta-balls in same "group" (meta-balls with 
same base name:
  * `MBall`, `MBall.001`, `MBall.002`, etc). The most important is to copy 
properties to the base
- * meta-ball, because this meta-ball influences polygonization of meta-balls. 
*/
+ * meta-ball, because this meta-ball influences polygonization of meta-balls.
+ */
 void BKE_mball_properties_copy(struct Main *bmain, struct MetaBall 
*active_metaball);
 
 bool BKE_mball_minmax_ex(
diff --git a/source/blender/blenkernel/BKE_object.h 
b/source/blender/blenkernel/BKE_object.h
index 96abea0e5ee..f0eb16a819d 100644
--- a/source/blender/blenkernel/BKE_object.h
+++ b/source/blender/blenkernel/BKE_object.h
@@ -366,9 +366,6 @@ void BKE_object_empty_draw_type_set(struct Object *ob, int 
value);
 
 void BKE_object_boundbox_calc_from_mesh(struct Object *ob, const struct Mesh 
*me_eval);
 bool BKE_object_boundbox_calc_from_evaluated_geometry(struct Object *ob);
-/**
- * Calculate visual bounds from an empty objects draw-type.
- */
 void BKE_object_minmax(struct Object *ob, float r_min[3], float r_max[3], bool 
use_hidden);
 bool BKE_object_minmax_dupli(struct Depsgraph *depsgraph,
  struct Scene *scene,
@@ -376,6 +373,12 @@ bool BKE_object_minmax_dupli(struct Depsgraph *depsgraph,
  float r_min[3],
  float r_max[3],
  bool use_hidden);
+/**
+ * Calculate visual bounds from an empty objects draw-type.
+ *
+ * \note This is not part of the calculation used by #BKE_object_boundbox_get
+ * as these bounds represent the extents of visual guides (use for viewport 
culling for e.g.)
+ */
 bool BKE_object_mi

[Bf-blender-cvs] [b39cd9a8490] temp-deform-curves-on-surface: Test: Retrieve original mesh information from the editmesh

2022-07-07 Thread Hans Goudey
Commit: b39cd9a8490514e9fdcfb86b09f65b90200f6e97
Author: Hans Goudey
Date:   Thu Jul 7 17:25:36 2022 -0500
Branches: temp-deform-curves-on-surface
https://developer.blender.org/rBb39cd9a8490514e9fdcfb86b09f65b90200f6e97

Test: Retrieve original mesh information from the editmesh

===

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

===

diff --git 
a/source/blender/nodes/geometry/nodes/node_geo_deform_curves_with_surface.cc 
b/source/blender/nodes/geometry/nodes/node_geo_deform_curves_with_surface.cc
index 7557023aef7..353c93a53de 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_deform_curves_with_surface.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_deform_curves_with_surface.cc
@@ -2,6 +2,8 @@
 
 #include "BKE_attribute_math.hh"
 #include "BKE_curves.hh"
+#include "BKE_editmesh.h"
+#include "BKE_lib_id.h"
 #include "BKE_mesh.h"
 #include "BKE_mesh_runtime.h"
 #include "BKE_mesh_wrapper.h"
@@ -197,7 +199,15 @@ static void node_geo_exec(GeoNodeExecParams params)
 {
   GeometrySet curves_geometry = params.extract_input("Curves");
 
-  auto pass_through_input = [&]() { params.set_output("Curves", 
std::move(curves_geometry)); };
+  Mesh *surface_mesh_orig = nullptr;
+  bool free_suface_mesh_orig = false;
+
+  auto pass_through_input = [&]() {
+params.set_output("Curves", std::move(curves_geometry));
+if (free_suface_mesh_orig) {
+  BKE_id_free(nullptr, surface_mesh_orig);
+}
+  };
 
   const Object *self_ob_eval = params.self_object();
   if (self_ob_eval == nullptr || self_ob_eval->type != OB_CURVES) {
@@ -218,19 +228,28 @@ static void node_geo_exec(GeoNodeExecParams params)
 return;
   }
   Object *surface_ob_orig = DEG_get_original_object(surface_ob_eval);
-  Mesh &surface_mesh_orig = *static_cast(surface_ob_orig->data);
+  Mesh &surface_object_data = *static_cast(surface_ob_orig->data);
+
+  if (BMEditMesh *em = surface_object_data.edit_mesh) {
+surface_mesh_orig = BKE_mesh_from_bmesh_for_eval_nomain(em->bm, NULL, 
&surface_object_data);
+free_suface_mesh_orig = true;
+  }
+  else {
+surface_mesh_orig = &surface_object_data;
+  }
   Mesh *surface_mesh_eval = 
BKE_modifier_get_evaluated_mesh_from_evaluated_object(surface_ob_eval,

   false);
   if (surface_mesh_eval == nullptr) {
 pass_through_input();
 return;
   }
+
   BKE_mesh_wrapper_ensure_mdata(surface_mesh_eval);
 
   MeshComponent mesh_eval;
   mesh_eval.replace(surface_mesh_eval, GeometryOwnershipType::ReadOnly);
   MeshComponent mesh_orig;
-  mesh_orig.replace(&surface_mesh_orig, GeometryOwnershipType::ReadOnly);
+  mesh_orig.replace(surface_mesh_orig, GeometryOwnershipType::ReadOnly);
 
   Curves &curves_id = *curves_geometry.get_curves_for_write();
   CurvesGeometry &curves = CurvesGeometry::wrap(curves_id.geometry);
@@ -259,8 +278,8 @@ static void node_geo_exec(GeoNodeExecParams params)
   rest_position_name, ATTR_DOMAIN_POINT, {0.0f, 0.0f, 0.0f});
   const Span surface_uv_coords = curves.surface_uv_coords();
 
-  const Span 
looptris_orig{BKE_mesh_runtime_looptri_ensure(&surface_mesh_orig),
- 
BKE_mesh_runtime_looptri_len(&surface_mesh_orig)};
+  const Span 
looptris_orig{BKE_mesh_runtime_looptri_ensure(surface_mesh_orig),
+ 
BKE_mesh_runtime_looptri_len(surface_mesh_orig)};
   const Span 
looptris_eval{BKE_mesh_runtime_looptri_ensure(surface_mesh_eval),
  
BKE_mesh_runtime_looptri_len(surface_mesh_eval)};
   const ReverseUVSampler reverse_uv_sampler_orig{uv_map_orig, looptris_orig};
@@ -270,10 +289,10 @@ static void node_geo_exec(GeoNodeExecParams params)
* because face normals or vertex normals may lose information (custom 
normals, auto smooth) in
* some cases. It isn't yet possible to retrieve lazily calculated face 
corner normals from a
* const mesh, so they are calculated here every time. */
-  Array corner_normals_orig(surface_mesh_orig.totloop);
+  Array corner_normals_orig(surface_mesh_orig->totloop);
   Array corner_normals_eval(surface_mesh_eval->totloop);
   BKE_mesh_calc_normals_split_ex(
-  &surface_mesh_orig, nullptr, 
reinterpret_cast(corner_normals_orig.data()));
+  surface_mesh_orig, nullptr, 
reinterpret_cast(corner_normals_orig.data()));
   BKE_mesh_calc_normals_split_ex(
   surface_mesh_eval, nullptr, 
reinterpret_cast(corner_normals_eval.data()));
 
@@ -282,7 +301,7 @@ static void node_geo_exec(GeoNodeExecParams params)
   const bke::CurvesSurfaceTransforms transforms{*self_ob_eval, 
surface_ob_eval};
 
   deform_curves(curves,
-surface_mesh_orig,
+*surface_mesh_orig,
 *surface_mesh_eval,
 surface_uv_coords,
 r

[Bf-blender-cvs] [349682e5bf9] temp-deform-curves-on-surface: Cleanup to naming and other small tweaks

2022-07-07 Thread Hans Goudey
Commit: 349682e5bf97112581de8e116210f94adeaa5dc1
Author: Hans Goudey
Date:   Thu Jul 7 16:32:02 2022 -0500
Branches: temp-deform-curves-on-surface
https://developer.blender.org/rB349682e5bf97112581de8e116210f94adeaa5dc1

Cleanup to naming and other small tweaks

===

M   source/blender/blenkernel/BKE_node.h
M   source/blender/blenkernel/intern/node.cc
M   source/blender/editors/curves/intern/curves_add.cc
M   source/blender/makesrna/intern/rna_object.c
M   source/blender/modifiers/intern/MOD_nodes.cc
M   source/blender/nodes/NOD_geometry.h
M   source/blender/nodes/NOD_static_types.h
M   
source/blender/nodes/geometry/nodes/node_geo_deform_curves_with_surface.cc

===

diff --git a/source/blender/blenkernel/BKE_node.h 
b/source/blender/blenkernel/BKE_node.h
index 71eb3f6664f..b7962ade312 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -1501,7 +1501,7 @@ struct TexResult;
 #define GEO_NODE_MESH_TO_VOLUME 1164
 #define GEO_NODE_UV_UNWRAP 1165
 #define GEO_NODE_UV_PACK_ISLANDS 1166
-#define GEO_NODE_DEFORM_CURVES_WITH_SURFACE 1167
+#define GEO_NODE_DEFORM_CURVES_ON_SURFACE 1167
 
 /** \} */
 
diff --git a/source/blender/blenkernel/intern/node.cc 
b/source/blender/blenkernel/intern/node.cc
index 1c797f29ce1..c6f140b9260 100644
--- a/source/blender/blenkernel/intern/node.cc
+++ b/source/blender/blenkernel/intern/node.cc
@@ -4749,7 +4749,7 @@ static void registerGeometryNodes()
   register_node_type_geo_curve_to_mesh();
   register_node_type_geo_curve_to_points();
   register_node_type_geo_curve_trim();
-  register_node_type_geo_deform_curves_with_surface();
+  register_node_type_geo_deform_curves_on_surface();
   register_node_type_geo_delete_geometry();
   register_node_type_geo_duplicate_elements();
   register_node_type_geo_distribute_points_on_faces();
diff --git a/source/blender/editors/curves/intern/curves_add.cc 
b/source/blender/editors/curves/intern/curves_add.cc
index c725ef2edb9..79916253207 100644
--- a/source/blender/editors/curves/intern/curves_add.cc
+++ b/source/blender/editors/curves/intern/curves_add.cc
@@ -24,7 +24,7 @@ namespace blender::ed::curves {
 static bool has_surface_deformation_node(const bNodeTree &ntree)
 {
   LISTBASE_FOREACH (const bNode *, node, &ntree.nodes) {
-if (node->type == GEO_NODE_DEFORM_CURVES_WITH_SURFACE) {
+if (node->type == GEO_NODE_DEFORM_CURVES_ON_SURFACE) {
   return true;
 }
 if (node->type == NODE_GROUP) {
@@ -65,16 +65,16 @@ void ensure_surface_deformation_node_exists(bContext &C, 
Object &curves_ob)
   Scene *scene = CTX_data_scene(&C);
 
   ModifierData *md = ED_object_modifier_add(
-  nullptr, bmain, scene, &curves_ob, "Hair Deform", eModifierType_Nodes);
+  nullptr, bmain, scene, &curves_ob, "Surface Deform", 
eModifierType_Nodes);
   NodesModifierData &nmd = *reinterpret_cast(md);
-  nmd.node_group = ntreeAddTree(bmain, "Hair Deform", "GeometryNodeTree");
+  nmd.node_group = ntreeAddTree(bmain, "Surface Deform", "GeometryNodeTree");
 
   bNodeTree *ntree = nmd.node_group;
   ntreeAddSocketInterface(ntree, SOCK_IN, "NodeSocketGeometry", "Geometry");
   ntreeAddSocketInterface(ntree, SOCK_OUT, "NodeSocketGeometry", "Geometry");
   bNode *group_input = nodeAddStaticNode(&C, ntree, NODE_GROUP_INPUT);
   bNode *group_output = nodeAddStaticNode(&C, ntree, NODE_GROUP_OUTPUT);
-  bNode *deform_node = nodeAddStaticNode(&C, ntree, 
GEO_NODE_DEFORM_CURVES_WITH_SURFACE);
+  bNode *deform_node = nodeAddStaticNode(&C, ntree, 
GEO_NODE_DEFORM_CURVES_ON_SURFACE);
 
   ED_node_tree_propagate_change(&C, bmain, nmd.node_group);
 
diff --git a/source/blender/makesrna/intern/rna_object.c 
b/source/blender/makesrna/intern/rna_object.c
index 3af992da3ee..a68ef361f04 100644
--- a/source/blender/makesrna/intern/rna_object.c
+++ b/source/blender/makesrna/intern/rna_object.c
@@ -3583,8 +3583,8 @@ static void rna_def_object(BlenderRNA *brna)
   RNA_def_property_boolean_sdna(prop, NULL, "modifier_flag", 
OB_MODIFIER_FLAG_ADD_REST_POSITION);
   RNA_def_property_ui_text(prop,
"Add Rest Position",
-   "Add a rest_position attribute that is a copy of 
the position "
-   "attribute right before shape keys and modifiers 
are evaluated");
+   "Add a \"rest_position\" attribute that is a copy 
of the position "
+   "attribute before shape keys and modifiers are 
evaluated");
   RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, 
"rna_Object_internal_update_data");
 
   /* render */
diff --git a/source/blender/modifiers/intern/MOD_nodes.cc 
b/source/blender/modifiers/intern/MOD_nodes.cc
index 02b146b85fb..a63a89e076b 100644
--- a/source/blender/modifiers/intern/MOD_nodes.cc
+++ b/source/blender/modifiers/intern/MOD_nodes.cc
@@ -191,7 +191,7

[Bf-blender-cvs] [01a223fe0c2] temp-deform-curves-on-surface: D14864 from Jacques

2022-07-07 Thread Hans Goudey
Commit: 01a223fe0c2279c8630a33d254cf7205fc3afa19
Author: Hans Goudey
Date:   Thu Jul 7 13:49:09 2022 -0500
Branches: temp-deform-curves-on-surface
https://developer.blender.org/rB01a223fe0c2279c8630a33d254cf7205fc3afa19

D14864 from Jacques

===

M   release/scripts/startup/bl_ui/properties_data_mesh.py
M   release/scripts/startup/nodeitems_builtins.py
M   source/blender/blenkernel/BKE_node.h
M   source/blender/blenkernel/intern/DerivedMesh.cc
M   source/blender/blenkernel/intern/node.cc
M   source/blender/editors/curves/intern/curves_add.cc
M   source/blender/editors/curves/intern/curves_ops.cc
M   source/blender/editors/include/ED_curves.h
M   source/blender/editors/object/object_add.cc
M   source/blender/editors/object/object_relations.c
M   source/blender/makesdna/DNA_object_types.h
M   source/blender/makesrna/intern/rna_object.c
M   source/blender/modifiers/intern/MOD_nodes.cc
M   source/blender/nodes/NOD_geometry.h
M   source/blender/nodes/NOD_static_types.h
M   source/blender/nodes/geometry/CMakeLists.txt
A   
source/blender/nodes/geometry/nodes/node_geo_deform_curves_with_surface.cc

===

diff --git a/release/scripts/startup/bl_ui/properties_data_mesh.py 
b/release/scripts/startup/bl_ui/properties_data_mesh.py
index 0b043905713..2fc949f4aae 100644
--- a/release/scripts/startup/bl_ui/properties_data_mesh.py
+++ b/release/scripts/startup/bl_ui/properties_data_mesh.py
@@ -411,6 +411,8 @@ class DATA_PT_shape_keys(MeshButtonsPanel, Panel):
 row.active = enable_edit_value
 row.prop(key, "eval_time")
 
+layout.prop(ob, "add_rest_position_attribute")
+
 
 class DATA_PT_uv_texture(MeshButtonsPanel, Panel):
 bl_label = "UV Maps"
diff --git a/release/scripts/startup/nodeitems_builtins.py 
b/release/scripts/startup/nodeitems_builtins.py
index 3f49fb9fb58..e59c98163d7 100644
--- a/release/scripts/startup/nodeitems_builtins.py
+++ b/release/scripts/startup/nodeitems_builtins.py
@@ -73,6 +73,7 @@ def curve_node_items(context):
 yield NodeItem("GeometryNodeCurveLength")
 yield NodeItem("GeometryNodeCurveToMesh")
 yield NodeItem("GeometryNodeCurveToPoints")
+yield NodeItem("GeometryNodeDeformCurvesWithSurface")
 yield NodeItem("GeometryNodeFillCurve")
 yield NodeItem("GeometryNodeFilletCurve")
 yield NodeItem("GeometryNodeResampleCurve")
diff --git a/source/blender/blenkernel/BKE_node.h 
b/source/blender/blenkernel/BKE_node.h
index e13ac3180ec..71eb3f6664f 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -1501,6 +1501,7 @@ struct TexResult;
 #define GEO_NODE_MESH_TO_VOLUME 1164
 #define GEO_NODE_UV_UNWRAP 1165
 #define GEO_NODE_UV_PACK_ISLANDS 1166
+#define GEO_NODE_DEFORM_CURVES_WITH_SURFACE 1167
 
 /** \} */
 
diff --git a/source/blender/blenkernel/intern/DerivedMesh.cc 
b/source/blender/blenkernel/intern/DerivedMesh.cc
index ffac89c15e6..c2ea01bcadf 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.cc
+++ b/source/blender/blenkernel/intern/DerivedMesh.cc
@@ -66,6 +66,9 @@
 #  include "DNA_userdef_types.h"
 #endif
 
+using blender::float3;
+using blender::IndexRange;
+
 /* very slow! enable for testing only! */
 //#define USE_MODIFIER_VALIDATE
 
@@ -814,6 +817,25 @@ static void mesh_calc_modifiers(struct Depsgraph 
*depsgraph,
   /* Clear errors before evaluation. */
   BKE_modifiers_clear_errors(ob);
 
+  if (ob->modifier_flag & OB_MODIFIER_FLAG_ADD_REST_POSITION) {
+if (mesh_final == nullptr) {
+  mesh_final = BKE_mesh_copy_for_eval(mesh_input, true);
+  ASSERT_IS_VALID_MESH(mesh_final);
+}
+float3 *rest_positions = static_cast(CustomData_add_layer_named(&mesh_final->vdata,
+  
CD_PROP_FLOAT3,
+  
CD_DEFAULT,
+  
nullptr,
+  
mesh_final->totvert,
+  
"rest_position"));
+blender::threading::parallel_for(
+IndexRange(mesh_final->totvert), 1024, [&](const IndexRange range) {
+  for (const int i : range) {
+rest_positions[i] = mesh_final->mvert[i].co;
+  }
+});
+  }
+
   /* Apply all leading deform modifiers. */
   if (use_deform) {
 for (; md; md = md->next, md_datamask = md_datamask->next) {
diff --git a/source/blender/blenkernel/intern/node.cc 
b/source/blender/blenkernel/intern/node.cc
index 5be912ffb2b..1c797f29ce1 100644
--- a/source/blender/blenkernel/intern/node.cc
+++ b/source/blender/blenkernel/intern/node.cc
@@ -4749,6 +4749,7 @@ static void re

[Bf-blender-cvs] [e142387b2fb] temp-deform-curves-on-surface: Threadsafe access to face corner normals

2022-07-07 Thread Hans Goudey
Commit: e142387b2fb3ec1f6a01b043dbc421abef2e5584
Author: Hans Goudey
Date:   Thu Jul 7 17:09:47 2022 -0500
Branches: temp-deform-curves-on-surface
https://developer.blender.org/rBe142387b2fb3ec1f6a01b043dbc421abef2e5584

Threadsafe access to face corner normals

===

M   source/blender/blenkernel/BKE_mesh.h
M   source/blender/blenkernel/intern/mesh.cc
M   
source/blender/nodes/geometry/nodes/node_geo_deform_curves_with_surface.cc

===

diff --git a/source/blender/blenkernel/BKE_mesh.h 
b/source/blender/blenkernel/BKE_mesh.h
index 66e0ff8e81a..847fb05fb92 100644
--- a/source/blender/blenkernel/BKE_mesh.h
+++ b/source/blender/blenkernel/BKE_mesh.h
@@ -710,7 +710,8 @@ void BKE_mesh_calc_normals_split(struct Mesh *mesh);
  * to split geometry along sharp edges.
  */
 void BKE_mesh_calc_normals_split_ex(struct Mesh *mesh,
-struct MLoopNorSpaceArray 
*r_lnors_spacearr);
+struct MLoopNorSpaceArray 
*r_lnors_spacearr,
+float (*r_corner_normals)[3]);
 
 /**
  * Higher level functions hiding most of the code needed around call to
diff --git a/source/blender/blenkernel/intern/mesh.cc 
b/source/blender/blenkernel/intern/mesh.cc
index ffbd824712a..9d02ae2d0fa 100644
--- a/source/blender/blenkernel/intern/mesh.cc
+++ b/source/blender/blenkernel/intern/mesh.cc
@@ -1922,9 +1922,25 @@ void BKE_mesh_vert_coords_apply_with_mat4(Mesh *mesh,
   BKE_mesh_tag_coords_changed(mesh);
 }
 
-void BKE_mesh_calc_normals_split_ex(Mesh *mesh, MLoopNorSpaceArray 
*r_lnors_spacearr)
+static float (*ensure_corner_normal_layer(Mesh &mesh))[3]
 {
   float(*r_loopnors)[3];
+  if (CustomData_has_layer(&mesh.ldata, CD_NORMAL)) {
+r_loopnors = (float(*)[3])CustomData_get_layer(&mesh.ldata, CD_NORMAL);
+memset(r_loopnors, 0, sizeof(float[3]) * mesh.totloop);
+  }
+  else {
+r_loopnors = (float(*)[3])CustomData_add_layer(
+&mesh.ldata, CD_NORMAL, CD_CALLOC, nullptr, mesh.totloop);
+CustomData_set_layer_flag(&mesh.ldata, CD_NORMAL, CD_FLAG_TEMPORARY);
+  }
+  return r_loopnors;
+}
+
+void BKE_mesh_calc_normals_split_ex(Mesh *mesh,
+MLoopNorSpaceArray *r_lnors_spacearr,
+float (*r_corner_normals)[3])
+{
   short(*clnors)[2] = nullptr;
 
   /* Note that we enforce computing clnors when the clnor space array is 
requested by caller here.
@@ -1934,16 +1950,6 @@ void BKE_mesh_calc_normals_split_ex(Mesh *mesh, 
MLoopNorSpaceArray *r_lnors_spac
  ((mesh->flag & ME_AUTOSMOOTH) != 0);
   const float split_angle = (mesh->flag & ME_AUTOSMOOTH) != 0 ? 
mesh->smoothresh : (float)M_PI;
 
-  if (CustomData_has_layer(&mesh->ldata, CD_NORMAL)) {
-r_loopnors = (float(*)[3])CustomData_get_layer(&mesh->ldata, CD_NORMAL);
-memset(r_loopnors, 0, sizeof(float[3]) * mesh->totloop);
-  }
-  else {
-r_loopnors = (float(*)[3])CustomData_add_layer(
-&mesh->ldata, CD_NORMAL, CD_CALLOC, nullptr, mesh->totloop);
-CustomData_set_layer_flag(&mesh->ldata, CD_NORMAL, CD_FLAG_TEMPORARY);
-  }
-
   /* may be nullptr */
   clnors = (short(*)[2])CustomData_get_layer(&mesh->ldata, 
CD_CUSTOMLOOPNORMAL);
 
@@ -1953,7 +1959,7 @@ void BKE_mesh_calc_normals_split_ex(Mesh *mesh, 
MLoopNorSpaceArray *r_lnors_spac
   mesh->medge,
   mesh->totedge,
   mesh->mloop,
-  r_loopnors,
+  r_corner_normals,
   mesh->totloop,
   mesh->mpoly,
   BKE_mesh_poly_normals_ensure(mesh),
@@ -1969,7 +1975,7 @@ void BKE_mesh_calc_normals_split_ex(Mesh *mesh, 
MLoopNorSpaceArray *r_lnors_spac
 
 void BKE_mesh_calc_normals_split(Mesh *mesh)
 {
-  BKE_mesh_calc_normals_split_ex(mesh, nullptr);
+  BKE_mesh_calc_normals_split_ex(mesh, nullptr, 
ensure_corner_normal_layer(*mesh));
 }
 
 /* Split faces helper functions. */
@@ -2188,7 +2194,8 @@ void BKE_mesh_split_faces(Mesh *mesh, bool 
free_loop_normals)
 
   MLoopNorSpaceArray lnors_spacearr = {nullptr};
   /* Compute loop normals and loop normal spaces (a.k.a. smooth fans of faces 
around vertices). */
-  BKE_mesh_calc_normals_split_ex(mesh, &lnors_spacearr);
+
+  BKE_mesh_calc_normals_split_ex(mesh, &lnors_spacearr, 
ensure_corner_normal_layer(*mesh));
   /* Stealing memarena from loop normals space array. */
   MemArena *memarena = lnors_spacearr.mem;
 
diff --git 
a/source/blender/nodes/geometry/nodes/node_geo_deform_curves_with_surface.cc 
b/source/blender/nodes/geometry/nodes/node_geo_deform_curves_with_surface.cc
index 00866bca48f..7557023aef7 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_deform_curves_with_surface.cc
+++ b/source/blender

[Bf-blender-cvs] [56bf92f0f6d] master: Cleanup: Calm GCC Conversion Warning

2022-07-07 Thread Harley Acheson
Commit: 56bf92f0f6df8684c5ffb63ffa7218322eedf574
Author: Harley Acheson
Date:   Thu Jul 7 14:29:37 2022 -0700
Branches: master
https://developer.blender.org/rB56bf92f0f6df8684c5ffb63ffa7218322eedf574

Cleanup: Calm GCC Conversion Warning

Commit b9c0eed206b0 introduced a GCC conversion warning because of an
assignment of a long int value to an int.

Own Code

===

M   source/blender/blenfont/intern/blf_glyph.c

===

diff --git a/source/blender/blenfont/intern/blf_glyph.c 
b/source/blender/blenfont/intern/blf_glyph.c
index 4db083366c3..103919e86f2 100644
--- a/source/blender/blenfont/intern/blf_glyph.c
+++ b/source/blender/blenfont/intern/blf_glyph.c
@@ -843,7 +843,7 @@ static bool blf_glyph_transform_width(FT_GlyphSlot glyph, 
float factor)
 static bool blf_glyph_transform_spacing(FT_GlyphSlot glyph, float factor)
 {
   if (glyph->advance.x > 0) {
-const int size = glyph->face->size->metrics.height;
+const long int size = glyph->face->size->metrics.height;
 glyph->advance.x += (FT_Pos)(factor * (float)size / 6.0f);
 return true;
   }

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


[Bf-blender-cvs] [b9c0eed206b] master: BLF: Add Support for Variable Fonts

2022-07-07 Thread Harley Acheson
Commit: b9c0eed206b0d7d1b6af6809c6d2cb6c2187bcc8
Author: Harley Acheson
Date:   Thu Jul 7 12:59:16 2022 -0700
Branches: master
https://developer.blender.org/rBb9c0eed206b0d7d1b6af6809c6d2cb6c2187bcc8

BLF: Add Support for Variable Fonts

Add support for Variable/Multiple Master font features. These are fonts
that contain a range of design variations along multiple axes. This
contains no client-facing options.

See D12977 for details and examples

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

Reviewed by Brecht Van Lommel

===

M   source/blender/blenfont/intern/blf_font.c
M   source/blender/blenfont/intern/blf_glyph.c
M   source/blender/blenfont/intern/blf_internal_types.h

===

diff --git a/source/blender/blenfont/intern/blf_font.c 
b/source/blender/blenfont/intern/blf_font.c
index 3e2927d581e..038e73cc928 100644
--- a/source/blender/blenfont/intern/blf_font.c
+++ b/source/blender/blenfont/intern/blf_font.c
@@ -18,7 +18,8 @@
 
 #include FT_FREETYPE_H
 #include FT_GLYPH_H
-#include FT_TRUETYPE_TABLES_H /* For TT_OS2 */
+#include FT_TRUETYPE_TABLES_H  /* For TT_OS2 */
+#include FT_MULTIPLE_MASTERS_H /* Variable font support. */
 
 #include "MEM_guardedalloc.h"
 
@@ -1285,6 +1286,10 @@ FontBLF *blf_font_new(const char *name, const char 
*filepath)
 MEM_freeN(mfile);
   }
 
+  if (FT_HAS_MULTIPLE_MASTERS(font->face)) {
+FT_Get_MM_Var(font->face, &(font->variations));
+  }
+
   font->name = BLI_strdup(name);
   font->filepath = BLI_strdup(filepath);
   blf_font_fill(font);
@@ -1351,6 +1356,10 @@ FontBLF *blf_font_new_from_mem(const char *name, const 
unsigned char *mem, int m
 return NULL;
   }
 
+  if (FT_HAS_MULTIPLE_MASTERS(font->face)) {
+FT_Get_MM_Var(font->face, &(font->variations));
+  }
+
   font->name = BLI_strdup(name);
   font->filepath = NULL;
   blf_font_fill(font);
@@ -1365,6 +1374,10 @@ void blf_font_free(FontBLF *font)
 MEM_freeN(font->kerning_cache);
   }
 
+  if (font->variations) {
+FT_Done_MM_Var(ft_lib, font->variations);
+  }
+
   FT_Done_Face(font->face);
   if (font->filepath) {
 MEM_freeN(font->filepath);
diff --git a/source/blender/blenfont/intern/blf_glyph.c 
b/source/blender/blenfont/intern/blf_glyph.c
index 2eb43e3df43..4db083366c3 100644
--- a/source/blender/blenfont/intern/blf_glyph.c
+++ b/source/blender/blenfont/intern/blf_glyph.c
@@ -18,7 +18,8 @@
 #include FT_GLYPH_H
 #include FT_OUTLINE_H
 #include FT_BITMAP_H
-#include FT_ADVANCES_H /* For FT_Get_Advance. */
+#include FT_ADVANCES_H /* For FT_Get_Advance. */
+#include FT_MULTIPLE_MASTERS_H /* Variable font support. */
 
 #include "MEM_guardedalloc.h"
 
@@ -64,7 +65,9 @@ static GlyphCacheBLF *blf_glyph_cache_find(FontBLF *font, 
float size, unsigned i
   GlyphCacheBLF *gc = (GlyphCacheBLF *)font->cache.first;
   while (gc) {
 if (gc->size == size && gc->dpi == dpi && (gc->bold == ((font->flags & 
BLF_BOLD) != 0)) &&
-(gc->italic == ((font->flags & BLF_ITALIC) != 0))) {
+(gc->italic == ((font->flags & BLF_ITALIC) != 0)) &&
+(gc->char_weight == font->char_weight) && (gc->char_slant == 
font->char_slant) &&
+(gc->char_width == font->char_width) && (gc->char_spacing == 
font->char_spacing)) {
   return gc;
 }
 gc = gc->next;
@@ -82,6 +85,10 @@ static GlyphCacheBLF *blf_glyph_cache_new(FontBLF *font)
   gc->dpi = font->dpi;
   gc->bold = ((font->flags & BLF_BOLD) != 0);
   gc->italic = ((font->flags & BLF_ITALIC) != 0);
+  gc->char_weight = font->char_weight;
+  gc->char_slant = font->char_slant;
+  gc->char_width = font->char_width;
+  gc->char_spacing = font->char_spacing;
 
   memset(gc->glyph_ascii_table, 0, sizeof(gc->glyph_ascii_table));
   memset(gc->bucket, 0, sizeof(gc->bucket));
@@ -673,6 +680,96 @@ static bool blf_glyph_render_bitmap(FontBLF *font, 
FT_GlyphSlot glyph)
 
 /** \} */
 
+/*  */
+/** \name Variations (Multiple Masters) support
+ * \{ */
+
+/**
+ * Return a design axis that matches an identifying tag.
+ *
+ * \param variations: Variation descriptors from `FT_Get_MM_Var`.
+ * \param tag: Axis tag (4-character string as uint), like 'wght'
+ * \param axis_index: returns index of axis in variations array.
+ */
+static FT_Var_Axis *blf_var_axis_by_tag(FT_MM_Var *variations, uint tag, int 
*axis_index)
+{
+  *axis_index = -1;
+  if (!variations) {
+return NULL;
+  }
+  for (int i = 0; i < (int)variations->num_axis; i++) {
+if (variations->axis[i].tag == tag) {
+  *axis_index = i;
+  return &(variations->axis)[i];
+  break;
+}
+  }
+  return NULL;
+}
+
+/**
+ * Convert a float factor to a fixed-point design coordinate.
+ *
+ * \param axis: Pointer to a design space axis structure.
+ * \param factor: -1 to 1 with 0 meaning "default"
+ */
+static FT_Fixed blf_factor_to_coordinate(FT_Var_Axis 

[Bf-blender-cvs] [fc06b4c0335] master: Fix T99332: resize video in image editor does not update correctly

2022-07-07 Thread Brecht Van Lommel
Commit: fc06b4c03356b5b9a272df8a2b96b6c4f9254ee7
Author: Brecht Van Lommel
Date:   Thu Jul 7 20:51:32 2022 +0200
Branches: master
https://developer.blender.org/rBfc06b4c03356b5b9a272df8a2b96b6c4f9254ee7

Fix T99332: resize video in image editor does not update correctly

Use the image user from the image editor to correctly get the frame in the
operators. Based on patch by Nicolas (john-g-h-doe) with changes by me.

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

===

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

===

diff --git a/source/blender/editors/space_image/image_ops.c 
b/source/blender/editors/space_image/image_ops.c
index 49420e9a2a1..9b622d34176 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -197,10 +197,17 @@ static ImageUser *image_user_from_context(const bContext 
*C)
   return (sima) ? &sima->iuser : NULL;
 }
 
-static ImageUser image_user_from_active_tile(Image *ima)
+static ImageUser image_user_from_context_and_active_tile(const bContext *C, 
Image *ima)
 {
+  /* Try to get image user from contexrt if available, otherwise use default. 
*/
+  ImageUser *iuser_context = image_user_from_context(C);
   ImageUser iuser;
-  BKE_imageuser_default(&iuser);
+  if (iuser_context) {
+iuser = *iuser_context;
+  }
+  else {
+BKE_imageuser_default(&iuser);
+  }
 
   /* Use the file associated with the active tile. Otherwise use the first 
tile. */
   if (ima && ima->source == IMA_SRC_TILED) {
@@ -233,7 +240,7 @@ static bool image_from_context_has_data_poll(bContext *C)
 static bool image_from_context_has_data_poll_active_tile(bContext *C)
 {
   Image *ima = image_from_context(C);
-  ImageUser iuser = image_user_from_active_tile(ima);
+  ImageUser iuser = image_user_from_context_and_active_tile(C, ima);
 
   return BKE_image_has_ibuf(ima, &iuser);
 }
@@ -1602,7 +1609,7 @@ static int image_file_browse_invoke(bContext *C, 
wmOperator *op, const wmEvent *
   }
 }
 else if (ima->source == IMA_SRC_TILED) {
-  ImageUser iuser = image_user_from_active_tile(ima);
+  ImageUser iuser = image_user_from_context_and_active_tile(C, ima);
   BKE_image_user_file_path(&iuser, ima, filepath);
 }
 
@@ -2698,7 +2705,7 @@ void IMAGE_OT_new(wmOperatorType *ot)
 static int image_flip_exec(bContext *C, wmOperator *op)
 {
   Image *ima = image_from_context(C);
-  ImageUser iuser = image_user_from_active_tile(ima);
+  ImageUser iuser = image_user_from_context_and_active_tile(C, ima);
   ImBuf *ibuf = BKE_image_acquire_ibuf(ima, &iuser, NULL);
   SpaceImage *sima = CTX_wm_space_image(C);
   const bool is_paint = ((sima != NULL) && (sima->mode == SI_MODE_PAINT));
@@ -2716,7 +2723,7 @@ static int image_flip_exec(bContext *C, wmOperator *op)
 return OPERATOR_FINISHED;
   }
 
-  ED_image_undo_push_begin_with_image(op->type->name, ima, ibuf, &sima->iuser);
+  ED_image_undo_push_begin_with_image(op->type->name, ima, ibuf, &iuser);
 
   if (is_paint) {
 ED_imapaint_clear_partial_redraw();
@@ -2819,7 +2826,7 @@ void IMAGE_OT_flip(wmOperatorType *ot)
 static int image_invert_exec(bContext *C, wmOperator *op)
 {
   Image *ima = image_from_context(C);
-  ImageUser iuser = image_user_from_active_tile(ima);
+  ImageUser iuser = image_user_from_context_and_active_tile(C, ima);
   ImBuf *ibuf = BKE_image_acquire_ibuf(ima, &iuser, NULL);
   SpaceImage *sima = CTX_wm_space_image(C);
   const bool is_paint = ((sima != NULL) && (sima->mode == SI_MODE_PAINT));
@@ -2837,7 +2844,7 @@ static int image_invert_exec(bContext *C, wmOperator *op)
 return OPERATOR_CANCELLED;
   }
 
-  ED_image_undo_push_begin_with_image(op->type->name, ima, ibuf, &sima->iuser);
+  ED_image_undo_push_begin_with_image(op->type->name, ima, ibuf, &iuser);
 
   if (is_paint) {
 ED_imapaint_clear_partial_redraw();
@@ -2943,7 +2950,7 @@ void IMAGE_OT_invert(wmOperatorType *ot)
 static int image_scale_invoke(bContext *C, wmOperator *op, const wmEvent 
*UNUSED(event))
 {
   Image *ima = image_from_context(C);
-  ImageUser iuser = image_user_from_active_tile(ima);
+  ImageUser iuser = image_user_from_context_and_active_tile(C, ima);
   PropertyRNA *prop = RNA_struct_find_property(op->ptr, "size");
   if (!RNA_property_is_set(op->ptr, prop)) {
 ImBuf *ibuf = BKE_image_acquire_ibuf(ima, &iuser, NULL);
@@ -2957,7 +2964,7 @@ static int image_scale_invoke(bContext *C, wmOperator 
*op, const wmEvent *UNUSED
 static int image_scale_exec(bContext *C, wmOperator *op)
 {
   Image *ima = image_from_context(C);
-  ImageUser iuser = image_user_from_active_tile(ima);
+  ImageUser iuser = image_user_from_context_and_active_tile(C, ima);
   ImBuf *ibuf = BKE_image_acquire_ibuf(ima, &iuser, NULL);
   SpaceImage *sima = CTX_wm_space_image(C);
   const bool is_paint = ((sima != NULL) && (sima->mode == SI_MODE_PAINT));
@@ -2982,7 +298

[Bf-blender-cvs] [52fa0c4251e] master: Cleanup: Remove unused variable

2022-07-07 Thread Hans Goudey
Commit: 52fa0c4251e7c92b2df665e9e3c150a54066389f
Author: Hans Goudey
Date:   Thu Jul 7 13:43:13 2022 -0500
Branches: master
https://developer.blender.org/rB52fa0c4251e7c92b2df665e9e3c150a54066389f

Cleanup: Remove unused variable

===

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

===

diff --git a/source/blender/makesrna/intern/rna_meta.c 
b/source/blender/makesrna/intern/rna_meta.c
index 898208e0ba1..75188f29fac 100644
--- a/source/blender/makesrna/intern/rna_meta.c
+++ b/source/blender/makesrna/intern/rna_meta.c
@@ -84,7 +84,6 @@ static void rna_MetaBall_redraw_data(Main *UNUSED(bmain), 
Scene *UNUSED(scene),
 static void rna_MetaBall_update_data(Main *bmain, Scene *UNUSED(scene), 
PointerRNA *ptr)
 {
   MetaBall *mb = (MetaBall *)ptr->owner_id;
-  Object *ob;
 
   /* NOTE: The check on the number of users allows to avoid many repetitive 
(slow) updates in some
* cases, like e.g. importers. Calling `BKE_mball_properties_copy` on an 
obdata with no users

___
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] [4e9e44ad28f] master: Cleanup: improve asserts in generic span

2022-07-07 Thread Jacques Lucke
Commit: 4e9e44ad28fc7a48e0d74a9f752847eb7be4e662
Author: Jacques Lucke
Date:   Thu Jul 7 19:27:30 2022 +0200
Branches: master
https://developer.blender.org/rB4e9e44ad28fc7a48e0d74a9f752847eb7be4e662

Cleanup: improve asserts in generic span

===

M   source/blender/blenlib/BLI_generic_span.hh

===

diff --git a/source/blender/blenlib/BLI_generic_span.hh 
b/source/blender/blenlib/BLI_generic_span.hh
index 0a40201634a..143ab235d2e 100644
--- a/source/blender/blenlib/BLI_generic_span.hh
+++ b/source/blender/blenlib/BLI_generic_span.hh
@@ -28,7 +28,8 @@ class GSpan {
   {
 BLI_assert(size >= 0);
 BLI_assert(buffer != nullptr || size == 0);
-BLI_assert(type->pointer_has_valid_alignment(buffer));
+BLI_assert(size == 0 || type != nullptr);
+BLI_assert(type == nullptr || type->pointer_has_valid_alignment(buffer));
   }
 
   GSpan(const CPPType &type, const void *buffer, int64_t size) : GSpan(&type, 
buffer, size)
@@ -119,7 +120,8 @@ class GMutableSpan {
   {
 BLI_assert(size >= 0);
 BLI_assert(buffer != nullptr || size == 0);
-BLI_assert(type->pointer_has_valid_alignment(buffer));
+BLI_assert(size == 0 || type != nullptr);
+BLI_assert(type == nullptr || type->pointer_has_valid_alignment(buffer));
   }
 
   GMutableSpan(const CPPType &type, void *buffer, int64_t size) : 
GMutableSpan(&type, buffer, size)

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


[Bf-blender-cvs] [ba62e20af67] master: BLI: make some spans default constructible

2022-07-07 Thread Jacques Lucke
Commit: ba62e20af67e1de25f781456df7175fa1b31db67
Author: Jacques Lucke
Date:   Thu Jul 7 19:19:01 2022 +0200
Branches: master
https://developer.blender.org/rBba62e20af67e1de25f781456df7175fa1b31db67

BLI: make some spans default constructible

`GSpan` and spans based on virtual arrays were not default constructible
before, which made them hard to use sometimes. It's generally fine for
spans to be empty.

The main thing the keep in mind is that the type pointer in `GSpan` may
be null now. Generally, code receiving spans as input can assume that
the type is not-null, but sometimes that may be valid. The old #type() method
that returned a reference to the type still exists. It asserts when the
type is null.

===

M   source/blender/blenlib/BLI_generic_span.hh
M   source/blender/blenlib/BLI_generic_virtual_array.hh
M   source/blender/blenlib/BLI_virtual_array.hh
M   source/blender/blenlib/intern/generic_virtual_array.cc
M   source/blender/blenlib/tests/BLI_virtual_array_test.cc

===

diff --git a/source/blender/blenlib/BLI_generic_span.hh 
b/source/blender/blenlib/BLI_generic_span.hh
index 4c0bfc83ba8..0a40201634a 100644
--- a/source/blender/blenlib/BLI_generic_span.hh
+++ b/source/blender/blenlib/BLI_generic_span.hh
@@ -16,20 +16,30 @@ namespace blender {
  */
 class GSpan {
  protected:
-  const CPPType *type_;
-  const void *data_;
-  int64_t size_;
+  const CPPType *type_ = nullptr;
+  const void *data_ = nullptr;
+  int64_t size_ = 0;
 
  public:
-  GSpan(const CPPType &type, const void *buffer, int64_t size)
-  : type_(&type), data_(buffer), size_(size)
+  GSpan() = default;
+
+  GSpan(const CPPType *type, const void *buffer, int64_t size)
+  : type_(type), data_(buffer), size_(size)
   {
 BLI_assert(size >= 0);
 BLI_assert(buffer != nullptr || size == 0);
-BLI_assert(type.pointer_has_valid_alignment(buffer));
+BLI_assert(type->pointer_has_valid_alignment(buffer));
+  }
+
+  GSpan(const CPPType &type, const void *buffer, int64_t size) : GSpan(&type, 
buffer, size)
+  {
+  }
+
+  GSpan(const CPPType &type) : type_(&type)
+  {
   }
 
-  GSpan(const CPPType &type) : GSpan(type, nullptr, 0)
+  GSpan(const CPPType *type) : type_(type)
   {
   }
 
@@ -41,9 +51,15 @@ class GSpan {
 
   const CPPType &type() const
   {
+BLI_assert(type_ != nullptr);
 return *type_;
   }
 
+  const CPPType *type_ptr() const
+  {
+return type_;
+  }
+
   bool is_empty() const
   {
 return size_ == 0;
@@ -76,7 +92,7 @@ class GSpan {
 BLI_assert(start >= 0);
 BLI_assert(size >= 0);
 const int64_t new_size = std::max(0, std::min(size, size_ - 
start));
-return GSpan(*type_, POINTER_OFFSET(data_, type_->size() * start), 
new_size);
+return GSpan(type_, POINTER_OFFSET(data_, type_->size() * start), 
new_size);
   }
 
   GSpan slice(const IndexRange range) const
@@ -91,20 +107,30 @@ class GSpan {
  */
 class GMutableSpan {
  protected:
-  const CPPType *type_;
-  void *data_;
-  int64_t size_;
+  const CPPType *type_ = nullptr;
+  void *data_ = nullptr;
+  int64_t size_ = 0;
 
  public:
-  GMutableSpan(const CPPType &type, void *buffer, int64_t size)
-  : type_(&type), data_(buffer), size_(size)
+  GMutableSpan() = default;
+
+  GMutableSpan(const CPPType *type, void *buffer, int64_t size)
+  : type_(type), data_(buffer), size_(size)
   {
 BLI_assert(size >= 0);
 BLI_assert(buffer != nullptr || size == 0);
-BLI_assert(type.pointer_has_valid_alignment(buffer));
+BLI_assert(type->pointer_has_valid_alignment(buffer));
+  }
+
+  GMutableSpan(const CPPType &type, void *buffer, int64_t size) : 
GMutableSpan(&type, buffer, size)
+  {
+  }
+
+  GMutableSpan(const CPPType &type) : type_(&type)
+  {
   }
 
-  GMutableSpan(const CPPType &type) : GMutableSpan(type, nullptr, 0)
+  GMutableSpan(const CPPType *type) : type_(type)
   {
   }
 
@@ -116,14 +142,20 @@ class GMutableSpan {
 
   operator GSpan() const
   {
-return GSpan(*type_, data_, size_);
+return GSpan(type_, data_, size_);
   }
 
   const CPPType &type() const
   {
+BLI_assert(type_ != nullptr);
 return *type_;
   }
 
+  const CPPType *type_ptr() const
+  {
+return type_;
+  }
+
   bool is_empty() const
   {
 return size_ == 0;
diff --git a/source/blender/blenlib/BLI_generic_virtual_array.hh 
b/source/blender/blenlib/BLI_generic_virtual_array.hh
index 3526925c2e2..43ca16a894f 100644
--- a/source/blender/blenlib/BLI_generic_virtual_array.hh
+++ b/source/blender/blenlib/BLI_generic_virtual_array.hh
@@ -267,6 +267,7 @@ class GVArraySpan : public GSpan {
   void *owned_data_ = nullptr;
 
  public:
+  GVArraySpan();
   GVArraySpan(GVArray varray);
   GVArraySpan(GVArraySpan &&other);
   ~GVArraySpan();
@@ -282,11 +283,14 @@ class GMutableVArraySpan : public GMutableSpan, 
NonCopyable, NonMovable {
   bool show_not_saved_warning_ = true;
 
 

[Bf-blender-cvs] [7cfea48752e] master: LibOverride: Make fully editable when creating an experimental user setting.

2022-07-07 Thread Bastien Montagne
Commit: 7cfea48752ebc544104d57d19736c201a98bc3cd
Author: Bastien Montagne
Date:   Thu Jul 7 18:17:30 2022 +0200
Branches: master
https://developer.blender.org/rB7cfea48752ebc544104d57d19736c201a98bc3cd

LibOverride: Make fully editable when creating an experimental user setting.

This is temporary to investigate which behavior should be kept when
creating an override hierarchy if there are no cherry-picked data
defined: make all overrides user-editable, or not.

This removes the 'make override - fully editable' menu entries.

===

M   release/scripts/startup/bl_ui/space_userpref.py
M   release/scripts/startup/bl_ui/space_view3d.py
M   source/blender/editors/interface/interface_templates.c
M   source/blender/editors/object/object_relations.c
M   source/blender/editors/space_outliner/outliner_tools.cc
M   source/blender/makesdna/DNA_userdef_types.h
M   source/blender/makesrna/intern/rna_userdef.c

===

diff --git a/release/scripts/startup/bl_ui/space_userpref.py 
b/release/scripts/startup/bl_ui/space_userpref.py
index 5070bd04142..e08b921b1a9 100644
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@ -2279,6 +2279,7 @@ class 
USERPREF_PT_experimental_prototypes(ExperimentalPanel, Panel):
 ({"property": "use_full_frame_compositor"}, "T88150"),
 ({"property": "enable_eevee_next"}, "T93220"),
 ({"property": "use_draw_manager_acquire_lock"}, "T98016"),
+({"property": "use_override_new_fully_editable"}, None),
 ),
 )
 
diff --git a/release/scripts/startup/bl_ui/space_view3d.py 
b/release/scripts/startup/bl_ui/space_view3d.py
index 91422a817f5..72119030919 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -2354,8 +2354,6 @@ class VIEW3D_MT_object_relations(Menu):
 layout = self.layout
 
 layout.operator("object.make_override_library", text="Make Library 
Override...")
-layout.operator("object.make_override_library",
-text="Make Library Override - Fully 
Editable...").do_fully_editable = True
 
 layout.operator("object.make_dupli_face")
 
diff --git a/source/blender/editors/interface/interface_templates.c 
b/source/blender/editors/interface/interface_templates.c
index 96d31700eb9..14da5a7cd62 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -741,8 +741,15 @@ static void 
template_id_liboverride_hierarchy_create(bContext *C,
 if (object_active != NULL) {
   object_active->id.tag |= LIB_TAG_DOIT;
 }
-BKE_lib_override_library_create(
-bmain, scene, view_layer, NULL, id, &collection_active->id, NULL, 
&id_override, false);
+BKE_lib_override_library_create(bmain,
+scene,
+view_layer,
+NULL,
+id,
+&collection_active->id,
+NULL,
+&id_override,
+
U.experimental.use_override_new_fully_editable);
   }
   else if (object_active != NULL && !ID_IS_LINKED(object_active) &&
&object_active->instance_collection->id == id) {
@@ -755,7 +762,7 @@ static void 
template_id_liboverride_hierarchy_create(bContext *C,
 &object_active->id,
 &object_active->id,
 &id_override,
-false);
+
U.experimental.use_override_new_fully_editable);
   }
   break;
 case ID_OB:
@@ -765,8 +772,15 @@ static void 
template_id_liboverride_hierarchy_create(bContext *C,
 if (object_active != NULL) {
   object_active->id.tag |= LIB_TAG_DOIT;
 }
-BKE_lib_override_library_create(
-bmain, scene, view_layer, NULL, id, &collection_active->id, NULL, 
&id_override, false);
+BKE_lib_override_library_create(bmain,
+scene,
+view_layer,
+NULL,
+id,
+&collection_active->id,
+NULL,
+&id_override,
+
U.experimental.use_override_new_fully_editable);
   }
   break;
 case ID_ME:
@@ -796,12 +810,19 @@ static void 
temp

[Bf-blender-cvs] [e0cc86978c0] master: Workspaces: Option to pin scene to a workspace

2022-07-07 Thread Julian Eisel
Commit: e0cc86978c0f72f57240214ccb6bc7fe71428827
Author: Julian Eisel
Date:   Thu Jul 7 17:51:18 2022 +0200
Branches: master
https://developer.blender.org/rBe0cc86978c0f72f57240214ccb6bc7fe71428827

Workspaces: Option to pin scene to a workspace

Adds a "Pin Scene" option to the workspace. When activated, the workspace will
remember the scene that was last activated in it, so that when switching back
to this workspace, the same scene will be reactivated. This is important for a
VSE workflow, so that users can switch between different workspaces displaying
a scene and thus a timeline for a specific task.

The option can be found in the Properties, Workspace tab. D11890 additionally
adds an icon for this to the scene switcher in the topbar.

The workspace data contains a pointer to the scene which is a UI to scene data
relation. When appending a workspace, the pointer is cleared.

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

Reviewed by: Brecht Van Lommel, Bastien Montagne (no final accept, but was fine
with the general design earlier)

===

M   release/scripts/startup/bl_ui/properties_workspace.py
M   source/blender/blenkernel/intern/workspace.c
M   source/blender/blenloader/intern/readfile.c
M   source/blender/editors/screen/workspace_edit.c
M   source/blender/makesdna/DNA_windowmanager_types.h
M   source/blender/makesdna/DNA_workspace_types.h
M   source/blender/makesrna/intern/rna_workspace.c
M   source/blender/windowmanager/intern/wm.c

===

diff --git a/release/scripts/startup/bl_ui/properties_workspace.py 
b/release/scripts/startup/bl_ui/properties_workspace.py
index 542d770c062..1a245b33cd2 100644
--- a/release/scripts/startup/bl_ui/properties_workspace.py
+++ b/release/scripts/startup/bl_ui/properties_workspace.py
@@ -28,6 +28,8 @@ class WORKSPACE_PT_main(WorkSpaceButtonsPanel, Panel):
 layout = self.layout
 layout.use_property_split = True
 layout.use_property_decorate = False
+
+layout.prop(workspace, "use_pin_scene")
 layout.prop(workspace, "object_mode", text="Mode")
 
 
diff --git a/source/blender/blenkernel/intern/workspace.c 
b/source/blender/blenkernel/intern/workspace.c
index ef0a3069815..0265dd037b1 100644
--- a/source/blender/blenkernel/intern/workspace.c
+++ b/source/blender/blenkernel/intern/workspace.c
@@ -67,6 +67,8 @@ static void workspace_foreach_id(ID *id, LibraryForeachIDData 
*data)
 {
   WorkSpace *workspace = (WorkSpace *)id;
 
+  BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, workspace->pin_scene, IDWALK_CB_NOP);
+
   LISTBASE_FOREACH (WorkSpaceLayout *, layout, &workspace->layouts) {
 BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, layout->screen, IDWALK_CB_USER);
   }
@@ -120,6 +122,15 @@ static void workspace_blend_read_lib(BlendLibReader 
*reader, ID *id)
   WorkSpace *workspace = (WorkSpace *)id;
   Main *bmain = BLO_read_lib_get_main(reader);
 
+  /* Do not keep the scene reference when appending a workspace. Setting a 
scene for a workspace is
+   * a convenience feature, but the workspace should never truly depend on 
scene data. */
+  if (ID_IS_LINKED(id)) {
+workspace->pin_scene = NULL;
+  }
+  else {
+BLO_read_id_address(reader, NULL, &workspace->pin_scene);
+  }
+
   /* Restore proper 'parent' pointers to relevant data, and clean up 
unused/invalid entries. */
   LISTBASE_FOREACH_MUTABLE (WorkSpaceDataRelation *, relation, 
&workspace->hook_layout_relations) {
 relation->parent = NULL;
diff --git a/source/blender/blenloader/intern/readfile.c 
b/source/blender/blenloader/intern/readfile.c
index 973965ada50..f0d390677bb 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -2732,6 +2732,8 @@ void blo_lib_link_restore(Main *oldmain,
 LISTBASE_FOREACH (WorkSpaceLayout *, layout, &workspace->layouts) {
   lib_link_workspace_layout_restore(id_map, newmain, layout);
 }
+workspace->pin_scene = restore_pointer_by_name(
+id_map, (ID *)workspace->pin_scene, USER_IGNORE);
   }
 
   LISTBASE_FOREACH (wmWindow *, win, &curwm->windows) {
@@ -2745,6 +2747,7 @@ void blo_lib_link_restore(Main *oldmain,
 if (win->scene == NULL) {
   win->scene = curscene;
 }
+win->unpinned_scene = restore_pointer_by_name(id_map, (ID 
*)win->unpinned_scene, USER_IGNORE);
 if (BKE_view_layer_find(win->scene, win->view_layer_name) == NULL) {
   STRNCPY(win->view_layer_name, cur_view_layer->name);
 }
diff --git a/source/blender/editors/screen/workspace_edit.c 
b/source/blender/editors/screen/workspace_edit.c
index 01417650b3d..0535a270176 100644
--- a/source/blender/editors/screen/workspace_edit.c
+++ b/source/blender/editors/screen/workspace_edit.c
@@ -54,17 +54,87 @@ WorkSpace *ED_workspace_add(Main *bmain, const char *name)
   return BKE_workspace_add(bmain, name);
 }
 
+static void w

[Bf-blender-cvs] [b8605ee458e] master: UI: Superimposed pin icon for workspace scene pinning in the scene switcher

2022-07-07 Thread Julian Eisel
Commit: b8605ee458e31420a4e6653c223f841c5875a21d
Author: Julian Eisel
Date:   Thu Jul 7 18:14:05 2022 +0200
Branches: master
https://developer.blender.org/rBb8605ee458e31420a4e6653c223f841c5875a21d

UI: Superimposed pin icon for workspace scene pinning in the scene switcher

Followup to the previous commit, to display a pin icon in the scene switcher.
This is a good indicator to have and such workspace-wide functionality should
be available in the topbar, close to what it belongs to (scene switching).
Downside is that it makes this already crowded region even more crowded. But
thanks to the use of superimposed icons, it's not too noisy visually.

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

Reviewed by: Campbell Barton

===

M   source/blender/editors/interface/interface_templates.c
M   source/blender/editors/screen/workspace_edit.c
M   source/blender/editors/space_buttons/space_buttons.c
M   source/blender/editors/space_topbar/space_topbar.c
M   source/blender/editors/space_view3d/space_view3d.c
M   source/blender/makesrna/intern/rna_workspace.c
M   source/blender/windowmanager/WM_types.h

===

diff --git a/source/blender/editors/interface/interface_templates.c 
b/source/blender/editors/interface/interface_templates.c
index 05ae5299e58..96d31700eb9 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -1023,6 +1023,26 @@ static const char *template_id_browse_tip(const 
StructRNA *type)
   return N_("Browse ID data to be linked");
 }
 
+/**
+ * Add a superimposed extra icon to \a but, for workspace pinning.
+ * Rather ugly special handling, but this is really a special case at this 
point, nothing worth
+ * generalizing.
+ */
+static void template_id_workspace_pin_extra_icon(const TemplateID 
*template_ui, uiBut *but)
+{
+  if ((template_ui->idcode != ID_SCE) || (template_ui->ptr.type != 
&RNA_Window)) {
+return;
+  }
+
+  const wmWindow *win = template_ui->ptr.data;
+  const WorkSpace *workspace = WM_window_get_active_workspace(win);
+  UI_but_extra_operator_icon_add(but,
+ "WORKSPACE_OT_scene_pin_toggle",
+ WM_OP_INVOKE_DEFAULT,
+ (workspace->flags & WORKSPACE_USE_PIN_SCENE) 
? ICON_PINNED :
+   
 ICON_UNPINNED);
+}
+
 /**
  * \return a type-based i18n context, needed e.g. by "New" button.
  * In most languages, this adjective takes different form based on gender of 
type name...
@@ -1220,6 +1240,8 @@ static void template_ID(const bContext *C,
   UI_but_flag_enable(but, UI_BUT_REDALERT);
 }
 
+template_id_workspace_pin_extra_icon(template_ui, but);
+
 if (ID_IS_LINKED(id)) {
   const bool disabled = !BKE_idtype_idcode_is_localizable(GS(id->name));
   if (id->tag & LIB_TAG_INDIRECT) {
diff --git a/source/blender/editors/screen/workspace_edit.c 
b/source/blender/editors/screen/workspace_edit.c
index 0535a270176..cb29f15420c 100644
--- a/source/blender/editors/screen/workspace_edit.c
+++ b/source/blender/editors/screen/workspace_edit.c
@@ -585,6 +585,35 @@ static void WORKSPACE_OT_reorder_to_front(wmOperatorType 
*ot)
   ot->exec = workspace_reorder_to_front_exec;
 }
 
+static int workspace_scene_pin_toggle(bContext *C, wmOperator *UNUSED(op))
+{
+  WorkSpace *workspace = workspace_context_get(C);
+
+  /* Trivial. The operator is only needed to display a superimposed extra 
icon, which
+   * requires an operator. */
+  workspace->flags ^= WORKSPACE_USE_PIN_SCENE;
+
+  WM_event_add_notifier(C, NC_WORKSPACE, NULL);
+
+  return OPERATOR_FINISHED;
+}
+
+static void WORKSPACE_OT_scene_pin_toggle(wmOperatorType *ot)
+{
+  /* identifiers */
+  ot->name = "Pin Scene to Workspace";
+  ot->description =
+  "Remember the last used scene for the current workspace and switch to it 
whenever this "
+  "workspace is activated again";
+  ot->idname = "WORKSPACE_OT_scene_pin_toggle";
+
+  /* api callbacks */
+  ot->poll = workspace_context_poll;
+  ot->exec = workspace_scene_pin_toggle;
+
+  ot->flag = OPTYPE_INTERNAL;
+}
+
 void ED_operatortypes_workspace(void)
 {
   WM_operatortype_append(WORKSPACE_OT_duplicate);
@@ -593,6 +622,7 @@ void ED_operatortypes_workspace(void)
   WM_operatortype_append(WORKSPACE_OT_append_activate);
   WM_operatortype_append(WORKSPACE_OT_reorder_to_back);
   WM_operatortype_append(WORKSPACE_OT_reorder_to_front);
+  WM_operatortype_append(WORKSPACE_OT_scene_pin_toggle);
 }
 
 /** \} Workspace Operators */
diff --git a/source/blender/editors/space_buttons/space_buttons.c 
b/source/blender/editors/space_buttons/space_buttons.c
index 052af39319c..e60946b8f66 100644
--- a/source/blender/editors/space_buttons/space_buttons.c
+++ b/source/blender/editor

[Bf-blender-cvs] [f9a805164a9] master: Outliner, Library Overrides: List child objects under parents

2022-07-07 Thread Julian Eisel
Commit: f9a805164a944c3b5762f07e535536b9f425651f
Author: Julian Eisel
Date:   Thu Jul 7 17:17:33 2022 +0200
Branches: master
https://developer.blender.org/rBf9a805164a944c3b5762f07e535536b9f425651f

Outliner, Library Overrides: List child objects under parents

Because children point to, or "use" their parent, the Library Overrides
Hierarchies mode in the Outliner would show parents contained in children, not
children contained in a parent. See D15339 for pictures.

In production files this would make the rig listed under all its children, so
it would appear many times in the tree. Now it appears once and the children
are collected under it.

Refactors the tree building, so instead of using
`BKE_library_foreach_ID_link()`, it now uses the ID relations mapping in
`MainIDRelations`.

Reviewed By: mont29

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

===

M   source/blender/editors/space_outliner/tree/tree_display.hh
M   
source/blender/editors/space_outliner/tree/tree_display_override_library_hierarchies.cc

===

diff --git a/source/blender/editors/space_outliner/tree/tree_display.hh 
b/source/blender/editors/space_outliner/tree/tree_display.hh
index 190e35c81d6..f8e35655c26 100644
--- a/source/blender/editors/space_outliner/tree/tree_display.hh
+++ b/source/blender/editors/space_outliner/tree/tree_display.hh
@@ -161,7 +161,6 @@ class TreeDisplayOverrideLibraryHierarchies final : public 
AbstractTreeDisplay {
   ListBase build_hierarchy_for_lib_or_main(Main *bmain,
TreeElement &parent_te,
Library *lib = nullptr);
-  void build_hierarchy_for_ID(Main *bmain, ID &override_root_id, TreeElementID 
&te_id) const;
 };
 
 /*  */
diff --git 
a/source/blender/editors/space_outliner/tree/tree_display_override_library_hierarchies.cc
 
b/source/blender/editors/space_outliner/tree/tree_display_override_library_hierarchies.cc
index 67798e978ab..f8705c3f0ad 100644
--- 
a/source/blender/editors/space_outliner/tree/tree_display_override_library_hierarchies.cc
+++ 
b/source/blender/editors/space_outliner/tree/tree_display_override_library_hierarchies.cc
@@ -4,25 +4,23 @@
  * \ingroup spoutliner
  */
 
-#include "DNA_ID.h"
-#include "DNA_collection_types.h"
 #include "DNA_key_types.h"
 #include "DNA_space_types.h"
 
-#include "BLI_listbase.h"
+#include "BLI_function_ref.hh"
+#include "BLI_ghash.h"
 #include "BLI_map.hh"
+
 #include "BLI_set.hh"
 
 #include "BLT_translation.h"
 
-#include "BKE_collection.h"
 #include "BKE_lib_query.h"
 #include "BKE_main.h"
 
 #include "../outliner_intern.hh"
 #include "common.hh"
 #include "tree_display.hh"
-#include "tree_element_id.hh"
 
 namespace blender::ed::outliner {
 
@@ -42,8 +40,8 @@ ListBase 
TreeDisplayOverrideLibraryHierarchies::buildTree(const TreeSourceData &
   TreeElement *current_file_te = outliner_add_element(
   &space_outliner_, &tree, source_data.bmain, nullptr, TSE_ID_BASE, -1);
   current_file_te->name = IFACE_("Current File");
+  AbstractTreeElement::uncollapse_by_default(current_file_te);
   {
-AbstractTreeElement::uncollapse_by_default(current_file_te);
 build_hierarchy_for_lib_or_main(source_data.bmain, *current_file_te);
 
 /* Add dummy child if there's nothing to display. */
@@ -76,11 +74,49 @@ ListBase 
TreeDisplayOverrideLibraryHierarchies::buildTree(const TreeSourceData &
   return tree;
 }
 
+/*  */
+/** \name Library override hierarchy building
+ * \{ */
+
+class OverrideIDHierarchyBuilder {
+  SpaceOutliner &space_outliner_;
+  MainIDRelations &id_relations_;
+
+  struct HierarchyBuildData {
+const ID &override_root_id_;
+/* The ancestor IDs leading to the current ID, to avoid IDs recursing into 
themselves. Changes
+ * with every level of recursion. */
+Set parent_ids{};
+/* The IDs that were already added to #parent_te, to avoid duplicates. 
Entirely new set with
+ * every level of recursion. */
+Set sibling_ids{};
+  };
+
+ public:
+  OverrideIDHierarchyBuilder(SpaceOutliner &space_outliner, MainIDRelations 
&id_relations)
+  : space_outliner_(space_outliner), id_relations_(id_relations)
+  {
+  }
+
+  void build_hierarchy_for_ID(ID &root_id, TreeElement &te_to_expand);
+
+ private:
+  void build_hierarchy_for_ID_recursive(const ID &parent_id,
+HierarchyBuildData &build_data,
+TreeElement &te_to_expand);
+};
+
 ListBase 
TreeDisplayOverrideLibraryHierarchies::build_hierarchy_for_lib_or_main(
 Main *bmain, TreeElement &parent_te, Library *lib)
 {
   ListBase tree = {nullptr};
 
+  /* Ensure #Main.relations contains the latest mapping of relations. Must be 
fre

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

2022-07-07 Thread Antonio Vazquez
Commit: 34f847648caced0125aa7899b5f305c686c6d78f
Author: Antonio Vazquez
Date:   Thu Jul 7 16:37:04 2022 +0200
Branches: asset-lite-greasepencil
https://developer.blender.org/rB34f847648caced0125aa7899b5f305c686c6d78f

Merge branch 'master' into asset-lite-greasepencil

===



===



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


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

2022-07-07 Thread Antonio Vazquez
Commit: 11dd93493b4cb1b9619f12ba5262301d2393afa0
Author: Antonio Vazquez
Date:   Thu Jul 7 16:36:12 2022 +0200
Branches: gpencil-new-data-proposal
https://developer.blender.org/rB11dd93493b4cb1b9619f12ba5262301d2393afa0

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

===



===



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


[Bf-blender-cvs] [fcf1a9ff71e] master: Fix T99256: Regression: Meta balls segfaulting copy-to-selected.

2022-07-07 Thread Bastien Montagne
Commit: fcf1a9ff71e20e4af56815c4db1816d786298c3f
Author: Bastien Montagne
Date:   Thu Jul 7 16:20:27 2022 +0200
Branches: master
https://developer.blender.org/rBfcf1a9ff71e20e4af56815c4db1816d786298c3f

Fix T99256: Regression: Meta balls segfaulting copy-to-selected.

Revealed by rB43167a2c251b, but actuall issue is the
`rna_MetaBall_update_data` function expecting a never-NULL `scene`
pointer, which is not guaranteed.

This lead to refactoring the duo
`rna_MetaBall_update_data`/`BKE_mball_properties_copy`, since it was
doing a very sub-optimal O(n^2) process, new code is O(2n) now
(n being the number of Objects).

Not sure why the objects were processed through the existing bases of
the existing scene in the first place, this could miss a lot of affected
objects (e.g. in case said objects are in an excluded collection, etc.).

Also noticed that both old and new implementation can fail to fully propagate
changes to all affected meta-balls in some specific corner cases, added
a comment about it in the code.

Reviewed By: sergey

Maniphest Tasks: T99256

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

===

M   source/blender/blenkernel/BKE_mball.h
M   source/blender/blenkernel/intern/mball.c
M   source/blender/makesrna/intern/rna_access.c
M   source/blender/makesrna/intern/rna_meta.c

===

diff --git a/source/blender/blenkernel/BKE_mball.h 
b/source/blender/blenkernel/BKE_mball.h
index f40d0bb3004..5a4988c7a5f 100644
--- a/source/blender/blenkernel/BKE_mball.h
+++ b/source/blender/blenkernel/BKE_mball.h
@@ -24,14 +24,25 @@ struct MetaBall *BKE_mball_add(struct Main *bmain, const 
char *name);
 bool BKE_mball_is_any_selected(const struct MetaBall *mb);
 bool BKE_mball_is_any_selected_multi(struct Base **bases, int bases_len);
 bool BKE_mball_is_any_unselected(const struct MetaBall *mb);
-bool BKE_mball_is_basis_for(struct Object *ob1, struct Object *ob2);
+
+/**
+ * Return `true` if `ob1` and `ob2` are part of the same metaBall group.
+ *
+ * \note Currently checks whether their two base names (without numerical 
suffix) is the same.
+ */
+bool BKE_mball_is_same_group(const struct Object *ob1, const struct Object 
*ob2);
+/**
+ * Return `true` if `ob1` and `ob2` are part of the same metaBall group, and 
`ob1` is its
+ * basis.
+ */
+bool BKE_mball_is_basis_for(const struct Object *ob1, const struct Object 
*ob2);
 /**
  * Test, if \a ob is a basis meta-ball.
  *
  * It test last character of Object ID name.
  * If last character is digit it return 0, else it return 1.
  */
-bool BKE_mball_is_basis(struct Object *ob);
+bool BKE_mball_is_basis(const struct Object *ob);
 /**
  * This function finds the basis meta-ball.
  *
@@ -58,13 +69,14 @@ struct BoundBox *BKE_mball_boundbox_get(struct Object *ob);
 float *BKE_mball_make_orco(struct Object *ob, struct ListBase *dispbase);
 
 /**
- * Copy some properties from object to other meta-ball object with same base 
name.
+ * Copy some properties from a meta-ball obdata to all other meta-ball obdata 
belonging to the same
+ * family (i.e. object sharing the same name basis).
  *
  * When some properties (wire-size, threshold, update flags) of meta-ball are 
changed, then this
  * properties are copied to all meta-balls in same "group" (meta-balls with 
same base name:
  * `MBall`, `MBall.001`, `MBall.002`, etc). The most important is to copy 
properties to the base
- * meta-ball, because this meta-ball influence polygonization of meta-balls. */
-void BKE_mball_properties_copy(struct Scene *scene, struct Object 
*active_object);
+ * meta-ball, because this meta-ball influences polygonization of meta-balls. 
*/
+void BKE_mball_properties_copy(struct Main *bmain, struct MetaBall 
*active_metaball);
 
 bool BKE_mball_minmax_ex(
 const struct MetaBall *mb, float min[3], float max[3], const float 
obmat[4][4], short flag);
diff --git a/source/blender/blenkernel/intern/mball.c 
b/source/blender/blenkernel/intern/mball.c
index 1340e53f06e..819bbde6556 100644
--- a/source/blender/blenkernel/intern/mball.c
+++ b/source/blender/blenkernel/intern/mball.c
@@ -347,7 +347,7 @@ float *BKE_mball_make_orco(Object *ob, ListBase *dispbase)
   return orcodata;
 }
 
-bool BKE_mball_is_basis(Object *ob)
+bool BKE_mball_is_basis(const Object *ob)
 {
   /* Meta-Ball Basis Notes from Blender-2.5x
* ===
@@ -370,7 +370,7 @@ bool BKE_mball_is_basis(Object *ob)
   return (!isdigit(ob->id.name[len - 1]));
 }
 
-bool BKE_mball_is_basis_for(Object *ob1, Object *ob2)
+bool BKE_mball_is_same_group(const Object *ob1, const Object *ob2)
 {
   int basis1nr, basis2nr;
   char basis1name[MAX_ID_NAME], basis2name[MAX_ID_NAME];
@@ -383,11 +383,12 @@ bool BKE_mball_is_basis_for(Object *ob1, Object *ob2)
   BLI_split_name_num(basis1name, &basis1nr, ob1->id.name + 2, '.');
   BLI_split_name_num(basis2name, &basis2nr

[Bf-blender-cvs] [c76e1ecac6d] master: Compositor: Pre-fill motion tracking fields

2022-07-07 Thread Sergey Sharybin
Commit: c76e1ecac6d6611269f15b5fd229ca726bde0337
Author: Sergey Sharybin
Date:   Thu Jul 7 16:13:26 2022 +0200
Branches: master
https://developer.blender.org/rBc76e1ecac6d6611269f15b5fd229ca726bde0337

Compositor: Pre-fill motion tracking fields

Extends current functionality which was only filling in
the active movie clip. Now we also pre-fill tracking object
name, as well as (plane)track name.

===

M   source/blender/nodes/composite/nodes/node_composite_keyingscreen.cc
M   source/blender/nodes/composite/nodes/node_composite_planetrackdeform.cc
M   source/blender/nodes/composite/nodes/node_composite_trackpos.cc

===

diff --git 
a/source/blender/nodes/composite/nodes/node_composite_keyingscreen.cc 
b/source/blender/nodes/composite/nodes/node_composite_keyingscreen.cc
index e4e37f630a2..e835ee9e721 100644
--- a/source/blender/nodes/composite/nodes/node_composite_keyingscreen.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_keyingscreen.cc
@@ -6,12 +6,14 @@
  */
 
 #include "DNA_movieclip_types.h"
+#include "DNA_tracking_types.h"
 
 #include "BLI_math_base.h"
 #include "BLI_math_color.h"
 
 #include "BKE_context.h"
 #include "BKE_lib_id.h"
+#include "BKE_tracking.h"
 
 #include "RNA_access.h"
 #include "RNA_prototypes.h"
@@ -38,8 +40,15 @@ static void node_composit_init_keyingscreen(const bContext 
*C, PointerRNA *ptr)
   node->storage = data;
 
   const Scene *scene = CTX_data_scene(C);
-  node->id = (ID *)scene->clip;
-  id_us_plus(node->id);
+  if (scene->clip) {
+MovieClip *clip = scene->clip;
+
+node->id = &clip->id;
+id_us_plus(&clip->id);
+
+const MovieTrackingObject *tracking_object = 
BKE_tracking_object_get_active(&clip->tracking);
+BLI_strncpy(data->tracking_object, tracking_object->name, 
sizeof(data->tracking_object));
+  }
 }
 
 static void node_composit_buts_keyingscreen(uiLayout *layout, bContext *C, 
PointerRNA *ptr)
diff --git 
a/source/blender/nodes/composite/nodes/node_composite_planetrackdeform.cc 
b/source/blender/nodes/composite/nodes/node_composite_planetrackdeform.cc
index 8055e350d51..472bf2344ca 100644
--- a/source/blender/nodes/composite/nodes/node_composite_planetrackdeform.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_planetrackdeform.cc
@@ -5,6 +5,11 @@
  * \ingroup cmpnodes
  */
 
+#include "DNA_movieclip_types.h"
+#include "DNA_tracking_types.h"
+
+#include "BKE_tracking.h"
+
 #include "RNA_access.h"
 #include "RNA_prototypes.h"
 
@@ -32,8 +37,23 @@ static void init(const bContext *C, PointerRNA *ptr)
   node->storage = data;
 
   const Scene *scene = CTX_data_scene(C);
-  node->id = (ID *)scene->clip;
-  id_us_plus(node->id);
+  if (scene->clip) {
+MovieClip *clip = scene->clip;
+MovieTracking *tracking = &clip->tracking;
+
+node->id = &clip->id;
+id_us_plus(&clip->id);
+
+const MovieTrackingObject *tracking_object = 
BKE_tracking_object_get_active(tracking);
+BLI_strncpy(data->tracking_object, tracking_object->name, 
sizeof(data->tracking_object));
+
+const MovieTrackingPlaneTrack *active_plane_track = 
BKE_tracking_plane_track_get_active(
+tracking);
+if (active_plane_track) {
+  BLI_strncpy(
+  data->plane_track_name, active_plane_track->name, 
sizeof(data->plane_track_name));
+}
+  }
 }
 
 static void node_composit_buts_planetrackdeform(uiLayout *layout, bContext *C, 
PointerRNA *ptr)
diff --git a/source/blender/nodes/composite/nodes/node_composite_trackpos.cc 
b/source/blender/nodes/composite/nodes/node_composite_trackpos.cc
index 723b82998ee..0e99ff59327 100644
--- a/source/blender/nodes/composite/nodes/node_composite_trackpos.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_trackpos.cc
@@ -5,6 +5,9 @@
  * \ingroup cmpnodes
  */
 
+#include "DNA_movieclip_types.h"
+#include "DNA_tracking_types.h"
+
 #include "BKE_context.h"
 #include "BKE_lib_id.h"
 #include "BKE_tracking.h"
@@ -34,8 +37,21 @@ static void init(const bContext *C, PointerRNA *ptr)
   node->storage = data;
 
   const Scene *scene = CTX_data_scene(C);
-  node->id = (ID *)scene->clip;
-  id_us_plus(node->id);
+  if (scene->clip) {
+MovieClip *clip = scene->clip;
+MovieTracking *tracking = &clip->tracking;
+
+node->id = &clip->id;
+id_us_plus(&clip->id);
+
+const MovieTrackingObject *tracking_object = 
BKE_tracking_object_get_active(tracking);
+BLI_strncpy(data->tracking_object, tracking_object->name, 
sizeof(data->tracking_object));
+
+const MovieTrackingTrack *active_track = 
BKE_tracking_track_get_active(tracking);
+if (active_track) {
+  BLI_strncpy(data->track_name, active_track->name, 
sizeof(data->track_name));
+}
+  }
 }
 
 static void node_composit_buts_trackpos(uiLayout *layout, bContext *C, 
PointerRNA *ptr)

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender

[Bf-blender-cvs] [59e1009f109] master: Cleanup: Use std::move for geometry set

2022-07-07 Thread Hans Goudey
Commit: 59e1009f1094b09d7ce961e574ba4acc33f9df97
Author: Hans Goudey
Date:   Thu Jul 7 09:01:46 2022 -0500
Branches: master
https://developer.blender.org/rB59e1009f1094b09d7ce961e574ba4acc33f9df97

Cleanup: Use std::move for geometry set

The only real improvement is avoiding some reference counting,
but the main for the change is consistency. Also don't move a
StringRef, since that doesn't own any data anyway.

===

M   
source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc

===

diff --git 
a/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc 
b/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc
index 1b01dd64c74..6be3a65cc1b 100644
--- 
a/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc
+++ 
b/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc
@@ -513,7 +513,7 @@ static void add_fields_as_extra_columns(SpaceSpreadsheet 
*sspreadsheet,
   const eAttrDomain domain = (eAttrDomain)sspreadsheet->attribute_domain;
   const int domain_num = component.attribute_domain_num(domain);
   for (const auto item : fields_to_show.items()) {
-StringRef name = item.key;
+const StringRef name = item.key;
 const GField &field = item.value;
 
 /* Use the cached evaluated array if it exists, otherwise evaluate the 
field now. */
@@ -527,7 +527,7 @@ static void add_fields_as_extra_columns(SpaceSpreadsheet 
*sspreadsheet,
   return evaluated_array;
 });
 
-r_extra_columns.add(std::move(name), evaluated_array.as_span());
+r_extra_columns.add(name, evaluated_array.as_span());
   }
 }
 
@@ -538,7 +538,6 @@ std::unique_ptr data_source_from_geometry(const 
bContext *C, Object
   const GeometryComponentType component_type = GeometryComponentType(
   sspreadsheet->geometry_component_type);
   GeometrySet geometry_set = 
spreadsheet_get_display_geometry_set(sspreadsheet, object_eval);
-
   if (!geometry_set.has(component_type)) {
 return {};
   }
@@ -548,10 +547,10 @@ std::unique_ptr 
data_source_from_geometry(const bContext *C, Object
   add_fields_as_extra_columns(sspreadsheet, component, extra_columns);
 
   if (component_type == GEO_COMPONENT_TYPE_VOLUME) {
-return std::make_unique(geometry_set);
+return std::make_unique(std::move(geometry_set));
   }
   return std::make_unique(
-  object_eval, geometry_set, component_type, domain, 
std::move(extra_columns));
+  object_eval, std::move(geometry_set), component_type, domain, 
std::move(extra_columns));
 }
 
 }  // namespace blender::ed::spreadsheet

___
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] [85ef8e19455] master: Cleanup: Use C++ style of avoiding unused variable warnings

2022-07-07 Thread Hans Goudey
Commit: 85ef8e194555240d518a7a7e7f06fcc4c47fa8c7
Author: Hans Goudey
Date:   Thu Jul 7 08:55:36 2022 -0500
Branches: master
https://developer.blender.org/rB85ef8e194555240d518a7a7e7f06fcc4c47fa8c7

Cleanup: Use C++ style of avoiding unused variable warnings

As documented in the best practices section of the style guide:
https://wiki.blender.org/wiki/Style_Guide/Best_Practice_C_Cpp

===

M   source/blender/editors/space_spreadsheet/spreadsheet_data_source.hh

===

diff --git 
a/source/blender/editors/space_spreadsheet/spreadsheet_data_source.hh 
b/source/blender/editors/space_spreadsheet/spreadsheet_data_source.hh
index 76c7131e268..6a09d3f84c6 100644
--- a/source/blender/editors/space_spreadsheet/spreadsheet_data_source.hh
+++ b/source/blender/editors/space_spreadsheet/spreadsheet_data_source.hh
@@ -27,9 +27,8 @@ class DataSource {
* column. (This can be made a bit more generic in the future when 
necessary.)
*/
   virtual void foreach_default_column_ids(
-  FunctionRef fn) const
+  FunctionRef /*fn*/) 
const
   {
-UNUSED_VARS(fn);
   }
 
   /**
@@ -37,9 +36,8 @@ class DataSource {
* returned.
*/
   virtual std::unique_ptr get_column_values(
-  const SpreadsheetColumnID &column_id) const
+  const SpreadsheetColumnID & /*column_id*/) const
   {
-UNUSED_VARS(column_id);
 return {};
   }

___
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] [a91f9c2c014] master: Cleanup: Use generic index mask utility

2022-07-07 Thread Hans Goudey
Commit: a91f9c2c01401285208f2962f3be339a5012ec2a
Author: Hans Goudey
Date:   Thu Jul 7 08:49:23 2022 -0500
Branches: master
https://developer.blender.org/rBa91f9c2c01401285208f2962f3be339a5012ec2a

Cleanup: Use generic index mask utility

This may lead to improved performance from multithreading as well.

===

M   
source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc

===

diff --git 
a/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc 
b/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc
index 6955f23e1c2..1b01dd64c74 100644
--- 
a/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc
+++ 
b/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc
@@ -1,5 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0-or-later */
 
+#include "BLI_index_mask_ops.hh"
 #include "BLI_virtual_array.hh"
 
 #include "BKE_context.h"
@@ -235,20 +236,10 @@ bool GeometryDataSource::has_selection_filter() const
   return true;
 }
 
-static IndexMask index_mask_from_bool_array(const VArray &selection,
-Vector &indices)
-{
-  for (const int i : selection.index_range()) {
-if (selection[i]) {
-  indices.append(i);
-}
-  }
-  return IndexMask(indices);
-}
-
 IndexMask GeometryDataSource::apply_selection_filter(Vector &indices) 
const
 {
   std::lock_guard lock{mutex_};
+  const IndexMask full_range(this->tot_rows());
 
   BLI_assert(object_eval_->mode == OB_MODE_EDIT);
   BLI_assert(component_->type() == GEO_COMPONENT_TYPE_MESH);
@@ -277,7 +268,7 @@ IndexMask 
GeometryDataSource::apply_selection_filter(Vector &indices) c
   }),
 ATTR_DOMAIN_POINT,
 domain_);
-return index_mask_from_bool_array(selection, indices);
+return index_mask_ops::find_indices_from_virtual_array(full_range, 
selection, 1024, indices);
   }
 
   if (mesh_eval->totvert == bm->totvert) {
@@ -290,10 +281,10 @@ IndexMask 
GeometryDataSource::apply_selection_filter(Vector &indices) c
   }),
 ATTR_DOMAIN_POINT,
 domain_);
-return index_mask_from_bool_array(selection, indices);
+return index_mask_ops::find_indices_from_virtual_array(full_range, 
selection, 2048, indices);
   }
 
-  return IndexMask(mesh_eval->totvert);
+  return full_range;
 }
 
 void VolumeDataSource::foreach_default_column_ids(

___
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] [f0ac55f5196] master: Fix: Spreadsheet does not display original curves data

2022-07-07 Thread Hans Goudey
Commit: f0ac55f51965c2abb811b2759241225762a06c94
Author: Hans Goudey
Date:   Thu Jul 7 08:35:22 2022 -0500
Branches: master
https://developer.blender.org/rBf0ac55f51965c2abb811b2759241225762a06c94

Fix: Spreadsheet does not display original curves data

The spreadsheet ignored the component choice in the data set region
for curves and volume objects, and the original curves data-block wasn't
retrieved from the original object.

===

M   
source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc

===

diff --git 
a/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc 
b/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc
index f5315b616d0..6955f23e1c2 100644
--- 
a/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc
+++ 
b/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc
@@ -398,6 +398,11 @@ GeometrySet spreadsheet_get_display_geometry_set(const 
SpaceSpreadsheet *sspread
   geometry_set.get_component_for_write();
   pointcloud_component.replace(pointcloud, 
GeometryOwnershipType::ReadOnly);
 }
+else if (object_orig->type == OB_CURVES) {
+  const Curves &curves_id = *(const Curves *)object_orig->data;
+  CurveComponent &curve_component = 
geometry_set.get_component_for_write();
+  curve_component.replace(&const_cast(curves_id), 
GeometryOwnershipType::ReadOnly);
+}
   }
   else {
 if (object_eval->mode == OB_MODE_EDIT && object_eval->type == OB_MESH) {
@@ -472,18 +477,6 @@ static void find_fields_to_evaluate(const SpaceSpreadsheet 
*sspreadsheet,
   }
 }
 
-static GeometryComponentType get_display_component_type(const bContext *C, 
Object *object_eval)
-{
-  SpaceSpreadsheet *sspreadsheet = CTX_wm_space_spreadsheet(C);
-  if (sspreadsheet->object_eval_state != 
SPREADSHEET_OBJECT_EVAL_STATE_ORIGINAL) {
-return (GeometryComponentType)sspreadsheet->geometry_component_type;
-  }
-  if (object_eval->type == OB_POINTCLOUD) {
-return GEO_COMPONENT_TYPE_POINT_CLOUD;
-  }
-  return GEO_COMPONENT_TYPE_MESH;
-}
-
 class GeometryComponentCacheKey : public SpreadsheetCache::Key {
  public:
   /* Use the pointer to the geometry component as a key to detect when the 
geometry changed. */
@@ -551,7 +544,8 @@ std::unique_ptr data_source_from_geometry(const 
bContext *C, Object
 {
   SpaceSpreadsheet *sspreadsheet = CTX_wm_space_spreadsheet(C);
   const eAttrDomain domain = (eAttrDomain)sspreadsheet->attribute_domain;
-  const GeometryComponentType component_type = get_display_component_type(C, 
object_eval);
+  const GeometryComponentType component_type = GeometryComponentType(
+  sspreadsheet->geometry_component_type);
   GeometrySet geometry_set = 
spreadsheet_get_display_geometry_set(sspreadsheet, object_eval);
 
   if (!geometry_set.has(component_type)) {

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


[Bf-blender-cvs] [3063d90cfc0] master: Fix T99453: Regression: Crash on calling menu search

2022-07-07 Thread Pratik Borhade
Commit: 3063d90cfc057b4e1f269fd0723abbc0f2ae12f0
Author: Pratik Borhade
Date:   Thu Jul 7 15:23:41 2022 +0200
Branches: master
https://developer.blender.org/rB3063d90cfc057b4e1f269fd0723abbc0f2ae12f0

Fix T99453: Regression: Crash on calling menu search

Fix T99453.
Crash due to null pointer access.
So wrap the function call in simple `if` check

Reviewed By: sybren

Maniphest Tasks: T99453

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

===

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

===

diff --git a/source/blender/editors/object/object_vgroup.c 
b/source/blender/editors/object/object_vgroup.c
index 158bc28662a..17b7fe7fe5e 100644
--- a/source/blender/editors/object/object_vgroup.c
+++ b/source/blender/editors/object/object_vgroup.c
@@ -732,8 +732,10 @@ const EnumPropertyItem 
*ED_object_vgroup_selection_itemf_helper(const bContext *
   }
 
   /* Set `Deform Bone` as default selection if armature is present. */
-  RNA_def_property_enum_default(
-  prop, BKE_modifiers_is_deformed_by_armature(ob) ? WT_VGROUP_BONE_DEFORM 
: WT_VGROUP_ALL);
+  if (ob) {
+RNA_def_property_enum_default(
+prop, BKE_modifiers_is_deformed_by_armature(ob) ? 
WT_VGROUP_BONE_DEFORM : WT_VGROUP_ALL);
+  }
 
   RNA_enum_item_end(&item, &totitem);
   *r_free = true;

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


[Bf-blender-cvs] [eb7218de8db] master: Fix T99386: Driven modifiers are always re-evaluated during animation

2022-07-07 Thread Sergey Sharybin
Commit: eb7218de8dba2a977fdcf8f2e75b16fcd8fc044a
Author: Sergey Sharybin
Date:   Mon Jul 4 13:02:24 2022 +0200
Branches: master
https://developer.blender.org/rBeb7218de8dba2a977fdcf8f2e75b16fcd8fc044a

Fix T99386: Driven modifiers are always re-evaluated during animation

Even if the driver is not dependent on time the modifiers were always
re-evaluated during playback. This is due to the legacy nature of the
check whether modifier depends on time or not: it was simply checking
for sub-string match for modifier in the F-Curve and drivers RNA paths.

Nowadays such dependencies are created by the dependency graph builder,
which allows to have more granular control over what depends on what.

The code is now simplified to only check for "static" dependency of the
modifier form time: for example, Wave modifier which always depends on
time (even without explicit animation involved).

This change also fixes missing relation from the animation component to
the shader_fx modifiers, fixing race condition.

Additional files used to verify relations:
- Geometry: F13257368
- Grease Pencil: F13257369
- Shader FX: F13257370

In these files different types of modifiers have an animated property,
and the purpose of the test is to verify that the modifiers do react
to the animation and that there is a relation between animation and
geometry components of the object. The latter one can only be checked
using the dependency graph relation visualization.

The drivers are not tested by these files. Those are not typically
depend on time, and if there were missing relation from driver to
the modifier we'd receive a bug report already. As well as if there
was a bug in missing time relation to a driver we'd also receive a
report.

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

===

M   source/blender/blenkernel/BKE_object.h
M   source/blender/blenkernel/intern/object.cc
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/blenkernel/BKE_object.h 
b/source/blender/blenkernel/BKE_object.h
index 6ed05bc267a..96abea0e5ee 100644
--- a/source/blender/blenkernel/BKE_object.h
+++ b/source/blender/blenkernel/BKE_object.h
@@ -69,9 +69,6 @@ void BKE_object_free_caches(struct Object *object);
 void BKE_object_modifier_hook_reset(struct Object *ob, struct HookModifierData 
*hmd);
 void BKE_object_modifier_gpencil_hook_reset(struct Object *ob,
 struct HookGpencilModifierData 
*hmd);
-bool BKE_object_modifier_gpencil_use_time(struct Object *ob, struct 
GpencilModifierData *md);
-
-bool BKE_object_shaderfx_use_time(struct Object *ob, struct ShaderFxData *fx);
 
 /**
  * \return True if the object's type supports regular modifiers (not grease 
pencil modifiers).
@@ -633,8 +630,6 @@ void BKE_object_groups_clear(struct Main *bmain, struct 
Scene *scene, struct Obj
  */
 struct KDTree_3d *BKE_object_as_kdtree(struct Object *ob, int *r_tot);
 
-bool BKE_object_modifier_use_time(struct Scene *scene, struct Object *ob, 
struct ModifierData *md);
-
 /**
  * \note this function should eventually be replaced by depsgraph 
functionality.
  * Avoid calling this in new code unless there is a very good reason for it!
diff --git a/source/blender/blenkernel/intern/object.cc 
b/source/blender/blenkernel/intern/object.cc
index 5ed1ac98ddf..f7436b6112c 100644
--- a/source/blender/blenkernel/intern/object.cc
+++ b/source/blender/blenkernel/intern/object.cc
@@ -5357,126 +5357,6 @@ KDTree_3d *BKE_object_as_kdtree(Object *ob, int *r_tot)
 /** \name Object Modifier Utilities
  * \{ */
 
-bool BKE_object_modifier_use_time(Scene *scene, Object *ob, ModifierData *md)
-{
-  if (BKE_modifier_depends_ontime(scene, md)) {
-return true;
-  }
-
-  /* Check whether modifier is animated. */
-  /* TODO: this should be handled as part of build_animdata() -- Aligorith */
-  if (ob->adt) {
-AnimData *adt = ob->adt;
-FCurve *fcu;
-
-char md_name_esc[sizeof(md->name) * 2];
-BLI_str_escape(md_name_esc, md->name, sizeof(md_name_esc));
-
-char pattern[sizeof(md_name_esc) + 16];
-BLI_snprintf(pattern, sizeof(pattern), "modifiers[\"%s\"]", md_name_esc);
-
-/* action - check for F-Curves with paths containing 'modifiers[' */
-if (adt->action) {
-  for (fcu = (FCurve *)adt->action->curves.first; fcu != nullptr; fcu = 
(FCurve *)fcu->next) {
-if (fcu->rna_path && strstr(fcu->rna_path, pattern)) {
-  return true;
-}
-  }
-}
-
-/* This here allows modifier properties to get driven and still update 
properly
- *
- * Workaround to get T26764 (e.g. subsurf levels not updating when 
animated/driven)
- * working, without the updating problems (T28525 T28690 T28774 T28777) 
caused
- * by the RNA updates

[Bf-blender-cvs] [9a4927031da] master: Cleanup: Remove redundant filtering of legacy normal attribute

2022-07-07 Thread Hans Goudey
Commit: 9a4927031dade70e2fac42a5003ab4a21bfb9e3d
Author: Hans Goudey
Date:   Thu Jul 7 08:15:29 2022 -0500
Branches: master
https://developer.blender.org/rB9a4927031dade70e2fac42a5003ab4a21bfb9e3d

Cleanup: Remove redundant filtering of legacy normal attribute

This is already done inside of `attribute_search_add_items`.

===

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

===

diff --git 
a/source/blender/editors/space_node/node_geometry_attribute_search.cc 
b/source/blender/editors/space_node/node_geometry_attribute_search.cc
index f08e23c8371..e328a86b0fd 100644
--- a/source/blender/editors/space_node/node_geometry_attribute_search.cc
+++ b/source/blender/editors/space_node/node_geometry_attribute_search.cc
@@ -113,14 +113,6 @@ static void attribute_search_update_fn(
 
   Vector infos = 
get_attribute_info_from_context(*C, *data);
 
-  /* Remove the deprecated normal attribute from the search. */
-  for (const int i : infos.index_range()) {
-if (infos[i]->domain == ATTR_DOMAIN_FACE && infos[i]->name == "normal") {
-  infos.remove(i);
-  break;
-}
-  }
-
   ui::attribute_search_add_items(str, true, infos, items, is_first);
 }

___
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] [ed7dc4282c0] master: Cleanup: Correct comment with spreadsheet enum type

2022-07-07 Thread Hans Goudey
Commit: ed7dc4282c034fded840ca69c428050af889742a
Author: Hans Goudey
Date:   Thu Jul 7 08:14:00 2022 -0500
Branches: master
https://developer.blender.org/rBed7dc4282c034fded840ca69c428050af889742a

Cleanup: Correct comment with spreadsheet enum type

===

M   source/blender/makesdna/DNA_space_types.h

===

diff --git a/source/blender/makesdna/DNA_space_types.h 
b/source/blender/makesdna/DNA_space_types.h
index 2a5ca4c9541..6bc68baa640 100644
--- a/source/blender/makesdna/DNA_space_types.h
+++ b/source/blender/makesdna/DNA_space_types.h
@@ -1939,7 +1939,7 @@ typedef struct SpaceSpreadsheet {
   uint8_t geometry_component_type;
   /* #eAttrDomain. */
   uint8_t attribute_domain;
-  /* eSpaceSpreadsheet_ObjectContext. */
+  /* eSpaceSpreadsheet_ObjectEvalState. */
   uint8_t object_eval_state;
 
   /* eSpaceSpreadsheet_Flag. */

___
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] [5c3dc52536d] master: Cleanup: Improve variable name

2022-07-07 Thread Hans Goudey
Commit: 5c3dc52536d373253a0de584f80f7ada9528f003
Author: Hans Goudey
Date:   Thu Jul 7 08:13:11 2022 -0500
Branches: master
https://developer.blender.org/rB5c3dc52536d373253a0de584f80f7ada9528f003

Cleanup: Improve variable name

The new name makes more sense in non-node-related contexts.

===

M   source/blender/editors/include/UI_interface.hh
M   source/blender/editors/interface/interface_template_attribute_search.cc

===

diff --git a/source/blender/editors/include/UI_interface.hh 
b/source/blender/editors/include/UI_interface.hh
index 63cf8fa0c56..82bfdd7e212 100644
--- a/source/blender/editors/include/UI_interface.hh
+++ b/source/blender/editors/include/UI_interface.hh
@@ -46,7 +46,7 @@ void template_breadcrumbs(uiLayout &layout, 
Span context_path);
 
 void attribute_search_add_items(
 StringRefNull str,
-bool is_output,
+bool can_create_attribute,
 Span infos,
 uiSearchItems *items,
 bool is_first);
diff --git 
a/source/blender/editors/interface/interface_template_attribute_search.cc 
b/source/blender/editors/interface/interface_template_attribute_search.cc
index 4e587bd5338..0a684903f0f 100644
--- a/source/blender/editors/interface/interface_template_attribute_search.cc
+++ b/source/blender/editors/interface/interface_template_attribute_search.cc
@@ -50,7 +50,7 @@ static bool attribute_search_item_add(uiSearchItems *items, 
const GeometryAttrib
 }
 
 void attribute_search_add_items(StringRefNull str,
-const bool is_output,
+const bool can_create_attribute,
 Span infos,
 uiSearchItems *seach_items,
 const bool is_first)
@@ -68,8 +68,12 @@ void attribute_search_add_items(StringRefNull str,
 }
 if (!contained) {
   dummy_info.name = str;
-  UI_search_item_add(
-  seach_items, str.c_str(), &dummy_info, is_output ? ICON_ADD : 
ICON_NONE, 0, 0);
+  UI_search_item_add(seach_items,
+ str.c_str(),
+ &dummy_info,
+ can_create_attribute ? ICON_ADD : ICON_NONE,
+ 0,
+ 0);
 }
   }

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


[Bf-blender-cvs] [e3ef56ef914] master: Curves: Add sculpt selection overlay

2022-07-07 Thread Hans Goudey
Commit: e3ef56ef91417519a3301746f4cfd244cd08ef85
Author: Hans Goudey
Date:   Thu Jul 7 08:06:30 2022 -0500
Branches: master
https://developer.blender.org/rBe3ef56ef91417519a3301746f4cfd244cd08ef85

Curves: Add sculpt selection overlay

This commit adds visualization to the selection in curves sculpt mode.
Previously it was only possible to see the selection when it was
connected to a material.

In order to obstruct the users vision as little as possible, the
selected areas of the curve are left as is, but a dark overlay
is drawn over unselected areas.

To make it work, the overlay requests the selection attribute and then
ensures that the evaluation is complete for curves. Then it retrieves
the evaluated selection GPU texture and passes that to the shader.
This reuses the existing generic attribute extraction system because
there currently wouldn't be any benefits to dealing with selection
separately, and because it avoids duplication of the logic that
extracts attributes from curves and evaluates them if necessary.

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

===

M   release/scripts/startup/bl_ui/space_view3d.py
M   source/blender/draw/CMakeLists.txt
M   source/blender/draw/engines/overlay/overlay_engine.c
M   source/blender/draw/engines/overlay/overlay_private.h
A   source/blender/draw/engines/overlay/overlay_sculpt_curves.cc
M   source/blender/draw/engines/overlay/overlay_shader.c
A   
source/blender/draw/engines/overlay/shaders/infos/overlay_sculpt_curves_info.hh
A   
source/blender/draw/engines/overlay/shaders/overlay_sculpt_curves_selection_frag.glsl
A   
source/blender/draw/engines/overlay/shaders/overlay_sculpt_curves_selection_vert.glsl
M   source/blender/draw/intern/draw_cache_impl.h
M   source/blender/draw/intern/draw_cache_impl_curves.cc
M   source/blender/draw/tests/shaders_test.cc
M   source/blender/editors/curves/intern/curves_ops.cc
M   source/blender/gpu/CMakeLists.txt

===

diff --git a/release/scripts/startup/bl_ui/space_view3d.py 
b/release/scripts/startup/bl_ui/space_view3d.py
index 5a38c4175a8..91422a817f5 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -6669,6 +6669,7 @@ class VIEW3D_PT_overlay_sculpt_curves(Panel):
 overlay = view.overlay
 
 row = layout.row(align=True)
+row.active = overlay.show_overlays
 row.prop(overlay, "sculpt_mode_mask_opacity", text="Selection Opacity")
 
 
diff --git a/source/blender/draw/CMakeLists.txt 
b/source/blender/draw/CMakeLists.txt
index f4af9e242d3..81e4b00290a 100644
--- a/source/blender/draw/CMakeLists.txt
+++ b/source/blender/draw/CMakeLists.txt
@@ -194,6 +194,7 @@ set(SRC
   engines/overlay/overlay_paint.c
   engines/overlay/overlay_particle.c
   engines/overlay/overlay_sculpt.c
+  engines/overlay/overlay_sculpt_curves.cc
   engines/overlay/overlay_shader.c
   engines/overlay/overlay_volume.c
   engines/overlay/overlay_wireframe.c
@@ -556,6 +557,8 @@ set(GLSL_SRC
   engines/overlay/shaders/overlay_particle_vert.glsl
   engines/overlay/shaders/overlay_point_varying_color_frag.glsl
   
engines/overlay/shaders/overlay_point_varying_color_varying_outline_aa_frag.glsl
+  engines/overlay/shaders/overlay_sculpt_curves_selection_frag.glsl
+  engines/overlay/shaders/overlay_sculpt_curves_selection_vert.glsl
   engines/overlay/shaders/overlay_sculpt_mask_frag.glsl
   engines/overlay/shaders/overlay_sculpt_mask_vert.glsl
   engines/overlay/shaders/overlay_uniform_color_frag.glsl
diff --git a/source/blender/draw/engines/overlay/overlay_engine.c 
b/source/blender/draw/engines/overlay/overlay_engine.c
index f8c28394b16..9ec0398e5cb 100644
--- a/source/blender/draw/engines/overlay/overlay_engine.c
+++ b/source/blender/draw/engines/overlay/overlay_engine.c
@@ -192,6 +192,8 @@ static void OVERLAY_cache_init(void *vedata)
   OVERLAY_edit_curves_cache_init(vedata);
   break;
 case CTX_MODE_SCULPT_CURVES:
+  OVERLAY_sculpt_curves_cache_init(vedata);
+  break;
 case CTX_MODE_OBJECT:
   break;
 default:
@@ -310,6 +312,8 @@ static void OVERLAY_cache_populate(void *vedata, Object *ob)
  (draw_ctx->object_mode & OB_MODE_ALL_PAINT);
   const bool in_sculpt_mode = (ob == draw_ctx->obact) && (ob->sculpt != NULL) 
&&
   (ob->sculpt->mode_type == OB_MODE_SCULPT);
+  const bool in_curves_sculpt_mode = (ob == draw_ctx->obact) &&
+ (ob->mode == OB_MODE_SCULPT_CURVES);
   const bool has_surface = ELEM(ob->type,
 OB_MESH,
 OB_CURVES_LEGACY,
@@ -428,6 +432,9 @@ static void OVERLAY_cache_populate(void *vedata, Object *ob)
   if (in_sculpt_mode) {
 OVERLAY_sculpt_cache_populate(vedata, ob);
   }
+  

[Bf-blender-cvs] [5d6e7df4a8b] master: GHOST: initialize grab axis for windows

2022-07-07 Thread Campbell Barton
Commit: 5d6e7df4a8b70aa98d86655b024a87ca3319c6be
Author: Campbell Barton
Date:   Thu Jul 7 21:42:05 2022 +1000
Branches: master
https://developer.blender.org/rB5d6e7df4a8b70aa98d86655b024a87ca3319c6be

GHOST: initialize grab axis for windows

While this didn't cause any user visible bugs, ASAN would report
an error when passing it as an argument.

===

M   intern/ghost/intern/GHOST_Window.cpp

===

diff --git a/intern/ghost/intern/GHOST_Window.cpp 
b/intern/ghost/intern/GHOST_Window.cpp
index be5d593c401..db4d6c3bb71 100644
--- a/intern/ghost/intern/GHOST_Window.cpp
+++ b/intern/ghost/intern/GHOST_Window.cpp
@@ -23,6 +23,7 @@ GHOST_Window::GHOST_Window(uint32_t width,
 : m_drawingContextType(GHOST_kDrawingContextTypeNone),
   m_cursorVisible(true),
   m_cursorGrab(GHOST_kGrabDisable),
+  m_cursorGrabAxis(GHOST_kAxisNone),
   m_cursorShape(GHOST_kStandardCursorDefault),
   m_wantStereoVisual(wantStereoVisual),
   m_context(new GHOST_ContextNone(false))

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


[Bf-blender-cvs] [a27024e36d8] master: ID Management: Purge: Make outliner button use recursive purge.

2022-07-07 Thread Bastien Montagne
Commit: a27024e36d879c3872cfb791f4c5ce805bf57857
Author: Bastien Montagne
Date:   Thu Jul 7 12:59:24 2022 +0200
Branches: master
https://developer.blender.org/rBa27024e36d879c3872cfb791f4c5ce805bf57857

ID Management: Purge: Make outliner button use recursive purge.

This change the 'Purge' button of the Outliner 'Orphaned' view to use
recursive purge, i.e. it wil not only delete immediately unused IDs (as
listed in the view) anymore, but also all their unused dependencies.

===

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

===

diff --git a/release/scripts/startup/bl_ui/space_outliner.py 
b/release/scripts/startup/bl_ui/space_outliner.py
index fff252ade01..18057de6767 100644
--- a/release/scripts/startup/bl_ui/space_outliner.py
+++ b/release/scripts/startup/bl_ui/space_outliner.py
@@ -55,7 +55,7 @@ class OUTLINER_HT_header(Header):
 layout.operator("outliner.collection_new", text="", 
icon='COLLECTION_NEW').nested = True
 
 elif display_mode == 'ORPHAN_DATA':
-layout.operator("outliner.orphans_purge", text="Purge")
+layout.operator("outliner.orphans_purge", 
text="Purge").do_recursive=True
 
 elif space.display_mode == 'DATA_API':
 layout.separator()

___
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] [97dd1070709] master: Fix T98029: Support isolated islands of IDs when purging unused ones.

2022-07-07 Thread Bastien Montagne
Commit: 97dd10707097536df24dd7ca7d2a45b9a6408711
Author: Bastien Montagne
Date:   Thu Jul 7 12:33:45 2022 +0200
Branches: master
https://developer.blender.org/rB97dd10707097536df24dd7ca7d2a45b9a6408711

Fix T98029: Support isolated islands of IDs when purging unused ones.

Cases were e.g. an object would use a material, and this material would
use this object (e.g. through a driver), even if both those data-blocks
are technically unused, they would remain forever since they were not
detected as such.

Now this is properly detected and purged as part of the 'recursive
purge' operation.

===

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

===

diff --git a/source/blender/blenkernel/intern/lib_query.c 
b/source/blender/blenkernel/intern/lib_query.c
index 5de8704e13b..38252a46b93 100644
--- a/source/blender/blenkernel/intern/lib_query.c
+++ b/source/blender/blenkernel/intern/lib_query.c
@@ -693,6 +693,13 @@ static void lib_query_unused_ids_tag_recurse(Main *bmain,
* First recursively check all its valid users, if all of them can be tagged 
as
* unused, then we can tag this ID as such too. */
   bool has_valid_from_users = false;
+  /* Preemptively consider this ID as unused. That way if there is a loop of 
dependency leading
+   * back to it, it won't create a fake 'valid user' detection.
+   * NOTE: This can only only be done for a subset of IDs, some types are 
never 'indirectly
+   * unused', same for IDs with a fake user. */
+  if ((id->flag & LIB_FAKEUSER) == 0 && !ELEM(GS(id->name), ID_SCE, ID_WM, 
ID_SCR, ID_WS, ID_LI)) {
+id->tag |= tag;
+  }
   for (MainIDRelationsEntryItem *id_from_item = id_relations->from_ids; 
id_from_item != NULL;
id_from_item = id_from_item->next) {
 if ((id_from_item->usage_flag & ignored_usages) != 0 ||
@@ -715,7 +722,11 @@ static void lib_query_unused_ids_tag_recurse(Main *bmain,
   break;
 }
   }
-  if (!has_valid_from_users) {
+  if (has_valid_from_users) {
+/* This ID has 'valid' users, clear the 'tag as unused' preemptively set 
above. */
+id->tag &= ~tag;
+  }
+  else {
 /* This ID has no 'valid' users, tag it as unused. */
 id->tag |= tag;
 if (r_num_tagged != NULL) {

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


[Bf-blender-cvs] [051a341cf00] master: Fix T99491: Crash when opening modifiers panel

2022-07-07 Thread Falk David
Commit: 051a341cf00ca1518b50b43bb95f95bc24bf2398
Author: Falk David
Date:   Wed Jul 6 17:09:00 2022 +0200
Branches: master
https://developer.blender.org/rB051a341cf00ca1518b50b43bb95f95bc24bf2398

Fix T99491: Crash when opening modifiers panel

This crashed because in `get_active_fcurve_channel`, the filter did not
filter out channels with no fcurve.

The fix adds the filter `ANIMFILTER_FCURVESONLY`.

See rB92d7f9ac56e0ff1e65c364487542dfb7c32a0a67 for the new filter.

Maniphest Tasks: T99491

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

===

M   source/blender/editors/space_graph/graph_utils.c

===

diff --git a/source/blender/editors/space_graph/graph_utils.c 
b/source/blender/editors/space_graph/graph_utils.c
index a813e6ae245..51af795893f 100644
--- a/source/blender/editors/space_graph/graph_utils.c
+++ b/source/blender/editors/space_graph/graph_utils.c
@@ -81,7 +81,7 @@ void ED_drivers_editor_init(bContext *C, ScrArea *area)
 bAnimListElem *get_active_fcurve_channel(bAnimContext *ac)
 {
   ListBase anim_data = {NULL, NULL};
-  int filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT | 
ANIMFILTER_ACTIVE);
+  int filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT | 
ANIMFILTER_ACTIVE | ANIMFILTER_FCURVESONLY);
   size_t items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, 
ac->datatype);
 
   /* We take the first F-Curve only, since some other ones may have had 
'active' flag set

___
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] [14980c9b3ad] master: Fix: Save modified images during file close

2022-07-07 Thread Jesse Yurkovich
Commit: 14980c9b3ad849340cad2cce5aa475228ff0c2b4
Author: Jesse Yurkovich
Date:   Thu Jul 7 02:36:54 2022 -0700
Branches: master
https://developer.blender.org/rB14980c9b3ad849340cad2cce5aa475228ff0c2b4

Fix: Save modified images during file close

Regressed in the following commit due to an inverted conditional:
{rB1159b63a07fd2cbc7fc48e162d57721c9c85b3f6}

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

===

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

===

diff --git a/source/blender/editors/space_image/image_ops.c 
b/source/blender/editors/space_image/image_ops.c
index b77bdc11ca5..49420e9a2a1 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -2391,7 +2391,7 @@ bool ED_image_save_all_modified(const bContext *C, 
ReportList *reports)
 if (image_has_valid_path(ima)) {
   ImageSaveOptions opts;
   Scene *scene = CTX_data_scene(C);
-  if (!BKE_image_save_options_init(&opts, bmain, scene, ima, NULL, 
false, false)) {
+  if (BKE_image_save_options_init(&opts, bmain, scene, ima, NULL, 
false, false)) {
 bool saved_successfully = BKE_image_save(reports, bmain, ima, 
NULL, &opts);
 ok = ok && saved_successfully;
   }

___
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] [f2562018762] master: Fix T99388: Obey relative path option when saving UDIMs

2022-07-07 Thread Jesse Yurkovich
Commit: f25620187620e75772adc18eaf121ef00416c791
Author: Jesse Yurkovich
Date:   Thu Jul 7 02:08:32 2022 -0700
Branches: master
https://developer.blender.org/rBf25620187620e75772adc18eaf121ef00416c791

Fix T99388: Obey relative path option when saving UDIMs

Ensure that the Image maintains the proper file path after saving all
the individual tiles.

The image_save_post function is unaware that the filepath it receives
is only for a single tile, not the entire Image, and happily keeps
setting ima->filepath to the concrete filepath for each tile.

There were 2 problems with the code that attempted to correct the
Image filepath back to the UDIM virtual form:
- It would trample the "relative" directory that might have been set
- It would do the wrong thing if no tiles could be saved at all

The design is now as follows: Example of trying to save to a new PathB
|  | all tiles ok | any tile not ok|
|  |  | ---|
| ima->filepath is currently empty | set to new PathB | keep empty |
| ima->filepath is currently PathA | set to new PathB | keep PathA |

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

===

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

===

diff --git a/source/blender/blenkernel/intern/image_save.cc 
b/source/blender/blenkernel/intern/image_save.cc
index 9dda3762553..07ffc35907a 100644
--- a/source/blender/blenkernel/intern/image_save.cc
+++ b/source/blender/blenkernel/intern/image_save.cc
@@ -253,6 +253,21 @@ void BKE_image_save_options_free(ImageSaveOptions *opts)
   BKE_image_format_free(&opts->im_format);
 }
 
+static void image_save_update_filepath(Image *ima,
+   const char *filepath,
+   const ImageSaveOptions *opts)
+{
+  if (opts->do_newpath) {
+BLI_strncpy(ima->filepath, filepath, sizeof(ima->filepath));
+
+/* only image path, never ibuf */
+if (opts->relative) {
+  const char *relbase = ID_BLEND_PATH(opts->bmain, &ima->id);
+  BLI_path_rel(ima->filepath, relbase); /* only after saving */
+}
+  }
+}
+
 static void image_save_post(ReportList *reports,
 Image *ima,
 ImBuf *ibuf,
@@ -273,13 +288,11 @@ static void image_save_post(ReportList *reports,
 
   if (opts->do_newpath) {
 BLI_strncpy(ibuf->name, filepath, sizeof(ibuf->name));
-BLI_strncpy(ima->filepath, filepath, sizeof(ima->filepath));
+  }
 
-/* only image path, never ibuf */
-if (opts->relative) {
-  const char *relbase = ID_BLEND_PATH(opts->bmain, &ima->id);
-  BLI_path_rel(ima->filepath, relbase); /* only after saving */
-}
+  /* The tiled image codepath must call this on its own. */
+  if (ima->source != IMA_SRC_TILED) {
+image_save_update_filepath(ima, filepath, opts);
   }
 
   ibuf->userflags &= ~IB_BITMAPDIRTY;
@@ -640,22 +653,23 @@ bool BKE_image_save(
 ok = image_save_single(reports, ima, iuser, opts, &colorspace_changed);
   }
   else {
-char filepath[FILE_MAX];
-BLI_strncpy(filepath, opts->filepath, sizeof(filepath));
-
 /* Save all the tiles. */
 LISTBASE_FOREACH (ImageTile *, tile, &ima->tiles) {
+  ImageSaveOptions tile_opts = *opts;
   BKE_image_set_filepath_from_tile_number(
-  opts->filepath, udim_pattern, tile_format, tile->tile_number);
+  tile_opts.filepath, udim_pattern, tile_format, tile->tile_number);
 
   iuser->tile = tile->tile_number;
-  ok = image_save_single(reports, ima, iuser, opts, &colorspace_changed);
+  ok = image_save_single(reports, ima, iuser, &tile_opts, 
&colorspace_changed);
   if (!ok) {
 break;
   }
 }
-BLI_strncpy(ima->filepath, filepath, sizeof(ima->filepath));
-BLI_strncpy(opts->filepath, filepath, sizeof(opts->filepath));
+
+/* Set the image path only if all tiles were ok. */
+if (ok) {
+  image_save_update_filepath(ima, opts->filepath, opts);
+}
 MEM_freeN(udim_pattern);
   }

___
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] [13c202a2631] temp-T97352-3d-texturing-seam-bleeding-b2: Use VectorList in UVIsland.

2022-07-07 Thread Jeroen Bakker
Commit: 13c202a2631a3d0ac210249c9e31b2ca07273c28
Author: Jeroen Bakker
Date:   Thu Jul 7 11:02:52 2022 +0200
Branches: temp-T97352-3d-texturing-seam-bleeding-b2
https://developer.blender.org/rB13c202a2631a3d0ac210249c9e31b2ca07273c28

Use VectorList in UVIsland.

===

M   source/blender/blenkernel/BKE_uv_islands.hh
M   source/blender/blenkernel/intern/pbvh_pixels.cc
M   source/blender/blenkernel/intern/uv_islands.cc
M   source/blender/blenlib/BLI_vector_list.hh

===

diff --git a/source/blender/blenkernel/BKE_uv_islands.hh 
b/source/blender/blenkernel/BKE_uv_islands.hh
index ce97f609664..3b266a7870a 100644
--- a/source/blender/blenkernel/BKE_uv_islands.hh
+++ b/source/blender/blenkernel/BKE_uv_islands.hh
@@ -14,6 +14,7 @@
 #include "BLI_math_vec_types.hh"
 #include "BLI_rect.h"
 #include "BLI_vector.hh"
+#include "BLI_vector_list.hh"
 
 #include "DNA_meshdata_types.h"
 
@@ -631,9 +632,9 @@ struct UVBorder {
 };
 
 struct UVIsland {
-  Vector uv_vertices;
-  Vector uv_edges;
-  Vector uv_primitives;
+  VectorList uv_vertices;
+  VectorList uv_edges;
+  VectorList uv_primitives;
   /**
* List of borders of this island. There can be multiple borders per island 
as a border could
* be completely encapsulated by another one.
@@ -641,38 +642,6 @@ struct UVIsland {
   Vector borders;
   Map> uv_vertex_lookup;
 
-  UVIsland(const uint64_t mesh_prim_len)
-  {
-/*
- * Reserve enough space for uv island extension. Worse case scenarios 
include islands
- * containing only a few faces, or the prims are oriented as a triangle 
strip. As we don't
- * categorize the exact topology we over allocate.
- *
- * There will at least be a single edge shared. Commonly this number is 
somewhere between 2-3,
- * except when topology form a triangle strip.
- *
- * There will at least be two vertices shared. Commonly there are 3 
vertices shared.
- *
- * NOTE: This could be improved by counting outer edges.
- *
- * The overallocation is needed as the elements in the vector are 
referenced to. When the
- * capacity of a vector is changed the pointers will become invalid. Other 
solutions:
- * - Store indices, but that decreases the readability of the code.
- * - Use dynamic memory pool (Vector of Arrays of Elements) as elements 
are only added or
- *   modified, never removed. See https://developer.blender.org/D13289 for
- *   `BLI_vector_list.hh`.
- * - Detect when vectors allocate and update pointers. Not easy to 
maintain when algorithm
- *   will change in the future.
- */
-uint64_t uv_prim_len = max_ii(2 * mesh_prim_len, 1);
-uint64_t uv_edge_len = uv_prim_len * 2;
-uint64_t uv_vertex_len = uv_prim_len * 2;
-
-uv_vertices.reserve(uv_vertex_len);
-uv_edges.reserve(uv_edge_len);
-uv_primitives.reserve(uv_prim_len);
-  }
-
   UVPrimitive *add_primitive(MeshPrimitive &primitive)
   {
 UVPrimitive uv_primitive(&primitive);
@@ -772,9 +741,11 @@ struct UVIsland {
  public:
   bool has_shared_edge(const UVPrimitive &primitive) const
   {
-for (const UVPrimitive &prim : uv_primitives) {
-  if (prim.has_shared_edge(primitive)) {
-return true;
+for (const VectorList::UsedVector &prims : uv_primitives) {
+  for (const UVPrimitive &prim : prims) {
+if (prim.has_shared_edge(primitive)) {
+  return true;
+}
   }
 }
 return false;
@@ -782,9 +753,11 @@ struct UVIsland {
 
   bool has_shared_edge(const MeshPrimitive &primitive) const
   {
-for (const UVPrimitive &prim : uv_primitives) {
-  if (prim.has_shared_edge(primitive)) {
-return true;
+for (const VectorList::UsedVector &primitives : 
uv_primitives) {
+  for (const UVPrimitive &prim : primitives) {
+if (prim.has_shared_edge(primitive)) {
+  return true;
+}
   }
 }
 return false;
@@ -792,9 +765,11 @@ struct UVIsland {
 
   const void extend_border(const UVPrimitive &primitive)
   {
-for (UVPrimitive &prim : uv_primitives) {
-  if (prim.has_shared_edge(primitive)) {
-append(primitive);
+for (const VectorList::UsedVector &primitives : 
uv_primitives) {
+  for (const UVPrimitive &prim : primitives) {
+if (prim.has_shared_edge(primitive)) {
+  append(primitive);
+}
   }
 }
   }
@@ -868,14 +843,7 @@ struct UVIslands {
 islands.reserve(mesh_data.uv_island_len);
 
 for (int64_t uv_island_id = 0; uv_island_id < mesh_data.uv_island_len; 
uv_island_id++) {
-  uint64_t mesh_prim_len = 0;
-  for (MeshPrimitive &primitive : mesh_data.primitives) {
-if (primitive.uv_island_id == uv_island_id) {
-  mesh_prim_len++;
-}
-  }
-
-  islands.append_as(UVIsland(mesh_prim_len));
+  islands.append_as(UVIsland());
   UVIsland *

[Bf-blender-cvs] [a042d365b37] temp-T97352-3d-texturing-seam-bleeding-b2: Added VectorList from D13289.

2022-07-07 Thread Jeroen Bakker
Commit: a042d365b376414ce4e3dc5cc443b69e7b5771d1
Author: Jeroen Bakker
Date:   Thu Jul 7 10:32:39 2022 +0200
Branches: temp-T97352-3d-texturing-seam-bleeding-b2
https://developer.blender.org/rBa042d365b376414ce4e3dc5cc443b69e7b5771d1

Added VectorList from D13289.

===

M   source/blender/blenlib/BLI_vector.hh

===

diff --git a/source/blender/blenlib/BLI_vector.hh 
b/source/blender/blenlib/BLI_vector.hh
index c23d846d277..23ec05572b6 100644
--- a/source/blender/blenlib/BLI_vector.hh
+++ b/source/blender/blenlib/BLI_vector.hh
@@ -900,6 +900,11 @@ class Vector {
 return static_cast(capacity_end_ - begin_);
   }
 
+  bool is_at_capacity() const
+  {
+return end_ == capacity_end_;
+  }
+
   /**
* Get an index range that makes looping over all indices more convenient 
and less error prone.
* Obviously, this should only be used when you actually need the index in 
the loop.

___
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] [50f9c1c09ce] master: OBJ: more robust .mtl texture offset/scale parsing (T89421)

2022-07-07 Thread Aras Pranckevicius
Commit: 50f9c1c09ce331c7ce09115016ba3e4407691701
Author: Aras Pranckevicius
Date:   Thu Jul 7 11:34:04 2022 +0300
Branches: master
https://developer.blender.org/rB50f9c1c09ce331c7ce09115016ba3e4407691701

OBJ: more robust .mtl texture offset/scale parsing (T89421)

As pointed out in a comment on T89421, if a MTL file contained
something like: `map_Ka -o 1 2.png` then it was parsed as having
offset `1 2` and the texture filename just a `.png`. Make it so that
mtl option numbers are parsed in a way where the number is only
accepted only if it's followed by whitespace.

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

===

M   source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc
M   source/blender/io/wavefront_obj/importer/obj_import_string_utils.cc
M   source/blender/io/wavefront_obj/importer/obj_import_string_utils.hh
M   source/blender/io/wavefront_obj/tests/obj_import_string_utils_tests.cc
M   source/blender/io/wavefront_obj/tests/obj_mtl_parser_tests.cc

===

diff --git a/source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc 
b/source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc
index 3cc17e7d8e6..c2aa96713b1 100644
--- a/source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc
+++ b/source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc
@@ -626,15 +626,15 @@ static bool parse_texture_option(const char *&p,
 {
   p = drop_whitespace(p, end);
   if (parse_keyword(p, end, "-o")) {
-p = parse_floats(p, end, 0.0f, tex_map.translation, 3);
+p = parse_floats(p, end, 0.0f, tex_map.translation, 3, true);
 return true;
   }
   if (parse_keyword(p, end, "-s")) {
-p = parse_floats(p, end, 1.0f, tex_map.scale, 3);
+p = parse_floats(p, end, 1.0f, tex_map.scale, 3, true);
 return true;
   }
   if (parse_keyword(p, end, "-bm")) {
-p = parse_float(p, end, 1.0f, material->map_Bump_strength);
+p = parse_float(p, end, 1.0f, material->map_Bump_strength, true, true);
 return true;
   }
   if (parse_keyword(p, end, "-type")) {
diff --git 
a/source/blender/io/wavefront_obj/importer/obj_import_string_utils.cc 
b/source/blender/io/wavefront_obj/importer/obj_import_string_utils.cc
index c8eaa046e68..bc9006e1051 100644
--- a/source/blender/io/wavefront_obj/importer/obj_import_string_utils.cc
+++ b/source/blender/io/wavefront_obj/importer/obj_import_string_utils.cc
@@ -62,8 +62,12 @@ static const char *drop_plus(const char *p, const char *end)
   return p;
 }
 
-const char *parse_float(
-const char *p, const char *end, float fallback, float &dst, bool 
skip_space)
+const char *parse_float(const char *p,
+const char *end,
+float fallback,
+float &dst,
+bool skip_space,
+bool require_trailing_space)
 {
   if (skip_space) {
 p = drop_whitespace(p, end);
@@ -73,13 +77,23 @@ const char *parse_float(
   if (res.ec == std::errc::invalid_argument || res.ec == 
std::errc::result_out_of_range) {
 dst = fallback;
   }
+  else if (require_trailing_space && res.ptr < end && 
!is_whitespace(*res.ptr)) {
+/* If there are trailing non-space characters, do not eat up the number. */
+dst = fallback;
+return p;
+  }
   return res.ptr;
 }
 
-const char *parse_floats(const char *p, const char *end, float fallback, float 
*dst, int count)
+const char *parse_floats(const char *p,
+ const char *end,
+ float fallback,
+ float *dst,
+ int count,
+ bool require_trailing_space)
 {
   for (int i = 0; i < count; ++i) {
-p = parse_float(p, end, fallback, dst[i]);
+p = parse_float(p, end, fallback, dst[i], true, require_trailing_space);
   }
   return p;
 }
diff --git 
a/source/blender/io/wavefront_obj/importer/obj_import_string_utils.hh 
b/source/blender/io/wavefront_obj/importer/obj_import_string_utils.hh
index 3f428b1ab5c..f6dd1a6b675 100644
--- a/source/blender/io/wavefront_obj/importer/obj_import_string_utils.hh
+++ b/source/blender/io/wavefront_obj/importer/obj_import_string_utils.hh
@@ -62,12 +62,17 @@ const char *parse_int(
  * The parsed result is stored in `dst`. The function skips
  * leading white-space unless `skip_space=false`. If the
  * number can't be parsed (invalid syntax, out of range),
- * `fallback` value is stored instead.
+ * `fallback` value is stored instead. If `require_trailing_space`
+ * is true, the character after the number has to be whitespace.
  *
  * Returns the start of remainder of the input string after parsing.
  */
-const char *parse_float(
-const char *p, const char *end, float fallback, float &dst, bool 
skip_space = true);
+const char *parse_float(const char *p,
+const ch

[Bf-blender-cvs] [bddcb89cdaa] master: OBJ: always set eevee blend mode when material "d" is below 1.0

2022-07-07 Thread Aras Pranckevicius
Commit: bddcb89cdaa6d9b36b3e42547a95bff792d37610
Author: Aras Pranckevicius
Date:   Thu Jul 7 11:32:56 2022 +0300
Branches: master
https://developer.blender.org/rBbddcb89cdaa6d9b36b3e42547a95bff792d37610

OBJ: always set eevee blend mode when material "d" is below 1.0

Fixes T97743: the import code was setting EEVEE blending mode whenever
a transparency texture was present (map_d), or when the materials
illum was saying "yo, transparency!". But if only the material's d
was below 1.0, it was not setting the blend mode, which is different
to user expectations.

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

===

M   source/blender/io/wavefront_obj/importer/obj_import_mtl.cc

===

diff --git a/source/blender/io/wavefront_obj/importer/obj_import_mtl.cc 
b/source/blender/io/wavefront_obj/importer/obj_import_mtl.cc
index f39def0a4af..60e419728f3 100644
--- a/source/blender/io/wavefront_obj/importer/obj_import_mtl.cc
+++ b/source/blender/io/wavefront_obj/importer/obj_import_mtl.cc
@@ -320,7 +320,7 @@ void ShaderNodetreeWrap::set_bsdf_socket_values(Material 
*mat)
   if (alpha != -1) {
 set_property_of_socket(SOCK_FLOAT, "Alpha", {alpha}, bsdf_);
   }
-  if (do_tranparency) {
+  if (do_tranparency || (alpha >= 0.0f && alpha < 1.0f)) {
 mat->blend_method = MA_BM_BLEND;
   }
 }

___
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] [1acb1b8cbd7] temp-T97352-3d-texturing-seam-bleeding-b2: Added VectorList from D13289.

2022-07-07 Thread Jeroen Bakker
Commit: 1acb1b8cbd7d71b5b39be2b53c72358f97de7ef5
Author: Jeroen Bakker
Date:   Thu Jul 7 10:32:39 2022 +0200
Branches: temp-T97352-3d-texturing-seam-bleeding-b2
https://developer.blender.org/rB1acb1b8cbd7d71b5b39be2b53c72358f97de7ef5

Added VectorList from D13289.

===

A   source/blender/blenlib/BLI_vector_list.hh
M   source/blender/blenlib/CMakeLists.txt

===

diff --git a/source/blender/blenlib/BLI_vector_list.hh 
b/source/blender/blenlib/BLI_vector_list.hh
new file mode 100644
index 000..177b2ef91d0
--- /dev/null
+++ b/source/blender/blenlib/BLI_vector_list.hh
@@ -0,0 +1,105 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#pragma once
+
+#include 
+
+#include "BLI_vector.hh"
+
+namespace blender {
+
+template class VectorList {
+ private:
+  using UsedVector = Vector;
+  static constexpr int64_t vector_capacity_start = 32;
+  static constexpr int64_t vector_capacity_soft_limit = 4096;
+
+  /**
+   * Contains the individual vectors. There must always be at least one vector.
+   */
+  Vector vectors_;
+
+ public:
+  VectorList()
+  {
+this->append_vector();
+  }
+
+  void append(const T &value)
+  {
+this->append_as(value);
+  }
+
+  void append(T &&value)
+  {
+this->append_as(std::move(value));
+  }
+
+  template void append_as(ForwardT &&value)
+  {
+UsedVector &vector = this->ensure_space_for_one();
+vector.append_unchecked_as(std::forward(value));
+  }
+
+  UsedVector *begin()
+  {
+return vectors_.begin();
+  }
+
+  UsedVector *end()
+  {
+return vectors_.end();
+  }
+
+  const UsedVector *begin() const
+  {
+return vectors_.begin();
+  }
+
+  const UsedVector *end() const
+  {
+return vectors_.end();
+  }
+
+ private:
+  UsedVector &ensure_space_for_one()
+  {
+UsedVector &vector = vectors_.last();
+if (LIKELY(!vector.is_at_capacity())) {
+  return vector;
+}
+this->append_vector();
+return vectors_.last();
+  }
+
+  void append_vector()
+  {
+const int64_t new_vector_capacity = this->get_next_vector_capacity();
+vectors_.append({});
+vectors_.last().reserve(new_vector_capacity);
+  }
+
+  int64_t get_next_vector_capacity()
+  {
+if (vectors_.is_empty()) {
+  return vector_capacity_start;
+}
+return std::min(vectors_.last().capacity() * 2, 
vector_capacity_soft_limit);
+  }
+};
+
+}  // namespace blender
\ No newline at end of file
diff --git a/source/blender/blenlib/CMakeLists.txt 
b/source/blender/blenlib/CMakeLists.txt
index 95b4987596e..a879045781b 100644
--- a/source/blender/blenlib/CMakeLists.txt
+++ b/source/blender/blenlib/CMakeLists.txt
@@ -324,6 +324,7 @@ set(SRC
   BLI_uvproject.h
   BLI_vector.hh
   BLI_vector_adaptor.hh
+  BLI_vector_list.hh
   BLI_vector_set.hh
   BLI_vector_set_slots.hh
   BLI_virtual_array.hh

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


[Bf-blender-cvs] [2016aabc511] temp-T97352-3d-texturing-seam-bleeding-b2: Reserve space to handle larger meshes.

2022-07-07 Thread Jeroen Bakker
Commit: 2016aabc5118784c22d13319ed5abcafced64d16
Author: Jeroen Bakker
Date:   Thu Jul 7 10:26:43 2022 +0200
Branches: temp-T97352-3d-texturing-seam-bleeding-b2
https://developer.blender.org/rB2016aabc5118784c22d13319ed5abcafced64d16

Reserve space to handle larger meshes.

===

M   source/blender/blenkernel/BKE_uv_islands.hh

===

diff --git a/source/blender/blenkernel/BKE_uv_islands.hh 
b/source/blender/blenkernel/BKE_uv_islands.hh
index 776167229ad..ce97f609664 100644
--- a/source/blender/blenkernel/BKE_uv_islands.hh
+++ b/source/blender/blenkernel/BKE_uv_islands.hh
@@ -641,12 +641,36 @@ struct UVIsland {
   Vector borders;
   Map> uv_vertex_lookup;
 
-  UVIsland()
+  UVIsland(const uint64_t mesh_prim_len)
   {
-// TODO: Base on actual island primitives. or replace pointers with 
indices.
-uv_vertices.reserve(100);
-uv_edges.reserve(100);
-uv_primitives.reserve(100);
+/*
+ * Reserve enough space for uv island extension. Worse case scenarios 
include islands
+ * containing only a few faces, or the prims are oriented as a triangle 
strip. As we don't
+ * categorize the exact topology we over allocate.
+ *
+ * There will at least be a single edge shared. Commonly this number is 
somewhere between 2-3,
+ * except when topology form a triangle strip.
+ *
+ * There will at least be two vertices shared. Commonly there are 3 
vertices shared.
+ *
+ * NOTE: This could be improved by counting outer edges.
+ *
+ * The overallocation is needed as the elements in the vector are 
referenced to. When the
+ * capacity of a vector is changed the pointers will become invalid. Other 
solutions:
+ * - Store indices, but that decreases the readability of the code.
+ * - Use dynamic memory pool (Vector of Arrays of Elements) as elements 
are only added or
+ *   modified, never removed. See https://developer.blender.org/D13289 for
+ *   `BLI_vector_list.hh`.
+ * - Detect when vectors allocate and update pointers. Not easy to 
maintain when algorithm
+ *   will change in the future.
+ */
+uint64_t uv_prim_len = max_ii(2 * mesh_prim_len, 1);
+uint64_t uv_edge_len = uv_prim_len * 2;
+uint64_t uv_vertex_len = uv_prim_len * 2;
+
+uv_vertices.reserve(uv_vertex_len);
+uv_edges.reserve(uv_edge_len);
+uv_primitives.reserve(uv_prim_len);
   }
 
   UVPrimitive *add_primitive(MeshPrimitive &primitive)
@@ -844,7 +868,14 @@ struct UVIslands {
 islands.reserve(mesh_data.uv_island_len);
 
 for (int64_t uv_island_id = 0; uv_island_id < mesh_data.uv_island_len; 
uv_island_id++) {
-  islands.append_as(UVIsland());
+  uint64_t mesh_prim_len = 0;
+  for (MeshPrimitive &primitive : mesh_data.primitives) {
+if (primitive.uv_island_id == uv_island_id) {
+  mesh_prim_len++;
+}
+  }
+
+  islands.append_as(UVIsland(mesh_prim_len));
   UVIsland *uv_island = &islands.last();
   for (MeshPrimitive &primitive : mesh_data.primitives) {
 if (primitive.uv_island_id == uv_island_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] [cd6270ff58b] temp-T97352-3d-texturing-seam-bleeding-b2: Removed some TODO's that were already fixed.

2022-07-07 Thread Jeroen Bakker
Commit: cd6270ff58ba152f5dfde18984ff816084e1b512
Author: Jeroen Bakker
Date:   Thu Jul 7 09:02:57 2022 +0200
Branches: temp-T97352-3d-texturing-seam-bleeding-b2
https://developer.blender.org/rBcd6270ff58ba152f5dfde18984ff816084e1b512

Removed some TODO's that were already fixed.

===

M   source/blender/blenkernel/BKE_uv_islands.hh

===

diff --git a/source/blender/blenkernel/BKE_uv_islands.hh 
b/source/blender/blenkernel/BKE_uv_islands.hh
index 2cc1bdbeb23..776167229ad 100644
--- a/source/blender/blenkernel/BKE_uv_islands.hh
+++ b/source/blender/blenkernel/BKE_uv_islands.hh
@@ -20,10 +20,6 @@
 #include "PIL_time_utildefines.h"
 
 namespace blender::bke::uv_islands {
-// TODO: primitives can be added twice
-// TODO: Joining uv island should check where the borders could be merged.
-// TODO: this isn't optimized for performance.
-
 /*
  * When enabled various parts of the code would generate an SVG file to visual 
see how the
  * algorithm makes decisions.
@@ -31,18 +27,15 @@ namespace blender::bke::uv_islands {
 //#define DEBUG_SVG
 //#define VALIDATE
 
-struct UVIslands;
-struct UVIslandsMask;
 struct MeshEdge;
 struct MeshPrimitive;
+struct UVBorder;
+struct UVEdge;
+struct UVIslands;
+struct UVIslandsMask;
 struct UVPrimitive;
 struct UVPrimitiveEdge;
-struct UVBorder;
 struct UVVertex;
-struct UVEdge;
-
-struct MeshEdge;
-struct MeshPrimitive;
 
 struct MeshVertex {
   int64_t v;
@@ -131,7 +124,10 @@ struct MeshPrimitive {
   }
 };
 
-/** Wrapper to contain all required mesh data. */
+/**
+ * MeshData contains input geometry data converted in a list of primitives, 
edges and vertices for
+ * quick access for both local space and uv space.
+ */
 struct MeshData {
  public:
   const MLoopTri *looptri;
@@ -144,6 +140,7 @@ struct MeshData {
   Vector primitives;
   Vector edges;
   Vector vertices;
+  /** Total number of uv islands detected. */
   int64_t uv_island_len;
 
   explicit MeshData(const MLoopTri *looptri,
@@ -213,7 +210,6 @@ struct MeshData {
 
   void init_edges()
   {
-/* TODO: use actual sized. */
 edges.reserve(looptri_len * 2);
 EdgeHash *eh = BLI_edgehash_new_ex(__func__, looptri_len * 3);
 for (int64_t i = 0; i < looptri_len; i++) {
@@ -251,10 +247,9 @@ struct MeshData {
   static const int64_t INVALID_UV_ISLAND_ID = -1;
   /**
* NOTE: doesn't support weird topology where unconnected mesh primitives 
share the same uv
-   * island. For a accurate implementation we should use uv_prim_lookup.
+   * island. For a accurate implementation we should use implement an 
uv_prim_lookup.
*/
-  static void _extract_uv_neighbors(Vector &prims_to_add,
-MeshPrimitive *primitive)
+  static void extract_uv_neighbors(Vector &prims_to_add, 
MeshPrimitive *primitive)
   {
 for (MeshEdge *edge : primitive->edges) {
   for (MeshPrimitive *other_primitive : edge->primitives) {
@@ -290,7 +285,7 @@ struct MeshData {
   while (!prims_to_add.is_empty()) {
 MeshPrimitive *primitive = prims_to_add.pop_last();
 primitive->uv_island_id = uv_island_id;
-_extract_uv_neighbors(prims_to_add, primitive);
+extract_uv_neighbors(prims_to_add, primitive);
   }
   uv_island_id++;
 }
@@ -303,7 +298,7 @@ struct UVVertex {
   /* Position in uv space. */
   float2 uv;
 
-  /* uv edges that are connected to this uvvertex. */
+  /* uv edges that share this UVVertex. */
   Vector uv_edges;
 
   explicit UVVertex()

___
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] [28105caaa39] master: Fix T99342: GPencil multiframe falloff is scaling wrongly in rotation

2022-07-07 Thread Antonio Vazquez
Commit: 28105caaa394b5a6c3d237fea7ddadecca7d0331
Author: Antonio Vazquez
Date:   Thu Jul 7 09:45:33 2022 +0200
Branches: master
https://developer.blender.org/rB28105caaa394b5a6c3d237fea7ddadecca7d0331

Fix T99342: GPencil multiframe falloff is scaling wrongly in rotation

The falloff was applied to scale by error. Now, the falloff is only applied to 
the rotation.

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

___
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