[Bf-blender-cvs] [17dddc94171] master: Fix: NLA Blend Domain Enable All Typo

2021-02-16 Thread Wayde Moss
Commit: 17dddc94171497c616eea8bcf47215ae118dd162
Author: Wayde Moss
Date:   Wed Feb 17 01:06:41 2021 -0500
Branches: master
https://developer.blender.org/rB17dddc94171497c616eea8bcf47215ae118dd162

Fix: NLA Blend Domain Enable All Typo

Introduced by my recent commit: rBc48360c2559a

Accidentally used 4 instead of `necs->length`.

===

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

===

diff --git a/source/blender/blenkernel/intern/anim_sys.c 
b/source/blender/blenkernel/intern/anim_sys.c
index 1d4893f5700..4d490f8f76a 100644
--- a/source/blender/blenkernel/intern/anim_sys.c
+++ b/source/blender/blenkernel/intern/anim_sys.c
@@ -2491,7 +2491,7 @@ void nlasnapshot_enable_all_blend_domain(NlaEvalSnapshot 
*snapshot)
   continue;
 }
 
-BLI_bitmap_set_all(necs->blend_domain.ptr, true, 4);
+BLI_bitmap_set_all(necs->blend_domain.ptr, true, necs->length);
   }
 }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [2da0f3e523f] master: Geometry Nodes: Support integer type in the Attribute Fill Node

2021-02-16 Thread Hans Goudey
Commit: 2da0f3e523f723743f73895941072b301edb596e
Author: Hans Goudey
Date:   Wed Feb 17 00:01:33 2021 -0600
Branches: master
https://developer.blender.org/rB2da0f3e523f723743f73895941072b301edb596e

Geometry Nodes: Support integer type in the Attribute Fill Node

This will be used by the material index attribute when it is added.

===

M   source/blender/makesrna/intern/rna_nodetree.c
M   source/blender/nodes/geometry/nodes/node_geo_attribute_fill.cc

===

diff --git a/source/blender/makesrna/intern/rna_nodetree.c 
b/source/blender/makesrna/intern/rna_nodetree.c
index e72f50e813d..b372ff4c273 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -1931,7 +1931,8 @@ static void 
rna_GeometryNodeAttributeRandomize_data_type_update(Main *bmain,
 
 static bool attribute_fill_type_supported(const EnumPropertyItem *item)
 {
-  return ELEM(item->value, CD_PROP_FLOAT, CD_PROP_FLOAT3, CD_PROP_COLOR, 
CD_PROP_BOOL);
+  return ELEM(
+  item->value, CD_PROP_FLOAT, CD_PROP_FLOAT3, CD_PROP_COLOR, CD_PROP_BOOL, 
CD_PROP_INT32);
 }
 static const EnumPropertyItem 
*rna_GeometryNodeAttributeFill_type_itemf(bContext *UNUSED(C),
 
PointerRNA *UNUSED(ptr),
diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_fill.cc 
b/source/blender/nodes/geometry/nodes/node_geo_attribute_fill.cc
index d2a7e40877f..e4cdd04b46b 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_attribute_fill.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_fill.cc
@@ -31,6 +31,7 @@ static bNodeSocketTemplate geo_node_attribute_fill_in[] = {
 {SOCK_FLOAT, N_("Value"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX},
 {SOCK_RGBA, N_("Value"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX},
 {SOCK_BOOLEAN, N_("Value"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX},
+{SOCK_INT, N_("Value"), 0, 0, 0, 0, -1000.0f, 1000.0f},
 {-1, ""},
 };
 
@@ -56,6 +57,7 @@ static void geo_node_attribute_fill_update(bNodeTree 
*UNUSED(ntree), bNode *node
   bNodeSocket *socket_value_float = socket_value_vector->next;
   bNodeSocket *socket_value_color4f = socket_value_float->next;
   bNodeSocket *socket_value_boolean = socket_value_color4f->next;
+  bNodeSocket *socket_value_int32 = socket_value_boolean->next;
 
   const CustomDataType data_type = static_cast(node->custom1);
 
@@ -63,6 +65,7 @@ static void geo_node_attribute_fill_update(bNodeTree 
*UNUSED(ntree), bNode *node
   nodeSetSocketAvailability(socket_value_float, data_type == CD_PROP_FLOAT);
   nodeSetSocketAvailability(socket_value_color4f, data_type == CD_PROP_COLOR);
   nodeSetSocketAvailability(socket_value_boolean, data_type == CD_PROP_BOOL);
+  nodeSetSocketAvailability(socket_value_int32, data_type == CD_PROP_INT32);
 }
 
 namespace blender::nodes {
@@ -124,6 +127,11 @@ static void fill_attribute(GeometryComponent , 
const GeoNodeExecParams
   attribute_span.fill(value);
   break;
 }
+case CD_PROP_INT32: {
+  const int value = params.get_input("Value_004");
+  MutableSpan attribute_span = 
attribute->get_span_for_write_only();
+  attribute_span.fill(value);
+}
 default:
   break;
   }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [47a269745ef] master: Fix T85716: "Applied Modifier:" report hides more important message

2021-02-16 Thread Hans Goudey
Commit: 47a269745ef2a6181fd139dca4d6975d6a8e1038
Author: Hans Goudey
Date:   Tue Feb 16 23:39:58 2021 -0600
Branches: master
https://developer.blender.org/rB47a269745ef2a6181fd139dca4d6975d6a8e1038

Fix T85716: "Applied Modifier:" report hides more important message

Since "Applied Modifier" was always added last, it obscured more important
messages when using the shortcut to delete modifiers. The purpose of the
report when using the shortcut was to make it clear that something
happened. Since another report does that anyway, only display the
"Applied Modifier" report if the report list length hasn't changed.

===

M   source/blender/editors/object/object_gpencil_modifier.c
M   source/blender/editors/object/object_modifier.c

===

diff --git a/source/blender/editors/object/object_gpencil_modifier.c 
b/source/blender/editors/object/object_gpencil_modifier.c
index a869a4c2583..3995728c428 100644
--- a/source/blender/editors/object/object_gpencil_modifier.c
+++ b/source/blender/editors/object/object_gpencil_modifier.c
@@ -730,14 +730,18 @@ static int gpencil_modifier_apply_exec(bContext *C, 
wmOperator *op)
   Object *ob = ED_object_active_context(C);
   GpencilModifierData *md = gpencil_edit_modifier_property_get(op, ob, 0);
   int apply_as = RNA_enum_get(op->ptr, "apply_as");
+  const bool do_report = RNA_boolean_get(op->ptr, "report");
 
   if (md == NULL) {
 return OPERATOR_CANCELLED;
   }
 
-  /* Store name temporarily for report. */
+  int reports_len;
   char name[MAX_NAME];
-  strcpy(name, md->name);
+  if (do_report) {
+reports_len = BLI_listbase_count(>reports->list);
+strcpy(name, md->name); /* Store name temporarily since the modifier is 
removed. */
+  }
 
   if (!ED_object_gpencil_modifier_apply(bmain, op->reports, depsgraph, ob, md, 
apply_as)) {
 return OPERATOR_CANCELLED;
@@ -746,8 +750,12 @@ static int gpencil_modifier_apply_exec(bContext *C, 
wmOperator *op)
   DEG_id_tag_update(>id, ID_RECALC_GEOMETRY);
   WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
 
-  if (RNA_boolean_get(op->ptr, "report")) {
-BKE_reportf(op->reports, RPT_INFO, "Applied modifier: %s", name);
+  if (do_report) {
+/* Only add this report if the operator didn't cause another one. The 
purpose here is
+ * to alert that something happened, and the previous report will do that 
anyway. */
+if (BLI_listbase_count(>reports->list) == reports_len) {
+  BKE_reportf(op->reports, RPT_INFO, "Applied modifier: %s", name);
+}
   }
 
   return OPERATOR_FINISHED;
diff --git a/source/blender/editors/object/object_modifier.c 
b/source/blender/editors/object/object_modifier.c
index 7e0e52d3874..7673649c261 100644
--- a/source/blender/editors/object/object_modifier.c
+++ b/source/blender/editors/object/object_modifier.c
@@ -1383,14 +1383,18 @@ static int modifier_apply_exec_ex(bContext *C, 
wmOperator *op, int apply_as, boo
   Scene *scene = CTX_data_scene(C);
   Object *ob = ED_object_active_context(C);
   ModifierData *md = edit_modifier_property_get(op, ob, 0);
+  const bool do_report = RNA_boolean_get(op->ptr, "report");
 
   if (md == NULL) {
 return OPERATOR_CANCELLED;
   }
 
-  /* Store name temporarily for report. */
+  int reports_len;
   char name[MAX_NAME];
-  strcpy(name, md->name);
+  if (do_report) {
+reports_len = BLI_listbase_count(>reports->list);
+strcpy(name, md->name); /* Store name temporarily since the modifier is 
removed. */
+  }
 
   if (!ED_object_modifier_apply(
   bmain, op->reports, depsgraph, scene, ob, md, apply_as, 
keep_modifier)) {
@@ -1401,8 +1405,12 @@ static int modifier_apply_exec_ex(bContext *C, 
wmOperator *op, int apply_as, boo
   DEG_relations_tag_update(bmain);
   WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
 
-  if (RNA_boolean_get(op->ptr, "report")) {
-BKE_reportf(op->reports, RPT_INFO, "Applied modifier: %s", name);
+  if (do_report) {
+/* Only add this report if the operator didn't cause another one. The 
purpose here is
+ * to alert that something happened, and the previous report will do that 
anyway. */
+if (BLI_listbase_count(>reports->list) == reports_len) {
+  BKE_reportf(op->reports, RPT_INFO, "Applied modifier: %s", name);
+}
   }
 
   return OPERATOR_FINISHED;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [c48360c2559] master: Fix: NLA Blends Non-Animated Upper Channel Values

2021-02-16 Thread Wayde Moss
Commit: c48360c2559acbe1cb8014ca0e81152f2febf199
Author: Wayde Moss
Date:   Tue Feb 16 23:58:29 2021 -0500
Branches: master
https://developer.blender.org/rBc48360c2559acbe1cb8014ca0e81152f2febf199

Fix: NLA Blends Non-Animated Upper Channel Values

Issue introduced by my commit: rB40b7929cc040

**User-level Problem**:
The issue resulted in a full-replace upper strip with only a Z location
channel full-replacing the XY location channels of the lower stack.
replaced to default. The expected behavior is that only the Z location
channel is affected.

**Technical-level Problem**:
Before the problematic commit, fcurves were blended as they were read.
So only existing animated channels would blend. My recent commit
changed the process to read all fcurve values into an isolated
upper_snapshot then blend with the lower stack. There is no data stored
to know whether the upper snapshot channel values were sampled from
fcurves or were default values. Only those sampled from fcurves should
be blended.

**Solution**:
Added a `blend_domain` bitmask member to NlaEvalChannelSnapshot.
The blending function only blends values within the `blend_domain`.
Sampled fcurve values are now marked as within the `blend_domain`.
We also now always copy the lower snapshot to the result snapshot which
only matters when they aren't the same. Currently, it's always the same
so the change is more for future unseen cases.

Reviewed By: sybren, #animation_rigging

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

===

M   source/blender/blenkernel/intern/anim_sys.c
M   source/blender/blenkernel/nla_private.h

===

diff --git a/source/blender/blenkernel/intern/anim_sys.c 
b/source/blender/blenkernel/intern/anim_sys.c
index 965dc4e0bec..1d4893f5700 100644
--- a/source/blender/blenkernel/intern/anim_sys.c
+++ b/source/blender/blenkernel/intern/anim_sys.c
@@ -1050,6 +1050,7 @@ static NlaEvalChannelSnapshot 
*nlaevalchan_snapshot_new(NlaEvalChannel *nec)
 
   nec_snapshot->channel = nec;
   nec_snapshot->length = length;
+  nlavalidmask_init(_snapshot->blend_domain, length);
 
   return nec_snapshot;
 }
@@ -1059,6 +1060,7 @@ static void 
nlaevalchan_snapshot_free(NlaEvalChannelSnapshot *nec_snapshot)
 {
   BLI_assert(!nec_snapshot->is_base);
 
+  nlavalidmask_free(_snapshot->blend_domain);
   MEM_freeN(nec_snapshot);
 }
 
@@ -1751,14 +1753,22 @@ static void nlasnapshot_from_action(PointerRNA *ptr,
   continue;
 }
 
-NlaEvalChannelSnapshot *necs = nlaeval_snapshot_ensure_channel(r_snapshot, 
nec);
 if (!nlaevalchan_validate_index_ex(nec, fcu->array_index)) {
   continue;
 }
 
+NlaEvalChannelSnapshot *necs = nlaeval_snapshot_ensure_channel(r_snapshot, 
nec);
+
 float value = evaluate_fcurve(fcu, modified_evaltime);
 evaluate_value_fmodifiers(, modifiers, fcu, , evaltime);
 necs->values[fcu->array_index] = value;
+
+if (nec->mix_mode == NEC_MIX_QUATERNION) {
+  BLI_bitmap_set_all(necs->blend_domain.ptr, true, 4);
+}
+else {
+  BLI_BITMAP_ENABLE(necs->blend_domain.ptr, fcu->array_index);
+}
   }
 }
 
@@ -1863,6 +1873,8 @@ static void nlastrip_evaluate_transition(PointerRNA *ptr,
 
   /** Replace \a snapshot2 NULL channels with base or default values so all 
channels blend. */
   nlasnapshot_ensure_channels(channels, );
+  /** Mark all \a snapshot2 channel's values to blend. */
+  nlasnapshot_enable_all_blend_domain();
   nlasnapshot_blend(
   channels, , , NLASTRIP_MODE_REPLACE, 
nes->strip_time, snapshot);
 
@@ -2471,6 +2483,18 @@ static void animsys_calculate_nla(PointerRNA *ptr,
 
 /* -- */
 
+void nlasnapshot_enable_all_blend_domain(NlaEvalSnapshot *snapshot)
+{
+  for (int i = 0; i < snapshot->size; i++) {
+NlaEvalChannelSnapshot *necs = nlaeval_snapshot_get(snapshot, i);
+if (necs == NULL) {
+  continue;
+}
+
+BLI_bitmap_set_all(necs->blend_domain.ptr, true, 4);
+  }
+}
+
 void nlasnapshot_ensure_channels(NlaEvalData *eval_data, NlaEvalSnapshot 
*snapshot)
 {
   LISTBASE_FOREACH (NlaEvalChannel *, nec, _data->channels) {
@@ -2479,7 +2503,12 @@ void nlasnapshot_ensure_channels(NlaEvalData *eval_data, 
NlaEvalSnapshot *snapsh
 }
 
 /** Blends the \a lower_snapshot with the \a upper_snapshot into \a 
r_blended_snapshot according
- * to the given \a upper_blendmode and \a upper_influence. */
+ * to the given \a upper_blendmode and \a upper_influence.
+ *
+ * For \a upper_snapshot, blending limited to values in the \a blend_domain. 
For Replace blendmode,
+ * this allows the upper snapshot to have a location XYZ channel where only a 
subset of values are
+ * blended.
+ */
 void nlasnapshot_blend(NlaEvalData *eval_data,
NlaEvalSnapshot *lower_snapshot,
NlaEvalSnapshot *upper_snapshot,
@@ -2507,19 +2536,30 @@ void nlasnapshot_blend(NlaEvalData 

[Bf-blender-cvs] [585db47d992] master: Cleanup: Return bool instead of int

2021-02-16 Thread Hans Goudey
Commit: 585db47d992700698cedc3e8eee03df92d067833
Author: Hans Goudey
Date:   Tue Feb 16 23:02:33 2021 -0600
Branches: master
https://developer.blender.org/rB585db47d992700698cedc3e8eee03df92d067833

Cleanup: Return bool instead of int

===

M   source/blender/editors/include/ED_object.h
M   source/blender/editors/object/object_gpencil_modifier.c

===

diff --git a/source/blender/editors/include/ED_object.h 
b/source/blender/editors/include/ED_object.h
index 73326a2d5f2..5dfce6071f0 100644
--- a/source/blender/editors/include/ED_object.h
+++ b/source/blender/editors/include/ED_object.h
@@ -462,25 +462,25 @@ bool ED_object_gpencil_modifier_remove(struct ReportList 
*reports,
struct Object *ob,
struct GpencilModifierData *md);
 void ED_object_gpencil_modifier_clear(struct Main *bmain, struct Object *ob);
-int ED_object_gpencil_modifier_move_down(struct ReportList *reports,
- struct Object *ob,
- struct GpencilModifierData *md);
-int ED_object_gpencil_modifier_move_up(struct ReportList *reports,
-   struct Object *ob,
-   struct GpencilModifierData *md);
+bool ED_object_gpencil_modifier_move_down(struct ReportList *reports,
+  struct Object *ob,
+  struct GpencilModifierData *md);
+bool ED_object_gpencil_modifier_move_up(struct ReportList *reports,
+struct Object *ob,
+struct GpencilModifierData *md);
 bool ED_object_gpencil_modifier_move_to_index(struct ReportList *reports,
   struct Object *ob,
   struct GpencilModifierData *md,
   const int index);
-int ED_object_gpencil_modifier_apply(struct Main *bmain,
- struct ReportList *reports,
- struct Depsgraph *depsgraph,
+bool ED_object_gpencil_modifier_apply(struct Main *bmain,
+  struct ReportList *reports,
+  struct Depsgraph *depsgraph,
+  struct Object *ob,
+  struct GpencilModifierData *md,
+  int mode);
+bool ED_object_gpencil_modifier_copy(struct ReportList *reports,
  struct Object *ob,
- struct GpencilModifierData *md,
- int mode);
-int ED_object_gpencil_modifier_copy(struct ReportList *reports,
-struct Object *ob,
-struct GpencilModifierData *md);
+ struct GpencilModifierData *md);
 void ED_object_gpencil_modifier_copy_to_object(struct Object *ob_dst,
struct GpencilModifierData *md);
 
diff --git a/source/blender/editors/object/object_gpencil_modifier.c 
b/source/blender/editors/object/object_gpencil_modifier.c
index f70e86bcb05..a869a4c2583 100644
--- a/source/blender/editors/object/object_gpencil_modifier.c
+++ b/source/blender/editors/object/object_gpencil_modifier.c
@@ -173,28 +173,28 @@ void ED_object_gpencil_modifier_clear(Main *bmain, Object 
*ob)
   DEG_relations_tag_update(bmain);
 }
 
-int ED_object_gpencil_modifier_move_up(ReportList *UNUSED(reports),
-   Object *ob,
-   GpencilModifierData *md)
+bool ED_object_gpencil_modifier_move_up(ReportList *UNUSED(reports),
+Object *ob,
+GpencilModifierData *md)
 {
   if (md->prev) {
 BLI_remlink(>greasepencil_modifiers, md);
 BLI_insertlinkbefore(>greasepencil_modifiers, md->prev, md);
   }
 
-  return 1;
+  return true;
 }
 
-int ED_object_gpencil_modifier_move_down(ReportList *UNUSED(reports),
- Object *ob,
- GpencilModifierData *md)
+bool ED_object_gpencil_modifier_move_down(ReportList *UNUSED(reports),
+  Object *ob,
+  GpencilModifierData *md)
 {
   if (md->next) {
 BLI_remlink(>greasepencil_modifiers, md);
 BLI_insertlinkafter(>greasepencil_modifiers, md->next, md);
   }
 
-  return 1;
+  return true;
 }
 
 bool ED_object_gpencil_modifier_move_to_index(ReportList *reports,
@@ -234,57 +234,57 @@ bool 

[Bf-blender-cvs] [2a3254a4b10] temp_T76472_graph_editor_fcurve_extrapolation: Graph Editor: FCurve Extrapolation Visibility T76472

2021-02-16 Thread Wayde Moss
Commit: 2a3254a4b1089b52b2fe74324b4a895cec0dedd8
Author: Wayde Moss
Date:   Fri Feb 12 16:38:04 2021 -0500
Branches: temp_T76472_graph_editor_fcurve_extrapolation
https://developer.blender.org/rB2a3254a4b1089b52b2fe74324b4a895cec0dedd8

Graph Editor: FCurve Extrapolation Visibility T76472

Adds toggle to graph editor (View->Show Extrapolation). When disabled, then 
fcurves only draw over the keyframe range. For baked fcurves, the range is all 
sampled points. For ghost fcurves, extraplation is always drawn since the 
sampled points may include extrapolated points of the original fcurve.

Show Extrapolation is the default.
___

**Technical Notes**:
- `draw_fcurve_curve()`: There are now explicit checks for floating point poor 
accuracy cases. Without them, then there would be visual flickering when no 
extrapolation is drawn and there is a discontinuity at the end (due to cyclic 
modifier). This removes the need for the `+samplefreq` in `etime = v2d->curxmax 
+ samplefreq`. It also removes the need to do so on `fcu_start/fcu_end`.
- `draw_fcurve_curve()`: Besides the previous note, the only other meaningful 
change is the `if(!draw_extrapolation)` branch which just changes `stime/etime` 
to match the keyframe bounds instead.

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

===

M   release/scripts/startup/bl_ui/space_graph.py
M   source/blender/editors/space_graph/graph_draw.c
M   source/blender/makesdna/DNA_space_types.h
M   source/blender/makesrna/intern/rna_space.c

===

diff --git a/release/scripts/startup/bl_ui/space_graph.py 
b/release/scripts/startup/bl_ui/space_graph.py
index 6ece6a4c841..31e81d1454e 100644
--- a/release/scripts/startup/bl_ui/space_graph.py
+++ b/release/scripts/startup/bl_ui/space_graph.py
@@ -135,6 +135,8 @@ class GRAPH_MT_view(Menu):
 
 layout.separator()
 
+layout.prop(st, "show_extrapolation")
+
 layout.prop(st, "show_handles")
 
 layout.prop(st, "use_only_selected_curves_handles")
diff --git a/source/blender/editors/space_graph/graph_draw.c 
b/source/blender/editors/space_graph/graph_draw.c
index 33e724459a9..e0a37e7306d 100644
--- a/source/blender/editors/space_graph/graph_draw.c
+++ b/source/blender/editors/space_graph/graph_draw.c
@@ -35,6 +35,7 @@
 #include "DNA_userdef_types.h"
 #include "DNA_windowmanager_types.h"
 
+#include "BKE_action.h"
 #include "BKE_anim_data.h"
 #include "BKE_context.h"
 #include "BKE_curve.h"
@@ -582,8 +583,13 @@ static void draw_fcurve_samples(SpaceGraph *sipo, ARegion 
*region, FCurve *fcu)
 
 /* Helper func - just draw the F-Curve by sampling the visible region
  * (for drawing curves with modifiers). */
-static void draw_fcurve_curve(
-bAnimContext *ac, ID *id, FCurve *fcu_, View2D *v2d, uint pos, const bool 
use_nla_remap)
+static void draw_fcurve_curve(bAnimContext *ac,
+  ID *id,
+  FCurve *fcu_,
+  View2D *v2d,
+  uint pos,
+  const bool use_nla_remap,
+  const bool draw_extrapolation)
 {
   SpaceGraph *sipo = (SpaceGraph *)ac->sl;
   short mapping_flag = ANIM_get_normalization_flags(ac);
@@ -644,40 +650,90 @@ static void draw_fcurve_curve(
 
   /* the start/end times are simply the horizontal extents of the 'cur' rect */
   float stime = v2d->cur.xmin;
-  float etime = v2d->cur.xmax +
-samplefreq; /* + samplefreq here so that last item gets 
included... */
+  float etime = v2d->cur.xmax;
 
-  /* at each sampling interval, add a new vertex
-   * - apply the unit correction factor to the calculated values so that
-   *   the displayed values appear correctly in the viewport
-   */
+  AnimData *adt = use_nla_remap ? BKE_animdata_from_id(id) : NULL;
+
+  /* If not drawing extrapolation, then change fcurve drawing bounds to its 
keyframe bounds clamped
+   * by graph editor bounds. */
+  if (!draw_extrapolation) {
+float fcu_start = 0;
+float fcu_end = 0;
+BKE_fcurve_calc_range(fcu_, _start, _end, false, false);
 
-  int n = roundf((etime - stime) / samplefreq);
+fcu_start = BKE_nla_tweakedit_remap(adt, fcu_start, NLATIME_CONVERT_MAP);
+fcu_end = BKE_nla_tweakedit_remap(adt, fcu_end, NLATIME_CONVERT_MAP);
 
-  if (n > 0) {
-immBegin(GPU_PRIM_LINE_STRIP, (n + 1));
+/* Account for reversed NLA strip effect. */
+if (fcu_end < fcu_start) {
+  SWAP(float, fcu_start, fcu_end);
+}
 
-AnimData *adt = use_nla_remap ? BKE_animdata_from_id(id) : NULL;
-/* NLA remapping is linear so we don't have to remap per iteration. */
-const float eval_start = BKE_nla_tweakedit_remap(adt, stime, 
NLATIME_CONVERT_UNMAP);
-const float eval_freq = BKE_nla_tweakedit_remap(
-adt, stime + samplefreq, 

[Bf-blender-cvs] [bfc7994d937] master: Cleanup: use edituv prefix for stretch area/angle data

2021-02-16 Thread Campbell Barton
Commit: bfc7994d937910e8d26112788e5283b9c975cc06
Author: Campbell Barton
Date:   Wed Feb 17 15:36:18 2021 +1100
Branches: master
https://developer.blender.org/rBbfc7994d937910e8d26112788e5283b9c975cc06

Cleanup: use edituv prefix for stretch area/angle data

===

M   source/blender/draw/intern/draw_cache_extract.h
M   source/blender/draw/intern/draw_cache_extract_mesh.c
M   source/blender/draw/intern/draw_cache_impl_mesh.c

===

diff --git a/source/blender/draw/intern/draw_cache_extract.h 
b/source/blender/draw/intern/draw_cache_extract.h
index a0679ba6442..c929fe7dfd3 100644
--- a/source/blender/draw/intern/draw_cache_extract.h
+++ b/source/blender/draw/intern/draw_cache_extract.h
@@ -109,8 +109,8 @@ typedef struct MeshBufferCache {
 /* Only for edit mode. */
 GPUVertBuf *edit_data; /* extend */
 GPUVertBuf *edituv_data;
-GPUVertBuf *stretch_area;
-GPUVertBuf *stretch_angle;
+GPUVertBuf *edituv_stretch_area;
+GPUVertBuf *edituv_stretch_angle;
 GPUVertBuf *mesh_analysis;
 GPUVertBuf *fdots_pos;
 GPUVertBuf *fdots_nor;
diff --git a/source/blender/draw/intern/draw_cache_extract_mesh.c 
b/source/blender/draw/intern/draw_cache_extract_mesh.c
index c1087918840..f167ea3d540 100644
--- a/source/blender/draw/intern/draw_cache_extract_mesh.c
+++ b/source/blender/draw/intern/draw_cache_extract_mesh.c
@@ -3849,9 +3849,9 @@ static const MeshExtract extract_edituv_data = {
 /** \name Extract Edit UV area stretch
  * \{ */
 
-static void *extract_stretch_area_init(const MeshRenderData *mr,
-   struct MeshBatchCache *UNUSED(cache),
-   void *buf)
+static void *extract_edituv_stretch_area_init(const MeshRenderData *mr,
+  struct MeshBatchCache 
*UNUSED(cache),
+  void *buf)
 {
   static GPUVertFormat format = {0};
   if (format.attr_len == 0) {
@@ -3880,10 +3880,10 @@ BLI_INLINE float area_ratio_to_stretch(float ratio, 
float tot_ratio, float inv_t
   return (ratio > 1.0f) ? (1.0f / ratio) : ratio;
 }
 
-static void mesh_stretch_area_finish(const MeshRenderData *mr,
- struct MeshBatchCache *cache,
- void *buf,
- void *UNUSED(data))
+static void mesh_edituv_stretch_area_finish(const MeshRenderData *mr,
+struct MeshBatchCache *cache,
+void *buf,
+void *UNUSED(data))
 {
   float tot_area = 0.0f, tot_uv_area = 0.0f;
   float *area_ratio = MEM_mallocN(sizeof(float) * mr->poly_len, __func__);
@@ -3952,9 +3952,9 @@ static void mesh_stretch_area_finish(const MeshRenderData 
*mr,
   MEM_freeN(area_ratio);
 }
 
-static const MeshExtract extract_stretch_area = {
-.init = extract_stretch_area_init,
-.finish = mesh_stretch_area_finish,
+static const MeshExtract extract_edituv_stretch_area = {
+.init = extract_edituv_stretch_area_init,
+.finish = mesh_edituv_stretch_area_finish,
 .data_flag = 0,
 .use_threading = false,
 };
@@ -4001,9 +4001,9 @@ static short v2_to_short_angle(const float v[2])
   return atan2f(v[1], v[0]) * (float)M_1_PI * SHRT_MAX;
 }
 
-static void edituv_get_stretch_angle(float auv[2][2],
- const float av[2][3],
- UVStretchAngle *r_stretch)
+static void edituv_get_edituv_stretch_angle(float auv[2][2],
+const float av[2][3],
+UVStretchAngle *r_stretch)
 {
   /* Send UV's to the shader and let it compute the aspect corrected angle. */
   r_stretch->uv_angles[0] = v2_to_short_angle(auv[0]);
@@ -4019,9 +4019,9 @@ static void edituv_get_stretch_angle(float auv[2][2],
 #endif
 }
 
-static void *extract_stretch_angle_init(const MeshRenderData *mr,
-struct MeshBatchCache *UNUSED(cache),
-void *buf)
+static void *extract_edituv_stretch_angle_init(const MeshRenderData *mr,
+   struct MeshBatchCache 
*UNUSED(cache),
+   void *buf)
 {
   static GPUVertFormat format = {0};
   if (format.attr_len == 0) {
@@ -4048,9 +4048,9 @@ static void *extract_stretch_angle_init(const 
MeshRenderData *mr,
   return data;
 }
 
-static void extract_stretch_angle_iter_poly_bm(const MeshRenderData *mr,
-   const ExtractPolyBMesh_Params 
*params,
-   void *_data)
+static void extract_edituv_stretch_angle_iter_poly_bm(const MeshRenderData *mr,
+

[Bf-blender-cvs] [2853ad775ef] master: Merge branch 'blender-v2.92-release'

2021-02-16 Thread Campbell Barton
Commit: 2853ad775ef91a154d9bfa89483ce8c0fa7eec5e
Author: Campbell Barton
Date:   Wed Feb 17 15:19:21 2021 +1100
Branches: master
https://developer.blender.org/rB2853ad775ef91a154d9bfa89483ce8c0fa7eec5e

Merge branch 'blender-v2.92-release'

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [6ce06957c9b] blender-v2.92-release: Fix T85680: Crash displaying UV stretch/area with modifiers

2021-02-16 Thread Campbell Barton
Commit: 6ce06957c9bf9c752f0a7ee2cb186948d0d67983
Author: Campbell Barton
Date:   Wed Feb 17 15:12:39 2021 +1100
Branches: blender-v2.92-release
https://developer.blender.org/rB6ce06957c9bf9c752f0a7ee2cb186948d0d67983

Fix T85680: Crash displaying UV stretch/area with modifiers

This uses the same logic as drawing UV's,
where non-bmesh defaults to mesh.

===

M   source/blender/draw/intern/draw_cache_extract_mesh.c

===

diff --git a/source/blender/draw/intern/draw_cache_extract_mesh.c 
b/source/blender/draw/intern/draw_cache_extract_mesh.c
index 9e2ac26f9f0..40d7614f93f 100644
--- a/source/blender/draw/intern/draw_cache_extract_mesh.c
+++ b/source/blender/draw/intern/draw_cache_extract_mesh.c
@@ -3903,7 +3903,8 @@ static void mesh_stretch_area_finish(const MeshRenderData 
*mr,
   area_ratio[f] = area_ratio_get(area, uvarea);
 }
   }
-  else if (mr->extract_type == MR_EXTRACT_MAPPED) {
+  else {
+BLI_assert(ELEM(mr->extract_type, MR_EXTRACT_MAPPED, MR_EXTRACT_MESH));
 const MLoopUV *uv_data = CustomData_get_layer(>me->ldata, CD_MLOOPUV);
 const MPoly *mp = mr->mpoly;
 for (int mp_index = 0; mp_index < mr->poly_len; mp_index++, mp++) {
@@ -3914,10 +3915,6 @@ static void mesh_stretch_area_finish(const 
MeshRenderData *mr,
   area_ratio[mp_index] = area_ratio_get(area, uvarea);
 }
   }
-  else {
-/* Should not happen. */
-BLI_assert(0);
-  }
 
   cache->tot_area = tot_area;
   cache->tot_uv_area = tot_uv_area;
@@ -3942,7 +3939,8 @@ static void mesh_stretch_area_finish(const MeshRenderData 
*mr,
   }
 }
   }
-  else if (mr->extract_type == MR_EXTRACT_MAPPED) {
+  else {
+BLI_assert(ELEM(mr->extract_type, MR_EXTRACT_MAPPED, MR_EXTRACT_MESH));
 const MPoly *mp = mr->mpoly;
 for (int mp_index = 0, l_index = 0; mp_index < mr->poly_len; mp_index++, 
mp++) {
   for (int i = 0; i < mp->totloop; i++, l_index++) {
@@ -3950,10 +3948,6 @@ static void mesh_stretch_area_finish(const 
MeshRenderData *mr,
   }
 }
   }
-  else {
-/* Should not happen. */
-BLI_assert(0);
-  }
 
   MEM_freeN(area_ratio);
 }
@@ -4047,11 +4041,9 @@ static void *extract_stretch_angle_init(const 
MeshRenderData *mr,
   if (mr->extract_type == MR_EXTRACT_BMESH) {
 data->cd_ofs = CustomData_get_offset(>bm->ldata, CD_MLOOPUV);
   }
-  else if (mr->extract_type == MR_EXTRACT_MAPPED) {
-data->luv = CustomData_get_layer(>me->ldata, CD_MLOOPUV);
-  }
   else {
-BLI_assert(0);
+BLI_assert(ELEM(mr->extract_type, MR_EXTRACT_MAPPED, MR_EXTRACT_MESH));
+data->luv = CustomData_get_layer(>me->ldata, CD_MLOOPUV);
   }
   return data;
 }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [99b4c856ef9] master: Cleanup: remove commented function

2021-02-16 Thread Campbell Barton
Commit: 99b4c856ef9140e96eb48c95cff04031ae36eeef
Author: Campbell Barton
Date:   Wed Feb 17 14:49:34 2021 +1100
Branches: master
https://developer.blender.org/rB99b4c856ef9140e96eb48c95cff04031ae36eeef

Cleanup: remove commented function

===

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

===

diff --git a/source/blender/blenkernel/intern/displist.c 
b/source/blender/blenkernel/intern/displist.c
index 19ead2d972a..1fcc1b1bcef 100644
--- a/source/blender/blenkernel/intern/displist.c
+++ b/source/blender/blenkernel/intern/displist.c
@@ -293,169 +293,6 @@ bool BKE_displist_surfindex_get(DispList *dl, int a, int 
*b, int *p1, int *p2, i
 #  pragma intel optimization_level 1
 #endif
 
-// static void curve_to_displist(Curve *cu,
-//   ListBase *nubase,
-//   const bool for_render,
-//   ListBase *dispbase)
-// {
-//   DispList *dl;
-//   BezTriple *bezt, *prevbezt;
-//   BPoint *bp;
-//   float *data;
-//   int a, len, resolu;
-//   const bool editmode = (!for_render && (cu->editnurb || cu->editfont));
-
-//   LISTBASE_FOREACH (Nurb *, nu, nubase) {
-// if (nu->hide != 0 && editmode) {
-//   continue;
-// }
-
-// if (for_render && cu->resolu_ren != 0) {
-//   resolu = cu->resolu_ren;
-// }
-// else {
-//   resolu = nu->resolu;
-// }
-
-// if (!BKE_nurb_check_valid_u(nu)) {
-//   /* pass */
-// }
-// else if (nu->type == CU_BEZIER) {
-//   /* count */
-//   len = 0;
-//   a = nu->pntsu - 1;
-//   if (nu->flagu & CU_NURB_CYCLIC) {
-// a++;
-//   }
-
-//   prevbezt = nu->bezt;
-//   bezt = prevbezt + 1;
-//   while (a--) {
-// if (a == 0 && (nu->flagu & CU_NURB_CYCLIC)) {
-//   bezt = nu->bezt;
-// }
-
-// if (prevbezt->h2 == HD_VECT && bezt->h1 == HD_VECT) {
-//   len++;
-// }
-// else {
-//   len += resolu;
-// }
-
-// if (a == 0 && (nu->flagu & CU_NURB_CYCLIC) == 0) {
-//   len++;
-// }
-
-// prevbezt = bezt;
-// bezt++;
-//   }
-
-//   dl = MEM_callocN(sizeof(DispList), "makeDispListbez");
-//   /* len+1 because of 'forward_diff_bezier' function */
-//   dl->verts = MEM_mallocN((len + 1) * sizeof(float[3]), "dlverts");
-//   BLI_addtail(dispbase, dl);
-//   dl->parts = 1;
-//   dl->nr = len;
-//   dl->col = nu->mat_nr;
-//   dl->charidx = nu->charidx;
-
-//   data = dl->verts;
-
-//   /* check that (len != 2) so we don't immediately loop back on 
ourselves */
-//   if (nu->flagu & CU_NURB_CYCLIC && (dl->nr != 2)) {
-// dl->type = DL_POLY;
-// a = nu->pntsu;
-//   }
-//   else {
-// dl->type = DL_SEGM;
-// a = nu->pntsu - 1;
-//   }
-
-//   prevbezt = nu->bezt;
-//   bezt = prevbezt + 1;
-
-//   while (a--) {
-// if (a == 0 && dl->type == DL_POLY) {
-//   bezt = nu->bezt;
-// }
-
-// if (prevbezt->h2 == HD_VECT && bezt->h1 == HD_VECT) {
-//   copy_v3_v3(data, prevbezt->vec[1]);
-//   data += 3;
-// }
-// else {
-//   int j;
-//   for (j = 0; j < 3; j++) {
-// BKE_curve_forward_diff_bezier(prevbezt->vec[1][j],
-//   prevbezt->vec[2][j],
-//   bezt->vec[0][j],
-//   bezt->vec[1][j],
-//   data + j,
-//   resolu,
-//   sizeof(float[3]));
-//   }
-
-//   data += 3 * resolu;
-// }
-
-// if (a == 0 && dl->type == DL_SEGM) {
-//   copy_v3_v3(data, bezt->vec[1]);
-// }
-
-// prevbezt = bezt;
-// bezt++;
-//   }
-// }
-// else if (nu->type == CU_NURBS) {
-//   len = (resolu * SEGMENTSU(nu));
-
-//   dl = MEM_callocN(sizeof(DispList), "makeDispListsurf");
-//   dl->verts = MEM_mallocN(len * sizeof(float[3]), "dlverts");
-//   BLI_addtail(dispbase, dl);
-//   dl->parts = 1;
-
-//   dl->nr = len;
-//   dl->col = nu->mat_nr;
-//   dl->charidx = nu->charidx;
-
-//   data = dl->verts;
-//   if (nu->flagu & CU_NURB_CYCLIC) {
-// dl->type = DL_POLY;
-//   }
-//   else {
-// dl->type = DL_SEGM;
-//   }
-//   BKE_nurb_makeCurve(nu, data, NULL, NULL, NULL, resolu, 
sizeof(float[3]));
-// }
-// else if (nu->type == CU_POLY) {
-//   len = nu->pntsu;
-//   dl = MEM_callocN(sizeof(DispList), "makeDispListpoly");
-//   dl->verts = MEM_mallocN(len * sizeof(float[3]), "dlverts");
-//   BLI_addtail(dispbase, dl);
-//   

[Bf-blender-cvs] [20a6255d49a] master: Cleanup: spelling

2021-02-16 Thread Campbell Barton
Commit: 20a6255d49aaa1ca0ad72e75be064b2c1a56353f
Author: Campbell Barton
Date:   Wed Feb 17 15:04:29 2021 +1100
Branches: master
https://developer.blender.org/rB20a6255d49aaa1ca0ad72e75be064b2c1a56353f

Cleanup: spelling

===

M   intern/cycles/kernel/svm/svm_noise.h
M   intern/ghost/intern/GHOST_ImeWin32.h
M   intern/ghost/intern/GHOST_WindowWin32.h
M   source/blender/blenfont/intern/blf_dir.c
M   source/blender/blenlib/intern/uvproject.c
M   source/blender/bmesh/intern/bmesh_marking.c
M   source/blender/draw/engines/eevee/eevee_depth_of_field.c
M   source/blender/draw/engines/eevee/eevee_renderpasses.c
M   source/blender/editors/animation/keyframes_edit.c
M   source/blender/editors/armature/pose_select.c
M   source/blender/editors/mesh/editmesh_loopcut.c
M   source/blender/editors/space_node/node_draw.cc
M   source/blender/editors/space_outliner/outliner_dragdrop.c
M   source/blender/editors/transform/transform_convert_armature.c
M   source/blender/editors/transform/transform_gizmo_extrude_3d.c
M   source/blender/gpu/intern/gpu_matrix.cc
M   source/blender/gpu/intern/gpu_shader_interface.hh
M   source/blender/gpu/opengl/gl_texture.cc
M   source/blender/makesdna/DNA_color_types.h

===

diff --git a/intern/cycles/kernel/svm/svm_noise.h 
b/intern/cycles/kernel/svm/svm_noise.h
index 7ad61f23cc1..94d8bfde555 100644
--- a/intern/cycles/kernel/svm/svm_noise.h
+++ b/intern/cycles/kernel/svm/svm_noise.h
@@ -616,7 +616,7 @@ ccl_device_noinline float perlin_3d(float x, float y, float 
z)
  *Point  Offset from v0
  * v0 (0, 0, 0, 0)
  * v1 (0, 0, 1, 0)  The full AVX type is computed by inserting the 
following
- * v2 (0, 1, 0, 0)  sse types into both the low and high parts of the 
AVX.
+ * v2 (0, 1, 0, 0)  SSE types into both the low and high parts of the 
AVX.
  * v3 (0, 1, 1, 0)
  * v4 (1, 0, 0, 0)
  * v5 (1, 0, 1, 0)  (0, 1, 0, 1) = shuffle<0, 2, 0, 2>(shuffle<2, 2, 
2, 2>(V, V + 1))
diff --git a/intern/ghost/intern/GHOST_ImeWin32.h 
b/intern/ghost/intern/GHOST_ImeWin32.h
index cbef0f0edc4..cd13ee1a8ae 100644
--- a/intern/ghost/intern/GHOST_ImeWin32.h
+++ b/intern/ghost/intern/GHOST_ImeWin32.h
@@ -365,7 +365,7 @@ class GHOST_ImeWin32 {
* MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED);
*   * "ja-JP" (0x0411)
* MAKELANGID(LANG_JAPANESE, SUBLANG_JAPANESE_JAPAN), etc.
-   *   (See  for other available values.)
+   *   (See `winnt.h` for other available values.)
* This Language ID is used for processing language-specific operations in
* IME functions.
*/
diff --git a/intern/ghost/intern/GHOST_WindowWin32.h 
b/intern/ghost/intern/GHOST_WindowWin32.h
index 71c97091189..d2d251fa2f2 100644
--- a/intern/ghost/intern/GHOST_WindowWin32.h
+++ b/intern/ghost/intern/GHOST_WindowWin32.h
@@ -570,7 +570,7 @@ class GHOST_WindowWin32 : public GHOST_Window {
 GHOST_WIN32_WTEnable enable;
 GHOST_WIN32_WTOverlap overlap;
 
-/** Stores the Tablet context if detected Tablet features using WinTab.dll 
*/
+/** Stores the Tablet context if detected Tablet features using 
`WinTab.dll` */
 HCTX tablet;
 LONG maxPressure;
 LONG maxAzimuth, maxAltitude;
diff --git a/source/blender/blenfont/intern/blf_dir.c 
b/source/blender/blenfont/intern/blf_dir.c
index 4fa915826b3..9520e971148 100644
--- a/source/blender/blenfont/intern/blf_dir.c
+++ b/source/blender/blenfont/intern/blf_dir.c
@@ -151,8 +151,9 @@ char *blf_dir_search(const char *file)
   return s;
 }
 
-/* Some font have additional file with metrics information,
- * in general, the extension of the file is: .afm or .pfm
+/**
+ * Some font have additional file with metrics information,
+ * in general, the extension of the file is: `.afm` or `.pfm`
  */
 char *blf_dir_metrics_search(const char *filename)
 {
diff --git a/source/blender/blenlib/intern/uvproject.c 
b/source/blender/blenlib/intern/uvproject.c
index 00fef29587c..329c4d48fe8 100644
--- a/source/blender/blenlib/intern/uvproject.c
+++ b/source/blender/blenlib/intern/uvproject.c
@@ -132,8 +132,8 @@ void BLI_uvproject_from_view(float target[2],
   target[1] = (y + target[1]) / winy;
 }
 
-/* 'rotmat' can be obedit->obmat when uv project is used.
- * 'winx' and 'winy' can be from scene->r.xsch/ysch */
+/* 'rotmat' can be `obedit->obmat` when uv project is used.
+ * 'winx' and 'winy' can be from `scene->r.xsch/ysch` */
 ProjCameraInfo *BLI_uvproject_camera_info(Object *ob, float (*rotmat)[4], 
float winx, float winy)
 {
   ProjCameraInfo uci;
diff --git a/source/blender/bmesh/intern/bmesh_marking.c 
b/source/blender/bmesh/intern/bmesh_marking.c
index 4fe6e6aee58..9cd1a2fd4ec 100644
--- a/source/blender/bmesh/intern/bmesh_marking.c
+++ b/source/blender/bmesh/intern/bmesh_marking.c
@@ -888,7 +888,7 @@ void 

[Bf-blender-cvs] [62592af8434] master: Cleanup: pass scene as const

2021-02-16 Thread Campbell Barton
Commit: 62592af84349629bccaa1c81df7965f4deb39fd4
Author: Campbell Barton
Date:   Wed Feb 17 10:27:50 2021 +1100
Branches: master
https://developer.blender.org/rB62592af84349629bccaa1c81df7965f4deb39fd4

Cleanup: pass scene as const

===

M   source/blender/blenkernel/BKE_modifier.h
M   source/blender/blenkernel/intern/modifier.c
M   source/blender/draw/intern/draw_cache_impl_mesh.c

===

diff --git a/source/blender/blenkernel/BKE_modifier.h 
b/source/blender/blenkernel/BKE_modifier.h
index 32b74d161b2..ab2ecbe2507 100644
--- a/source/blender/blenkernel/BKE_modifier.h
+++ b/source/blender/blenkernel/BKE_modifier.h
@@ -453,7 +453,7 @@ void BKE_modifiers_foreach_tex_link(struct Object *ob, 
TexWalkFunc walk, void *u
 struct ModifierData *BKE_modifiers_findby_type(struct Object *ob, ModifierType 
type);
 struct ModifierData *BKE_modifiers_findby_name(struct Object *ob, const char 
*name);
 void BKE_modifiers_clear_errors(struct Object *ob);
-int BKE_modifiers_get_cage_index(struct Scene *scene,
+int BKE_modifiers_get_cage_index(const struct Scene *scene,
  struct Object *ob,
  int *r_lastPossibleCageIndex,
  bool is_virtual);
@@ -469,8 +469,8 @@ struct Object *BKE_modifiers_is_deformed_by_lattice(struct 
Object *ob);
 struct Object *BKE_modifiers_is_deformed_by_curve(struct Object *ob);
 bool BKE_modifiers_uses_multires(struct Object *ob);
 bool BKE_modifiers_uses_armature(struct Object *ob, struct bArmature *arm);
-bool BKE_modifiers_uses_subsurf_facedots(struct Scene *scene, struct Object 
*ob);
-bool BKE_modifiers_is_correctable_deformed(struct Scene *scene, struct Object 
*ob);
+bool BKE_modifiers_uses_subsurf_facedots(const struct Scene *scene, struct 
Object *ob);
+bool BKE_modifiers_is_correctable_deformed(const struct Scene *scene, struct 
Object *ob);
 void BKE_modifier_free_temporary_data(struct ModifierData *md);
 
 typedef struct CDMaskLink {
@@ -484,14 +484,14 @@ typedef struct CDMaskLink {
  * pointed to by md for correct evaluation, assuming the data indicated by
  * final_datamask is required at the end of the stack.
  */
-struct CDMaskLink *BKE_modifier_calc_data_masks(struct Scene *scene,
+struct CDMaskLink *BKE_modifier_calc_data_masks(const struct Scene *scene,
 struct Object *ob,
 struct ModifierData *md,
 struct CustomData_MeshMasks 
*final_datamask,
 int required_mode,
 ModifierData *previewmd,
 const struct 
CustomData_MeshMasks *previewmask);
-struct ModifierData *BKE_modifier_get_last_preview(struct Scene *scene,
+struct ModifierData *BKE_modifier_get_last_preview(const struct Scene *scene,
struct ModifierData *md,
int required_mode);
 
diff --git a/source/blender/blenkernel/intern/modifier.c 
b/source/blender/blenkernel/intern/modifier.c
index a2a0bd84234..34b7c4234ec 100644
--- a/source/blender/blenkernel/intern/modifier.c
+++ b/source/blender/blenkernel/intern/modifier.c
@@ -464,7 +464,7 @@ void BKE_modifier_set_error(const Object *ob, ModifierData 
*md, const char *_for
  * then is NULL)
  * also used for some mesh tools to give warnings
  */
-int BKE_modifiers_get_cage_index(struct Scene *scene,
+int BKE_modifiers_get_cage_index(const Scene *scene,
  Object *ob,
  int *r_lastPossibleCageIndex,
  bool is_virtual)
@@ -587,7 +587,7 @@ bool BKE_modifier_is_nonlocal_in_liboverride(const Object 
*ob, const ModifierDat
   (md == NULL || (md->flag & eModifierFlag_OverrideLibrary_Local) == 
0));
 }
 
-CDMaskLink *BKE_modifier_calc_data_masks(struct Scene *scene,
+CDMaskLink *BKE_modifier_calc_data_masks(const struct Scene *scene,
  Object *ob,
  ModifierData *md,
  CustomData_MeshMasks *final_datamask,
@@ -655,7 +655,7 @@ CDMaskLink *BKE_modifier_calc_data_masks(struct Scene 
*scene,
   return dataMasks;
 }
 
-ModifierData *BKE_modifier_get_last_preview(struct Scene *scene,
+ModifierData *BKE_modifier_get_last_preview(const struct Scene *scene,
 ModifierData *md,
 int required_mode)
 {
@@ -878,7 +878,7 @@ bool BKE_modifiers_uses_armature(Object *ob, bArmature *arm)
   return false;
 }
 
-bool BKE_modifiers_uses_subsurf_facedots(struct Scene *scene, Object *ob)
+bool 

[Bf-blender-cvs] [ab484ff22f4] master: Fix T85664: 3D Viewport issues with curve poly splines

2021-02-16 Thread Hans Goudey
Commit: ab484ff22f4d9a1651f1b5b3475a222a056b001d
Author: Hans Goudey
Date:   Tue Feb 16 21:40:16 2021 -0600
Branches: master
https://developer.blender.org/rBab484ff22f4d9a1651f1b5b3475a222a056b001d

Fix T85664: 3D Viewport issues with curve poly splines

Caused by cleanup in rBcdb3cbd64401, where an index
was used to index `float *` instead of `float[3]`.

===

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

===

diff --git a/source/blender/blenkernel/intern/displist.c 
b/source/blender/blenkernel/intern/displist.c
index dc274e25823..19ead2d972a 100644
--- a/source/blender/blenkernel/intern/displist.c
+++ b/source/blender/blenkernel/intern/displist.c
@@ -292,6 +292,170 @@ bool BKE_displist_surfindex_get(DispList *dl, int a, int 
*b, int *p1, int *p2, i
 /* ICC with the optimization -02 causes crashes. */
 #  pragma intel optimization_level 1
 #endif
+
+// static void curve_to_displist(Curve *cu,
+//   ListBase *nubase,
+//   const bool for_render,
+//   ListBase *dispbase)
+// {
+//   DispList *dl;
+//   BezTriple *bezt, *prevbezt;
+//   BPoint *bp;
+//   float *data;
+//   int a, len, resolu;
+//   const bool editmode = (!for_render && (cu->editnurb || cu->editfont));
+
+//   LISTBASE_FOREACH (Nurb *, nu, nubase) {
+// if (nu->hide != 0 && editmode) {
+//   continue;
+// }
+
+// if (for_render && cu->resolu_ren != 0) {
+//   resolu = cu->resolu_ren;
+// }
+// else {
+//   resolu = nu->resolu;
+// }
+
+// if (!BKE_nurb_check_valid_u(nu)) {
+//   /* pass */
+// }
+// else if (nu->type == CU_BEZIER) {
+//   /* count */
+//   len = 0;
+//   a = nu->pntsu - 1;
+//   if (nu->flagu & CU_NURB_CYCLIC) {
+// a++;
+//   }
+
+//   prevbezt = nu->bezt;
+//   bezt = prevbezt + 1;
+//   while (a--) {
+// if (a == 0 && (nu->flagu & CU_NURB_CYCLIC)) {
+//   bezt = nu->bezt;
+// }
+
+// if (prevbezt->h2 == HD_VECT && bezt->h1 == HD_VECT) {
+//   len++;
+// }
+// else {
+//   len += resolu;
+// }
+
+// if (a == 0 && (nu->flagu & CU_NURB_CYCLIC) == 0) {
+//   len++;
+// }
+
+// prevbezt = bezt;
+// bezt++;
+//   }
+
+//   dl = MEM_callocN(sizeof(DispList), "makeDispListbez");
+//   /* len+1 because of 'forward_diff_bezier' function */
+//   dl->verts = MEM_mallocN((len + 1) * sizeof(float[3]), "dlverts");
+//   BLI_addtail(dispbase, dl);
+//   dl->parts = 1;
+//   dl->nr = len;
+//   dl->col = nu->mat_nr;
+//   dl->charidx = nu->charidx;
+
+//   data = dl->verts;
+
+//   /* check that (len != 2) so we don't immediately loop back on 
ourselves */
+//   if (nu->flagu & CU_NURB_CYCLIC && (dl->nr != 2)) {
+// dl->type = DL_POLY;
+// a = nu->pntsu;
+//   }
+//   else {
+// dl->type = DL_SEGM;
+// a = nu->pntsu - 1;
+//   }
+
+//   prevbezt = nu->bezt;
+//   bezt = prevbezt + 1;
+
+//   while (a--) {
+// if (a == 0 && dl->type == DL_POLY) {
+//   bezt = nu->bezt;
+// }
+
+// if (prevbezt->h2 == HD_VECT && bezt->h1 == HD_VECT) {
+//   copy_v3_v3(data, prevbezt->vec[1]);
+//   data += 3;
+// }
+// else {
+//   int j;
+//   for (j = 0; j < 3; j++) {
+// BKE_curve_forward_diff_bezier(prevbezt->vec[1][j],
+//   prevbezt->vec[2][j],
+//   bezt->vec[0][j],
+//   bezt->vec[1][j],
+//   data + j,
+//   resolu,
+//   sizeof(float[3]));
+//   }
+
+//   data += 3 * resolu;
+// }
+
+// if (a == 0 && dl->type == DL_SEGM) {
+//   copy_v3_v3(data, bezt->vec[1]);
+// }
+
+// prevbezt = bezt;
+// bezt++;
+//   }
+// }
+// else if (nu->type == CU_NURBS) {
+//   len = (resolu * SEGMENTSU(nu));
+
+//   dl = MEM_callocN(sizeof(DispList), "makeDispListsurf");
+//   dl->verts = MEM_mallocN(len * sizeof(float[3]), "dlverts");
+//   BLI_addtail(dispbase, dl);
+//   dl->parts = 1;
+
+//   dl->nr = len;
+//   dl->col = nu->mat_nr;
+//   dl->charidx = nu->charidx;
+
+//   data = dl->verts;
+//   if (nu->flagu & CU_NURB_CYCLIC) {
+// dl->type = DL_POLY;
+//   }
+//   else {
+// dl->type = DL_SEGM;
+//   }
+//   BKE_nurb_makeCurve(nu, data, NULL, NULL, NULL, resolu, 
sizeof(float[3]));
+// }
+// else if (nu->type == CU_POLY) {
+//   len = nu->pntsu;
+//   dl 

[Bf-blender-cvs] [5c523c65785] master: Merge branch 'blender-v2.92-release'

2021-02-16 Thread Nicholas Rishel
Commit: 5c523c6578500fa8a8da676627d4e453db142cd3
Author: Nicholas Rishel
Date:   Tue Feb 16 18:10:42 2021 -0800
Branches: master
https://developer.blender.org/rB5c523c6578500fa8a8da676627d4e453db142cd3

Merge branch 'blender-v2.92-release'

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [ab210098424] blender-v2.92-release: Fix T84701: Popup closes on release while dragging parameter.

2021-02-16 Thread Nicholas Rishel
Commit: ab210098424bf53b1fdac3de2d016d3e4aa04bfe
Author: Nicholas Rishel
Date:   Tue Feb 16 17:45:57 2021 -0800
Branches: blender-v2.92-release
https://developer.blender.org/rBab210098424bf53b1fdac3de2d016d3e4aa04bfe

Fix T84701: Popup closes on release while dragging parameter.

Windows Ghost cursor movement was previously changed to use SendInput
because SetCursorPos sporadically allows the cursor to escape the
window. This is now reverted because SendInput causes mouse history via
GetMouseMovePointsEx to contain invalid movement history, likely due to
interaction with mouse acceleration. This resulted in popups closing
when the cursor appeared to leave their range.

===

M   intern/ghost/intern/GHOST_SystemWin32.cpp

===

diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp 
b/intern/ghost/intern/GHOST_SystemWin32.cpp
index c86b332d228..43780b6d618 100644
--- a/intern/ghost/intern/GHOST_SystemWin32.cpp
+++ b/intern/ghost/intern/GHOST_SystemWin32.cpp
@@ -531,20 +531,7 @@ GHOST_TSuccess 
GHOST_SystemWin32::setCursorPosition(GHOST_TInt32 x, GHOST_TInt32
 {
   if (!::GetActiveWindow())
 return GHOST_kFailure;
-
-  INPUT input;
-  input.type = INPUT_MOUSE;
-  input.mi.mouseData = 0;
-  input.mi.time = ::GetTickCount();
-  /* Map from virtual screen to 0-65535 inclusive. */
-  input.mi.dx = (x - GetSystemMetrics(SM_XVIRTUALSCREEN)) * 65535 /
-(GetSystemMetrics(SM_CXVIRTUALSCREEN) - 1);
-  input.mi.dy = (y - GetSystemMetrics(SM_YVIRTUALSCREEN)) * 65535 /
-(GetSystemMetrics(SM_CYVIRTUALSCREEN) - 1);
-  input.mi.dwFlags = MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE | 
MOUSEEVENTF_VIRTUALDESK;
-  SendInput(1, , sizeof(input));
-
-  return GHOST_kSuccess;
+  return ::SetCursorPos(x, y) == TRUE ? GHOST_kSuccess : GHOST_kFailure;
 }
 
 GHOST_TSuccess GHOST_SystemWin32::getModifierKeys(GHOST_ModifierKeys ) 
const

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [53874b413e7] sculpt-dev: Sculpt Expand: More comments

2021-02-16 Thread Pablo Dobarro
Commit: 53874b413e7364c99b10bcd04616e3973fc7307e
Author: Pablo Dobarro
Date:   Wed Feb 17 00:17:49 2021 +0100
Branches: sculpt-dev
https://developer.blender.org/rB53874b413e7364c99b10bcd04616e3973fc7307e

Sculpt Expand: More comments

===

M   source/blender/editors/sculpt_paint/sculpt_expand.c
M   source/blender/editors/sculpt_paint/sculpt_geodesic.c
M   source/blender/editors/sculpt_paint/sculpt_intern.h

===

diff --git a/source/blender/editors/sculpt_paint/sculpt_expand.c 
b/source/blender/editors/sculpt_paint/sculpt_expand.c
index d8076b40e8c..4d8aa3b3189 100644
--- a/source/blender/editors/sculpt_paint/sculpt_expand.c
+++ b/source/blender/editors/sculpt_paint/sculpt_expand.c
@@ -98,10 +98,16 @@
  */
 #define SCULPT_EXPAND_VERTEX_NONE -1
 
+/* Used for defining an unitialized active component index for an unused 
symmetry pass. */
+
+#define EXPAND_ACTIVE_COMPOMENT_NONE -1
 /* Defines how much each time the texture distortion is increased/decreased 
when using the modal
  * keymap. */
 #define SCULPT_EXPAND_TEXTURE_DISTORTION_STEP 0.01f
 
+/* This threshold offsets the required falloff value to start a new loop. This 
is needed because in
+ * some situations, vertices which have the same falloff value as max_falloff 
will start a new
+ * loop, which is undesired. */
 #define SCULPT_EXPAND_LOOP_THRESHOLD 0.1f
 
 /* Expand Modal Keymap. */
@@ -378,9 +384,7 @@ static BLI_bitmap 
*sculpt_expand_boundary_from_enabled(SculptSession *ss,
   return boundary_vertices;
 }
 
-
-
-/* Functions implementing differnt algorithms for initializing the falloff 
values. */
+/* Functions implementing different algorithms for initializing falloff 
values. */
 
 /* Geodesic: Initializes the falloff with geodesic distances from the given 
active vertex, taking
  * symmetry into account. */
@@ -772,9 +776,11 @@ static void 
sculpt_expand_mesh_face_falloff_from_vertex_falloff(SculptSession *s
   }
 }
 
-/* Recursions. These functions will generate new falloff values based on the 
state of the vertices from the current ExpandCache options and falloff values. 
*/
+/* Recursions. These functions will generate new falloff values based on the 
state of the vertices
+ * from the current ExpandCache options and falloff values. */
 
-/* Geodesic recursion: Initializes falloff values using geodesic distances 
from the boundary of the current vertices state. */
+/* Geodesic recursion: Initializes falloff values using geodesic distances 
from the boundary of the
+ * current vertices state. */
 static void sculpt_expand_geodesics_from_state_boundary(Object *ob,
 ExpandCache 
*expand_cache,
 BLI_bitmap 
*enabled_vertices)
@@ -800,7 +806,8 @@ static void 
sculpt_expand_geodesics_from_state_boundary(Object *ob,
   BLI_gset_free(initial_vertices, NULL);
 }
 
-/* Geodesic recursion: Initializes falloff values using topology steps from 
the boundary of the current vertices state, increasing the value by 1 each time 
a new vertex is visited. */
+/* Geodesic recursion: Initializes falloff values using topology steps from 
the boundary of the
+ * current vertices state, increasing the value by 1 each time a new vertex is 
visited. */
 static void sculpt_expand_topology_from_state_boundary(Object *ob,
ExpandCache 
*expand_cache,
BLI_bitmap 
*enabled_vertices)
@@ -844,7 +851,9 @@ static void sculpt_expand_resursion_step_add(Object *ob,
 
   BLI_bitmap *enabled_vertices = sculpt_expand_bitmap_from_enabled(ss, 
expand_cache);
 
-  /* Each time a new recursion step is created, reset the distortion strength. 
This is the expedted result from the recursion, as otherwise the new falloff 
will render with undesired distortion from the beginning */
+  /* Each time a new recursion step is created, reset the distortion strength. 
This is the expedted
+   * result from the recursion, as otherwise the new falloff will render with 
undesired distortion
+   * from the beginning */
   expand_cache->texture_distortion_strength = 0.0f;
 
   switch (recursion_type) {
@@ -923,8 +932,8 @@ static void 
sculpt_expand_initialize_from_face_set_boundary(Object *ob,
   }
 }
 
-
-/* Main function to initialize new falloff values in a ExpandCache given an 
initial vertex and a falloff type. */
+/* Main function to initialize new falloff values in a ExpandCache given an 
initial vertex and a
+ * falloff type. */
 static void sculpt_expand_falloff_factors_from_vertex_and_symm_create(
 ExpandCache *expand_cache,
 Sculpt *sd,
@@ -979,8 +988,9 @@ static void 
sculpt_expand_falloff_factors_from_vertex_and_symm_create(
   }
 }
 
-
-/* Adds to the snapping Face Set gset all Face Sets which contain all enabled 

[Bf-blender-cvs] [1b029b790b2] sculpt-dev: Sculpt Expand: Refactor, more comments

2021-02-16 Thread Pablo Dobarro
Commit: 1b029b790b22b51b1586bf4fb62b5f3426b08a50
Author: Pablo Dobarro
Date:   Tue Feb 16 21:03:34 2021 +0100
Branches: sculpt-dev
https://developer.blender.org/rB1b029b790b22b51b1586bf4fb62b5f3426b08a50

Sculpt Expand: Refactor, more comments

===

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

===

diff --git a/source/blender/editors/sculpt_paint/sculpt_expand.c 
b/source/blender/editors/sculpt_paint/sculpt_expand.c
index 10e6b17706b..d8076b40e8c 100644
--- a/source/blender/editors/sculpt_paint/sculpt_expand.c
+++ b/source/blender/editors/sculpt_paint/sculpt_expand.c
@@ -330,6 +330,56 @@ static float 
sculpt_expand_gradient_value_get(SculptSession *ss,
   return BKE_brush_curve_strength(expand_cache->brush, linear_falloff, 1.0f);
 }
 
+/* Utility functions for getting all vertices state during expand. */
+
+/* Returns a bitmap indexed by vertex index which contains if the vertex was 
enabled or not for a
+ * give expand_cache state. */
+static BLI_bitmap *sculpt_expand_bitmap_from_enabled(SculptSession *ss, 
ExpandCache *expand_cache)
+{
+  const int totvert = SCULPT_vertex_count_get(ss);
+  BLI_bitmap *enabled_vertices = BLI_BITMAP_NEW(totvert, "enabled vertices");
+  for (int i = 0; i < totvert; i++) {
+const bool enabled = sculpt_expand_state_get(ss, expand_cache, i);
+BLI_BITMAP_SET(enabled_vertices, i, enabled);
+  }
+  return enabled_vertices;
+}
+
+/* Returns a bitmap indexed by vertex index which contains if the vertex is in 
the boundary of the
+ * enabled vertices. This is defined as vertices that are enabled and at least 
have one connected
+ * vertex that is not enabled. */
+static BLI_bitmap *sculpt_expand_boundary_from_enabled(SculptSession *ss,
+   BLI_bitmap 
*enabled_vertices,
+   const bool 
use_mesh_boundary)
+{
+  const int totvert = SCULPT_vertex_count_get(ss);
+  BLI_bitmap *boundary_vertices = BLI_BITMAP_NEW(totvert, "boundary vertices");
+  for (int i = 0; i < totvert; i++) {
+if (!BLI_BITMAP_TEST(enabled_vertices, i)) {
+  continue;
+}
+
+bool is_expand_boundary = false;
+SculptVertexNeighborIter ni;
+SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN (ss, i, ni) {
+  if (!BLI_BITMAP_TEST(enabled_vertices, ni.index)) {
+is_expand_boundary = true;
+  }
+}
+SCULPT_VERTEX_NEIGHBORS_ITER_END(ni);
+
+if (use_mesh_boundary && SCULPT_vertex_is_boundary(ss, i)) {
+  is_expand_boundary = true;
+}
+
+BLI_BITMAP_SET(boundary_vertices, i, is_expand_boundary);
+  }
+
+  return boundary_vertices;
+}
+
+
+
 /* Functions implementing differnt algorithms for initializing the falloff 
values. */
 
 /* Geodesic: Initializes the falloff with geodesic distances from the given 
active vertex, taking
@@ -722,56 +772,9 @@ static void 
sculpt_expand_mesh_face_falloff_from_vertex_falloff(SculptSession *s
   }
 }
 
-/* Utility functions for getting all vertices state during expand. */
-
-/* Returns a bitmap indexed by vertex index which contains if the vertex was 
enabled or not for a
- * give expand_cache state. */
-static BLI_bitmap *sculpt_expand_bitmap_from_enabled(SculptSession *ss, 
ExpandCache *expand_cache)
-{
-  const int totvert = SCULPT_vertex_count_get(ss);
-  BLI_bitmap *enabled_vertices = BLI_BITMAP_NEW(totvert, "enabled vertices");
-  for (int i = 0; i < totvert; i++) {
-const bool enabled = sculpt_expand_state_get(ss, expand_cache, i);
-BLI_BITMAP_SET(enabled_vertices, i, enabled);
-  }
-  return enabled_vertices;
-}
-
-/* Returns a bitmap indexed by vertex index which contains if the vertex is in 
the boundary of the
- * enabled vertices. This is defined as vertices that are enabled and at least 
have one connected
- * vertex that is not enabled. */
-static BLI_bitmap *sculpt_expand_boundary_from_enabled(SculptSession *ss,
-   BLI_bitmap 
*enabled_vertices,
-   const bool 
use_mesh_boundary)
-{
-  const int totvert = SCULPT_vertex_count_get(ss);
-  BLI_bitmap *boundary_vertices = BLI_BITMAP_NEW(totvert, "boundary vertices");
-  for (int i = 0; i < totvert; i++) {
-if (!BLI_BITMAP_TEST(enabled_vertices, i)) {
-  continue;
-}
-
-bool is_expand_boundary = false;
-SculptVertexNeighborIter ni;
-SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN (ss, i, ni) {
-  if (!BLI_BITMAP_TEST(enabled_vertices, ni.index)) {
-is_expand_boundary = true;
-  }
-}
-SCULPT_VERTEX_NEIGHBORS_ITER_END(ni);
-
-if (use_mesh_boundary && SCULPT_vertex_is_boundary(ss, i)) {
-  is_expand_boundary = true;
-}
-
-BLI_BITMAP_SET(boundary_vertices, i, is_expand_boundary);
-  }
-
-  return boundary_vertices;
-}
-
-/* Recursions:
+/* Recursions. These functions will 

[Bf-blender-cvs] [461d4fc1aae] master: Geometry Nodes: Node error messages

2021-02-16 Thread Hans Goudey
Commit: 461d4fc1aae200a6310a254b6e7c08070d9e94a7
Author: Hans Goudey
Date:   Tue Feb 16 17:15:08 2021 -0600
Branches: master
https://developer.blender.org/rB461d4fc1aae200a6310a254b6e7c08070d9e94a7

Geometry Nodes: Node error messages

This patch adds icons to the right side of nodes when they encounter a
a problem. When hovered, a tooltip displays describing the encountered
while evaluating the node.

Some examples are: attribute doesn't exist, mesh has no faces,
incorrect attribute type, etc. Exposing more messages to the system
will be an ongoing process. Multiple warnings per node are supported.

The system is implemented somewhat generically so that the basic
structure can also be used to store more information from evaluation
for the interface, like a list of available attributes.

Currently the messages are just button tooltips. They could be styled
differently in the future. Another limitation is that every instance of
a node group in a parent node tree will have the same error messages,
the "evaluation context" used to decide when to display the tooltips
must be extended to support node tree paths.

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

===

A   source/blender/blenkernel/BKE_node_ui_storage.hh
M   source/blender/blenkernel/CMakeLists.txt
M   source/blender/blenkernel/intern/node.cc
A   source/blender/blenkernel/intern/node_ui_storage.cc
M   source/blender/editors/space_node/node_draw.cc
M   source/blender/makesdna/DNA_node_types.h
M   source/blender/modifiers/intern/MOD_nodes.cc
M   source/blender/nodes/NOD_geometry_exec.hh
M   source/blender/nodes/geometry/nodes/node_geo_attribute_randomize.cc
M   source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc
M   source/blender/nodes/geometry/nodes/node_geo_point_instance.cc
M   source/blender/nodes/intern/node_geometry_exec.cc

===

diff --git a/source/blender/blenkernel/BKE_node_ui_storage.hh 
b/source/blender/blenkernel/BKE_node_ui_storage.hh
new file mode 100644
index 000..0b8ef60a603
--- /dev/null
+++ b/source/blender/blenkernel/BKE_node_ui_storage.hh
@@ -0,0 +1,95 @@
+/*
+ * 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 "BLI_hash.hh"
+#include "BLI_map.hh"
+#include "BLI_session_uuid.h"
+
+#include "DNA_ID.h"
+#include "DNA_modifier_types.h"
+#include "DNA_session_uuid_types.h"
+
+struct bNode;
+struct bNodeTree;
+struct Object;
+struct ModifierData;
+
+using blender::Map;
+
+/**
+ * Contains the context necessary to determine when to display settings for a 
certain node tree
+ * that may be used for multiple modifiers and objects. The object name and 
modifier session UUID
+ * are used instead of pointers because they are re-allocated between 
evaluations.
+ *
+ * \note This does not yet handle the context of nested node trees.
+ */
+class NodeTreeEvaluationContext {
+ private:
+  std::string object_name_;
+  SessionUUID modifier_session_uuid_;
+
+ public:
+  NodeTreeEvaluationContext(const Object , const ModifierData )
+  {
+object_name_ = reinterpret_cast(object).name;
+modifier_session_uuid_ = modifier.session_uuid;
+  }
+
+  uint64_t hash() const
+  {
+const uint64_t hash1 = blender::DefaultHash{}(object_name_);
+const uint64_t hash2 = 
BLI_session_uuid_hash_uint64(_session_uuid_);
+return hash1 ^ (hash2 * 33); /* Copied from DefaultHash for std::pair. */
+  }
+
+  bool operator==(const NodeTreeEvaluationContext ) const
+  {
+return other.object_name_ == object_name_ &&
+   BLI_session_uuid_is_equal(_session_uuid_, 
_session_uuid_);
+  }
+};
+
+enum class NodeWarningType {
+  Error,
+  Warning,
+  Info,
+};
+
+struct NodeWarning {
+  NodeWarningType type;
+  std::string message;
+};
+
+struct NodeUIStorage {
+  blender::Vector warnings;
+};
+
+struct NodeTreeUIStorage {
+  Map> context_map;
+};
+
+void BKE_nodetree_ui_storage_free_for_context(bNodeTree ,
+  const NodeTreeEvaluationContext 
);
+
+void BKE_nodetree_ui_storage_ensure(bNodeTree );
+
+void BKE_nodetree_error_message_add(bNodeTree ,
+const 

[Bf-blender-cvs] [dff24cf649d] usd-importer-T81257-merge: USD import: uniform interpolation normals.

2021-02-16 Thread makowalski
Commit: dff24cf649db0380290ee3b50057b625f1f44299
Author: makowalski
Date:   Tue Feb 16 17:37:38 2021 -0500
Branches: usd-importer-T81257-merge
https://developer.blender.org/rBdff24cf649db0380290ee3b50057b625f1f44299

USD import: uniform interpolation normals.

Added logic to import USD normals with uniform interpolation
(i.e., per-face normals) as Blender loop normals.

===

M   source/blender/io/usd/intern/usd_reader_mesh.cc
M   source/blender/io/usd/intern/usd_reader_mesh.h

===

diff --git a/source/blender/io/usd/intern/usd_reader_mesh.cc 
b/source/blender/io/usd/intern/usd_reader_mesh.cc
index 9c735e930f0..b57959ce6b2 100644
--- a/source/blender/io/usd/intern/usd_reader_mesh.cc
+++ b/source/blender/io/usd/intern/usd_reader_mesh.cc
@@ -553,6 +553,43 @@ void USDMeshReader::process_normals_face_varying(Mesh 
*mesh)
   MEM_freeN(lnors);
 }
 
+// Set USD uniform (per-face) normals as Blender loop normals.
+void USDMeshReader::process_normals_uniform(Mesh *mesh)
+{
+  if (m_normals.empty()) {
+BKE_mesh_calc_normals(mesh);
+return;
+  }
+
+  // Check for normals count mismatches to prevent crashes.
+  if (m_normals.size() != mesh->totpoly) {
+std::cerr << "WARNING: uniform normal count mismatch for mesh " << 
mesh->id.name << std::endl;
+BKE_mesh_calc_normals(mesh);
+return;
+  }
+
+  float(*lnors)[3] = static_cast(
+MEM_malloc_arrayN(mesh->totloop, sizeof(float[3]), "USD::FaceNormals"));
+
+  MPoly *mpoly = mesh->mpoly;
+
+  for (int i = 0, e = mesh->totpoly; i < e; ++i, ++mpoly) {
+
+for (int j = 0; j < mpoly->totloop; j++) {
+  int loop_index = mpoly->loopstart + j;
+  lnors[loop_index][0] = m_normals[i][0];
+  lnors[loop_index][1] = m_normals[i][1];
+  lnors[loop_index][2] = m_normals[i][2];
+}
+  }
+
+  mesh->flag |= ME_AUTOSMOOTH;
+  BKE_mesh_set_custom_normals(mesh, lnors);
+
+  MEM_freeN(lnors);
+}
+
+
 void USDMeshReader::read_mesh_sample(const std::string _full_name,
  ImportSettings *settings,
  Mesh *mesh,
@@ -599,8 +636,16 @@ void USDMeshReader::read_mesh_sample(const std::string 
_full_name,
 
   if ((settings->read_flag & MOD_MESHSEQ_READ_POLY) != 0) {
 read_mpolys(mesh, mesh_prim, motionSampleTime);
-if (m_normalInterpolation == pxr::UsdGeomTokens->faceVarying)
+if (m_normalInterpolation == pxr::UsdGeomTokens->faceVarying) {
   process_normals_face_varying(mesh);
+}
+else if (m_normalInterpolation == pxr::UsdGeomTokens->uniform) {
+  process_normals_uniform(mesh);
+}
+else {
+  // Default
+  BKE_mesh_calc_normals(mesh);
+}
   }
 
   // Process point normals after reading polys.  This
diff --git a/source/blender/io/usd/intern/usd_reader_mesh.h 
b/source/blender/io/usd/intern/usd_reader_mesh.h
index e4933c018ad..3a392c54998 100644
--- a/source/blender/io/usd/intern/usd_reader_mesh.h
+++ b/source/blender/io/usd/intern/usd_reader_mesh.h
@@ -50,6 +50,7 @@ class USDMeshReader : public USDGeomReader {
  private:
   void process_normals_vertex_varying(Mesh *mesh);
   void process_normals_face_varying(Mesh *mesh);
+  void process_normals_uniform(Mesh *mesh);
   void readFaceSetsSample(Main *bmain, Mesh *mesh, double motionSampleTime);
   void assign_facesets_to_mpoly(double motionSampleTime,
 struct MPoly *mpoly,

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [c9c4802c1c2] master: Fix T85671: color management crash with Medium Contrast look

2021-02-16 Thread Brecht Van Lommel
Commit: c9c4802c1c26d1125d9bb41ff9187b61e167cc42
Author: Brecht Van Lommel
Date:   Tue Feb 16 22:37:27 2021 +0100
Branches: master
https://developer.blender.org/rBc9c4802c1c26d1125d9bb41ff9187b61e167cc42

Fix T85671: color management crash with Medium Contrast look

===

M   intern/opencolorio/ocio_impl.cc

===

diff --git a/intern/opencolorio/ocio_impl.cc b/intern/opencolorio/ocio_impl.cc
index 69a8d8b17af..c4d7a0c4fe9 100644
--- a/intern/opencolorio/ocio_impl.cc
+++ b/intern/opencolorio/ocio_impl.cc
@@ -682,19 +682,25 @@ OCIO_ConstProcessorRcPtr 
*OCIOImpl::createDisplayProcessor(OCIO_ConstConfigRcPtr
   }
 
   /* Add look transform. */
-  const bool use_look = (strlen(look) != 0);
+  bool use_look = (look != nullptr && look[0] != 0);
   if (use_look) {
 const char *look_output = LookTransform::GetLooksResultColorSpace(
 config, config->getCurrentContext(), look);
 
-LookTransformRcPtr lt = LookTransform::Create();
-lt->setSrc(input);
-lt->setDst(look_output);
-lt->setLooks(look);
-group->appendTransform(lt);
+if (look_output != nullptr && look_output[0] != 0) {
+  LookTransformRcPtr lt = LookTransform::Create();
+  lt->setSrc(input);
+  lt->setDst(look_output);
+  lt->setLooks(look);
+  group->appendTransform(lt);
 
-/* Make further transforms aware of the color space change. */
-input = look_output;
+  /* Make further transforms aware of the color space change. */
+  input = look_output;
+}
+else {
+  /* For empty looks, no output color space is returned. */
+  use_look = false;
+}
   }
 
   /* Add view and display transform. */

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [ba79b8013f1] master: Cleanup: Use consistent order placement for include

2021-02-16 Thread Hans Goudey
Commit: ba79b8013f1f1f47b7d3db3f0a1d82826c607281
Author: Hans Goudey
Date:   Tue Feb 16 16:17:03 2021 -0600
Branches: master
https://developer.blender.org/rBba79b8013f1f1f47b7d3db3f0a1d82826c607281

Cleanup: Use consistent order placement for include

===

M   source/blender/imbuf/intern/indexer.c

===

diff --git a/source/blender/imbuf/intern/indexer.c 
b/source/blender/imbuf/intern/indexer.c
index f10e3b31141..c9581c108c0 100644
--- a/source/blender/imbuf/intern/indexer.c
+++ b/source/blender/imbuf/intern/indexer.c
@@ -29,6 +29,7 @@
 #include "BLI_ghash.h"
 #include "BLI_path_util.h"
 #include "BLI_string.h"
+#include "BLI_threads.h"
 #include "BLI_utildefines.h"
 #ifdef _WIN32
 #  include "BLI_winstuff.h"
@@ -40,8 +41,6 @@
 
 #include "BKE_global.h"
 
-#  include "BLI_threads.h"
-
 #ifdef WITH_AVI
 #  include "AVI_avi.h"
 #endif

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [4b1c960c979] usd-importer-T81257: USD import: uniform interpolation normals.

2021-02-16 Thread makowalski
Commit: 4b1c960c979f7d5eb1aaae2d5d00d54ce377885f
Author: makowalski
Date:   Tue Feb 16 16:26:17 2021 -0500
Branches: usd-importer-T81257
https://developer.blender.org/rB4b1c960c979f7d5eb1aaae2d5d00d54ce377885f

USD import: uniform interpolation normals.

Added logic to import USD normals with uniform interpolation
(i.e., per-face normals) as Blender loop normals.

===

M   source/blender/io/usd/import/usd_reader_mesh.cc

===

diff --git a/source/blender/io/usd/import/usd_reader_mesh.cc 
b/source/blender/io/usd/import/usd_reader_mesh.cc
index 5b1a52f88d2..9a9b121c617 100644
--- a/source/blender/io/usd/import/usd_reader_mesh.cc
+++ b/source/blender/io/usd/import/usd_reader_mesh.cc
@@ -270,6 +270,52 @@ void process_loop_normals(Mesh *mesh, const MeshSampleData 
_data)
   MEM_freeN(lnors);
 }
 
+// Set USD uniform (per-face) normals as Blender loop normals.
+void process_uniform_normals(Mesh *mesh, const MeshSampleData _data)
+{
+  if (!mesh) {
+return;
+  }
+
+  size_t norm_count = mesh_data.normals.size();
+
+  if (norm_count == 0) {
+process_no_normals(mesh);
+return;
+  }
+
+  if (norm_count != mesh->totpoly) {
+std::cerr << "WARNING: uniform normal count mismatch for mesh " << 
mesh->id.name << std::endl;
+process_no_normals(mesh);
+return;
+  }
+
+  float(*lnors)[3] = static_cast(
+  MEM_malloc_arrayN(mesh->totloop, sizeof(float[3]), "USD::FaceNormals"));
+
+  MPoly *mpoly = mesh->mpoly;
+
+  for (int p = 0; p < mesh->totpoly; ++p, ++mpoly) {
+
+for (int l = 0; l < mpoly->totloop; ++l) {
+  int loop_index = mpoly->loopstart + l;
+  if (mesh_data.y_up) {
+copy_zup_from_yup(lnors[loop_index], mesh_data.normals[p].data());
+  }
+  else {
+lnors[loop_index][0] = mesh_data.normals[p].data()[0];
+lnors[loop_index][1] = mesh_data.normals[p].data()[1];
+lnors[loop_index][2] = mesh_data.normals[p].data()[2];
+  }
+}
+  }
+
+  mesh->flag |= ME_AUTOSMOOTH;
+  BKE_mesh_set_custom_normals(mesh, lnors);
+
+  MEM_freeN(lnors);
+}
+
 void process_vertex_normals(Mesh *mesh, const MeshSampleData _data)
 {
   if (!mesh) {
@@ -321,6 +367,9 @@ void process_normals(Mesh *mesh, const MeshSampleData 
_data)
   else if (mesh_data.normals_interpolation == pxr::UsdGeomTokens->vertex) {
 process_vertex_normals(mesh, mesh_data); /* 'point normals' in Houdini. */
   }
+  else if (mesh_data.normals_interpolation == pxr::UsdGeomTokens->uniform) {
+process_uniform_normals(mesh, mesh_data); /* per-face normals. */
+  }
   else {
 process_no_normals(mesh);
   }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [acd99f12e72] sculpt-dev: Sculpt Expand: Cleanup, comments

2021-02-16 Thread Pablo Dobarro
Commit: acd99f12e72edd331e40a381cbd8313fef0a3a21
Author: Pablo Dobarro
Date:   Tue Feb 16 20:38:06 2021 +0100
Branches: sculpt-dev
https://developer.blender.org/rBacd99f12e72edd331e40a381cbd8313fef0a3a21

Sculpt Expand: Cleanup, comments

===

M   source/blender/editors/sculpt_paint/sculpt.c
M   source/blender/editors/sculpt_paint/sculpt_expand.c
M   source/blender/editors/sculpt_paint/sculpt_intern.h

===

diff --git a/source/blender/editors/sculpt_paint/sculpt.c 
b/source/blender/editors/sculpt_paint/sculpt.c
index fd90506f103..50d40402d06 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -10471,8 +10471,6 @@ static void SCULPT_OT_mask_init(wmOperatorType *ot)
"");
 }
 
-
-
 static int sculpt_reset_brushes_exec(bContext *C, wmOperator *op)
 {
   Main *bmain = CTX_data_main(C);
diff --git a/source/blender/editors/sculpt_paint/sculpt_expand.c 
b/source/blender/editors/sculpt_paint/sculpt_expand.c
index bfcd07e4d84..10e6b17706b 100644
--- a/source/blender/editors/sculpt_paint/sculpt_expand.c
+++ b/source/blender/editors/sculpt_paint/sculpt_expand.c
@@ -75,8 +75,36 @@
 #include 
 #include 
 
+/* Sculpt Expand. */
+/* Operator for creating selections and patterns in Scupt Mode. Expand can 
create masks, face sets
+ * and fill vertex colors. */
+/* The main functinality of the operator
+ * - The operator initializes a value per vertex, called "falloff". There are 
multiple algorithms
+ * to generate these falloff values which will create different patterns in 
the result when using
+ * the operator. These falloff values require algorithms that rely on mesh 
connectivity, so they
+ * are only valid on parts of the mesh that are in the same connected 
component as the given
+ * initial vertices. If needed, these falloff values are propagated from 
vertex or grids into the
+ * base mesh faces.
+ * - On each modal callback, the operator gets the active vertex and face and 
gets its falloff
+ * value from its precalculated falloff. This is now the active falloff value.
+ * - Using the active falloff value and the settings of the expand operation 
(which can be modified
+ * during execution using the modal keymap), the operator loops over all 
elements in the mesh to
+ * check if they are enabled of not.
+ * - Based on each element state after evaluating the settings, the desired 
mesh data (mask, face
+ * sets, colors...) is updated.
+ */
+
+/* Used for defining an invalid vertex state (for example, when the cursor is 
not over the mesh).
+ */
 #define SCULPT_EXPAND_VERTEX_NONE -1
 
+/* Defines how much each time the texture distortion is increased/decreased 
when using the modal
+ * keymap. */
+#define SCULPT_EXPAND_TEXTURE_DISTORTION_STEP 0.01f
+
+#define SCULPT_EXPAND_LOOP_THRESHOLD 0.1f
+
+/* Expand Modal Keymap. */
 enum {
   SCULPT_EXPAND_MODAL_CONFIRM = 1,
   SCULPT_EXPAND_MODAL_CANCEL,
@@ -118,9 +146,10 @@ static EnumPropertyItem 
prop_sculpt_expand_target_type_items[] = {
 {0, NULL, 0, NULL, NULL},
 };
 
-#define SCULPT_EXPAND_TEXTURE_DISTORTION_STEP 0.01f
-#define SCULPT_EXPAND_LOOP_THRESHOLD 0.1f
+/* Functions for getting the state of mesh elements (vertices and base mesh 
faces). */
 
+/* Returns true if the vertex is in a connected component with correctly 
initialized falloff
+ * values. */
 static bool sculpt_expand_is_vert_in_active_compoment(SculptSession *ss,
   ExpandCache 
*expand_cache,
   const int v)
@@ -133,6 +162,8 @@ static bool 
sculpt_expand_is_vert_in_active_compoment(SculptSession *ss,
   return false;
 }
 
+/* Returns true if the face is in a connected component with correctly 
initialized falloff values.
+ */
 static bool sculpt_expand_is_face_in_active_component(SculptSession *ss,
   ExpandCache 
*expand_cache,
   const int f)
@@ -141,49 +172,55 @@ static bool 
sculpt_expand_is_face_in_active_component(SculptSession *ss,
   return sculpt_expand_is_vert_in_active_compoment(ss, expand_cache, loop->v);
 }
 
+/* Returns the falloff value of a vertex. This function includes texture 
distortion, which is not
+ * precomputed into the initial falloff values. */
 static float sculpt_expand_falloff_value_vertex_get(SculptSession *ss,
 ExpandCache *expand_cache,
-const int i)
+const int v)
 {
   if (expand_cache->texture_distortion_strength == 0.0f) {
-return expand_cache->falloff_factor[i];
+return expand_cache->falloff[v];
   }
 
   if (!expand_cache->brush->mtex.tex) {
-return 

[Bf-blender-cvs] [eb2e2605404] master: Cleanup: Used derived node in geometry exec params

2021-02-16 Thread Hans Goudey
Commit: eb2e260540439e75cd8fb74e9bb41d1e87213496
Author: Hans Goudey
Date:   Tue Feb 16 13:06:18 2021 -0600
Branches: master
https://developer.blender.org/rBeb2e260540439e75cd8fb74e9bb41d1e87213496

Cleanup: Used derived node in geometry exec params

Since the derived node tree is already build for the evaluation system,
it's simpler to pass a derived node to the params struct. This will also
allow context lookups in nested node groups for node error messages,
since the derived node has that information readily accessible.

===

M   source/blender/modifiers/intern/MOD_nodes.cc
M   source/blender/nodes/NOD_geometry_exec.hh
M   source/blender/nodes/intern/node_geometry_exec.cc

===

diff --git a/source/blender/modifiers/intern/MOD_nodes.cc 
b/source/blender/modifiers/intern/MOD_nodes.cc
index 0fec7cfe937..706ef8578ac 100644
--- a/source/blender/modifiers/intern/MOD_nodes.cc
+++ b/source/blender/modifiers/intern/MOD_nodes.cc
@@ -331,7 +331,6 @@ class GeometryNodesEvaluator {
   void compute_output_and_forward(const DOutputSocket _to_compute)
   {
 const DNode  = socket_to_compute.node();
-const bNode  = *node.bnode();
 
 if (!socket_to_compute.is_available()) {
   /* If the output is not available, use a default value. */
@@ -360,7 +359,7 @@ class GeometryNodesEvaluator {
 /* Execute the node. */
 GValueMap node_outputs_map{allocator_};
 GeoNodeExecParams params{
-bnode, node_inputs_map, node_outputs_map, handle_map_, self_object_, 
depsgraph_};
+node, node_inputs_map, node_outputs_map, handle_map_, self_object_, 
depsgraph_};
 this->execute_node(node, params);
 
 /* Forward computed outputs to linked input sockets. */
diff --git a/source/blender/nodes/NOD_geometry_exec.hh 
b/source/blender/nodes/NOD_geometry_exec.hh
index 1149ab51ad0..18de52ed6d4 100644
--- a/source/blender/nodes/NOD_geometry_exec.hh
+++ b/source/blender/nodes/NOD_geometry_exec.hh
@@ -25,6 +25,8 @@
 
 #include "DNA_node_types.h"
 
+#include "NOD_derived_node_tree.hh"
+
 struct Depsgraph;
 
 namespace blender::nodes {
@@ -55,7 +57,7 @@ using fn::GValueMap;
 
 class GeoNodeExecParams {
  private:
-  const bNode _;
+  const DNode _;
   GValueMap _values_;
   GValueMap _values_;
   const PersistentDataHandleMap _map_;
@@ -63,7 +65,7 @@ class GeoNodeExecParams {
   Depsgraph *depsgraph_;
 
  public:
-  GeoNodeExecParams(const bNode ,
+  GeoNodeExecParams(const DNode ,
 GValueMap _values,
 GValueMap _values,
 const PersistentDataHandleMap _map,
@@ -178,7 +180,7 @@ class GeoNodeExecParams {
*/
   const bNode () const
   {
-return node_;
+return *node_.bnode();
   }
 
   const PersistentDataHandleMap _map() const
diff --git a/source/blender/nodes/intern/node_geometry_exec.cc 
b/source/blender/nodes/intern/node_geometry_exec.cc
index 3de8209859b..7f4f75c294f 100644
--- a/source/blender/nodes/intern/node_geometry_exec.cc
+++ b/source/blender/nodes/intern/node_geometry_exec.cc
@@ -14,6 +14,7 @@
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
+#include "NOD_derived_node_tree.hh"
 #include "NOD_geometry_exec.hh"
 #include "NOD_type_callbacks.hh"
 
@@ -23,12 +24,9 @@ namespace blender::nodes {
 
 const bNodeSocket *GeoNodeExecParams::find_available_socket(const StringRef 
name) const
 {
-  LISTBASE_FOREACH (const bNodeSocket *, socket, _.inputs) {
-if ((socket->flag & SOCK_UNAVAIL) != 0) {
-  continue;
-}
-if (name == socket->name) {
-  return socket;
+  for (const DSocket *socket : node_.inputs()) {
+if (socket->is_available() && socket->name() == name) {
+  return socket->bsocket();
 }
   }
 
@@ -144,18 +142,19 @@ void GeoNodeExecParams::check_extract_input(StringRef 
identifier,
 const CPPType *requested_type) 
const
 {
   bNodeSocket *found_socket = nullptr;
-  LISTBASE_FOREACH (bNodeSocket *, socket, _.inputs) {
-if (identifier == socket->identifier) {
-  found_socket = socket;
+  for (const DSocket *socket : node_.inputs()) {
+if (socket->identifier() == identifier) {
+  found_socket = socket->bsocket();
   break;
 }
   }
+
   if (found_socket == nullptr) {
 std::cout << "Did not find an input socket with the identifier '" << 
identifier << "'.\n";
 std::cout << "Possible identifiers are: ";
-LISTBASE_FOREACH (bNodeSocket *, socket, _.inputs) {
-  if ((socket->flag & SOCK_UNAVAIL) == 0) {
-std::cout << "'" << socket->identifier << "', ";
+for (const DSocket *socket : node_.inputs()) {
+  if (socket->is_available()) {
+std::cout << "'" << socket->identifier() << "', ";
   }
 }
 std::cout << "\n";
@@ -185,18 +184,19 @@ void GeoNodeExecParams::check_extract_input(StringRef 
identifier,
 void 

[Bf-blender-cvs] [c075b8bff22] master: Cleanup: Remove use of designated initializers in C++

2021-02-16 Thread Hans Goudey
Commit: c075b8bff22073b890679855b3342a57640bfba4
Author: Hans Goudey
Date:   Tue Feb 16 12:02:45 2021 -0600
Branches: master
https://developer.blender.org/rBc075b8bff22073b890679855b3342a57640bfba4

Cleanup: Remove use of designated initializers in C++

===

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

===

diff --git a/source/blender/editors/space_node/node_draw.cc 
b/source/blender/editors/space_node/node_draw.cc
index 044f3882d07..8662217961c 100644
--- a/source/blender/editors/space_node/node_draw.cc
+++ b/source/blender/editors/space_node/node_draw.cc
@@ -775,10 +775,10 @@ static void node_socket_draw_multi_input(const float 
color[4],
   const float outline_width = 1.0f;
   /* UI_draw_roundbox draws the outline on the outer side, so compensate for 
the outline width. */
   const rctf rect = {
-  .xmin = locx - width + outline_width * 0.5f,
-  .xmax = locx + width - outline_width * 0.5f,
-  .ymin = locy - height + outline_width * 0.5f,
-  .ymax = locy + height - outline_width * 0.5f,
+  locx - width + outline_width * 0.5f,
+  locx + width - outline_width * 0.5f,
+  locy - height + outline_width * 0.5f,
+  locy + height - outline_width * 0.5f,
   };
 
   UI_draw_roundbox_corner_set(UI_CNR_ALL);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [37067ef6cb3] temp-node-error-messages: Cleanup

2021-02-16 Thread Hans Goudey
Commit: 37067ef6cb3041d769f635b6f5bc04e8f56726ed
Author: Hans Goudey
Date:   Tue Feb 16 11:16:24 2021 -0600
Branches: temp-node-error-messages
https://developer.blender.org/rB37067ef6cb3041d769f635b6f5bc04e8f56726ed

Cleanup

===

M   source/blender/blenkernel/BKE_node.h
M   source/blender/blenkernel/BKE_node_ui_storage.hh
M   source/blender/blenkernel/intern/node.cc
M   source/blender/blenkernel/intern/node_ui_storage.cc
M   source/blender/editors/space_node/node_draw.cc
M   source/blender/imbuf/intern/indexer.c
M   source/blender/makesdna/DNA_node_types.h
M   source/blender/modifiers/intern/MOD_nodes.cc
M   source/blender/nodes/NOD_geometry_exec.hh

===

diff --git a/source/blender/blenkernel/BKE_node.h 
b/source/blender/blenkernel/BKE_node.h
index 62c06af0884..7984bbc980a 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -848,7 +848,7 @@ bool BKE_node_is_connected_to_output(struct bNodeTree 
*ntree, struct bNode *node
 /* ** COMMON NODES *** */
 
 #define NODE_UNDEFINED -2 /* node type is not registered */
-#define NODE_CUSTOM -1 /* for dynamically registered custom types */
+#define NODE_CUSTOM -1/* for dynamically registered custom types */
 #define NODE_GROUP 2
 // #define NODE_FORLOOP 3   /* deprecated */
 // #define NODE_WHILELOOP   4   /* deprecated */
diff --git a/source/blender/blenkernel/BKE_node_ui_storage.hh 
b/source/blender/blenkernel/BKE_node_ui_storage.hh
index ac0c4dcfab0..fa08b167c72 100644
--- a/source/blender/blenkernel/BKE_node_ui_storage.hh
+++ b/source/blender/blenkernel/BKE_node_ui_storage.hh
@@ -29,11 +29,15 @@ struct bNodeTree;
 struct Object;
 struct ModifierData;
 
+/**
+ * Contains the context necessary to determine when to display settings for a 
certain node tree
+ * that may be used for multiple modifiers and objects.
+ *
+ * \note This does not yet handle the context of nested node trees.
+ */
 struct NodeUIStorageContextModifier {
   std::string object_name;
   SessionUUID modifier_session_uuid;
-  /* TODO: The same node tree can be used multiple times in a parent node tree,
-   * so the tree path should be added to the context here. */
 
   NodeUIStorageContextModifier(const Object , const ModifierData 
)
   {
@@ -45,7 +49,7 @@ struct NodeUIStorageContextModifier {
   {
 const uint64_t hash1 = blender::DefaultHash{}(object_name);
 const uint64_t hash2 = 
BLI_session_uuid_hash_uint64(_session_uuid);
-return hash1 ^ (hash2 * 33); /* Copied from DefaultHash pair hash 
function. */
+return hash1 ^ (hash2 * 33); /* Copied from DefaultHash for std::pair. */
   }
 
   bool operator==(const NodeUIStorageContextModifier ) const
@@ -74,12 +78,12 @@ struct NodeTreeUIStorage {
   blender::Map> node_map;
 };
 
-void BKE_nodetree_ui_storage_clear(struct bNodeTree );
+void BKE_nodetree_ui_storage_free(bNodeTree );
 
-void BKE_nodetree_ui_storage_ensure(bNodeTree );
+void BKE_nodetree_ui_storage_add(bNodeTree );
 
-void BKE_nodetree_error_message_add(struct bNodeTree ,
+void BKE_nodetree_error_message_add(bNodeTree ,
 const NodeUIStorageContextModifier 
,
-const struct bNode ,
+const bNode ,
 const NodeWarningType type,
 std::string message);
diff --git a/source/blender/blenkernel/intern/node.cc 
b/source/blender/blenkernel/intern/node.cc
index 8e63815f734..1c1683c38ae 100644
--- a/source/blender/blenkernel/intern/node.cc
+++ b/source/blender/blenkernel/intern/node.cc
@@ -220,7 +220,7 @@ static void ntree_copy_data(Main *UNUSED(bmain), ID 
*id_dst, const ID *id_src, c
 
   /* Don't copy error messages in the runtime struct.
* They should be filled during execution anyway. */
-  ntree_dst->runtime = nullptr;
+  ntree_dst->ui_storage = nullptr;
 }
 
 static void ntree_free_data(ID *id)
@@ -275,7 +275,7 @@ static void ntree_free_data(ID *id)
 BKE_libblock_free_data(>id, true);
   }
 
-  BKE_nodetree_ui_storage_clear(*ntree);
+  BKE_nodetree_ui_storage_free(*ntree);
 }
 
 static void library_foreach_node_socket(LibraryForeachIDData *data, 
bNodeSocket *sock)
@@ -565,7 +565,7 @@ static void ntree_blend_write(BlendWriter *writer, ID *id, 
const void *id_addres
 ntree->interface_type = nullptr;
 ntree->progress = nullptr;
 ntree->execdata = nullptr;
-ntree->runtime = nullptr;
+ntree->ui_storage = nullptr;
 
 BLO_write_id_struct(writer, bNodeTree, id_address, >id);
 
@@ -597,7 +597,7 @@ void ntreeBlendReadData(BlendDataReader *reader, bNodeTree 
*ntree)
 
   ntree->progress = nullptr;
   ntree->execdata = nullptr;
-  ntree->runtime = nullptr;
+  ntree->ui_storage = nullptr;
 
   BLO_read_data_address(reader, >adt);
   

[Bf-blender-cvs] [375be25eaf7] temp-node-error-messages: Remove "TODO"

2021-02-16 Thread Hans Goudey
Commit: 375be25eaf76552f87ea5362c51dd29c2f025dc8
Author: Hans Goudey
Date:   Tue Feb 16 11:21:16 2021 -0600
Branches: temp-node-error-messages
https://developer.blender.org/rB375be25eaf76552f87ea5362c51dd29c2f025dc8

Remove "TODO"

===

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

===

diff --git a/source/blender/editors/space_node/node_draw.cc 
b/source/blender/editors/space_node/node_draw.cc
index 8a6d6523ed5..a136c431cc2 100644
--- a/source/blender/editors/space_node/node_draw.cc
+++ b/source/blender/editors/space_node/node_draw.cc
@@ -1260,7 +1260,7 @@ static void node_add_error_message_button(
 return;
   }
 
-  /* TODO: The UI API forces us to allocate memory for each error message we 
pass.
+  /* The UI API forces us to allocate memory for each error message we pass.
* The ownership of #UI_but_func_tooltip_set's argument is transferred to 
the button.
* We shouldn't need to do this though, investigate improving this. */
   int total_str_len = node_ui_storage->warnings.size(); /* Leave room for new 
line characters. */

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [88dcfd17326] temp-node-error-messages: Merge branch 'master' into temp-node-error-messages

2021-02-16 Thread Hans Goudey
Commit: 88dcfd17326fc1e65dbd18a4e62f24e5a3ef4d26
Author: Hans Goudey
Date:   Tue Feb 16 11:02:55 2021 -0600
Branches: temp-node-error-messages
https://developer.blender.org/rB88dcfd17326fc1e65dbd18a4e62f24e5a3ef4d26

Merge branch 'master' into temp-node-error-messages

===



===

diff --cc source/blender/editors/space_node/node_draw.cc
index b71652ea58f,044f3882d07..bf2f9ac0718
--- a/source/blender/editors/space_node/node_draw.cc
+++ b/source/blender/editors/space_node/node_draw.cc
@@@ -1186,124 -1178,6 +1186,124 @@@ void node_draw_sockets(const View2D *v2
}
  }
  
 +static int node_error_type_to_icon(const NodeWarningType type)
 +{
 +  switch (type) {
 +case NodeWarningType::Error:
 +  return ICON_ERROR;
 +case NodeWarningType::Warning:
 +  return ICON_ERROR;
 +case NodeWarningType::Info:
 +  return ICON_INFO;
 +  }
 +
 +  BLI_assert(false);
 +  return ICON_ERROR;
 +}
 +
 +static uint8_t node_error_type_priority(const NodeWarningType type)
 +{
 +  switch (type) {
 +case NodeWarningType::Error:
 +  return 3;
 +case NodeWarningType::Warning:
 +  return 2;
 +case NodeWarningType::Info:
 +  return 1;
 +  }
 +
 +  BLI_assert(false);
 +  return 0;
 +}
 +
 +static char *node_errrors_tooltip_fn(bContext *UNUSED(C), void *argN, const 
char *UNUSED(tip))
 +{
 +  char *message = static_cast(argN);
 +
 +  return BLI_strdup(message);
 +}
 +
 +#define NODE_HEADER_ICON_SIZE 0.8f * U.widget_unit
 +
 +static const NodeUIStorage *node_ui_storage_get_from_context(const bContext 
*C,
 + const bNodeTree 
,
 + const bNode 
)
 +{
 +  const NodeTreeUIStorage *node_tree_ui_storage = ntree.runtime;
 +  if (node_tree_ui_storage == nullptr) {
 +return nullptr;
 +  }
 +  const Map *node_ui_storage =
 +  node_tree_ui_storage->node_map.lookup_ptr(node.name);
 +  if (node_ui_storage == nullptr) {
 +return nullptr;
 +  }
 +
 +  const Object *active_object = CTX_data_active_object(C);
 +  const ModifierData *active_modifier = 
BKE_object_active_modifier(active_object);
 +  if (active_object == nullptr || active_modifier == nullptr) {
 +return nullptr;
 +  }
 +  const NodeUIStorageContextModifier context = 
NodeUIStorageContextModifier(*active_object,
 +
*active_modifier);
 +
 +  return node_ui_storage->lookup_ptr(context);
 +}
 +
 +static void node_add_error_message_button(
 +const bContext *C, bNodeTree , bNode , const rctf , float 
_offset)
 +{
 +  const NodeUIStorage *node_ui_storage = node_ui_storage_get_from_context(C, 
ntree, node);
 +  if (node_ui_storage == nullptr) {
 +return;
 +  }
 +
 +  /* TODO: The UI API forces us to allocate memory for each error message we 
pass.
 +   * The ownership of #UI_but_func_tooltip_set's argument is transferred to 
the button.
 +   * We shouldn't need to do this though, investigate improving this. */
 +  int total_str_len = node_ui_storage->warnings.size(); /* Leave room for new 
line characters. */
 +  for (const NodeWarning  : node_ui_storage->warnings) {
 +total_str_len += warning.message.size();
 +  }
 +  char *tooltip_alloc = (char *)MEM_mallocN(sizeof(char) * total_str_len, 
__func__);
 +  int tooltip_offest = 0;
 +  for (const NodeWarning  : node_ui_storage->warnings) {
 +BLI_strncpy(tooltip_alloc + tooltip_offest, warning.message.c_str(), 
warning.message.size());
 +tooltip_offest += warning.message.size();
 +BLI_strncpy(tooltip_alloc + tooltip_offest, "\n", 1);
 +tooltip_offest++;
 +  }
 +
 +  uint8_t highest_priority = 0;
 +  NodeWarningType highest_priority_type = NodeWarningType::Info;
 +  for (const NodeWarning  : node_ui_storage->warnings) {
 +const uint8_t priority = node_error_type_priority(warning.type);
 +if (priority > highest_priority) {
 +  highest_priority = priority;
 +  highest_priority_type = warning.type;
 +}
 +  }
 +
 +  icon_offset -= NODE_HEADER_ICON_SIZE;
 +  UI_block_emboss_set(node.block, UI_EMBOSS_NONE);
 +  uiBut *but = uiDefIconBut(node.block,
 +UI_BTYPE_BUT,
 +0,
 +node_error_type_to_icon(highest_priority_type),
 +icon_offset,
 +rect.ymax - NODE_DY,
 +NODE_HEADER_ICON_SIZE,
 +UI_UNIT_Y,
- NULL,
++nullptr,
 +0,
 +0,
 +0,
 +0,
- NULL);
++nullptr);
 +  UI_but_func_tooltip_set(but, node_errrors_tooltip_fn, 

[Bf-blender-cvs] [520d965c77f] master: Cleanup: Compile node_draw.c with C++

2021-02-16 Thread Hans Goudey
Commit: 520d965c77f9109492013d33cff659cd6055ff11
Author: Hans Goudey
Date:   Tue Feb 16 10:55:10 2021 -0600
Branches: master
https://developer.blender.org/rB520d965c77f9109492013d33cff659cd6055ff11

Cleanup: Compile node_draw.c with C++

This will allow using C++ data structures to draw  node error messages.
This required removing a forward declared enum for grease pencil undo.
Compiles with clang tidy.

===

M   source/blender/editors/gpencil/gpencil_undo.c
M   source/blender/editors/include/ED_gpencil.h
M   source/blender/editors/include/ED_node.h
M   source/blender/editors/space_node/CMakeLists.txt
R095source/blender/editors/space_node/node_draw.c   
source/blender/editors/space_node/node_draw.cc
M   source/blender/editors/space_node/node_intern.h

===

diff --git a/source/blender/editors/gpencil/gpencil_undo.c 
b/source/blender/editors/gpencil/gpencil_undo.c
index 583878883fa..ede1d3eefaa 100644
--- a/source/blender/editors/gpencil/gpencil_undo.c
+++ b/source/blender/editors/gpencil/gpencil_undo.c
@@ -62,19 +62,23 @@ int ED_gpencil_session_active(void)
   return (BLI_listbase_is_empty(_nodes) == false);
 }
 
-int ED_undo_gpencil_step(bContext *C, const eUndoStepDir step)
+/**
+ * \param step: eUndoStepDir.
+ */
+int ED_undo_gpencil_step(bContext *C, const int step)
 {
   bGPdata **gpd_ptr = NULL, *new_gpd = NULL;
 
   gpd_ptr = ED_gpencil_data_get_pointers(C, NULL);
 
-  if (step == STEP_UNDO) {
+  const eUndoStepDir undo_step = (eUndoStepDir)step;
+  if (undo_step == STEP_UNDO) {
 if (cur_node->prev) {
   cur_node = cur_node->prev;
   new_gpd = cur_node->gpd;
 }
   }
-  else if (step == STEP_REDO) {
+  else if (undo_step == STEP_REDO) {
 if (cur_node->next) {
   cur_node = cur_node->next;
   new_gpd = cur_node->gpd;
diff --git a/source/blender/editors/include/ED_gpencil.h 
b/source/blender/editors/include/ED_gpencil.h
index 12aef6e9464..2fbf280475b 100644
--- a/source/blender/editors/include/ED_gpencil.h
+++ b/source/blender/editors/include/ED_gpencil.h
@@ -62,8 +62,6 @@ struct bAnimContext;
 struct wmKeyConfig;
 struct wmOperator;
 
-enum eUndoStepDir;
-
 #define GPENCIL_MINIMUM_JOIN_DIST 20.0f
 
 /* Reproject stroke modes. */
@@ -215,7 +213,7 @@ bool ED_gpencil_anim_copybuf_paste(struct bAnimContext *ac, 
const short copy_mod
 
 /*  Grease-Pencil Undo System -- */
 int ED_gpencil_session_active(void);
-int ED_undo_gpencil_step(struct bContext *C, const enum eUndoStepDir step);
+int ED_undo_gpencil_step(struct bContext *C, const int step); /* eUndoStepDir. 
*/
 
 /*  Grease-Pencil Armature -- */
 bool ED_gpencil_add_armature(const struct bContext *C,
diff --git a/source/blender/editors/include/ED_node.h 
b/source/blender/editors/include/ED_node.h
index 78f354a300d..ea2383457c2 100644
--- a/source/blender/editors/include/ED_node.h
+++ b/source/blender/editors/include/ED_node.h
@@ -80,7 +80,7 @@ void ED_node_sample_set(const float col[4]);
 void ED_node_draw_snap(
 struct View2D *v2d, const float cent[2], float size, NodeBorder border, 
unsigned int pos);
 
-/* node_draw.c */
+/* node_draw.cc */
 void ED_node_socket_draw(struct bNodeSocket *sock,
  const struct rcti *rect,
  const float color[4],
diff --git a/source/blender/editors/space_node/CMakeLists.txt 
b/source/blender/editors/space_node/CMakeLists.txt
index f4a3bb96aeb..c640b076ba4 100644
--- a/source/blender/editors/space_node/CMakeLists.txt
+++ b/source/blender/editors/space_node/CMakeLists.txt
@@ -40,7 +40,7 @@ set(SRC
   drawnode.c
   node_add.c
   node_buttons.c
-  node_draw.c
+  node_draw.cc
   node_edit.c
   node_gizmo.c
   node_group.c
diff --git a/source/blender/editors/space_node/node_draw.c 
b/source/blender/editors/space_node/node_draw.cc
similarity index 95%
rename from source/blender/editors/space_node/node_draw.c
rename to source/blender/editors/space_node/node_draw.cc
index c7be5f848f7..044f3882d07 100644
--- a/source/blender/editors/space_node/node_draw.c
+++ b/source/blender/editors/space_node/node_draw.cc
@@ -74,9 +74,11 @@
 #  include "COM_compositor.h"
 #endif
 
+extern "C" {
 /* XXX interface.h */
 extern void ui_draw_dropshadow(
 const rctf *rct, float radius, float aspect, float alpha, int select);
+}
 
 float ED_node_grid_size(void)
 {
@@ -103,13 +105,13 @@ static bNodeTree *node_tree_from_ID(ID *id)
 return ntreeFromID(id);
   }
 
-  return NULL;
+  return nullptr;
 }
 
 void ED_node_tag_update_id(ID *id)
 {
   bNodeTree *ntree = node_tree_from_ID(id);
-  if (id == NULL || ntree == NULL) {
+  if (id == nullptr || ntree == nullptr) {
 return;
   }
 
@@ -156,7 +158,7 @@ void ED_node_tag_update_nodetree(Main *bmain, bNodeTree 
*ntree, bNode *node)
   }
 
   bool do_tag_update = true;
-  if (node != NULL) {
+  if (node != 

[Bf-blender-cvs] [1d4969905d9] temp-node-error-messages: Changes from review

2021-02-16 Thread Hans Goudey
Commit: 1d4969905d9a7722857ec2d2305f0d78c399f659
Author: Hans Goudey
Date:   Tue Feb 16 10:32:13 2021 -0600
Branches: temp-node-error-messages
https://developer.blender.org/rB1d4969905d9a7722857ec2d2305f0d78c399f659

Changes from review

===

M   source/blender/blenkernel/BKE_node_ui_storage.hh
M   source/blender/blenkernel/intern/attribute_access.cc
M   source/blender/blenkernel/intern/node_ui_storage.cc
M   source/blender/editors/space_node/node_draw.cc
M   source/blender/modifiers/intern/MOD_nodes.cc
M   source/blender/nodes/NOD_geometry_exec.hh
M   source/blender/nodes/geometry/nodes/node_geo_attribute_mix.cc
M   source/blender/nodes/intern/node_geometry_exec.cc

===

diff --git a/source/blender/blenkernel/BKE_node_ui_storage.hh 
b/source/blender/blenkernel/BKE_node_ui_storage.hh
index b498e75f289..ac0c4dcfab0 100644
--- a/source/blender/blenkernel/BKE_node_ui_storage.hh
+++ b/source/blender/blenkernel/BKE_node_ui_storage.hh
@@ -32,6 +32,8 @@ struct ModifierData;
 struct NodeUIStorageContextModifier {
   std::string object_name;
   SessionUUID modifier_session_uuid;
+  /* TODO: The same node tree can be used multiple times in a parent node tree,
+   * so the tree path should be added to the context here. */
 
   NodeUIStorageContextModifier(const Object , const ModifierData 
)
   {
@@ -41,10 +43,9 @@ struct NodeUIStorageContextModifier {
 
   uint64_t hash() const
   {
-
 const uint64_t hash1 = blender::DefaultHash{}(object_name);
 const uint64_t hash2 = 
BLI_session_uuid_hash_uint64(_session_uuid);
-return hash1 ^ (hash2 * 33);
+return hash1 ^ (hash2 * 33); /* Copied from DefaultHash pair hash 
function. */
   }
 
   bool operator==(const NodeUIStorageContextModifier ) const
@@ -71,8 +72,6 @@ struct NodeUIStorage {
 
 struct NodeTreeUIStorage {
   blender::Map> node_map;
-
-  NodeTreeUIStorage() = default;
 };
 
 void BKE_nodetree_ui_storage_clear(struct bNodeTree );
@@ -83,4 +82,4 @@ void BKE_nodetree_error_message_add(struct bNodeTree ,
 const NodeUIStorageContextModifier 
,
 const struct bNode ,
 const NodeWarningType type,
-const std::string );
+std::string message);
diff --git a/source/blender/blenkernel/intern/attribute_access.cc 
b/source/blender/blenkernel/intern/attribute_access.cc
index ebe9d591dbd..f594ec54a7e 100644
--- a/source/blender/blenkernel/intern/attribute_access.cc
+++ b/source/blender/blenkernel/intern/attribute_access.cc
@@ -1662,10 +1662,7 @@ ReadAttributePtr 
GeometryComponent::attribute_get_for_read(const StringRef attri
   if (attribute) {
 return attribute;
   }
-  if (default_value != nullptr) {
-return this->attribute_get_constant_for_read(domain, data_type, 
default_value);
-  }
-  return nullptr;
+  return this->attribute_get_constant_for_read(domain, data_type, 
default_value);
 }
 
 blender::bke::ReadAttributePtr 
GeometryComponent::attribute_get_constant_for_read(
@@ -1829,7 +1826,6 @@ void OutputAttributePtr::save()
 OutputAttributePtr::~OutputAttributePtr()
 {
   if (attribute_) {
-/* TODO: Fix that this is printing all the time now, even after applying 
and saving. */
 CLOG_ERROR(, "Forgot to call #save or #apply_span_and_save.");
   }
 }
diff --git a/source/blender/blenkernel/intern/node_ui_storage.cc 
b/source/blender/blenkernel/intern/node_ui_storage.cc
index 5df1b5d34d2..696d228a425 100644
--- a/source/blender/blenkernel/intern/node_ui_storage.cc
+++ b/source/blender/blenkernel/intern/node_ui_storage.cc
@@ -79,11 +79,13 @@ static void node_error_message_log(bNodeTree ,
   }
 }
 
+/* USE THE AS METHODS */
+
 void BKE_nodetree_error_message_add(bNodeTree ,
 const NodeUIStorageContextModifier 
,
 const bNode ,
 const NodeWarningType type,
-const std::string )
+std::string message)
 {
   BLI_assert(ntree.runtime != nullptr);
   NodeTreeUIStorage _tree_ui_storage = *ntree.runtime;
@@ -95,5 +97,5 @@ void BKE_nodetree_error_message_add(bNodeTree ,
 
   NodeUIStorage _ui_storage = 
context_to_storage_map.lookup_or_add_default(context);
 
-  node_ui_storage.warnings.append({type, message});
+  node_ui_storage.warnings.append({type, std::move(message)});
 }
diff --git a/source/blender/editors/space_node/node_draw.cc 
b/source/blender/editors/space_node/node_draw.cc
index ebd87ffdcbd..b71652ea58f 100644
--- a/source/blender/editors/space_node/node_draw.cc
+++ b/source/blender/editors/space_node/node_draw.cc
@@ -1727,7 +1727,7 @@ void node_set_cursor(wmWindow *win, SpaceNode *snode, 
float cursor[2])
 }
 else {
   /* 

[Bf-blender-cvs] [8642395e872] temp-node-error-messages: Merge branch 'master' into temp-node-error-messages

2021-02-16 Thread Hans Goudey
Commit: 8642395e872090d92571efa35fcad8bda3e7e109
Author: Hans Goudey
Date:   Tue Feb 16 08:25:33 2021 -0600
Branches: temp-node-error-messages
https://developer.blender.org/rB8642395e872090d92571efa35fcad8bda3e7e109

Merge branch 'master' into temp-node-error-messages

===



===

diff --cc source/blender/nodes/NOD_geometry_exec.hh
index 6a7bb2e2220,1149ab51ad0..f1f9a087eed
--- a/source/blender/nodes/NOD_geometry_exec.hh
+++ b/source/blender/nodes/NOD_geometry_exec.hh
@@@ -20,7 -20,7 +20,8 @@@
  
  #include "BKE_attribute_access.hh"
  #include "BKE_geometry_set.hh"
+ #include "BKE_geometry_set_instances.hh"
 +#include "BKE_node_ui_storage.hh"
  #include "BKE_persistent_data_handle.hh"
  
  #include "DNA_node_types.h"

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [b4155903376] temp-gpencil-interpolate: GPencil: Fix problem when select interpolated strokes

2021-02-16 Thread Antonio Vazquez
Commit: b4155903376eb30c52e4827286b4b51161c07d77
Author: Antonio Vazquez
Date:   Tue Feb 16 17:28:07 2021 +0100
Branches: temp-gpencil-interpolate
https://developer.blender.org/rBb4155903376eb30c52e4827286b4b51161c07d77

GPencil: Fix problem when select interpolated strokes

The pairs were not calculated as expected.

===

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

===

diff --git a/source/blender/editors/gpencil/gpencil_interpolate.c 
b/source/blender/editors/gpencil/gpencil_interpolate.c
index f20b4cafcb3..2784fbaf943 100644
--- a/source/blender/editors/gpencil/gpencil_interpolate.c
+++ b/source/blender/editors/gpencil/gpencil_interpolate.c
@@ -93,7 +93,7 @@ static bool gpencil_view3d_poll(bContext *C)
 }
 
 /* Return the stroke related to the selection index, returning the stroke with
- * the smallest selection index greater that reference index. */
+ * the smallest selection index greater than reference index. */
 static bGPDstroke *gpencil_stroke_get_related(GHash *used_strokes,
   bGPDframe *gpf,
   const int reference_index)
@@ -104,6 +104,7 @@ static bGPDstroke *gpencil_stroke_get_related(GHash 
*used_strokes,
 if (gps->select_index > reference_index) {
   if (!BLI_ghash_haskey(used_strokes, gps)) {
 if (gps->select_index < lower_index) {
+  lower_index = gps->select_index;
   gps_found = gps;
 }
   }
@@ -136,14 +137,15 @@ static void gpencil_stroke_pair_table(bContext *C,
   LISTBASE_FOREACH (bGPDstroke *, gps_from, >prevFrame->strokes) {
 bGPDstroke *gps_to = NULL;
 /* only selected */
-if ((only_selected) && ((gps_from->flag & GP_STROKE_SELECT) == 0)) {
+if ((GPENCIL_EDIT_MODE(gpd)) && (only_selected) &&
+((gps_from->flag & GP_STROKE_SELECT) == 0)) {
   continue;
 }
 /* skip strokes that are invalid for current view */
 if (ED_gpencil_stroke_can_use(C, gps_from) == false) {
   continue;
 }
-/* check if the color is editable */
+/* Check if the material is editable. */
 if (ED_gpencil_stroke_material_editable(tgpi->ob, tgpil->gpl, gps_from) == 
false) {
   continue;
 }
@@ -157,10 +159,12 @@ static void gpencil_stroke_pair_table(bContext *C,
   int fFrame = BLI_findindex(>prevFrame->strokes, gps_from);
   gps_to = BLI_findlink(>nextFrame->strokes, fFrame);
 }
-/* Insert the pair entry in the hash table. */
-if (gps_to != NULL) {
-  BLI_ghash_insert(tgpil->pair_strokes, gps_from, gps_to);
+
+if (ELEM(NULL, gps_from, gps_to)) {
+  continue;
 }
+/* Insert the pair entry in the hash table. */
+BLI_ghash_insert(tgpil->pair_strokes, gps_from, gps_to);
   }
 }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [8a76addf1e7] temp-gpencil-interpolate: GPencil: Fix compiler error after merge

2021-02-16 Thread Antonio Vazquez
Commit: 8a76addf1e71848a3c97a8729832f356c4c9fd69
Author: Antonio Vazquez
Date:   Tue Feb 16 16:53:50 2021 +0100
Branches: temp-gpencil-interpolate
https://developer.blender.org/rB8a76addf1e71848a3c97a8729832f356c4c9fd69

GPencil: Fix compiler error after merge

===

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

===

diff --git a/source/blender/editors/gpencil/gpencil_interpolate.c 
b/source/blender/editors/gpencil/gpencil_interpolate.c
index 5c134605d82..f20b4cafcb3 100644
--- a/source/blender/editors/gpencil/gpencil_interpolate.c
+++ b/source/blender/editors/gpencil/gpencil_interpolate.c
@@ -54,6 +54,7 @@
 #include "BKE_report.h"
 
 #include "UI_interface.h"
+#include "UI_resources.h"
 
 #include "WM_api.h"
 #include "WM_types.h"

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [21df41c84d4] temp-gpencil-interpolate: Merge branch 'master' into temp-gpencil-interpolate

2021-02-16 Thread Antonio Vazquez
Commit: 21df41c84d4f9bb69517b1740994ba541228c6d0
Author: Antonio Vazquez
Date:   Tue Feb 16 16:19:26 2021 +0100
Branches: temp-gpencil-interpolate
https://developer.blender.org/rB21df41c84d4f9bb69517b1740994ba541228c6d0

Merge branch 'master' into temp-gpencil-interpolate

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [8971018eb64] master: UI: Add support for bl_description for panels

2021-02-16 Thread Aaron Carlisle
Commit: 8971018eb64a68119687c74db875fd45f89cbdf8
Author: Aaron Carlisle
Date:   Tue Feb 16 09:38:42 2021 -0500
Branches: master
https://developer.blender.org/rB8971018eb64a68119687c74db875fd45f89cbdf8

UI: Add support for bl_description for panels

This commit adds support for `bl_description` and python docstrings for panels.
This is useful for pop-over panel types so they can have a label and 
description.

This commit also includes an example use case.

Reviewed By: campbellbarton

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

===

M   release/scripts/startup/bl_ui/space_properties.py
M   source/blender/blenkernel/BKE_screen.h
M   source/blender/editors/interface/interface_layout.c
M   source/blender/makesrna/intern/rna_ui.c

===

diff --git a/release/scripts/startup/bl_ui/space_properties.py 
b/release/scripts/startup/bl_ui/space_properties.py
index 053df113dd7..b7d5b5007d6 100644
--- a/release/scripts/startup/bl_ui/space_properties.py
+++ b/release/scripts/startup/bl_ui/space_properties.py
@@ -72,9 +72,10 @@ class PROPERTIES_PT_navigation_bar(Panel):
 
 
 class PROPERTIES_PT_options(Panel):
+"""Show options for the properties editor"""
 bl_space_type = 'PROPERTIES'
 bl_region_type = 'HEADER'
-bl_label = 'Show options for the properties editor'
+bl_label = "Options"
 
 def draw(self, context):
 layout = self.layout
diff --git a/source/blender/blenkernel/BKE_screen.h 
b/source/blender/blenkernel/BKE_screen.h
index 2fc0caf1a2c..32c888b058f 100644
--- a/source/blender/blenkernel/BKE_screen.h
+++ b/source/blender/blenkernel/BKE_screen.h
@@ -240,6 +240,7 @@ typedef struct PanelType {
 
   char idname[BKE_ST_MAXNAME]; /* unique name */
   char label[BKE_ST_MAXNAME];  /* for panel header */
+  char *description;   /* for panel tooltip */
   char translation_context[BKE_ST_MAXNAME];
   char context[BKE_ST_MAXNAME];   /* for buttons window */
   char category[BKE_ST_MAXNAME];  /* for category tabs */
diff --git a/source/blender/editors/interface/interface_layout.c 
b/source/blender/editors/interface/interface_layout.c
index fef243d7193..8f90dc7f801 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -3057,7 +3057,8 @@ void uiItemPopoverPanel_ptr(
 };
 pt->draw_header(C, );
   }
-  uiBut *but = ui_item_menu(layout, name, icon, ui_item_paneltype_func, pt, 
NULL, NULL, true);
+  uiBut *but = ui_item_menu(
+  layout, name, icon, ui_item_paneltype_func, pt, NULL, pt->description, 
true);
   but->type = UI_BTYPE_POPOVER;
   if (!ok) {
 but->flag |= UI_BUT_DISABLED;
diff --git a/source/blender/makesrna/intern/rna_ui.c 
b/source/blender/makesrna/intern/rna_ui.c
index 1d3a7750c39..5e5b3549986 100644
--- a/source/blender/makesrna/intern/rna_ui.c
+++ b/source/blender/makesrna/intern/rna_ui.c
@@ -261,9 +261,14 @@ static StructRNA *rna_Panel_register(Main *bmain,
   Panel dummypanel = {NULL};
   PointerRNA dummyptr;
   int have_function[4];
+  size_t over_alloc = 0; /* Warning, if this becomes a mess, we better do 
another allocation. */
+  char _panel_descr[RNA_DYN_DESCR_MAX];
+  size_t description_size = 0;
 
   /* setup dummy panel & panel type to store static properties in */
   dummypanel.type = 
+  _panel_descr[0] = '\0';
+  dummypanel.type->description = _panel_descr;
   RNA_pointer_create(NULL, _Panel, , );
 
   /* We have to set default context! Else we get a void string... */
@@ -355,9 +360,22 @@ static StructRNA *rna_Panel_register(Main *bmain,
   }
 
   /* create a new panel type */
-  pt = MEM_mallocN(sizeof(PanelType), "python buttons panel");
+  if (_panel_descr[0]) {
+description_size = strlen(_panel_descr) + 1;
+over_alloc += description_size;
+  }
+  pt = MEM_callocN(sizeof(PanelType) + over_alloc, "python buttons panel");
   memcpy(pt, , sizeof(dummypt));
 
+  if (_panel_descr[0]) {
+char *buf = (char *)(pt + 1);
+memcpy(buf, _panel_descr, description_size);
+pt->description = buf;
+  }
+  else {
+pt->description = NULL;
+  }
+
   pt->rna_ext.srna = RNA_def_struct_ptr(_RNA, pt->idname, _Panel);
   RNA_def_struct_translation_context(pt->rna_ext.srna, 
pt->translation_context);
   pt->rna_ext.data = data;
@@ -993,6 +1011,18 @@ static StructRNA *rna_Menu_refine(PointerRNA *mtr)
   return (menu->type && menu->type->rna_ext.srna) ? menu->type->rna_ext.srna : 
_Menu;
 }
 
+static void rna_Panel_bl_description_set(PointerRNA *ptr, const char *value)
+{
+  Panel *data = (Panel *)(ptr->data);
+  char *str = (char *)data->type->description;
+  if (!str[0]) {
+BLI_strncpy(str, value, RNA_DYN_DESCR_MAX); /* utf8 already ensured */
+  }
+  else {
+BLI_assert(!"setting the bl_description on a non-builtin panel");
+  }
+}
+
 static void rna_Menu_bl_description_set(PointerRNA *ptr, const char *value)
 {
  

[Bf-blender-cvs] [e81fca1ed38] master: Assets: Remove appended asset when dropping operation fails

2021-02-16 Thread Julian Eisel
Commit: e81fca1ed38ea447a1023dae3841f8980def28e4
Author: Julian Eisel
Date:   Tue Feb 16 15:24:22 2021 +0100
Branches: master
https://developer.blender.org/rBe81fca1ed38ea447a1023dae3841f8980def28e4

Assets: Remove appended asset when dropping operation fails

When dropping an asset somewhere, it is appended and then a drop operation is
called to actually add it to the scene based on current context. If this drop
operation fails, the appended data-block is now still in the .blend. The user
may not notice and not expect this.
Instead idea is to rollback any changes done by dropping code if the operation
fails, namely removing the appended data-block again.

Adds a new `cancel()` callback which is called if the drop operator returns
`OPERATOR_CANCELLED` to drop-boxes and a generic function to deal with assets
on drop failure.

Also removes the `free_id_on_error` property of the `NODE_OT_add_group`
operator, which was used as ad-hoc solution to get this same behavior.

===

M   source/blender/editors/screen/screen_ops.c
M   source/blender/editors/space_clip/space_clip.c
M   source/blender/editors/space_console/space_console.c
M   source/blender/editors/space_file/space_file.c
M   source/blender/editors/space_image/space_image.c
M   source/blender/editors/space_node/node_add.c
M   source/blender/editors/space_node/space_node.c
M   source/blender/editors/space_outliner/outliner_dragdrop.c
M   source/blender/editors/space_sequencer/space_sequencer.c
M   source/blender/editors/space_text/space_text.c
M   source/blender/editors/space_view3d/space_view3d.c
M   source/blender/windowmanager/WM_api.h
M   source/blender/windowmanager/WM_types.h
M   source/blender/windowmanager/intern/wm_dragdrop.c
M   source/blender/windowmanager/intern/wm_event_system.c

===

diff --git a/source/blender/editors/screen/screen_ops.c 
b/source/blender/editors/screen/screen_ops.c
index 0fc7e713bac..47feb49bd44 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -5567,8 +5567,8 @@ void ED_keymap_screen(wmKeyConfig *keyconf)
 
   /* dropbox for entire window */
   ListBase *lb = WM_dropboxmap_find("Window", 0, 0);
-  WM_dropbox_add(lb, "WM_OT_drop_blend_file", blend_file_drop_poll, 
blend_file_drop_copy);
-  WM_dropbox_add(lb, "UI_OT_drop_color", UI_drop_color_poll, 
UI_drop_color_copy);
+  WM_dropbox_add(lb, "WM_OT_drop_blend_file", blend_file_drop_poll, 
blend_file_drop_copy, NULL);
+  WM_dropbox_add(lb, "UI_OT_drop_color", UI_drop_color_poll, 
UI_drop_color_copy, NULL);
 
   keymap_modal_set(keyconf);
 }
diff --git a/source/blender/editors/space_clip/space_clip.c 
b/source/blender/editors/space_clip/space_clip.c
index 2a7c64a83f7..e0a524a79c1 100644
--- a/source/blender/editors/space_clip/space_clip.c
+++ b/source/blender/editors/space_clip/space_clip.c
@@ -639,7 +639,7 @@ static void clip_dropboxes(void)
 {
   ListBase *lb = WM_dropboxmap_find("Clip", SPACE_CLIP, 0);
 
-  WM_dropbox_add(lb, "CLIP_OT_open", clip_drop_poll, clip_drop_copy);
+  WM_dropbox_add(lb, "CLIP_OT_open", clip_drop_poll, clip_drop_copy, NULL);
 }
 
 static void clip_refresh(const bContext *C, ScrArea *area)
diff --git a/source/blender/editors/space_console/space_console.c 
b/source/blender/editors/space_console/space_console.c
index b24579d9871..56a6204b385 100644
--- a/source/blender/editors/space_console/space_console.c
+++ b/source/blender/editors/space_console/space_console.c
@@ -196,8 +196,8 @@ static void console_dropboxes(void)
 {
   ListBase *lb = WM_dropboxmap_find("Console", SPACE_CONSOLE, RGN_TYPE_WINDOW);
 
-  WM_dropbox_add(lb, "CONSOLE_OT_insert", id_drop_poll, id_drop_copy);
-  WM_dropbox_add(lb, "CONSOLE_OT_insert", path_drop_poll, path_drop_copy);
+  WM_dropbox_add(lb, "CONSOLE_OT_insert", id_drop_poll, id_drop_copy, NULL);
+  WM_dropbox_add(lb, "CONSOLE_OT_insert", path_drop_poll, path_drop_copy, 
NULL);
 }
 
 /* * end drop *** */
diff --git a/source/blender/editors/space_file/space_file.c 
b/source/blender/editors/space_file/space_file.c
index 178ca264182..66d24c7ab53 100644
--- a/source/blender/editors/space_file/space_file.c
+++ b/source/blender/editors/space_file/space_file.c
@@ -766,7 +766,7 @@ static void file_dropboxes(void)
 {
   ListBase *lb = WM_dropboxmap_find("Window", SPACE_EMPTY, RGN_TYPE_WINDOW);
 
-  WM_dropbox_add(lb, "FILE_OT_filepath_drop", filepath_drop_poll, 
filepath_drop_copy);
+  WM_dropbox_add(lb, "FILE_OT_filepath_drop", filepath_drop_poll, 
filepath_drop_copy, NULL);
 }
 
 static int file_space_subtype_get(ScrArea *area)
diff --git a/source/blender/editors/space_image/space_image.c 
b/source/blender/editors/space_image/space_image.c
index 69976bc088c..95ca8aba399 100644
--- a/source/blender/editors/space_image/space_image.c
+++ 

[Bf-blender-cvs] [5e8dcdf8b56] temp-node-error-messages: Working error messages, fixed incorrect buffer length

2021-02-16 Thread Hans Goudey
Commit: 5e8dcdf8b56fd61c029fd43eee32669b9bbf7d14
Author: Hans Goudey
Date:   Tue Feb 16 08:11:22 2021 -0600
Branches: temp-node-error-messages
https://developer.blender.org/rB5e8dcdf8b56fd61c029fd43eee32669b9bbf7d14

Working error messages, fixed incorrect buffer length

===

M   source/blender/blenkernel/BKE_node_ui_storage.hh
M   source/blender/blenkernel/intern/node_ui_storage.cc
M   source/blender/editors/space_node/node_draw.cc
M   source/blender/nodes/intern/node_geometry_exec.cc

===

diff --git a/source/blender/blenkernel/BKE_node_ui_storage.hh 
b/source/blender/blenkernel/BKE_node_ui_storage.hh
index 4a50bcf54ce..b498e75f289 100644
--- a/source/blender/blenkernel/BKE_node_ui_storage.hh
+++ b/source/blender/blenkernel/BKE_node_ui_storage.hh
@@ -18,6 +18,11 @@
 
 #include "BLI_hash.hh"
 #include "BLI_map.hh"
+#include "BLI_session_uuid.h"
+
+#include "DNA_ID.h"
+#include "DNA_modifier_types.h"
+#include "DNA_session_uuid_types.h"
 
 struct bNode;
 struct bNodeTree;
@@ -25,19 +30,27 @@ struct Object;
 struct ModifierData;
 
 struct NodeUIStorageContextModifier {
-  const struct Object *object;
-  const struct ModifierData *modifier;
+  std::string object_name;
+  SessionUUID modifier_session_uuid;
+
+  NodeUIStorageContextModifier(const Object , const ModifierData 
)
+  {
+object_name = reinterpret_cast(object).name;
+modifier_session_uuid = modifier.session_uuid;
+  }
 
   uint64_t hash() const
   {
-const uint64_t hash1 = blender::DefaultHash{}(object);
-const uint64_t hash2 = blender::DefaultHash{}(modifier);
+
+const uint64_t hash1 = blender::DefaultHash{}(object_name);
+const uint64_t hash2 = 
BLI_session_uuid_hash_uint64(_session_uuid);
 return hash1 ^ (hash2 * 33);
   }
 
   bool operator==(const NodeUIStorageContextModifier ) const
   {
-return other.object == object && other.modifier == modifier;
+return other.object_name == object_name &&
+   BLI_session_uuid_is_equal(_session_uuid, 
_session_uuid);
   }
 };
 
@@ -57,8 +70,7 @@ struct NodeUIStorage {
 };
 
 struct NodeTreeUIStorage {
-  blender::Map>
-  node_map;
+  blender::Map> node_map;
 
   NodeTreeUIStorage() = default;
 };
diff --git a/source/blender/blenkernel/intern/node_ui_storage.cc 
b/source/blender/blenkernel/intern/node_ui_storage.cc
index 844bf0fbb37..5df1b5d34d2 100644
--- a/source/blender/blenkernel/intern/node_ui_storage.cc
+++ b/source/blender/blenkernel/intern/node_ui_storage.cc
@@ -91,7 +91,7 @@ void BKE_nodetree_error_message_add(bNodeTree ,
   node_error_message_log(ntree, node, message, type);
 
   Map _to_storage_map =
-  node_tree_ui_storage.node_map.lookup_or_add_default();
+  node_tree_ui_storage.node_map.lookup_or_add_default(node.name);
 
   NodeUIStorage _ui_storage = 
context_to_storage_map.lookup_or_add_default(context);
 
diff --git a/source/blender/editors/space_node/node_draw.cc 
b/source/blender/editors/space_node/node_draw.cc
index ba1c13593f2..ebd87ffdcbd 100644
--- a/source/blender/editors/space_node/node_draw.cc
+++ b/source/blender/editors/space_node/node_draw.cc
@@ -1234,7 +1234,7 @@ static const NodeUIStorage 
*node_ui_storage_get_from_context(const bContext *C,
 return nullptr;
   }
   const Map *node_ui_storage =
-  node_tree_ui_storage->node_map.lookup_ptr();
+  node_tree_ui_storage->node_map.lookup_ptr(node.name);
   if (node_ui_storage == nullptr) {
 return nullptr;
   }
@@ -1244,7 +1244,8 @@ static const NodeUIStorage 
*node_ui_storage_get_from_context(const bContext *C,
   if (active_object == nullptr || active_modifier == nullptr) {
 return nullptr;
   }
-  const NodeUIStorageContextModifier context = {active_object, 
active_modifier};
+  const NodeUIStorageContextModifier context = 
NodeUIStorageContextModifier(*active_object,
+
*active_modifier);
 
   return node_ui_storage->lookup_ptr(context);
 }
@@ -1264,7 +1265,7 @@ static void node_add_error_message_button(
   for (const NodeWarning  : node_ui_storage->warnings) {
 total_str_len += warning.message.size();
   }
-  char *tooltip_alloc = (char *)MEM_mallocN(sizeof(char), __func__);
+  char *tooltip_alloc = (char *)MEM_mallocN(sizeof(char) * total_str_len, 
__func__);
   int tooltip_offest = 0;
   for (const NodeWarning  : node_ui_storage->warnings) {
 BLI_strncpy(tooltip_alloc + tooltip_offest, warning.message.c_str(), 
warning.message.size());
diff --git a/source/blender/nodes/intern/node_geometry_exec.cc 
b/source/blender/nodes/intern/node_geometry_exec.cc
index 35ff87147c6..3f56c01ad1a 100644
--- a/source/blender/nodes/intern/node_geometry_exec.cc
+++ b/source/blender/nodes/intern/node_geometry_exec.cc
@@ -32,7 +32,8 @@ void GeoNodeExecParams::error_message_add(const 
NodeWarningType type,
 {
   bNodeTree *original_ntree = (bNodeTree 

[Bf-blender-cvs] [58bac408ef4] temp-node-error-messages: Add error message in attribute randomize node

2021-02-16 Thread Hans Goudey
Commit: 58bac408ef45b108b5d5a4f1103b592923f74eec
Author: Hans Goudey
Date:   Mon Feb 15 23:42:12 2021 -0600
Branches: temp-node-error-messages
https://developer.blender.org/rB58bac408ef45b108b5d5a4f1103b592923f74eec

Add error message in attribute randomize node

===

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

===

diff --git 
a/source/blender/nodes/geometry/nodes/node_geo_attribute_randomize.cc 
b/source/blender/nodes/geometry/nodes/node_geo_attribute_randomize.cc
index 8a098c366a0..4a18544671c 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_attribute_randomize.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_randomize.cc
@@ -214,6 +214,8 @@ static void 
randomize_attribute_on_component(GeometryComponent ,
* doesn't already exist, don't do the operation. */
   if (operation != GEO_NODE_ATTRIBUTE_RANDOMIZE_REPLACE_CREATE) {
 if (!component.attribute_exists(attribute_name)) {
+  params.error_message_add(NodeWarningType::Error,
+   "Attribute with name \'" + attribute_name + "\' 
does not exist.");
   return;
 }
   }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [00365a0c9a3] temp-node-error-messages: Fix crash with undo

2021-02-16 Thread Hans Goudey
Commit: 00365a0c9a33fd815030dc258afefc2962d75f06
Author: Hans Goudey
Date:   Mon Feb 15 23:42:02 2021 -0600
Branches: temp-node-error-messages
https://developer.blender.org/rB00365a0c9a33fd815030dc258afefc2962d75f06

Fix crash with undo

===

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

===

diff --git a/source/blender/blenkernel/intern/node.cc 
b/source/blender/blenkernel/intern/node.cc
index 32356671c05..8e63815f734 100644
--- a/source/blender/blenkernel/intern/node.cc
+++ b/source/blender/blenkernel/intern/node.cc
@@ -565,7 +565,7 @@ static void ntree_blend_write(BlendWriter *writer, ID *id, 
const void *id_addres
 ntree->interface_type = nullptr;
 ntree->progress = nullptr;
 ntree->execdata = nullptr;
-// ntree->runtime = nullptr;
+ntree->runtime = nullptr;
 
 BLO_write_id_struct(writer, bNodeTree, id_address, >id);
 
@@ -597,7 +597,7 @@ void ntreeBlendReadData(BlendDataReader *reader, bNodeTree 
*ntree)
 
   ntree->progress = nullptr;
   ntree->execdata = nullptr;
-  // ntree->runtime = nullptr;
+  ntree->runtime = nullptr;
 
   BLO_read_data_address(reader, >adt);
   BKE_animdata_blend_read_data(reader, ntree->adt);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [500bc99da5d] master: Fix T85697: implement interpolation for float custom data type

2021-02-16 Thread Jacques Lucke
Commit: 500bc99da5dbcdf7c728833326fc29babaf529e0
Author: Jacques Lucke
Date:   Tue Feb 16 14:25:35 2021 +0100
Branches: master
https://developer.blender.org/rB500bc99da5dbcdf7c728833326fc29babaf529e0

Fix T85697: implement interpolation for float custom data type

This just hasn't been implemented before.

===

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

===

diff --git a/source/blender/blenkernel/intern/customdata.c 
b/source/blender/blenkernel/intern/customdata.c
index 782b4fc200e..9188d8c1afd 100644
--- a/source/blender/blenkernel/intern/customdata.c
+++ b/source/blender/blenkernel/intern/customdata.c
@@ -473,6 +473,21 @@ static void layerCopy_propFloat(const void *source, void 
*dest, int count)
   memcpy(dest, source, sizeof(MFloatProperty) * count);
 }
 
+static void layerInterp_propFloat(const void **sources,
+  const float *weights,
+  const float *UNUSED(sub_weights),
+  int count,
+  void *dest)
+{
+  float result = 0.0f;
+  for (int i = 0; i < count; i++) {
+const float interp_weight = weights[i];
+const float src = *(const float *)sources[i];
+result += src * interp_weight;
+  }
+  *(float *)dest = result;
+}
+
 static bool layerValidate_propFloat(void *data, const uint totitems, const 
bool do_fixes)
 {
   MFloatProperty *fp = data;
@@ -1553,7 +1568,7 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
  N_("Float"),
  layerCopy_propFloat,
  NULL,
- NULL,
+ layerInterp_propFloat,
  NULL,
  NULL,
  layerValidate_propFloat},

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [82ade442990] master: LibOverride: Add support for rotation mode of PoseBones.

2021-02-16 Thread Bastien Montagne
Commit: 82ade44299083e86acbaafbcb21ac350d861881d
Author: Bastien Montagne
Date:   Tue Feb 16 14:22:44 2021 +0100
Branches: master
https://developer.blender.org/rB82ade44299083e86acbaafbcb21ac350d861881d

LibOverride: Add support for rotation mode of PoseBones.

Request from the studio.

===

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

===

diff --git a/source/blender/makesrna/intern/rna_pose.c 
b/source/blender/makesrna/intern/rna_pose.c
index 89a6c7cdf9d..bd45990fe30 100644
--- a/source/blender/makesrna/intern/rna_pose.c
+++ b/source/blender/makesrna/intern/rna_pose.c
@@ -1142,6 +1142,7 @@ static void rna_def_pose_channel(BlenderRNA *brna)
 
   prop = RNA_def_property(srna, "rotation_mode", PROP_ENUM, PROP_NONE);
   RNA_def_property_enum_sdna(prop, NULL, "rotmode");
+  RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
   RNA_def_property_enum_items(prop, rna_enum_object_rotation_mode_items);
   RNA_def_property_enum_funcs(prop, NULL, "rna_PoseChannel_rotation_mode_set", 
NULL);
   /* XXX... disabled, since proxy-locked layers are currently

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [2442c85dc3d] master: Merge branch 'blender-v2.92-release'

2021-02-16 Thread Philipp Oeser
Commit: 2442c85dc3da289343f13fecf56b77ad09aceefa
Author: Philipp Oeser
Date:   Tue Feb 16 13:58:03 2021 +0100
Branches: master
https://developer.blender.org/rB2442c85dc3da289343f13fecf56b77ad09aceefa

Merge branch 'blender-v2.92-release'

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [c13754e6475] blender-v2.92-release: Fixes T84928 : Lattice vertices at unexpected positions when changing lattice resolution from 1 to 3 or more.

2021-02-16 Thread Pratik Borhade
Commit: c13754e6475e438ebd2fbafa2e51aa58504dc5f9
Author: Pratik Borhade
Date:   Tue Feb 16 13:21:28 2021 +0100
Branches: blender-v2.92-release
https://developer.blender.org/rBc13754e6475e438ebd2fbafa2e51aa58504dc5f9

Fixes T84928 : Lattice vertices at unexpected positions when changing lattice 
resolution from 1 to 3 or more.

Fix for T84928 .
Considering the changes , issue is resolved ( Ignoring readability issues) .

**Changes **:

  - `Change in value assignment of fu/v/w :`  Observing previous code , I 
noticed ,value assigned to them is equivalent to -0.5 ( i.e. co-ordinate of 
left most vertex of lattice size =1 where  centre of lattice is origin ) .

  - `Change in value assignment of du/v/w :`Margin ( distance ) between 
each division of surface along any axis is equivalent to **( (length of surface 
along axis ) / (no of division line - 1) )** . that's why is changed it to 
(default_size/unew -1) .

  - ` New variable declared "default_size"  :`  As far as I gone through the 
code , I noticed values  1 < du ,fu < 1  , which indicates these values were 
calculated with respect to default lattice of size 1 .

  - `removed pntsu/v/w != 1 check :`  Following changes inside the if block 
worked properly for pntsu/v/w = 1 .

Reviewed By: lichtwerk, campbellbarton

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

===

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

===

diff --git a/source/blender/blenkernel/intern/lattice.c 
b/source/blender/blenkernel/intern/lattice.c
index 74f78106be5..84ffd8c636b 100644
--- a/source/blender/blenkernel/intern/lattice.c
+++ b/source/blender/blenkernel/intern/lattice.c
@@ -319,19 +319,21 @@ void BKE_lattice_resize(Lattice *lt, int uNew, int vNew, 
int wNew, Object *ltOb)
* size first.
*/
   if (ltOb) {
-if (uNew != 1 && lt->pntsu != 1) {
-  fu = lt->fu;
-  du = (lt->pntsu - 1) * lt->du / (uNew - 1);
+const float default_size = 1.0;
+
+if (uNew != 1) {
+  fu = -default_size / 2.0;
+  du = default_size / (uNew - 1);
 }
 
-if (vNew != 1 && lt->pntsv != 1) {
-  fv = lt->fv;
-  dv = (lt->pntsv - 1) * lt->dv / (vNew - 1);
+if (vNew != 1) {
+  fv = -default_size / 2.0;
+  dv = default_size / (vNew - 1);
 }
 
-if (wNew != 1 && lt->pntsw != 1) {
-  fw = lt->fw;
-  dw = (lt->pntsw - 1) * lt->dw / (wNew - 1);
+if (wNew != 1) {
+  fw = -default_size / 2.0;
+  dw = default_size / (wNew - 1);
 }
   }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [1ec30d4b156] master: Fix T85697: subdivision surface node output does not contain vertex group names

2021-02-16 Thread Jacques Lucke
Commit: 1ec30d4b15684df333926aae78516b07dab428ad
Author: Jacques Lucke
Date:   Tue Feb 16 13:35:06 2021 +0100
Branches: master
https://developer.blender.org/rB1ec30d4b15684df333926aae78516b07dab428ad

Fix T85697: subdivision surface node output does not contain vertex group names

The vertex weights were actually interpolated correctly. The issue was that
vertex group names were removed from the output geometry set. We have
to keep track of these names separately from the mesh, for legacy reasons.
Vertex group names are not stored on meshes but objects instead.

===

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

===

diff --git 
a/source/blender/nodes/geometry/nodes/node_geo_subdivision_surface.cc 
b/source/blender/nodes/geometry/nodes/node_geo_subdivision_surface.cc
index 4cdb669f964..47304a0de68 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_subdivision_surface.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_subdivision_surface.cc
@@ -109,7 +109,8 @@ static void 
geo_node_subdivision_surface_exec(GeoNodeExecParams params)
   Mesh *mesh_out = BKE_subdiv_to_mesh(subdiv, _settings, mesh_in);
   BKE_mesh_calc_normals(mesh_out);
 
-  geometry_set.replace_mesh(mesh_out);
+  MeshComponent _component = 
geometry_set.get_component_for_write();
+  mesh_component.replace_mesh_but_keep_vertex_group_names(mesh_out);
 
   // BKE_subdiv_stats_print(>stats);
   BKE_subdiv_free(subdiv);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [5ea44ce3335] temp-gpencil-io: Merge branch 'master' into temp-gpencil-io

2021-02-16 Thread Antonio Vazquez
Commit: 5ea44ce3335d092bbffb9f269c66b7002f829c34
Author: Antonio Vazquez
Date:   Tue Feb 16 12:57:59 2021 +0100
Branches: temp-gpencil-io
https://developer.blender.org/rB5ea44ce3335d092bbffb9f269c66b7002f829c34

Merge branch 'master' into temp-gpencil-io

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [9eab14b016b] greasepencil-object: Merge branch 'master' into greasepencil-object

2021-02-16 Thread Antonio Vazquez
Commit: 9eab14b016b9c937ab7f5a63318b293ee963143a
Author: Antonio Vazquez
Date:   Tue Feb 16 12:57:43 2021 +0100
Branches: greasepencil-object
https://developer.blender.org/rB9eab14b016b9c937ab7f5a63318b293ee963143a

Merge branch 'master' into greasepencil-object

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [ed185c1ec59] temp-gpencil-interpolate: Merge branch 'master' into temp-gpencil-interpolate

2021-02-16 Thread Antonio Vazquez
Commit: ed185c1ec593b695256f875a93efa0147eac9016
Author: Antonio Vazquez
Date:   Tue Feb 16 12:57:25 2021 +0100
Branches: temp-gpencil-interpolate
https://developer.blender.org/rBed185c1ec593b695256f875a93efa0147eac9016

Merge branch 'master' into temp-gpencil-interpolate

===



===

diff --cc source/blender/makesdna/DNA_scene_types.h
index 90957d799aa,2362686cfce..4605ea26740
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@@ -1142,11 -1158,9 +1142,11 @@@ typedef enum eGP_Interpolate_SettingsFl
GP_TOOLFLAG_INTERPOLATE_ALL_LAYERS = (1 << 0),
/* apply interpolation to only selected */
GP_TOOLFLAG_INTERPOLATE_ONLY_SELECTED = (1 << 1),
 +  /* flip strokes */
 +  GP_TOOLFLAG_INTERPOLATE_FLIP = (1 << 2),
  } eGP_Interpolate_SettingsFlag;
  
- /* GP_Interpolate_Settings.type */
+ /** #GP_Interpolate_Settings.type */
  typedef enum eGP_Interpolate_Type {
/* Traditional Linear Interpolation */
GP_IPO_LINEAR = 0,

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [5688f791f51] master: Geometry Nodes: move realize-instances code to blenkernel

2021-02-16 Thread Jacques Lucke
Commit: 5688f791f51827d77f4479bee90c4e88add72ce6
Author: Jacques Lucke
Date:   Tue Feb 16 12:30:42 2021 +0100
Branches: master
https://developer.blender.org/rB5688f791f51827d77f4479bee90c4e88add72ce6

Geometry Nodes: move realize-instances code to blenkernel

I need to access this functionality from modifier code. Therefore it should
not be in the nodes module.

===

M   source/blender/blenkernel/BKE_geometry_set_instances.hh
M   source/blender/blenkernel/intern/geometry_set_instances.cc
M   source/blender/nodes/NOD_geometry_exec.hh
M   source/blender/nodes/geometry/node_geometry_util.cc
M   source/blender/nodes/geometry/node_geometry_util.hh

===

diff --git a/source/blender/blenkernel/BKE_geometry_set_instances.hh 
b/source/blender/blenkernel/BKE_geometry_set_instances.hh
index 11725d75df9..4f3c9c65203 100644
--- a/source/blender/blenkernel/BKE_geometry_set_instances.hh
+++ b/source/blender/blenkernel/BKE_geometry_set_instances.hh
@@ -14,6 +14,8 @@
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
+#pragma once
+
 #include "BKE_geometry_set.hh"
 
 namespace blender::bke {
@@ -39,4 +41,21 @@ struct GeometryInstanceGroup {
 
 Vector geometry_set_gather_instances(const GeometrySet 
_set);
 
+GeometrySet geometry_set_realize_instances(const GeometrySet _set);
+
+struct AttributeInfo {
+  CustomDataType data_type;
+  AttributeDomain domain;
+};
+
+/**
+ * Add information about all the attributes on every component of the type. 
The resulting info
+ * will contain the highest complexity data type and the highest priority 
domain among every
+ * attribute with the given name on all of the input components.
+ */
+void gather_attribute_info(Map ,
+   const GeometryComponentType component_type,
+   Span set_groups,
+   const Set _attributes);
+
 }  // namespace blender::bke
diff --git a/source/blender/blenkernel/intern/geometry_set_instances.cc 
b/source/blender/blenkernel/intern/geometry_set_instances.cc
index 6410aeb49fa..8e9edc86bca 100644
--- a/source/blender/blenkernel/intern/geometry_set_instances.cc
+++ b/source/blender/blenkernel/intern/geometry_set_instances.cc
@@ -15,10 +15,14 @@
  */
 
 #include "BKE_geometry_set_instances.hh"
+#include "BKE_mesh.h"
 #include "BKE_mesh_wrapper.h"
 #include "BKE_modifier.h"
+#include "BKE_pointcloud.h"
 
 #include "DNA_collection_types.h"
+#include "DNA_mesh_types.h"
+#include "DNA_meshdata_types.h"
 #include "DNA_object_types.h"
 
 namespace blender::bke {
@@ -160,4 +164,247 @@ Vector 
geometry_set_gather_instances(const GeometrySet 
   return result_vector;
 }
 
+void gather_attribute_info(Map ,
+   const GeometryComponentType component_type,
+   Span set_groups,
+   const Set _attributes)
+{
+  for (const GeometryInstanceGroup _group : set_groups) {
+const GeometrySet  = set_group.geometry_set;
+if (!set.has(component_type)) {
+  continue;
+}
+const GeometryComponent  = 
*set.get_component_for_read(component_type);
+
+for (const std::string  : component.attribute_names()) {
+  if (ignored_attributes.contains(name)) {
+continue;
+  }
+  const ReadAttributePtr read_attribute = 
component.attribute_try_get_for_read(name);
+  if (!read_attribute) {
+continue;
+  }
+  const AttributeDomain domain = read_attribute->domain();
+  const CustomDataType data_type = read_attribute->custom_data_type();
+
+  auto add_info = [&, data_type, domain](AttributeInfo *info) {
+info->domain = domain;
+info->data_type = data_type;
+  };
+  auto modify_info = [&, data_type, domain](AttributeInfo *info) {
+info->domain = domain; /* TODO: Use highest priority domain. */
+info->data_type = bke::attribute_data_type_highest_complexity(
+{info->data_type, data_type});
+  };
+
+  attributes.add_or_modify(name, add_info, modify_info);
+}
+  }
+}
+
+static Mesh 
*join_mesh_topology_and_builtin_attributes(Span 
set_groups)
+{
+  int totverts = 0;
+  int totloops = 0;
+  int totedges = 0;
+  int totpolys = 0;
+  int64_t cd_dirty_vert = 0;
+  int64_t cd_dirty_poly = 0;
+  int64_t cd_dirty_edge = 0;
+  int64_t cd_dirty_loop = 0;
+  for (const GeometryInstanceGroup _group : set_groups) {
+const GeometrySet  = set_group.geometry_set;
+if (set.has_mesh()) {
+  const Mesh  = *set.get_mesh_for_read();
+  totverts += mesh.totvert * set_group.transforms.size();
+  totloops += mesh.totloop * set_group.transforms.size();
+  totedges += mesh.totedge * set_group.transforms.size();
+  totpolys += mesh.totpoly * set_group.transforms.size();
+  cd_dirty_vert |= mesh.runtime.cd_dirty_vert;
+  cd_dirty_poly |= 

[Bf-blender-cvs] [81944920a74] xr-actions-D9124: Fix build error on Linux / gcc

2021-02-16 Thread Peter Kim
Commit: 81944920a74ee65f5b9c43f0200a897854a1b3ce
Author: Peter Kim
Date:   Tue Feb 16 20:12:57 2021 +0900
Branches: xr-actions-D9124
https://developer.blender.org/rB81944920a74ee65f5b9c43f0200a897854a1b3ce

Fix build error on Linux / gcc

===

M   source/blender/windowmanager/xr/intern/wm_xr_intern.h

===

diff --git a/source/blender/windowmanager/xr/intern/wm_xr_intern.h 
b/source/blender/windowmanager/xr/intern/wm_xr_intern.h
index 67fc7ab22ae..d59f010fc66 100644
--- a/source/blender/windowmanager/xr/intern/wm_xr_intern.h
+++ b/source/blender/windowmanager/xr/intern/wm_xr_intern.h
@@ -24,8 +24,6 @@
 
 #include "wm_xr.h"
 
-enum wmXrActionType;
-enum wmXrOpFlag;
 struct wmXrActionSet;
 struct GHash;
 
@@ -131,7 +129,7 @@ typedef struct wmXrDrawData {
 
 typedef struct wmXrAction {
   char *name;
-  enum wmXrActionType type;
+  char type; /* wmXrActionType */
   unsigned int count_subaction_paths;
   char **subaction_paths;
   /** States for each subaction path. */
@@ -148,7 +146,7 @@ typedef struct wmXrAction {
   /** Operator to be called on XR events. */
   struct wmOperatorType *ot;
   IDProperty *op_properties;
-  enum wmXrOpFlag op_flag;
+  char op_flag; /* wmXrOpFlag */
 } wmXrAction;
 
 typedef struct wmXrActionSet {

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [f21eb52ecc8] xr-actions-D9124: Merge branch 'master' into xr-actions-D9124

2021-02-16 Thread Peter Kim
Commit: f21eb52ecc8c7ac1dcdb40fa3c3a316f0374f544
Author: Peter Kim
Date:   Tue Feb 16 20:15:34 2021 +0900
Branches: xr-actions-D9124
https://developer.blender.org/rBf21eb52ecc8c7ac1dcdb40fa3c3a316f0374f544

Merge branch 'master' into xr-actions-D9124

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [21de1f91480] master: Geometry Nodes: move geometry set instance handling to separate file

2021-02-16 Thread Jacques Lucke
Commit: 21de1f91480ac2165517a4ba244fa0708a939baf
Author: Jacques Lucke
Date:   Tue Feb 16 12:07:10 2021 +0100
Branches: master
https://developer.blender.org/rB21de1f91480ac2165517a4ba244fa0708a939baf

Geometry Nodes: move geometry set instance handling to separate file

In an upcoming commit I'll also move the make-instances-real functionality
to this file. This code is not essential to working with geometry sets in 
general,
so it makes sense to move it to a separate header.

===

M   source/blender/blenkernel/BKE_geometry_set.hh
A   source/blender/blenkernel/BKE_geometry_set_instances.hh
M   source/blender/blenkernel/CMakeLists.txt
M   source/blender/blenkernel/intern/geometry_set.cc
A   source/blender/blenkernel/intern/geometry_set_instances.cc
M   source/blender/nodes/geometry/node_geometry_util.cc
M   source/blender/nodes/geometry/node_geometry_util.hh

===

diff --git a/source/blender/blenkernel/BKE_geometry_set.hh 
b/source/blender/blenkernel/BKE_geometry_set.hh
index 5b429a61b3f..02b3c88183a 100644
--- a/source/blender/blenkernel/BKE_geometry_set.hh
+++ b/source/blender/blenkernel/BKE_geometry_set.hh
@@ -467,25 +467,3 @@ class VolumeComponent : public GeometryComponent {
 
   static constexpr inline GeometryComponentType static_type = 
GeometryComponentType::Volume;
 };
-
-/**
- * Used to keep track of a group of instances using the same geometry data.
- */
-struct GeometryInstanceGroup {
-  /**
-   * The geometry set instanced on each of the transforms. The components are 
not necessarily
-   * owned here. For example, they may be owned by the instanced object. This 
cannot be a
-   * reference because not all instanced data will necessarily have a 
#geometry_set_eval.
-   */
-  GeometrySet geometry_set;
-
-  /**
-   * As an optimization to avoid copying, the same geometry set can be 
associated with multiple
-   * instances. Each instance is stored as a transform matrix here. Again, 
these must be owned
-   * because they may be transformed from the original data. TODO: Validate 
that last statement.
-   */
-  blender::Vector transforms;
-};
-
-blender::Vector BKE_geometry_set_gather_instances(
-const GeometrySet _set);
diff --git a/source/blender/blenkernel/BKE_geometry_set_instances.hh 
b/source/blender/blenkernel/BKE_geometry_set_instances.hh
new file mode 100644
index 000..11725d75df9
--- /dev/null
+++ b/source/blender/blenkernel/BKE_geometry_set_instances.hh
@@ -0,0 +1,42 @@
+/*
+ * 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.
+ */
+
+#include "BKE_geometry_set.hh"
+
+namespace blender::bke {
+
+/**
+ * Used to keep track of a group of instances using the same geometry data.
+ */
+struct GeometryInstanceGroup {
+  /**
+   * The geometry set instanced on each of the transforms. The components are 
not necessarily
+   * owned here. For example, they may be owned by the instanced object. This 
cannot be a
+   * reference because not all instanced data will necessarily have a 
#geometry_set_eval.
+   */
+  GeometrySet geometry_set;
+
+  /**
+   * As an optimization to avoid copying, the same geometry set can be 
associated with multiple
+   * instances. Each instance is stored as a transform matrix here. Again, 
these must be owned
+   * because they may be transformed from the original data. TODO: Validate 
that last statement.
+   */
+  Vector transforms;
+};
+
+Vector geometry_set_gather_instances(const GeometrySet 
_set);
+
+}  // namespace blender::bke
diff --git a/source/blender/blenkernel/CMakeLists.txt 
b/source/blender/blenkernel/CMakeLists.txt
index 6b6d2b45d02..ead01dbd6cb 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -130,6 +130,7 @@ set(SRC
   intern/font.c
   intern/freestyle.c
   intern/geometry_set.cc
+  intern/geometry_set_instances.cc
   intern/gpencil.c
   intern/gpencil_curve.c
   intern/gpencil_geom.c
@@ -327,6 +328,7 @@ set(SRC
   BKE_freestyle.h
   BKE_geometry_set.h
   BKE_geometry_set.hh
+  BKE_geometry_set_instances.hh
   BKE_global.h
   BKE_gpencil.h
   BKE_gpencil_curve.h
diff --git a/source/blender/blenkernel/intern/geometry_set.cc 

[Bf-blender-cvs] [39f60e6909e] master: Geometry Nodes: move some attribute utilities to blenkernel

2021-02-16 Thread Jacques Lucke
Commit: 39f60e6909e61b8b7982e637a2091a84d618ddd7
Author: Jacques Lucke
Date:   Tue Feb 16 11:55:00 2021 +0100
Branches: master
https://developer.blender.org/rB39f60e6909e61b8b7982e637a2091a84d618ddd7

Geometry Nodes: move some attribute utilities to blenkernel

I need to access these utilities from modifier code as well.
Therefore, they should not live in the nodes module.

===

M   source/blender/blenkernel/BKE_attribute_access.hh
M   source/blender/blenkernel/intern/attribute_access.cc
M   source/blender/nodes/geometry/node_geometry_util.cc
M   source/blender/nodes/geometry/node_geometry_util.hh
M   source/blender/nodes/geometry/nodes/node_geo_attribute_compare.cc
M   source/blender/nodes/geometry/nodes/node_geo_attribute_mix.cc
M   source/blender/nodes/geometry/nodes/node_geo_attribute_separate_xyz.cc
M   source/blender/nodes/geometry/nodes/node_geo_join_geometry.cc
M   source/blender/nodes/intern/node_geometry_exec.cc

===

diff --git a/source/blender/blenkernel/BKE_attribute_access.hh 
b/source/blender/blenkernel/BKE_attribute_access.hh
index 55c8b36669d..653c0f0d85d 100644
--- a/source/blender/blenkernel/BKE_attribute_access.hh
+++ b/source/blender/blenkernel/BKE_attribute_access.hh
@@ -33,6 +33,8 @@ using fn::CPPType;
 
 const CPPType *custom_data_type_to_cpp_type(const CustomDataType type);
 CustomDataType cpp_type_to_custom_data_type(const CPPType );
+CustomDataType attribute_data_type_highest_complexity(Span 
data_types);
+AttributeDomain attribute_domain_highest_priority(Span 
domains);
 
 /**
  * This class offers an indirection for reading an attribute.
diff --git a/source/blender/blenkernel/intern/attribute_access.cc 
b/source/blender/blenkernel/intern/attribute_access.cc
index 17f8b5ba2b3..f594ec54a7e 100644
--- a/source/blender/blenkernel/intern/attribute_access.cc
+++ b/source/blender/blenkernel/intern/attribute_access.cc
@@ -508,6 +508,96 @@ CustomDataType cpp_type_to_custom_data_type(const 
blender::fn::CPPType )
   return static_cast(-1);
 }
 
+static int attribute_data_type_complexity(const CustomDataType data_type)
+{
+  switch (data_type) {
+case CD_PROP_BOOL:
+  return 0;
+case CD_PROP_INT32:
+  return 1;
+case CD_PROP_FLOAT:
+  return 2;
+case CD_PROP_FLOAT2:
+  return 3;
+case CD_PROP_FLOAT3:
+  return 4;
+case CD_PROP_COLOR:
+  return 5;
+#if 0 /* These attribute types are not supported yet. */
+case CD_MLOOPCOL:
+  return 3;
+case CD_PROP_STRING:
+  return 6;
+#endif
+default:
+  /* Only accept "generic" custom data types used by the attribute system. 
*/
+  BLI_assert(false);
+  return 0;
+  }
+}
+
+CustomDataType attribute_data_type_highest_complexity(Span 
data_types)
+{
+  int highest_complexity = INT_MIN;
+  CustomDataType most_complex_type = CD_PROP_COLOR;
+
+  for (const CustomDataType data_type : data_types) {
+const int complexity = attribute_data_type_complexity(data_type);
+if (complexity > highest_complexity) {
+  highest_complexity = complexity;
+  most_complex_type = data_type;
+}
+  }
+
+  return most_complex_type;
+}
+
+/**
+ * \note Generally the order should mirror the order of the domains
+ * established in each component's ComponentAttributeProviders.
+ */
+static int attribute_domain_priority(const AttributeDomain domain)
+{
+  switch (domain) {
+#if 0
+case ATTR_DOMAIN_CURVE:
+  return 0;
+#endif
+case ATTR_DOMAIN_POLYGON:
+  return 1;
+case ATTR_DOMAIN_EDGE:
+  return 2;
+case ATTR_DOMAIN_POINT:
+  return 3;
+case ATTR_DOMAIN_CORNER:
+  return 4;
+default:
+  /* Domain not supported in nodes yet. */
+  BLI_assert(false);
+  return 0;
+  }
+}
+
+/**
+ * Domains with a higher "information density" have a higher priority, in order
+ * to choose a domain that will not lose data through domain conversion.
+ */
+AttributeDomain attribute_domain_highest_priority(Span 
domains)
+{
+  int highest_priority = INT_MIN;
+  AttributeDomain highest_priority_domain = ATTR_DOMAIN_CORNER;
+
+  for (const AttributeDomain domain : domains) {
+const int priority = attribute_domain_priority(domain);
+if (priority > highest_priority) {
+  highest_priority = priority;
+  highest_priority_domain = domain;
+}
+  }
+
+  return highest_priority_domain;
+}
+
 /**
  * A #BuiltinAttributeProvider is responsible for exactly one attribute on a 
geometry component.
  * The attribute is identified by its name and has a fixed domain and type. 
Builtin attributes do
diff --git a/source/blender/nodes/geometry/node_geometry_util.cc 
b/source/blender/nodes/geometry/node_geometry_util.cc
index c0f8fbade49..08de467cd55 100644
--- a/source/blender/nodes/geometry/node_geometry_util.cc
+++ b/source/blender/nodes/geometry/node_geometry_util.cc
@@ -55,7 +55,8 @@ void 

[Bf-blender-cvs] [c03650073e6] master: Cleanup: spelling

2021-02-16 Thread Campbell Barton
Commit: c03650073e60194500e13dc996168c4930970f5b
Author: Campbell Barton
Date:   Tue Feb 16 21:15:45 2021 +1100
Branches: master
https://developer.blender.org/rBc03650073e60194500e13dc996168c4930970f5b

Cleanup: spelling

===

M   intern/cycles/kernel/closure/bsdf_microfacet.h
M   intern/cycles/kernel/kernel_subsurface.h
M   intern/cycles/util/util_string.h
M   intern/ghost/intern/GHOST_SystemCocoa.mm
M   release/scripts/startup/bl_operators/userpref.py
M   source/blender/blenkernel/intern/geometry_set.cc
M   source/blender/blenloader/intern/versioning_defaults.c
M   source/blender/draw/engines/eevee/eevee_depth_of_field.c
M   source/blender/draw/engines/eevee/eevee_effects.c
M   source/blender/draw/engines/eevee/eevee_temporal_sampling.c
M   source/blender/editors/animation/keyframing.c
M   source/blender/editors/armature/armature_edit.c
M   source/blender/editors/curve/editcurve.c
M   source/blender/editors/interface/view2d_ops.c
M   source/blender/editors/mesh/editmesh_select.c
M   source/blender/editors/object/object_vgroup.c
M   source/blender/editors/screen/screen_ops.c
M   source/blender/editors/space_file/file_ops.c
M   source/blender/editors/space_view3d/view3d_draw.c
M   source/blender/nodes/geometry/nodes/node_geo_point_separate.cc

===

diff --git a/intern/cycles/kernel/closure/bsdf_microfacet.h 
b/intern/cycles/kernel/closure/bsdf_microfacet.h
index 32639ba24ec..aed4b849aca 100644
--- a/intern/cycles/kernel/closure/bsdf_microfacet.h
+++ b/intern/cycles/kernel/closure/bsdf_microfacet.h
@@ -487,11 +487,11 @@ ccl_device float3 bsdf_microfacet_ggx_eval_reflect(const 
ShaderClosure *sc,
 float3 out = F * G * common;
 
 /* eq. 2 in distribution of visible normals sampling
- * pm = Dw = G1o * dot(m, I) * D / dot(N, I); */
+ * `pm = Dw = G1o * dot(m, I) * D / dot(N, I);` */
 
 /* eq. 38 - but see also:
  * eq. 17 in http://www.graphics.cornell.edu/~bjw/wardnotes.pdf
- * pdf = pm * 0.25 / dot(m, I); */
+ * `pdf = pm * 0.25 / dot(m, I);` */
 *pdf = G1o * common;
 
 return out;
diff --git a/intern/cycles/kernel/kernel_subsurface.h 
b/intern/cycles/kernel/kernel_subsurface.h
index 50a232dd82e..d8258a8336c 100644
--- a/intern/cycles/kernel/kernel_subsurface.h
+++ b/intern/cycles/kernel/kernel_subsurface.h
@@ -390,8 +390,8 @@ ccl_device_forceinline float eval_phase_dwivedi(float v, 
float phase_log, float
 
 ccl_device_forceinline float sample_phase_dwivedi(float v, float phase_log, 
float rand)
 {
-  /* Based on Eq. 10 from [2]: v - (v + 1) * pow((v - 1) / (v + 1), rand)
-   * Since we're already precomputing phase_log = log((v + 1) / (v - 1)) for 
the evaluation,
+  /* Based on Eq. 10 from [2]: `v - (v + 1) * pow((v - 1) / (v + 1), rand)`
+   * Since we're already pre-computing `phase_log = log((v + 1) / (v - 1))` 
for the evaluation,
* we can implement the power function like this. */
   return v - (v + 1) * expf(-rand * phase_log);
 }
@@ -455,7 +455,7 @@ ccl_device_noinline
   float3 sigma_s = sigma_t * alpha;
 
   /* Theoretically it should be better to use the exact alpha for the channel 
we're sampling at
-   * each bounce, but in practise there doesn't seem to be a noticeable 
difference in exchange
+   * each bounce, but in practice there doesn't seem to be a noticeable 
difference in exchange
* for making the code significantly more complex and slower (if direction 
sampling depends on
* the sampled channel, we need to compute its PDF per-channel and consider 
it for MIS later on).
*
diff --git a/intern/cycles/util/util_string.h b/intern/cycles/util/util_string.h
index 6b6f493bd94..f2272819b2f 100644
--- a/intern/cycles/util/util_string.h
+++ b/intern/cycles/util/util_string.h
@@ -52,7 +52,7 @@ string string_remove_trademark(const string );
 string string_from_bool(const bool var);
 string to_string(const char *str);
 
-/* Wide char strings are only used on Windows to deal with non-ascii
+/* Wide char strings are only used on Windows to deal with non-ASCII
  * characters in file names and such. No reason to use such strings
  * for something else at this moment.
  *
diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm 
b/intern/ghost/intern/GHOST_SystemCocoa.mm
index d7dbfbe8813..f42d4af109a 100644
--- a/intern/ghost/intern/GHOST_SystemCocoa.mm
+++ b/intern/ghost/intern/GHOST_SystemCocoa.mm
@@ -1286,7 +1286,7 @@ GHOST_TSuccess 
GHOST_SystemCocoa::handleDraggingEvent(GHOST_TEventType eventType
   return GHOST_kFailure;
 }
 
-/* Then get Alpha values by getting the RGBA image (that is 
premultiplied btw) */
+/* Then get Alpha values by getting the RGBA image (that is 
pre-multiplied BTW) */
 blBitmapFormatImageRGBA = [[NSBitmapImageRep alloc]
 

[Bf-blender-cvs] [a059f072741] master: Fix add-on & app-template installation logic for overwriting modules

2021-02-16 Thread Campbell Barton
Commit: a059f072741d671ad882c44e93f6f62bb38f27d8
Author: Campbell Barton
Date:   Tue Feb 16 19:53:24 2021 +1100
Branches: master
https://developer.blender.org/rBa059f072741d671ad882c44e93f6f62bb38f27d8

Fix add-on & app-template installation logic for overwriting modules

The logic to remove one Python module before installing another
only worked in simple cases where a file replaced a file.

- Installing a single file add-on over a Python package with the same
  name caused an error as the directory isn't empty.

- Removing existing module directories from the zip-file did nothing
  as the directories from the zip-file that end with a slash were
  compared with directories from `os.listdir` that don't.

- `module_filesystem_remove` assumed ZipFile.namelist() was a list of
  files in the root of the zip-file when it's a list of all files.

  While I couldn't find any bugs caused by this, it performed checks
  that don't make sense, comparing files at different depths of the
  file-system.

===

M   release/scripts/startup/bl_operators/userpref.py

===

diff --git a/release/scripts/startup/bl_operators/userpref.py 
b/release/scripts/startup/bl_operators/userpref.py
index 7f2fa1292ee..7c51d49d8e7 100644
--- a/release/scripts/startup/bl_operators/userpref.py
+++ b/release/scripts/startup/bl_operators/userpref.py
@@ -36,16 +36,36 @@ from bpy.props import (
 from bpy.app.translations import pgettext_tip as tip_
 
 
-def module_filesystem_remove(path_base, module_name):
+def _zipfile_root_namelist(file_to_extract):
+# Return a list of root paths from zipfile.ZipFile.namelist.
 import os
+root_paths = []
+for f in file_to_extract.namelist():
+# Python's `zipfile` API always adds a separate at the end of 
directories.
+# use `os.path.normpath` instead of `f.removesuffix(os.sep)`
+# since paths could be stored as `./paths/./`.
+#
+# Note that `..` prefixed paths can exist in ZIP files but they don't 
write to parent directory when extracting.
+# Nor do they pass the `os.sep not in f` test, this is important,
+# otherwise `shutil.rmtree` below could made to remove directories 
outside the installation directory.
+f = os.path.normpath(f)
+if os.sep not in f:
+root_paths.append(f)
+return root_paths
+
+
+def _module_filesystem_remove(path_base, module_name):
+# Remove all Python modules with `module_name` in `base_path`.
+# The `module_name` is expected to be a result from 
`_zipfile_root_namelist`.
+import os
+import shutil
 module_name = os.path.splitext(module_name)[0]
 for f in os.listdir(path_base):
 f_base = os.path.splitext(f)[0]
 if f_base == module_name:
 f_full = os.path.join(path_base, f)
-
 if os.path.isdir(f_full):
-os.rmdir(f_full)
+shutil.rmtree(f_full)
 else:
 os.remove(f_full)
 
@@ -635,11 +655,12 @@ class PREFERENCES_OT_addon_install(Operator):
 traceback.print_exc()
 return {'CANCELLED'}
 
+file_to_extract_root = _zipfile_root_namelist(file_to_extract)
 if self.overwrite:
-for f in file_to_extract.namelist():
-module_filesystem_remove(path_addons, f)
+for f in file_to_extract_root:
+_module_filesystem_remove(path_addons, f)
 else:
-for f in file_to_extract.namelist():
+for f in file_to_extract_root:
 path_dest = os.path.join(path_addons, os.path.basename(f))
 if os.path.exists(path_dest):
 self.report({'WARNING'}, "File already installed to 
%r\n" % path_dest)
@@ -655,7 +676,7 @@ class PREFERENCES_OT_addon_install(Operator):
 path_dest = os.path.join(path_addons, os.path.basename(pyfile))
 
 if self.overwrite:
-module_filesystem_remove(path_addons, os.path.basename(pyfile))
+_module_filesystem_remove(path_addons, 
os.path.basename(pyfile))
 elif os.path.exists(path_dest):
 self.report({'WARNING'}, "File already installed to %r\n" % 
path_dest)
 return {'CANCELLED'}
@@ -878,11 +899,13 @@ class PREFERENCES_OT_app_template_install(Operator):
 traceback.print_exc()
 return {'CANCELLED'}
 
+# _module_extract_prepare(file_to_extract)
+file_to_extract_root = _zipfile_root_namelist(file_to_extract)
 if self.overwrite:
-for f in file_to_extract.namelist():
-module_filesystem_remove(path_app_templates, f)
+for f in file_to_extract_root:
+_module_filesystem_remove(path_app_templates, f)
   

[Bf-blender-cvs] [a35011cd69c] compositor-cryptomatte-workflow: Code style: const + naming

2021-02-16 Thread Jeroen Bakker
Commit: a35011cd69cba2bc518b2c748532204211f0e8ab
Author: Jeroen Bakker
Date:   Mon Feb 15 12:32:31 2021 +0100
Branches: compositor-cryptomatte-workflow
https://developer.blender.org/rBa35011cd69cba2bc518b2c748532204211f0e8ab

Code style: const + naming

===

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

===

diff --git a/source/blender/editors/interface/interface_eyedropper_color.c 
b/source/blender/editors/interface/interface_eyedropper_color.c
index 311d5af4c16..aff86a67963 100644
--- a/source/blender/editors/interface/interface_eyedropper_color.c
+++ b/source/blender/editors/interface/interface_eyedropper_color.c
@@ -139,22 +139,25 @@ static void eyedropper_exit(bContext *C, wmOperator *op)
 
 static bool eyedropper_cryptomatte_sample_renderlayer_fl(RenderLayer *rl,
  const char *prefix,
- float fpos[2],
+ const float fpos[2],
  float r_col[3])
 {
-  if (rl) {
-LISTBASE_FOREACH (RenderPass *, rpass, >passes) {
-  if (STRPREFIX(rpass->name, prefix)) {
-BLI_assert(rpass->channels == 4);
-int x = (int)(fpos[0] * rpass->rectx);
-int y = (int)(fpos[1] * rpass->recty);
-int offset = 4 * (y * rpass->rectx + x);
-zero_v3(r_col);
-r_col[0] = rpass->rect[offset];
-return true;
-  }
+  if (!rl) {
+return false;
+  }
+
+  LISTBASE_FOREACH (RenderPass *, render_pass, >passes) {
+if (STRPREFIX(render_pass->name, prefix)) {
+  BLI_assert(render_pass->channels == 4);
+  const int x = (int)(fpos[0] * render_pass->rectx);
+  const int y = (int)(fpos[1] * render_pass->recty);
+  const int offset = 4 * (y * render_pass->rectx + x);
+  zero_v3(r_col);
+  r_col[0] = render_pass->rect[offset];
+  return true;
 }
   }
+
   return false;
 }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [db326ae96d2] compositor-cryptomatte-workflow: Moved conversion to layer prefix function to cryptomatte node.

2021-02-16 Thread Jeroen Bakker
Commit: db326ae96d20381a542dcfb99d37872b375a73bc
Author: Jeroen Bakker
Date:   Mon Feb 15 14:03:13 2021 +0100
Branches: compositor-cryptomatte-workflow
https://developer.blender.org/rBdb326ae96d20381a542dcfb99d37872b375a73bc

Moved conversion to layer prefix function to cryptomatte node.

===

M   source/blender/blenkernel/BKE_node.h
M   source/blender/compositor/nodes/COM_CryptomatteNode.cpp
M   source/blender/compositor/nodes/COM_CryptomatteNode.h
M   source/blender/editors/interface/interface_eyedropper_color.c
M   source/blender/editors/space_node/drawnode.c
M   source/blender/nodes/composite/nodes/node_composite_cryptomatte.c

===

diff --git a/source/blender/blenkernel/BKE_node.h 
b/source/blender/blenkernel/BKE_node.h
index f0525927bbb..e39b6a448f9 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -1285,6 +1285,7 @@ void ntreeCompositColorBalanceSyncFromCDL(bNodeTree 
*ntree, bNode *node);
 
 void ntreeCompositCryptomatteSyncFromAdd(struct Main *bmain, bNodeTree *ntree, 
bNode *node);
 void ntreeCompositCryptomatteSyncFromRemove(struct Main *bmain, bNodeTree 
*ntree, bNode *node);
+const char *ntreeCompositCryptomatteLayerPrefix(const bNode *node);
 
 /** \} */
 
diff --git a/source/blender/compositor/nodes/COM_CryptomatteNode.cpp 
b/source/blender/compositor/nodes/COM_CryptomatteNode.cpp
index ee11eb4f961..ff06d9e0998 100644
--- a/source/blender/compositor/nodes/COM_CryptomatteNode.cpp
+++ b/source/blender/compositor/nodes/COM_CryptomatteNode.cpp
@@ -40,28 +40,10 @@ CryptomatteNode::CryptomatteNode(bNode *editorNode) : 
Node(editorNode)
   /* pass */
 }
 
-blender::StringRef CryptomatteNode::getCryptomatteLayerPrefix(const bNode 
) const
-{
-  NodeCryptomatte *cryptoMatteSettings = (NodeCryptomatte *)node.storage;
-
-  switch (cryptoMatteSettings->type) {
-case CMP_CRYPTOMATTE_TYPE_OBJECT:
-  return CRYPTOMATTE_LAYER_PREFIX_OBJECT;
-
-case CMP_CRYPTOMATTE_TYPE_MATERIAL:
-  return CRYPTOMATTE_LAYER_PREFIX_MATERIAL;
-
-case CMP_CRYPTOMATTE_TYPE_ASSET:
-  return CRYPTOMATTE_LAYER_PREFIX_ASSET;
-  }
-  BLI_assert(false && "Invalid Cryptomatte layer.");
-  return "";
-}
-
 void CryptomatteNode::buildInputOperationsFromRenderSource(
 const CompositorContext ,
 const bNode ,
-blender::Vector _input_operations) const
+blender::Vector _input_operations)
 {
   Scene *scene = (Scene *)node.id;
   BLI_assert(GS(scene->id.name) == ID_SCE);
@@ -77,7 +59,7 @@ void CryptomatteNode::buildInputOperationsFromRenderSource(
   if (view_layer) {
 RenderLayer *render_layer = RE_GetRenderLayer(render_result, 
view_layer->name);
 if (render_layer) {
-  std::string prefix = getCryptomatteLayerPrefix(node);
+  std::string prefix = ntreeCompositCryptomatteLayerPrefix();
   LISTBASE_FOREACH (RenderPass *, rpass, _layer->passes) {
 if (blender::StringRef(rpass->name, 
sizeof(rpass->name)).startswith(prefix)) {
   RenderLayersProg *op = new RenderLayersProg(rpass->name, 
COM_DT_COLOR, rpass->channels);
@@ -96,7 +78,7 @@ void CryptomatteNode::buildInputOperationsFromRenderSource(
 void CryptomatteNode::buildInputOperationsFromImageSource(
 const CompositorContext ,
 const bNode ,
-blender::Vector _input_operations) const
+blender::Vector _input_operations)
 {
   NodeCryptomatte *cryptoMatteSettings = (NodeCryptomatte *)node.storage;
   Image *image = (Image *)node.id;
@@ -128,7 +110,7 @@ void CryptomatteNode::buildInputOperationsFromImageSource(
 RenderLayer *render_layer = (RenderLayer 
*)BLI_findlink(>rr->layers, iuser->layer);
 if (render_layer) {
   int render_pass_index = 0;
-  std::string prefix = getCryptomatteLayerPrefix(node);
+  std::string prefix = ntreeCompositCryptomatteLayerPrefix();
   for (RenderPass *rpass = (RenderPass *)render_layer->passes.first; rpass;
rpass = rpass->next, render_pass_index++) {
 if (blender::StringRef(rpass->name, 
sizeof(rpass->name)).startswith(prefix)) {
@@ -146,7 +128,7 @@ void CryptomatteNode::buildInputOperationsFromImageSource(
 }
 
 blender::Vector CryptomatteNode::createInputOperations(
-const CompositorContext , const bNode ) const
+const CompositorContext , const bNode )
 {
   blender::Vector input_operations;
   switch (node.custom1) {
diff --git a/source/blender/compositor/nodes/COM_CryptomatteNode.h 
b/source/blender/compositor/nodes/COM_CryptomatteNode.h
index bd7a0a11837..931f96f5e47 100644
--- a/source/blender/compositor/nodes/COM_CryptomatteNode.h
+++ b/source/blender/compositor/nodes/COM_CryptomatteNode.h
@@ -32,15 +32,15 @@ class CryptomatteNode : public Node {
   void convertToOperations(NodeConverter , const CompositorContext 
) const;
 
  private:
-  blender::StringRef getCryptomatteLayerPrefix(const bNode ) const;
-  

[Bf-blender-cvs] [27ea45a0cbc] compositor-cryptomatte-workflow: Reverted wrong merge: Draw manager render result.

2021-02-16 Thread Jeroen Bakker
Commit: 27ea45a0cbcae77f43865183c8ea545660cb39ca
Author: Jeroen Bakker
Date:   Mon Feb 15 12:28:59 2021 +0100
Branches: compositor-cryptomatte-workflow
https://developer.blender.org/rB27ea45a0cbcae77f43865183c8ea545660cb39ca

Reverted wrong merge: Draw manager render result.

===

M   source/blender/draw/engines/eevee/eevee_cryptomatte.c
M   source/blender/draw/engines/eevee/eevee_engine.c
M   source/blender/draw/engines/eevee/eevee_private.h
M   source/blender/draw/engines/eevee/eevee_render.c
M   source/blender/draw/engines/gpencil/gpencil_engine.h
M   source/blender/draw/engines/gpencil/gpencil_render.c
M   source/blender/draw/engines/workbench/workbench_private.h
M   source/blender/draw/engines/workbench/workbench_render.c
M   source/blender/draw/intern/DRW_render.h
M   source/blender/draw/intern/draw_manager.c

===

diff --git a/source/blender/draw/engines/eevee/eevee_cryptomatte.c 
b/source/blender/draw/engines/eevee/eevee_cryptomatte.c
index f15d541f86d..13a3f1766a9 100644
--- a/source/blender/draw/engines/eevee/eevee_cryptomatte.c
+++ b/source/blender/draw/engines/eevee/eevee_cryptomatte.c
@@ -613,8 +613,7 @@ static void eevee_cryptomatte_extract_render_passes(
   }
 }
 
-void EEVEE_cryptomatte_render_result(RenderResult *render_result,
- RenderLayer *rl,
+void EEVEE_cryptomatte_render_result(RenderLayer *rl,
  const char *viewname,
  const rcti *rect,
  EEVEE_Data *vedata,
@@ -657,11 +656,6 @@ void EEVEE_cryptomatte_render_result(RenderResult 
*render_result,
 rect_offset_x,
 rect_offset_y,
 viewport_width);
-BKE_cryptomatte_store_metadata(g_data->cryptomatte_session,
-   render_result,
-   view_layer,
-   VIEW_LAYER_CRYPTOMATTE_OBJECT,
-   "CryptoObject");
 layer_index++;
   }
   if ((cryptomatte_layers & VIEW_LAYER_CRYPTOMATTE_MATERIAL) != 0) {
@@ -679,11 +673,6 @@ void EEVEE_cryptomatte_render_result(RenderResult 
*render_result,
 rect_offset_x,
 rect_offset_y,
 viewport_width);
-BKE_cryptomatte_store_metadata(g_data->cryptomatte_session,
-   render_result,
-   view_layer,
-   VIEW_LAYER_CRYPTOMATTE_MATERIAL,
-   "CryptoMaterial");
 layer_index++;
   }
   if ((cryptomatte_layers & VIEW_LAYER_CRYPTOMATTE_ASSET) != 0) {
@@ -701,11 +690,6 @@ void EEVEE_cryptomatte_render_result(RenderResult 
*render_result,
 rect_offset_x,
 rect_offset_y,
 viewport_width);
-BKE_cryptomatte_store_metadata(g_data->cryptomatte_session,
-   render_result,
-   view_layer,
-   VIEW_LAYER_CRYPTOMATTE_ASSET,
-   "CryptoAsset");
 layer_index++;
   }
 }
diff --git a/source/blender/draw/engines/eevee/eevee_engine.c 
b/source/blender/draw/engines/eevee/eevee_engine.c
index 379da2691a8..d1238d7b82e 100644
--- a/source/blender/draw/engines/eevee/eevee_engine.c
+++ b/source/blender/draw/engines/eevee/eevee_engine.c
@@ -440,7 +440,6 @@ static void eevee_render_reset_passes(EEVEE_Data *vedata)
 
 static void eevee_render_to_image(void *vedata,
   RenderEngine *engine,
-  struct RenderResult *render_result,
   struct RenderLayer *render_layer,
   const rcti *rect)
 {
@@ -579,7 +578,7 @@ static void eevee_render_to_image(void *vedata,
 return;
   }
 
-  EEVEE_render_read_result(vedata, engine, render_result, render_layer, rect);
+  EEVEE_render_read_result(vedata, engine, render_layer, rect);
 
   /* Restore original viewport size. */
   DRW_render_viewport_size_set((int[2]){g_data->size_orig[0], 
g_data->size_orig[1]});
diff --git a/source/blender/draw/engines/eevee/eevee_private.h 
b/source/blender/draw/engines/eevee/eevee_private.h
index 580abba5b22..17d0ead86c5 100644
--- a/source/blender/draw/engines/eevee/eevee_private.h
+++ b/source/blender/draw/engines/eevee/eevee_private.h
@@ -1353,8 +1353,7 @@ void 
EEVEE_cryptomatte_output_accumulate(EEVEE_ViewLayerData *sldata, EEVEE_Data
 void 

[Bf-blender-cvs] [412295cc89b] compositor-cryptomatte-workflow: Cleanup: Split converToOperations in multiple methods.

2021-02-16 Thread Jeroen Bakker
Commit: 412295cc89be96e5559f0b34860c9af850e11cc2
Author: Jeroen Bakker
Date:   Mon Feb 15 12:09:48 2021 +0100
Branches: compositor-cryptomatte-workflow
https://developer.blender.org/rB412295cc89be96e5559f0b34860c9af850e11cc2

Cleanup: Split converToOperations in multiple methods.

===

M   source/blender/compositor/nodes/COM_CryptomatteNode.cpp
M   source/blender/compositor/nodes/COM_CryptomatteNode.h

===

diff --git a/source/blender/compositor/nodes/COM_CryptomatteNode.cpp 
b/source/blender/compositor/nodes/COM_CryptomatteNode.cpp
index 3352bde22bc..4b6c6b2c266 100644
--- a/source/blender/compositor/nodes/COM_CryptomatteNode.cpp
+++ b/source/blender/compositor/nodes/COM_CryptomatteNode.cpp
@@ -29,128 +29,162 @@
 #include "COM_SetAlphaMultiplyOperation.h"
 #include "COM_SetColorOperation.h"
 #include 
+#include 
+
+constexpr blender::StringRef CRYPTOMATTE_LAYER_PREFIX_OBJECT("CryptoObject");
+constexpr blender::StringRef 
CRYPTOMATTE_LAYER_PREFIX_MATERIAL("CryptoMaterial");
+constexpr blender::StringRef CRYPTOMATTE_LAYER_PREFIX_ASSET("CryptoAsset");
 
 CryptomatteNode::CryptomatteNode(bNode *editorNode) : Node(editorNode)
 {
   /* pass */
 }
 
-void CryptomatteNode::convertToOperations(NodeConverter ,
-  const CompositorContext ) 
const
+blender::StringRef CryptomatteNode::getCryptomatteLayerPrefix(const bNode 
) const
 {
-  NodeInput *inputSocketImage = this->getInputSocket(0);
-  NodeOutput *outputSocketImage = this->getOutputSocket(0);
-  NodeOutput *outputSocketMatte = this->getOutputSocket(1);
-  NodeOutput *outputSocketPick = this->getOutputSocket(2);
-
-  bNode *node = this->getbNode();
-  NodeCryptomatte *cryptoMatteSettings = (NodeCryptomatte *)node->storage;
+  NodeCryptomatte *cryptoMatteSettings = (NodeCryptomatte *)node.storage;
 
-  const char *prefix = "";
   switch (cryptoMatteSettings->type) {
 case CMP_CRYPTOMATTE_TYPE_OBJECT:
-  prefix = "CryptoObject";
-  break;
+  return CRYPTOMATTE_LAYER_PREFIX_OBJECT;
+
 case CMP_CRYPTOMATTE_TYPE_MATERIAL:
-  prefix = "CryptoMaterial";
-  break;
+  return CRYPTOMATTE_LAYER_PREFIX_MATERIAL;
+
 case CMP_CRYPTOMATTE_TYPE_ASSET:
-  prefix = "CryptoAsset";
-  break;
+  return CRYPTOMATTE_LAYER_PREFIX_ASSET;
   }
-  BLI_assert(prefix[0] != '\0');
-
-  vector input_operations;
-  if (node->custom1 == CMP_CRYPTOMATTE_SRC_RENDER) {
-Scene *scene = (Scene *)node->id;
-BLI_assert(GS(scene->id.name) == ID_SCE);
-Render *re = (scene) ? RE_GetSceneRender(scene) : NULL;
-
-if (re) {
-  const short layerId = node->custom2;
-  RenderResult *rr = RE_AcquireResultRead(re);
-  if (rr) {
-ViewLayer *view_layer = (ViewLayer *)BLI_findlink(>view_layers, 
layerId);
-if (view_layer) {
-  RenderLayer *rl = RE_GetRenderLayer(rr, view_layer->name);
-  if (rl) {
-LISTBASE_FOREACH (RenderPass *, rpass, >passes) {
-  if (STRPREFIX(rpass->name, prefix)) {
-RenderLayersProg *op = new RenderLayersProg(
-rpass->name, COM_DT_COLOR, rpass->channels);
-op->setScene(scene);
-op->setLayerId(layerId);
-op->setRenderData(context.getRenderData());
-op->setViewName(context.getViewName());
-input_operations.push_back(op);
-  }
+  BLI_assert(false && "Invalid Cryptomatte layer.");
+  return "";
+}
+
+void CryptomatteNode::buildInputOperationsFromRenderSource(
+const CompositorContext ,
+const bNode ,
+blender::Vector _input_operations) const
+{
+  Scene *scene = (Scene *)node.id;
+  BLI_assert(GS(scene->id.name) == ID_SCE);
+  Render *render = (scene) ? RE_GetSceneRender(scene) : NULL;
+
+  if (render) {
+const short cryptomatte_layer_id = node.custom2;
+RenderResult *rr = RE_AcquireResultRead(render);
+if (rr) {
+  ViewLayer *view_layer = (ViewLayer *)BLI_findlink(>view_layers, 
cryptomatte_layer_id);
+  if (view_layer) {
+RenderLayer *render_layer = RE_GetRenderLayer(rr, view_layer->name);
+if (render_layer) {
+  std::string prefix = getCryptomatteLayerPrefix(node);
+  LISTBASE_FOREACH (RenderPass *, rpass, _layer->passes) {
+if (blender::StringRef(rpass->name, 
sizeof(rpass->name)).startswith(prefix)) {
+  RenderLayersProg *op = new RenderLayersProg(
+  rpass->name, COM_DT_COLOR, rpass->channels);
+  op->setScene(scene);
+  op->setLayerId(cryptomatte_layer_id);
+  op->setRenderData(context.getRenderData());
+  op->setViewName(context.getViewName());
+  r_input_operations.append(op);
 }
   }
 }
   }
-  RE_ReleaseResult(re);
 }
+RE_ReleaseResult(render);
   }
- 

[Bf-blender-cvs] [a78f6531dc8] compositor-cryptomatte-workflow: Added poll function to only select multilayer OpenEXRs.

2021-02-16 Thread Jeroen Bakker
Commit: a78f6531dc814e46e59ad41afd32874a7dc0b009
Author: Jeroen Bakker
Date:   Mon Feb 15 16:31:30 2021 +0100
Branches: compositor-cryptomatte-workflow
https://developer.blender.org/rBa78f6531dc814e46e59ad41afd32874a7dc0b009

Added poll function to only select multilayer OpenEXRs.

===

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

===

diff --git a/source/blender/makesrna/intern/rna_nodetree.c 
b/source/blender/makesrna/intern/rna_nodetree.c
index afb2954356b..bb5cafc2db7 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -3777,6 +3777,12 @@ static void rna_NodeCryptomatte_image_set(PointerRNA 
*ptr,
   }
 }
 
+static bool rna_NodeCryptomatte_image_poll(PointerRNA *UNUSED(ptr), PointerRNA 
value)
+{
+  Image *image = (Image *)value.owner_id;
+  return image->type == IMA_TYPE_MULTILAYER;
+}
+
 static void rna_NodeCryptomatte_matte_get(PointerRNA *ptr, char *value)
 {
   bNode *node = (bNode *)ptr->data;
@@ -8448,8 +8454,11 @@ static void def_cmp_cryptomatte(StructRNA *srna)
   RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
 
   prop = RNA_def_property(srna, "image", PROP_POINTER, PROP_NONE);
-  RNA_def_property_pointer_funcs(
-  prop, "rna_NodeCryptomatte_image_get", "rna_NodeCryptomatte_image_set", 
NULL, NULL);
+  RNA_def_property_pointer_funcs(prop,
+ "rna_NodeCryptomatte_image_get",
+ "rna_NodeCryptomatte_image_set",
+ NULL,
+ "rna_NodeCryptomatte_image_poll");
   RNA_def_property_struct_type(prop, "Image");
   RNA_def_property_flag(prop, PROP_EDITABLE);
   RNA_def_property_ui_text(prop, "Image", "");

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [6548a6868b5] compositor-cryptomatte-workflow: Cleanup: Remove unused constants.

2021-02-16 Thread Jeroen Bakker
Commit: 6548a6868b5d668d03168aaa4b82bb75ef4730d3
Author: Jeroen Bakker
Date:   Mon Feb 15 16:31:14 2021 +0100
Branches: compositor-cryptomatte-workflow
https://developer.blender.org/rB6548a6868b5d668d03168aaa4b82bb75ef4730d3

Cleanup: Remove unused constants.

===

M   source/blender/compositor/nodes/COM_CryptomatteNode.cpp

===

diff --git a/source/blender/compositor/nodes/COM_CryptomatteNode.cpp 
b/source/blender/compositor/nodes/COM_CryptomatteNode.cpp
index ff06d9e0998..12d8c5a3878 100644
--- a/source/blender/compositor/nodes/COM_CryptomatteNode.cpp
+++ b/source/blender/compositor/nodes/COM_CryptomatteNode.cpp
@@ -31,10 +31,6 @@
 #include 
 #include 
 
-constexpr blender::StringRef CRYPTOMATTE_LAYER_PREFIX_OBJECT("CryptoObject");
-constexpr blender::StringRef 
CRYPTOMATTE_LAYER_PREFIX_MATERIAL("CryptoMaterial");
-constexpr blender::StringRef CRYPTOMATTE_LAYER_PREFIX_ASSET("CryptoAsset");
-
 CryptomatteNode::CryptomatteNode(bNode *editorNode) : Node(editorNode)
 {
   /* pass */

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [71cd1267ade] compositor-cryptomatte-workflow: Cleanup: use zero_v3 to clean data.

2021-02-16 Thread Jeroen Bakker
Commit: 71cd1267adeaedb96bba0721c8f49802ba071c8a
Author: Jeroen Bakker
Date:   Mon Feb 15 14:07:24 2021 +0100
Branches: compositor-cryptomatte-workflow
https://developer.blender.org/rB71cd1267adeaedb96bba0721c8f49802ba071c8a

Cleanup: use zero_v3 to clean data.

===

M   source/blender/nodes/composite/nodes/node_composite_cryptomatte.c

===

diff --git a/source/blender/nodes/composite/nodes/node_composite_cryptomatte.c 
b/source/blender/nodes/composite/nodes/node_composite_cryptomatte.c
index 24b0f1b9e03..861e9512231 100644
--- a/source/blender/nodes/composite/nodes/node_composite_cryptomatte.c
+++ b/source/blender/nodes/composite/nodes/node_composite_cryptomatte.c
@@ -92,9 +92,7 @@ void ntreeCompositCryptomatteSyncFromAdd(Main *bmain, 
bNodeTree *UNUSED(ntree),
   NodeCryptomatte *n = node->storage;
   if (n->add[0] != 0.0f) {
 cryptomatte_add(bmain, n, n->add[0]);
-n->add[0] = 0.0f;
-n->add[1] = 0.0f;
-n->add[2] = 0.0f;
+zero_v3(n->add);
   }
 }
 
@@ -105,9 +103,7 @@ void ntreeCompositCryptomatteSyncFromRemove(Main 
*UNUSED(bmain),
   NodeCryptomatte *n = node->storage;
   if (n->remove[0] != 0.0f) {
 cryptomatte_remove(n, n->remove[0]);
-n->remove[0] = 0.0f;
-n->remove[1] = 0.0f;
-n->remove[2] = 0.0f;
+zero_v3(n->remove);
   }
 }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [4ef8e143dd2] compositor-cryptomatte-workflow: Compositor: Redesign Cryptomatte node for better usability

2021-02-16 Thread Jeroen Bakker
Commit: 4ef8e143dd2d84e3d0bf04dfcc8f8629ec7bbf88
Author: Jeroen Bakker
Date:   Mon Feb 15 10:02:14 2021 +0100
Branches: compositor-cryptomatte-workflow
https://developer.blender.org/rB4ef8e143dd2d84e3d0bf04dfcc8f8629ec7bbf88

Compositor: Redesign Cryptomatte node for better usability

In the current implementation, cryptomatte passes are connected to the node
and elements are picked by using the eyedropper tool on a special pick channel.

This design has two disadvantages - both connecting all passes individually
and always having to switch to the picker channel are tedious.

With the new design, the user selects the RenderLayer or Image from which the
Cryptomatte layers are directly loaded (the type of pass is determined by an
enum). This allows the node to automatically detect all relevant passes.

Then, when using the eyedropper tool, the operator looks up the selected
coordinates from the picked Image, Node backdrop or Clip and reads the picked
object directly from the Renderlayer/Image, therefore allowing to pick in any
context (e.g. by clicking on the Combined pass in the Image Viewer).

Technically there is some loss of flexibility because the Cryptomatte pass
inputs can no longer be connected to other nodes, but since any compositing
done on them is likely to break the Cryptomatte system anyways, this isn't
really a concern in practise.

In the future, this would also allow to automatically translate values to names
by looking up the value in the associated metadata of the input, or to get a
better visualization of overlapping areas in the Pick output since we could
blend colors now that the output doesn't have to contain the exact value.

{F9502764}

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

===

M   source/blender/blenkernel/BKE_cryptomatte.h
M   source/blender/blenkernel/BKE_node.h
M   source/blender/blenkernel/intern/cryptomatte.cc
M   source/blender/blenkernel/intern/node.cc
M   source/blender/blenkernel/intern/scene.c
M   source/blender/blenloader/intern/versioning_290.c
M   source/blender/compositor/nodes/COM_CryptomatteNode.cpp
M   source/blender/draw/engines/eevee/eevee_cryptomatte.c
M   source/blender/draw/engines/eevee/eevee_engine.c
M   source/blender/draw/engines/eevee/eevee_private.h
M   source/blender/draw/engines/eevee/eevee_render.c
M   source/blender/draw/engines/gpencil/gpencil_engine.h
M   source/blender/draw/engines/gpencil/gpencil_render.c
M   source/blender/draw/engines/workbench/workbench_private.h
M   source/blender/draw/engines/workbench/workbench_render.c
M   source/blender/draw/intern/DRW_render.h
M   source/blender/draw/intern/draw_manager.c
M   source/blender/editors/include/ED_clip.h
M   source/blender/editors/include/ED_image.h
M   source/blender/editors/include/ED_node.h
M   source/blender/editors/include/UI_interface.h
M   source/blender/editors/interface/CMakeLists.txt
M   source/blender/editors/interface/interface_eyedropper_color.c
M   source/blender/editors/interface/interface_templates.c
M   source/blender/editors/space_clip/clip_editor.c
M   source/blender/editors/space_image/image_ops.c
M   source/blender/editors/space_node/drawnode.c
M   source/blender/editors/space_node/node_edit.c
M   source/blender/editors/space_node/node_intern.h
M   source/blender/editors/space_node/node_ops.c
M   source/blender/editors/space_node/node_view.c
M   source/blender/makesdna/DNA_node_types.h
M   source/blender/makesrna/RNA_access.h
M   source/blender/makesrna/intern/rna_nodetree.c
M   source/blender/nodes/composite/nodes/node_composite_cryptomatte.c

===

diff --git a/source/blender/blenkernel/BKE_cryptomatte.h 
b/source/blender/blenkernel/BKE_cryptomatte.h
index eb2de96a745..27982593388 100644
--- a/source/blender/blenkernel/BKE_cryptomatte.h
+++ b/source/blender/blenkernel/BKE_cryptomatte.h
@@ -49,6 +49,7 @@ uint32_t BKE_cryptomatte_material_hash(struct 
CryptomatteSession *session,
 uint32_t BKE_cryptomatte_asset_hash(struct CryptomatteSession *session,
 const struct Object *object);
 float BKE_cryptomatte_hash_to_float(uint32_t cryptomatte_hash);
+struct ID *BKE_cryptomatte_find_id(const struct Main *bmain, const float 
encoded_hash);
 
 char *BKE_cryptomatte_entries_to_matte_id(struct NodeCryptomatte 
*node_storage);
 void BKE_cryptomatte_matte_id_to_entries(const struct Main *bmain,
@@ -63,4 +64,4 @@ void BKE_cryptomatte_store_metadata(struct CryptomatteSession 
*session,
 
 #ifdef __cplusplus
 }
-#endif
+#endif
\ No newline at end of file
diff --git a/source/blender/blenkernel/BKE_node.h 
b/source/blender/blenkernel/BKE_node.h
index 7984bbc980a..b450481ba21 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h

[Bf-blender-cvs] [1e512a37fe1] compositor-cryptomatte-workflow: Code-style: reduce indentation.

2021-02-16 Thread Jeroen Bakker
Commit: 1e512a37fe1aa8f666d6a82910bd2507735c09e4
Author: Jeroen Bakker
Date:   Mon Feb 15 12:21:37 2021 +0100
Branches: compositor-cryptomatte-workflow
https://developer.blender.org/rB1e512a37fe1aa8f666d6a82910bd2507735c09e4

Code-style: reduce indentation.

===

M   source/blender/compositor/nodes/COM_CryptomatteNode.cpp

===

diff --git a/source/blender/compositor/nodes/COM_CryptomatteNode.cpp 
b/source/blender/compositor/nodes/COM_CryptomatteNode.cpp
index f4cd124567f..ee11eb4f961 100644
--- a/source/blender/compositor/nodes/COM_CryptomatteNode.cpp
+++ b/source/blender/compositor/nodes/COM_CryptomatteNode.cpp
@@ -65,33 +65,32 @@ void CryptomatteNode::buildInputOperationsFromRenderSource(
 {
   Scene *scene = (Scene *)node.id;
   BLI_assert(GS(scene->id.name) == ID_SCE);
-  Render *render = (scene) ? RE_GetSceneRender(scene) : NULL;
-
-  if (render) {
-const short cryptomatte_layer_id = node.custom2;
-RenderResult *rr = RE_AcquireResultRead(render);
-if (rr) {
-  ViewLayer *view_layer = (ViewLayer *)BLI_findlink(>view_layers, 
cryptomatte_layer_id);
-  if (view_layer) {
-RenderLayer *render_layer = RE_GetRenderLayer(rr, view_layer->name);
-if (render_layer) {
-  std::string prefix = getCryptomatteLayerPrefix(node);
-  LISTBASE_FOREACH (RenderPass *, rpass, _layer->passes) {
-if (blender::StringRef(rpass->name, 
sizeof(rpass->name)).startswith(prefix)) {
-  RenderLayersProg *op = new RenderLayersProg(
-  rpass->name, COM_DT_COLOR, rpass->channels);
-  op->setScene(scene);
-  op->setLayerId(cryptomatte_layer_id);
-  op->setRenderData(context.getRenderData());
-  op->setViewName(context.getViewName());
-  r_input_operations.append(op);
-}
-  }
+  Render *render = (scene) ? RE_GetSceneRender(scene) : nullptr;
+  RenderResult *render_result = render ? RE_AcquireResultRead(render) : 
nullptr;
+
+  if (!render_result) {
+return;
+  }
+
+  const short cryptomatte_layer_id = node.custom2;
+  ViewLayer *view_layer = (ViewLayer *)BLI_findlink(>view_layers, 
cryptomatte_layer_id);
+  if (view_layer) {
+RenderLayer *render_layer = RE_GetRenderLayer(render_result, 
view_layer->name);
+if (render_layer) {
+  std::string prefix = getCryptomatteLayerPrefix(node);
+  LISTBASE_FOREACH (RenderPass *, rpass, _layer->passes) {
+if (blender::StringRef(rpass->name, 
sizeof(rpass->name)).startswith(prefix)) {
+  RenderLayersProg *op = new RenderLayersProg(rpass->name, 
COM_DT_COLOR, rpass->channels);
+  op->setScene(scene);
+  op->setLayerId(cryptomatte_layer_id);
+  op->setRenderData(context.getRenderData());
+  op->setViewName(context.getViewName());
+  r_input_operations.append(op);
 }
   }
 }
-RE_ReleaseResult(render);
   }
+  RE_ReleaseResult(render);
 }
 
 void CryptomatteNode::buildInputOperationsFromImageSource(
@@ -102,46 +101,48 @@ void CryptomatteNode::buildInputOperationsFromImageSource(
   NodeCryptomatte *cryptoMatteSettings = (NodeCryptomatte *)node.storage;
   Image *image = (Image *)node.id;
   BLI_assert(!image || GS(image->id.name) == ID_IM);
+  if (!image || image->type != IMA_TYPE_MULTILAYER) {
+return;
+  }
+
   ImageUser *iuser = >iuser;
   BKE_image_user_frame_calc(image, iuser, context.getFramenumber());
-
-  if (image && image->type == IMA_TYPE_MULTILAYER) {
-ImBuf *ibuf = BKE_image_acquire_ibuf(image, iuser, NULL);
-if (image->rr) {
-  int view = 0;
-  if (BLI_listbase_count_at_most(>rr->views, 2) > 1) {
-if (iuser->view == 0) {
-  /* Heuristic to match image name with scene names, check if the view 
name exists in the
-   * image. */
-  view = BLI_findstringindex(
-  >rr->views, context.getViewName(), offsetof(RenderView, 
name));
-  if (view == -1)
-view = 0;
-}
-else {
-  view = iuser->view - 1;
-}
+  ImBuf *ibuf = BKE_image_acquire_ibuf(image, iuser, NULL);
+
+  if (image->rr) {
+int view = 0;
+if (BLI_listbase_count_at_most(>rr->views, 2) > 1) {
+  if (iuser->view == 0) {
+/* Heuristic to match image name with scene names, check if the view 
name exists in the
+ * image. */
+view = BLI_findstringindex(
+>rr->views, context.getViewName(), offsetof(RenderView, 
name));
+if (view == -1)
+  view = 0;
   }
+  else {
+view = iuser->view - 1;
+  }
+}
 
-  RenderLayer *render_layer = (RenderLayer 
*)BLI_findlink(>rr->layers, iuser->layer);
-  if (render_layer) {
-int render_pass_index = 0;
-std::string prefix = getCryptomatteLayerPrefix(node);
-for (RenderPass *rpass = (RenderPass 

[Bf-blender-cvs] [2521d8c23e5] compositor-cryptomatte-workflow: Code-style: switch statement.

2021-02-16 Thread Jeroen Bakker
Commit: 2521d8c23e574b5d0a4f095905c6bf1b5fdd5ddf
Author: Jeroen Bakker
Date:   Mon Feb 15 11:31:31 2021 +0100
Branches: compositor-cryptomatte-workflow
https://developer.blender.org/rB2521d8c23e574b5d0a4f095905c6bf1b5fdd5ddf

Code-style: switch statement.

===

M   source/blender/blenkernel/BKE_node.h
M   source/blender/compositor/nodes/COM_CryptomatteNode.cpp
M   source/blender/makesdna/DNA_node_types.h

===

diff --git a/source/blender/blenkernel/BKE_node.h 
b/source/blender/blenkernel/BKE_node.h
index b450481ba21..f0525927bbb 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -1237,15 +1237,10 @@ void ntreeGPUMaterialNodes(struct bNodeTree *localtree,
 #define CMP_TRACKPOS_RELATIVE_FRAME 2
 #define CMP_TRACKPOS_ABSOLUTE_FRAME 3
 
-/* cryptomatte source */
+/* Cryptomatte source. */
 #define CMP_CRYPTOMATTE_SRC_RENDER 0
 #define CMP_CRYPTOMATTE_SRC_IMAGE 1
 
-/* cryptomatte type */
-#define CMP_CRYPTOMATTE_TYPE_OBJECT 0
-#define CMP_CRYPTOMATTE_TYPE_MATERIAL 1
-#define CMP_CRYPTOMATTE_TYPE_ASSET 2
-
 /* API */
 void ntreeCompositExecTree(struct Scene *scene,
struct bNodeTree *ntree,
diff --git a/source/blender/compositor/nodes/COM_CryptomatteNode.cpp 
b/source/blender/compositor/nodes/COM_CryptomatteNode.cpp
index 1eea6447947..3352bde22bc 100644
--- a/source/blender/compositor/nodes/COM_CryptomatteNode.cpp
+++ b/source/blender/compositor/nodes/COM_CryptomatteNode.cpp
@@ -57,10 +57,8 @@ void CryptomatteNode::convertToOperations(NodeConverter 
,
 case CMP_CRYPTOMATTE_TYPE_ASSET:
   prefix = "CryptoAsset";
   break;
-default:
-  BLI_assert(false);
-  break;
   }
+  BLI_assert(prefix[0] != '\0');
 
   vector input_operations;
   if (node->custom1 == CMP_CRYPTOMATTE_SRC_RENDER) {
diff --git a/source/blender/makesdna/DNA_node_types.h 
b/source/blender/makesdna/DNA_node_types.h
index 001321b85d1..0145556905f 100644
--- a/source/blender/makesdna/DNA_node_types.h
+++ b/source/blender/makesdna/DNA_node_types.h
@@ -1056,6 +1056,13 @@ typedef struct NodeSunBeams {
   float ray_length;
 } NodeSunBeams;
 
+/* NodeCryptomatte.type. */
+typedef enum eNodeCryptomatteLayerTypes {
+  CMP_CRYPTOMATTE_TYPE_OBJECT = 0,
+  CMP_CRYPTOMATTE_TYPE_MATERIAL = 1,
+  CMP_CRYPTOMATTE_TYPE_ASSET = 2,
+} eNodeCryptomatteLayerType;
+
 typedef struct CryptomatteEntry {
   struct CryptomatteEntry *next, *prev;
   float encoded_hash;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [ebc3fbf501c] compositor-cryptomatte-workflow: Clean-up: removed comment

2021-02-16 Thread Jeroen Bakker
Commit: ebc3fbf501c5e5b16571be3c0e6da5b269773f23
Author: Jeroen Bakker
Date:   Mon Feb 15 13:43:58 2021 +0100
Branches: compositor-cryptomatte-workflow
https://developer.blender.org/rBebc3fbf501c5e5b16571be3c0e6da5b269773f23

Clean-up: removed comment

===

M   source/blender/editors/space_clip/clip_editor.c

===

diff --git a/source/blender/editors/space_clip/clip_editor.c 
b/source/blender/editors/space_clip/clip_editor.c
index 1b835a28bd8..36375ad1ef3 100644
--- a/source/blender/editors/space_clip/clip_editor.c
+++ b/source/blender/editors/space_clip/clip_editor.c
@@ -269,7 +269,6 @@ ImBuf *ED_space_clip_get_stable_buffer(SpaceClip *sc, float 
loc[2], float *scale
   return NULL;
 }
 
-/* Returns mouse position in backdrop image space. */
 bool ED_space_clip_get_position(struct SpaceClip *sc,
 struct ARegion *ar,
 int mval[2],

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [6669f68ff56] compositor-cryptomatte-workflow: Codestyle: Spelling in comments.

2021-02-16 Thread Jeroen Bakker
Commit: 6669f68ff56b2ff0a4075eee51be222a45d22c1b
Author: Jeroen Bakker
Date:   Mon Feb 15 12:13:49 2021 +0100
Branches: compositor-cryptomatte-workflow
https://developer.blender.org/rB6669f68ff56b2ff0a4075eee51be222a45d22c1b

Codestyle: Spelling in comments.

===

M   source/blender/compositor/nodes/COM_CryptomatteNode.cpp

===

diff --git a/source/blender/compositor/nodes/COM_CryptomatteNode.cpp 
b/source/blender/compositor/nodes/COM_CryptomatteNode.cpp
index 4b6c6b2c266..f4cd124567f 100644
--- a/source/blender/compositor/nodes/COM_CryptomatteNode.cpp
+++ b/source/blender/compositor/nodes/COM_CryptomatteNode.cpp
@@ -111,8 +111,8 @@ void CryptomatteNode::buildInputOperationsFromImageSource(
   int view = 0;
   if (BLI_listbase_count_at_most(>rr->views, 2) > 1) {
 if (iuser->view == 0) {
-  /* heuristic to match image name with scene names, check if the view 
name exists in the
-   * image */
+  /* Heuristic to match image name with scene names, check if the view 
name exists in the
+   * image. */
   view = BLI_findstringindex(
   >rr->views, context.getViewName(), offsetof(RenderView, 
name));
   if (view == -1)

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [8c131be7693] compositor-cryptomatte-workflow: Removed duplicate versioning code.

2021-02-16 Thread Jeroen Bakker
Commit: 8c131be7693002883c68945faef6eeead88d6c56
Author: Jeroen Bakker
Date:   Mon Feb 15 11:16:13 2021 +0100
Branches: compositor-cryptomatte-workflow
https://developer.blender.org/rB8c131be7693002883c68945faef6eeead88d6c56

Removed duplicate versioning code.

===

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

===

diff --git a/source/blender/blenloader/intern/versioning_290.c 
b/source/blender/blenloader/intern/versioning_290.c
index 15fbdb73668..b8ca2f17fd2 100644
--- a/source/blender/blenloader/intern/versioning_290.c
+++ b/source/blender/blenloader/intern/versioning_290.c
@@ -325,18 +325,6 @@ static void seq_convert_transform_crop_lb_2(const Scene 
*scene,
   }
 }
 
-static void compositor_convert_cryptomatte_node(Main *bmain, bNode *node)
-{
-  NodeCryptomatte *storage = (NodeCryptomatte *)node->storage;
-
-  char *matte_id = storage->matte_id;
-  if (matte_id == NULL || strlen(storage->matte_id) == 0) {
-return;
-  }
-  BKE_cryptomatte_matte_id_to_entries(bmain, storage, storage->matte_id);
-  MEM_SAFE_FREE(storage->matte_id);
-}
-
 void do_versions_after_linking_290(Main *bmain, ReportList *UNUSED(reports))
 {
   if (!MAIN_VERSION_ATLEAST(bmain, 290, 1)) {
@@ -1753,19 +1741,6 @@ void blo_do_versions_290(FileData *fd, Library 
*UNUSED(lib), Main *bmain)
   }
 }
 
-/* Convert `NodeCryptomatte->storage->matte_id` to 
`NodeCryptomatte->storage->entries` */
-if (!DNA_struct_find(fd->filesdna, "CryptomatteEntry")) {
-  LISTBASE_FOREACH (Scene *, scene, >scenes) {
-if (scene->nodetree) {
-  LISTBASE_FOREACH (bNode *, node, >nodetree->nodes) {
-if (node->type == CMP_NODE_CRYPTOMATTE) {
-  compositor_convert_cryptomatte_node(bmain, node);
-}
-  }
-}
-  }
-}
-
 /* Keep this block, even when empty. */
   }
 }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [41dfeb8e6dd] compositor-cryptomatte-workflow: Fixed bad merge

2021-02-16 Thread Jeroen Bakker
Commit: 41dfeb8e6ddd09fb284462f91d91a0ca1ad0aaae
Author: Jeroen Bakker
Date:   Mon Feb 15 10:08:49 2021 +0100
Branches: compositor-cryptomatte-workflow
https://developer.blender.org/rB41dfeb8e6ddd09fb284462f91d91a0ca1ad0aaae

Fixed bad merge

===

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

===

diff --git a/source/blender/blenloader/intern/versioning_290.c 
b/source/blender/blenloader/intern/versioning_290.c
index 28986d4704c..15fbdb73668 100644
--- a/source/blender/blenloader/intern/versioning_290.c
+++ b/source/blender/blenloader/intern/versioning_290.c
@@ -611,19 +611,6 @@ void do_versions_after_linking_290(Main *bmain, ReportList 
*UNUSED(reports))
*/
   {
 /* Keep this block, even when empty. */
-
-/* Convert `NodeCryptomatte->storage->matte_id` to 
`NodeCryptomatte->storage->entries` */
-if (!DNA_struct_find(fd->filesdna, "CryptomatteEntry")) {
-  LISTBASE_FOREACH (Scene *, scene, >scenes) {
-if (scene->nodetree) {
-  LISTBASE_FOREACH (bNode *, node, >nodetree->nodes) {
-if (node->type == CMP_NODE_CRYPTOMATTE) {
-  compositor_convert_cryptomatte_node(bmain, node);
-}
-  }
-}
-  }
-}
   }
 }
 
@@ -1766,6 +1753,19 @@ void blo_do_versions_290(FileData *fd, Library 
*UNUSED(lib), Main *bmain)
   }
 }
 
+/* Convert `NodeCryptomatte->storage->matte_id` to 
`NodeCryptomatte->storage->entries` */
+if (!DNA_struct_find(fd->filesdna, "CryptomatteEntry")) {
+  LISTBASE_FOREACH (Scene *, scene, >scenes) {
+if (scene->nodetree) {
+  LISTBASE_FOREACH (bNode *, node, >nodetree->nodes) {
+if (node->type == CMP_NODE_CRYPTOMATTE) {
+  compositor_convert_cryptomatte_node(bmain, node);
+}
+  }
+}
+  }
+}
+
 /* Keep this block, even when empty. */
   }
 }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [36814ddc94b] master: Workbench: Improve AntiAliasing sampling

2021-02-16 Thread Jeroen Bakker
Commit: 36814ddc94b56a66675b854bc0d7485828ddcd31
Author: Jeroen Bakker
Date:   Tue Feb 16 08:59:17 2021 +0100
Branches: master
https://developer.blender.org/rB36814ddc94b56a66675b854bc0d7485828ddcd31

Workbench: Improve AntiAliasing sampling

This improves stability and convergence speed of Workbench Temporal 
AntiAliasing.

This adds a filtering kernel (blackmann-haris, same as EEVEE/Cycles) to the
temporal antialiasing sampling. We also gather neighbor pixels since they might
end up in the pixel footprint.

We use a 1px radius for the filter window which is a bit less than the 1.5 
default
of cycles and EEVEE since it does blur quite a bit more than what we have now.

Another improvement is that the filtering is now in log space which improves
AntiAliasing around highlights.

Theses improvement may not be very useful for every day case but it was an
experiment to try to make TAA usable for GPencil.

Test file used :
{F9798807}

|filtered+logspace|filtered|original|
|{F9798847}|{F9798848}|{F9798849}|

Reviewed By: jbakker

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

===

M   
source/blender/draw/engines/workbench/shaders/workbench_effect_smaa_frag.glsl
M   
source/blender/draw/engines/workbench/shaders/workbench_effect_taa_frag.glsl
M   source/blender/draw/engines/workbench/workbench_effect_antialiasing.c
M   source/blender/draw/engines/workbench/workbench_private.h

===

diff --git 
a/source/blender/draw/engines/workbench/shaders/workbench_effect_smaa_frag.glsl 
b/source/blender/draw/engines/workbench/shaders/workbench_effect_smaa_frag.glsl
index 2dea2fc4883..9797a5e3301 100644
--- 
a/source/blender/draw/engines/workbench/shaders/workbench_effect_smaa_frag.glsl
+++ 
b/source/blender/draw/engines/workbench/shaders/workbench_effect_smaa_frag.glsl
@@ -5,7 +5,7 @@ uniform sampler2D searchTex;
 uniform sampler2D blendTex;
 uniform sampler2D colorTex;
 uniform float mixFactor;
-uniform float taaSampleCountInv;
+uniform float taaAccumulatedWeight;
 
 in vec2 uvs;
 in vec2 pixcoord;
@@ -39,6 +39,12 @@ void main()
   if (mixFactor < 1.0) {
 fragColor += texture(colorTex, uvs) * (1.0 - mixFactor);
   }
-  fragColor *= taaSampleCountInv;
+  fragColor /= taaAccumulatedWeight;
+  fragColor = exp2(fragColor) - 0.5;
+
+  /* Avoid float precision issue. */
+  if (fragColor.a > 0.999) {
+fragColor.a = 1.0;
+  }
 #endif
 }
diff --git 
a/source/blender/draw/engines/workbench/shaders/workbench_effect_taa_frag.glsl 
b/source/blender/draw/engines/workbench/shaders/workbench_effect_taa_frag.glsl
index b877c2c3f76..d021e4696f7 100644
--- 
a/source/blender/draw/engines/workbench/shaders/workbench_effect_taa_frag.glsl
+++ 
b/source/blender/draw/engines/workbench/shaders/workbench_effect_taa_frag.glsl
@@ -1,11 +1,22 @@
 
 uniform sampler2D colorBuffer;
-
-in vec4 uvcoordsvar;
+uniform float samplesWeights[9];
 
 out vec4 fragColor;
 
 void main()
 {
-  fragColor = texture(colorBuffer, uvcoordsvar.st);
+  vec2 texel_size = 1.0 / vec2(textureSize(colorBuffer, 0));
+  vec2 uv = gl_FragCoord.xy * texel_size;
+
+  fragColor = vec4(0.0);
+  int i = 0;
+  for (int x = -1; x <= 1; x++) {
+for (int y = -1; y <= 1; y++, i++) {
+  /* Use log2 space to avoid highlights creating too much aliasing. */
+  vec4 color = log2(texture(colorBuffer, uv + vec2(x, y) * texel_size) + 
0.5);
+
+  fragColor += color * samplesWeights[i];
+}
+  }
 }
diff --git 
a/source/blender/draw/engines/workbench/workbench_effect_antialiasing.c 
b/source/blender/draw/engines/workbench/workbench_effect_antialiasing.c
index feb48b2623d..83aa7f6e344 100644
--- a/source/blender/draw/engines/workbench/workbench_effect_antialiasing.c
+++ b/source/blender/draw/engines/workbench/workbench_effect_antialiasing.c
@@ -264,6 +264,37 @@ void workbench_antialiasing_engine_init(WORKBENCH_Data 
*vedata)
   }
 }
 
+static float filter_blackman_harris(float x, const float width)
+{
+  if (x > width * 0.5f) {
+return 0.0f;
+  }
+  x = 2.0f * M_PI * clamp_f((x / width + 0.5f), 0.0f, 1.0f);
+  return 0.35875f - 0.48829f * cosf(x) + 0.14128f * cosf(2.0f * x) - 0.01168f 
* cosf(3.0f * x);
+}
+
+/* Compute weights for the 3x3 neighborhood using a 1.5px filter. */
+static void workbench_antialiasing_weights_get(const float offset[2],
+   float r_weights[9],
+   float *r_weight_sum)
+{
+  /* NOTE: If filter width is bigger than 2.0f, then we need to sample more 
neighborhood. */
+  const float filter_width = 2.0f;
+  *r_weight_sum = 0.0f;
+  int i = 0;
+  for (int x = -1; x <= 1; x++) {
+for (int y = -1; y <= 1; y++, i++) {
+  float sample_co[2] = {x, y};
+  add_v2_v2(sample_co, offset);
+  float r = len_v2(sample_co);
+  /* fclem: is radial distance ok here? */
+  float weight =