[Bf-blender-cvs] [a04fff990c8] temp-gpencil-bezier-stroke-type: Merge branch 'master' into temp-gpencil-bezier-stroke-type

2021-04-06 Thread Falk David
Commit: a04fff990c8a65ac1406e50441e787c0ec6fc80f
Author: Falk David
Date:   Wed Apr 7 08:47:33 2021 +0200
Branches: temp-gpencil-bezier-stroke-type
https://developer.blender.org/rBa04fff990c8a65ac1406e50441e787c0ec6fc80f

Merge branch 'master' into temp-gpencil-bezier-stroke-type

===



===



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


[Bf-blender-cvs] [9ba1a842f22] temp-gpencil-bezier-stroke-type: GPencil: Free poly weights when curve is updated

2021-04-06 Thread Falk David
Commit: 9ba1a842f22c7d6d2057d5cc5d6790342bcebce0
Author: Falk David
Date:   Wed Apr 7 08:46:18 2021 +0200
Branches: temp-gpencil-bezier-stroke-type
https://developer.blender.org/rB9ba1a842f22c7d6d2057d5cc5d6790342bcebce0

GPencil: Free poly weights when curve is updated

The poly weights should be freed when the stroke is converted to type
bezier or when the curve is refitted. This makes sure that we do not
leak the weight memory later.

===

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

===

diff --git a/source/blender/blenkernel/intern/gpencil_curve.c 
b/source/blender/blenkernel/intern/gpencil_curve.c
index b4d41844887..b0a7e2c99d1 100644
--- a/source/blender/blenkernel/intern/gpencil_curve.c
+++ b/source/blender/blenkernel/intern/gpencil_curve.c
@@ -1169,11 +1169,15 @@ void BKE_gpencil_stroke_editcurve_update(bGPDstroke 
*gps,
 return;
   }
 
+  /* Assign pointer. This makes the stroke a bezier stroke. */
   gps->editcurve = editcurve;
   if (prev_flag) {
 gps->editcurve->flag = prev_flag;
   }
 
+  /* Free the poly weights (if not null). Should no longer be used. */
+  BKE_gpencil_free_stroke_weights(gps);
+
   if (do_partial_update) {
 BKE_gpencil_editcurve_recalculate_handles(gps);
   }

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


[Bf-blender-cvs] [efc03eaf594] temp-gpencil-bezier-stroke-type: GPencil: Cleanup armature deform code

2021-04-06 Thread Falk David
Commit: efc03eaf5947ac3e3c390ce10092187082be5d27
Author: Falk David
Date:   Wed Apr 7 08:44:42 2021 +0200
Branches: temp-gpencil-bezier-stroke-type
https://developer.blender.org/rBefc03eaf5947ac3e3c390ce10092187082be5d27

GPencil: Cleanup armature deform code

===

M   source/blender/blenkernel/intern/armature_deform.c
M   source/blender/gpencil_modifiers/intern/MOD_gpencilarmature.c

===

diff --git a/source/blender/blenkernel/intern/armature_deform.c 
b/source/blender/blenkernel/intern/armature_deform.c
index 32624c85cc8..94eb046e46e 100644
--- a/source/blender/blenkernel/intern/armature_deform.c
+++ b/source/blender/blenkernel/intern/armature_deform.c
@@ -524,10 +524,9 @@ static void armature_deform_coords_impl(const Object 
*ob_arm,
   if (GPENCIL_STROKE_TYPE_BEZIER(gps_target)) {
 bGPDcurve *gpc = gps_target->editcurve;
 dverts = gpc->dvert;
-if (dverts) {
+if (dverts != NULL) {
   dverts_len = gpc->tot_curve_points * 3;
   temp_dverts = MEM_mallocN(sizeof(MDeformVert) * dverts_len, 
__func__);
-  dverts = temp_dverts;
   for (i = 0; i < gpc->tot_curve_points; i++) {
 MDeformVert *dvert_src = &gpc->dvert[i];
 int idx = i * 3;
@@ -541,6 +540,7 @@ static void armature_deform_coords_impl(const Object 
*ob_arm,
   }
 }
   }
+  dverts = temp_dverts;
 }
   }
   else {
@@ -638,7 +638,7 @@ static void armature_deform_coords_impl(const Object 
*ob_arm,
 MEM_freeN(pchan_from_defbase);
   }
 
-  if (temp_dverts) {
+  if (temp_dverts != NULL) {
 bGPDcurve *gpc = gps_target->editcurve;
 for (int i = 0; i < gpc->tot_curve_points * 3; i++) {
   MDeformVert *dvert = &temp_dverts[i];
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilarmature.c 
b/source/blender/gpencil_modifiers/intern/MOD_gpencilarmature.c
index 1180e49d09f..085b19192aa 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilarmature.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilarmature.c
@@ -41,6 +41,7 @@
 #include "BKE_armature.h"
 #include "BKE_context.h"
 #include "BKE_gpencil.h"
+#include "BKE_gpencil_curve.h"
 #include "BKE_gpencil_geom.h"
 #include "BKE_gpencil_modifier.h"
 #include "BKE_lib_query.h"
@@ -117,15 +118,14 @@ static void 
gpencil_deform_bezier_verts(ArmatureGpencilModifierData *mmd,
 bGPDstroke *gps)
 {
   bGPDcurve *gpc = gps->editcurve;
-  bGPDcurve_point *pt = gpc->curve_points;
   const int totpoints = gpc->tot_curve_points * 3;
   float(*vert_coords)[3] = MEM_mallocN(sizeof(float[3]) * totpoints, __func__);
-  int i;
 
   BKE_gpencil_dvert_ensure(gps);
 
   /* prepare array of points */
-  for (i = 0; i < gpc->tot_curve_points; i++, pt++) {
+  for (int i = 0; i < gpc->tot_curve_points; i++) {
+bGPDcurve_point *pt = &gpc->curve_points[i];
 BezTriple *bezt = &pt->bezt;
 int idx = i * 3;
 copy_v3_v3(vert_coords[idx], bezt->vec[0]);
@@ -145,8 +145,8 @@ static void 
gpencil_deform_bezier_verts(ArmatureGpencilModifierData *mmd,
  gps);
 
   /* Apply deformed coordinates */
-  pt = gpc->curve_points;
-  for (i = 0; i < gpc->tot_curve_points; i++, pt++) {
+  for (int i = 0; i < gpc->tot_curve_points; i++) {
+bGPDcurve_point *pt = &gpc->curve_points[i];
 BezTriple *bezt = &pt->bezt;
 int idx = i * 3;
 copy_v3_v3(bezt->vec[0], vert_coords[idx]);
@@ -154,6 +154,9 @@ static void 
gpencil_deform_bezier_verts(ArmatureGpencilModifierData *mmd,
 copy_v3_v3(bezt->vec[2], vert_coords[idx + 2]);
   }
 
+  /* Recalculate the handles. */
+  BKE_gpencil_editcurve_recalculate_handles(gps);
+
   MEM_freeN(vert_coords);
 }

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


[Bf-blender-cvs] [2fbee4598cb] master: Fix T87195: Boolean node multi-input socket only accepts one link

2021-04-06 Thread Hans Goudey
Commit: 2fbee4598cb7ba0430bf16a0ebb9ec9fabacf42d
Author: Hans Goudey
Date:   Wed Apr 7 00:32:16 2021 -0500
Branches: master
https://developer.blender.org/rB2fbee4598cb7ba0430bf16a0ebb9ec9fabacf42d

Fix T87195: Boolean node multi-input socket only accepts one link

The default insert link callback for nodes was trying to move the
existing link away, since it didn't properly handle multi-input sockets
(though the problem wasn't exposed for the join node). We can basically
skip all of this "moving existing links" for multi-input sockets, unless
we are at the link limit.

===

M   source/blender/nodes/intern/node_util.c

===

diff --git a/source/blender/nodes/intern/node_util.c 
b/source/blender/nodes/intern/node_util.c
index 3289caad9ba..4076dc852b3 100644
--- a/source/blender/nodes/intern/node_util.c
+++ b/source/blender/nodes/intern/node_util.c
@@ -310,6 +310,13 @@ void node_insert_link_default(bNodeTree *ntree, bNode 
*node, bNodeLink *link)
 return;
   }
 
+  /* If we're not at the link limit of the target socket, we can skip
+   * trying to move existing links to another socket. */
+  const int to_link_limit = nodeSocketLinkLimit(socket);
+  if (socket->total_inputs + 1 < to_link_limit) {
+return;
+  }
+
   LISTBASE_FOREACH_MUTABLE (bNodeLink *, to_link, &ntree->links) {
 if (socket == to_link->tosock) {
   bNodeSocket *new_socket = node_find_linkable_socket(ntree, node, socket);

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


[Bf-blender-cvs] [fd0a0096dd0] master: Cleanup: Various cleanup of node link handling functions

2021-04-06 Thread Hans Goudey
Commit: fd0a0096dd07c7672d82ca91d5edd5315c2a2c5f
Author: Hans Goudey
Date:   Wed Apr 7 00:26:03 2021 -0500
Branches: master
https://developer.blender.org/rBfd0a0096dd07c7672d82ca91d5edd5315c2a2c5f

Cleanup: Various cleanup of node link handling functions

Use LISTBASE_FOREACH macro, rename variables, comment formatting,
simplification of logic, etc.

===

M   source/blender/editors/space_node/node_relationships.c
M   source/blender/nodes/intern/node_util.c

===

diff --git a/source/blender/editors/space_node/node_relationships.c 
b/source/blender/editors/space_node/node_relationships.c
index 95584847d6e..80601747f2e 100644
--- a/source/blender/editors/space_node/node_relationships.c
+++ b/source/blender/editors/space_node/node_relationships.c
@@ -745,14 +745,11 @@ static void node_link_update_header(bContext *C, 
bNodeLinkDrag *UNUSED(nldrag))
   ED_workspace_status_text(C, header);
 }
 
-static int node_count_links(bNodeTree *ntree, bNodeSocket *sock)
+static int node_count_links(const bNodeTree *ntree, const bNodeSocket *socket)
 {
   int count = 0;
   LISTBASE_FOREACH (bNodeLink *, link, &ntree->links) {
-if (link->fromsock == sock) {
-  count++;
-}
-if (link->tosock == sock) {
+if (ELEM(socket, link->fromsock, link->tosock)) {
   count++;
 }
   }
diff --git a/source/blender/nodes/intern/node_util.c 
b/source/blender/nodes/intern/node_util.c
index 00db819721c..3289caad9ba 100644
--- a/source/blender/nodes/intern/node_util.c
+++ b/source/blender/nodes/intern/node_util.c
@@ -239,24 +239,21 @@ void node_filter_label(bNodeTree *UNUSED(ntree), bNode 
*node, char *label, int m
 /** \name Link Insertion
  * \{ */
 
-/* test if two sockets are interchangeable */
-static bool node_link_socket_match(bNodeSocket *a, bNodeSocket *b)
+static bool node_link_socket_match(const bNodeSocket *a, const bNodeSocket *b)
 {
-  /* check if sockets are of the same type */
+  /* Check if sockets are of the same type. */
   if (a->typeinfo != b->typeinfo) {
 return false;
   }
 
-  /* tests if alphabetic prefix matches
-   * this allows for imperfect matches, such as numeric suffixes,
-   * like Color1/Color2
-   */
+  /* Test if alphabetic prefix matches, allowing for imperfect matches, such 
as numeric suffixes
+   * like Color1/Color2. */
   int prefix_len = 0;
-  char *ca = a->name, *cb = b->name;
+  const char *ca = a->name, *cb = b->name;
   for (; *ca != '\0' && *cb != '\0'; ca++, cb++) {
-/* end of common prefix? */
+/* End of common prefix? */
 if (*ca != *cb) {
-  /* prefix delimited by non-alphabetic char */
+  /* Prefix delimited by non-alphabetic char. */
   if (isalpha(*ca) || isalpha(*cb)) {
 return false;
   }
@@ -267,75 +264,66 @@ static bool node_link_socket_match(bNodeSocket *a, 
bNodeSocket *b)
   return prefix_len > 0;
 }
 
-static int node_count_links(bNodeTree *ntree, bNodeSocket *sock)
+static int node_count_links(const bNodeTree *ntree, const bNodeSocket *socket)
 {
-  bNodeLink *link;
   int count = 0;
-  for (link = ntree->links.first; link; link = link->next) {
-if (link->fromsock == sock) {
-  count++;
-}
-if (link->tosock == sock) {
+  LISTBASE_FOREACH (bNodeLink *, link, &ntree->links) {
+if (ELEM(socket, link->fromsock, link->tosock)) {
   count++;
 }
   }
   return count;
 }
 
-/* Find an eligible socket for linking. */
-static bNodeSocket *node_find_linkable_socket(bNodeTree *ntree, bNode *node, 
bNodeSocket *cur)
+static bNodeSocket *node_find_linkable_socket(bNodeTree *ntree,
+  bNode *node,
+  bNodeSocket *to_socket)
 {
-  bNodeSocket *first = cur->in_out == SOCK_IN ? node->inputs.first : 
node->outputs.first;
-  bNodeSocket *sock;
-
-  /* Iterate over all sockets of the target node, to find one that matches the 
same socket type.
-   * The idea behind this is: When a user connects an input to a socket that is
-   * already linked (and if its not an Multi Input Socket), we try to find a 
replacement socket for
-   * the link that we try to overwrite and connect that previous link to the 
new socket. */
-  sock = cur->next ? cur->next : first; /* Wrap around the list end. */
-  while (sock != cur) {
-if (!nodeSocketIsHidden(sock) && node_link_socket_match(sock, cur)) {
-  break;
+  bNodeSocket *first = to_socket->in_out == SOCK_IN ? node->inputs.first : 
node->outputs.first;
+
+  /* Wrap around the list end. */
+  bNodeSocket *socket_iter = to_socket->next ? to_socket->next : first;
+  while (socket_iter != to_socket) {
+if (!nodeSocketIsHidden(socket_iter) && 
node_link_socket_match(socket_iter, to_socket)) {
+  const int link_count = node_count_links(ntree, socket_iter);
+  /* Add one to account for the new link being added. */
+  if (link_count + 1 <= n

[Bf-blender-cvs] [e0a1a2f49da] master: Geometry Nodes: Bounding Box Node

2021-04-06 Thread Hans Goudey
Commit: e0a1a2f49dab57d3e58372a38441b7d49c6e0fe1
Author: Hans Goudey
Date:   Tue Apr 6 16:02:55 2021 -0500
Branches: master
https://developer.blender.org/rBe0a1a2f49dab57d3e58372a38441b7d49c6e0fe1

Geometry Nodes: Bounding Box Node

This commit adds a simple node to output the min and max of an
axis-aligned bounding box for the input geometry, as well a rectangular
prism mesh created from these values for convenience.

The initial use case for this node is a "bounding box boolean", where
doing the boolean with just a bounding box could be signigicantly
faster, for cases like cutting a hole in a wall for a window. But it's
easy to imagine other cases where it could be useful.

This node supports mesh and point cloud data right now, volume support
will come as a separate patch. Also note that there is plenty of room
to improve the performance of this node through parallelization.

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

===

M   release/scripts/startup/nodeitems_builtins.py
M   source/blender/blenkernel/BKE_node.h
M   source/blender/blenkernel/intern/node.cc
M   source/blender/nodes/CMakeLists.txt
M   source/blender/nodes/NOD_geometry.h
M   source/blender/nodes/NOD_static_types.h
M   source/blender/nodes/geometry/node_geometry_util.hh
A   source/blender/nodes/geometry/nodes/node_geo_bounding_box.cc
M   source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cube.cc

===

diff --git a/release/scripts/startup/nodeitems_builtins.py 
b/release/scripts/startup/nodeitems_builtins.py
index 7e887caf3f2..ab4d9353e1b 100644
--- a/release/scripts/startup/nodeitems_builtins.py
+++ b/release/scripts/startup/nodeitems_builtins.py
@@ -505,6 +505,7 @@ geometry_node_categories = [
 NodeItem("ShaderNodeCombineRGB"),
 ]),
 GeometryNodeCategory("GEO_GEOMETRY", "Geometry", items=[
+NodeItem("GeometryNodeBoundBox"),
 NodeItem("GeometryNodeTransform"),
 NodeItem("GeometryNodeJoinGeometry"),
 ]),
diff --git a/source/blender/blenkernel/BKE_node.h 
b/source/blender/blenkernel/BKE_node.h
index 1b229bce574..30c76dc894c 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -1398,6 +1398,7 @@ int ntreeTexExecTree(struct bNodeTree *ntree,
 #define GEO_NODE_MESH_PRIMITIVE_GRID 1039
 #define GEO_NODE_ATTRIBUTE_MAP_RANGE 1040
 #define GEO_NODE_ATTRIBUTE_CLAMP 1041
+#define GEO_NODE_BOUNDING_BOX 1042
 
 /** \} */
 
diff --git a/source/blender/blenkernel/intern/node.cc 
b/source/blender/blenkernel/intern/node.cc
index 315ff40289d..496141c9247 100644
--- a/source/blender/blenkernel/intern/node.cc
+++ b/source/blender/blenkernel/intern/node.cc
@@ -4937,6 +4937,7 @@ static void registerGeometryNodes()
   register_node_type_geo_attribute_vector_math();
   register_node_type_geo_attribute_remove();
   register_node_type_geo_boolean();
+  register_node_type_geo_bounding_box();
   register_node_type_geo_collection_info();
   register_node_type_geo_edge_split();
   register_node_type_geo_is_viewport();
diff --git a/source/blender/nodes/CMakeLists.txt 
b/source/blender/nodes/CMakeLists.txt
index eaf68678f5f..88482b71f68 100644
--- a/source/blender/nodes/CMakeLists.txt
+++ b/source/blender/nodes/CMakeLists.txt
@@ -156,6 +156,7 @@ set(SRC
   geometry/nodes/node_geo_attribute_separate_xyz.cc
   geometry/nodes/node_geo_attribute_vector_math.cc
   geometry/nodes/node_geo_boolean.cc
+  geometry/nodes/node_geo_bounding_box.cc
   geometry/nodes/node_geo_collection_info.cc
   geometry/nodes/node_geo_common.cc
   geometry/nodes/node_geo_edge_split.cc
diff --git a/source/blender/nodes/NOD_geometry.h 
b/source/blender/nodes/NOD_geometry.h
index 3a26f38d6ba..4ea4fe79504 100644
--- a/source/blender/nodes/NOD_geometry.h
+++ b/source/blender/nodes/NOD_geometry.h
@@ -42,6 +42,7 @@ void register_node_type_geo_attribute_separate_xyz(void);
 void register_node_type_geo_attribute_vector_math(void);
 void register_node_type_geo_attribute_remove(void);
 void register_node_type_geo_boolean(void);
+void register_node_type_geo_bounding_box(void);
 void register_node_type_geo_collection_info(void);
 void register_node_type_geo_edge_split(void);
 void register_node_type_geo_is_viewport(void);
diff --git a/source/blender/nodes/NOD_static_types.h 
b/source/blender/nodes/NOD_static_types.h
index 0b1efaca502..bf6bf34325a 100644
--- a/source/blender/nodes/NOD_static_types.h
+++ b/source/blender/nodes/NOD_static_types.h
@@ -309,6 +309,7 @@ DefNode(GeometryNode, GEO_NODE_MESH_PRIMITIVE_LINE, 
def_geo_mesh_line, "MESH_PRI
 DefNode(GeometryNode, GEO_NODE_MESH_PRIMITIVE_GRID, 0, "MESH_PRIMITIVE_GRID", 
MeshGrid, "Grid", "")
 DefNode(GeometryNode, GEO_NODE_ATTRIBUTE_MAP_RANGE, 
def_geo_attribute_map_range, "ATTRIBUTE_MAP_RANGE", AttributeMapRange, 
"Attribute Map Range", "")
 DefNode(GeometryNode, GEO_NODE_ATTRIBUTE_CLAM

[Bf-blender-cvs] [d29bdda34c5] sculpt-dev: Fix build error with include

2021-04-06 Thread Pablo Dobarro
Commit: d29bdda34c5d62774f1dd804e542cff57a51d2c6
Author: Pablo Dobarro
Date:   Tue Apr 6 19:56:17 2021 +0200
Branches: sculpt-dev
https://developer.blender.org/rBd29bdda34c5d62774f1dd804e542cff57a51d2c6

Fix build error with include

===

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

===

diff --git a/source/blender/editors/object/object_modes.c 
b/source/blender/editors/object/object_modes.c
index 4fc34f91c9b..4c07b067e4a 100644
--- a/source/blender/editors/object/object_modes.c
+++ b/source/blender/editors/object/object_modes.c
@@ -66,7 +66,7 @@
 #include "ED_armature.h"
 #include "ED_gpencil.h"
 #include "ED_screen.h"
-#include "ED_space_API.h"
+#include "ED_space_api.h"
 #include "ED_transform_snap_object_context.h"
 #include "ED_undo.h"
 #include "ED_view3d.h"

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


[Bf-blender-cvs] [e3ee04dec50] sculpt-dev: Object: Flash objects on mode transfer

2021-04-06 Thread Pablo Dobarro
Commit: e3ee04dec502a164e5c23a0af54206e33e4452ae
Author: Pablo Dobarro
Date:   Tue Apr 6 19:49:18 2021 +0200
Branches: sculpt-dev
https://developer.blender.org/rBe3ee04dec502a164e5c23a0af54206e33e4452ae

Object: Flash objects on mode transfer

===

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

===

diff --git a/source/blender/editors/object/object_modes.c 
b/source/blender/editors/object/object_modes.c
index 99103cf10c7..4fc34f91c9b 100644
--- a/source/blender/editors/object/object_modes.c
+++ b/source/blender/editors/object/object_modes.c
@@ -21,19 +21,32 @@
  * actual mode switching logic is per-object type.
  */
 
+#include "MEM_guardedalloc.h"
+
 #include "DNA_gpencil_types.h"
+#include "DNA_mesh_types.h"
+#include "DNA_meshdata_types.h"
 #include "DNA_object_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_workspace_types.h"
 
+#include "PIL_time.h"
+
 #include "BLI_kdopbvh.h"
 #include "BLI_math.h"
 #include "BLI_utildefines.h"
 
+#include "GPU_immediate.h"
+#include "GPU_immediate_util.h"
+#include "GPU_matrix.h"
+#include "GPU_state.h"
+
 #include "BKE_context.h"
 #include "BKE_gpencil_modifier.h"
 #include "BKE_layer.h"
 #include "BKE_main.h"
+#include "BKE_mesh_runtime.h"
+#include "BKE_mesh_types.h"
 #include "BKE_modifier.h"
 #include "BKE_object.h"
 #include "BKE_paint.h"
@@ -44,6 +57,8 @@
 #include "WM_types.h"
 
 #include "RNA_access.h"
+#include "RNA_define.h"
+#include "RNA_enum_types.h"
 
 #include "DEG_depsgraph.h"
 #include "DEG_depsgraph_query.h"
@@ -51,6 +66,7 @@
 #include "ED_armature.h"
 #include "ED_gpencil.h"
 #include "ED_screen.h"
+#include "ED_space_API.h"
 #include "ED_transform_snap_object_context.h"
 #include "ED_undo.h"
 #include "ED_view3d.h"
@@ -406,6 +422,89 @@ bool ED_object_mode_generic_has_data(struct Depsgraph 
*depsgraph, struct Object
  * leaving the mode of the current object.
  * \{ */
 
+typedef struct SwitchObjectCustomData {
+  void *draw_handle;
+  Object *target_object;
+  Mesh *mesh;
+  MLoopTri *looptri;
+  wmTimer *timer;
+
+  int tottris;
+  double start_time;
+  float alpha;
+} SwitchObjectCustomData;
+
+static void switch_object_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), 
void *arg)
+{
+  SwitchObjectCustomData *cd = arg;
+
+  if (!cd->mesh) {
+return;
+  }
+  if (!cd->looptri) {
+return;
+  }
+
+  GPU_blend(GPU_BLEND_ALPHA);
+  GPU_line_smooth(true);
+
+  uint pos3d = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 
3, GPU_FETCH_FLOAT);
+  immBindBuiltinProgram(GPU_SHADER_3D_CLIPPED_UNIFORM_COLOR);
+  GPU_matrix_push();
+  GPU_matrix_mul(cd->target_object->obmat);
+
+  const float col_base = 0.6f;
+  immUniformColor4f(col_base, col_base, col_base, 0.25 * cd->alpha);
+
+  Mesh *mesh = cd->mesh;
+  immBegin(GPU_PRIM_TRIS, cd->tottris * 3);
+
+  for (int i = 0; i < cd->tottris; i++) {
+MLoopTri *looptri = &cd->looptri[i];
+for (int j = 0; j < 3; j++) {
+  MLoop *loop = &mesh->mloop[looptri->tri[j]];
+  MVert *vert = &mesh->mvert[loop->v];
+  float co[3] = {0.0f, 0.0f, 0.0f};
+  immVertex3fv(pos3d, vert->co);
+}
+  }
+
+  immEnd();
+
+  immUnbindProgram();
+  GPU_matrix_pop();
+  GPU_blend(GPU_BLEND_NONE);
+
+  GPU_line_smooth(false);
+}
+
+static int object_switch_object_modal(bContext *C, wmOperator *op, const 
wmEvent *event)
+{
+
+  ARegion *region = CTX_wm_region(C);
+  SwitchObjectCustomData *cd = op->customdata;
+  if (cd->start_time == 0.0) {
+cd->start_time = PIL_check_seconds_timer();
+  }
+  const double time = PIL_check_seconds_timer();
+  const double delta_time = time - cd->start_time;
+  float alpha = 1.0f - (6.0 * delta_time);
+
+  if (alpha > 0.01f) {
+cd->alpha = alpha;
+ED_region_tag_redraw(region);
+return OPERATOR_RUNNING_MODAL;
+  }
+
+  WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), cd->timer);
+
+  ED_region_draw_cb_exit(region->type, cd->draw_handle);
+  MEM_freeN(op->customdata);
+  ED_region_tag_redraw(region);
+
+  return OPERATOR_FINISHED;
+}
+
 static bool object_switch_object_poll(bContext *C)
 {
 
@@ -445,6 +544,7 @@ static int object_switch_object_invoke(bContext *C, 
wmOperator *op, const wmEven
   }
 
   int retval = OPERATOR_CANCELLED;
+  bool switched = false;
 
   ED_undo_group_begin(C);
 
@@ -474,11 +574,43 @@ static int object_switch_object_invoke(bContext *C, 
wmOperator *op, const wmEven
 WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
 WM_toolsystem_update_from_context_view3d(C);
 retval = OPERATOR_FINISHED;
+switched = true;
   }
 
   ED_undo_group_end(C);
 
-  return retval;
+  const bool flash_object = true;
+
+  if (!flash_object) {
+if (switched) {
+  return OPERATOR_FINISHED;
+}
+else {
+  return OPERATOR_CANCELLED;
+}
+  }
+
+  SwitchObjectCustomData *cd = MEM_callocN(sizeof(SwitchObjectCustomData),
+  

[Bf-blender-cvs] [347c8255eda] sculpt-dev: Merge branch 'master' into sculpt-dev

2021-04-06 Thread Pablo Dobarro
Commit: 347c8255edac4c5e58ab4b91b1c3deabff6155dc
Author: Pablo Dobarro
Date:   Tue Apr 6 17:49:13 2021 +0200
Branches: sculpt-dev
https://developer.blender.org/rB347c8255edac4c5e58ab4b91b1c3deabff6155dc

Merge branch 'master' into sculpt-dev

===



===



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


[Bf-blender-cvs] [93114180d71] master: Geometry Nodes: Use distance units for socket values

2021-04-06 Thread Wannes Malfait
Commit: 93114180d71a7160954c30efba3012294c39c93b
Author: Wannes Malfait
Date:   Tue Apr 6 12:02:28 2021 -0500
Branches: master
https://developer.blender.org/rB93114180d71a7160954c30efba3012294c39c93b

Geometry Nodes: Use distance units for socket values

This adds the property subtybe `PROP_DISTANCE` where appropriate.

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

===

M   source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc
M   source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc
M   source/blender/nodes/geometry/nodes/node_geo_volume_to_mesh.cc

===

diff --git a/source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc 
b/source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc
index 1e1f5e9d085..8f0708c9263 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_point_distribute.cc
@@ -44,7 +44,7 @@ using blender::bke::GeometryInstanceGroup;
 
 static bNodeSocketTemplate geo_node_point_distribute_in[] = {
 {SOCK_GEOMETRY, N_("Geometry")},
-{SOCK_FLOAT, N_("Distance Min"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 10.0f, 
PROP_NONE},
+{SOCK_FLOAT, N_("Distance Min"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 10.0f, 
PROP_DISTANCE},
 {SOCK_FLOAT, N_("Density Max"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 10.0f, 
PROP_NONE},
 {SOCK_STRING, N_("Density Attribute")},
 {SOCK_INT, N_("Seed"), 0, 0, 0, 0, -1, 1},
diff --git a/source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc 
b/source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc
index eb441a0a568..a9eb136597e 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc
@@ -31,7 +31,7 @@
 static bNodeSocketTemplate geo_node_points_to_volume_in[] = {
 {SOCK_GEOMETRY, N_("Geometry")},
 {SOCK_FLOAT, N_("Density"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, FLT_MAX},
-{SOCK_FLOAT, N_("Voxel Size"), 0.3f, 0.0f, 0.0f, 0.0f, 0.01f, FLT_MAX},
+{SOCK_FLOAT, N_("Voxel Size"), 0.3f, 0.0f, 0.0f, 0.0f, 0.01f, FLT_MAX, 
PROP_DISTANCE},
 {SOCK_FLOAT, N_("Voxel Amount"), 64.0f, 0.0f, 0.0f, 0.0f, 0.0f, FLT_MAX},
 {SOCK_STRING, N_("Radius")},
 {SOCK_FLOAT, N_("Radius"), 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, FLT_MAX},
diff --git a/source/blender/nodes/geometry/nodes/node_geo_volume_to_mesh.cc 
b/source/blender/nodes/geometry/nodes/node_geo_volume_to_mesh.cc
index 1c0e7106b19..348ad453ddc 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_volume_to_mesh.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_volume_to_mesh.cc
@@ -37,7 +37,7 @@
 static bNodeSocketTemplate geo_node_volume_to_mesh_in[] = {
 {SOCK_GEOMETRY, N_("Geometry")},
 {SOCK_STRING, N_("Density")},
-{SOCK_FLOAT, N_("Voxel Size"), 0.3f, 0.0f, 0.0f, 0.0f, 0.01f, FLT_MAX},
+{SOCK_FLOAT, N_("Voxel Size"), 0.3f, 0.0f, 0.0f, 0.0f, 0.01f, FLT_MAX, 
PROP_DISTANCE},
 {SOCK_FLOAT, N_("Voxel Amount"), 64.0f, 0.0f, 0.0f, 0.0f, 0.0f, FLT_MAX},
 {SOCK_FLOAT, N_("Threshold"), 0.1f, 0.0f, 0.0f, 0.0f, 0.0f, FLT_MAX},
 {SOCK_FLOAT, N_("Adaptivity"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 
PROP_FACTOR},

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


[Bf-blender-cvs] [f0216c023f5] temp-gpencil-bezier-stroke-type: GPencil: Fill memory leak

2021-04-06 Thread Antonio Vazquez
Commit: f0216c023f5793b53a709e4bfb3ff1fd2d37b44e
Author: Antonio Vazquez
Date:   Tue Apr 6 17:40:28 2021 +0200
Branches: temp-gpencil-bezier-stroke-type
https://developer.blender.org/rBf0216c023f5793b53a709e4bfb3ff1fd2d37b44e

GPencil: Fill memory leak

Still some memory is leaking

===

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

===

diff --git a/source/blender/blenkernel/intern/armature_deform.c 
b/source/blender/blenkernel/intern/armature_deform.c
index 6638a3b8bc8..32624c85cc8 100644
--- a/source/blender/blenkernel/intern/armature_deform.c
+++ b/source/blender/blenkernel/intern/armature_deform.c
@@ -642,8 +642,9 @@ static void armature_deform_coords_impl(const Object 
*ob_arm,
 bGPDcurve *gpc = gps_target->editcurve;
 for (int i = 0; i < gpc->tot_curve_points * 3; i++) {
   MDeformVert *dvert = &temp_dverts[i];
-  BKE_gpencil_free_point_weights(dvert);
+  MEM_SAFE_FREE(dvert->dw);
 }
+MEM_freeN(temp_dverts);
   }
 }

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


[Bf-blender-cvs] [b61b34a5d27] master: Fix T87236: crash reading file with grease pencil palettes

2021-04-06 Thread Philipp Oeser
Commit: b61b34a5d2795648c277f6ad6ea3c46425e7d715
Author: Philipp Oeser
Date:   Tue Apr 6 16:35:36 2021 +0200
Branches: master
https://developer.blender.org/rBb61b34a5d2795648c277f6ad6ea3c46425e7d715

Fix T87236: crash reading file with grease pencil palettes

Caused by typo in {rB76689e851700}.

Since Palettes and bGPDpalette are not the same size, this would not
only cause a crash in versioning code, but could only go downhill from
here on.

Maniphest Tasks: T87236

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

===

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

===

diff --git a/source/blender/blenkernel/intern/gpencil.c 
b/source/blender/blenkernel/intern/gpencil.c
index f7b895c7ca7..47b9a92d4bd 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -222,7 +222,7 @@ void BKE_gpencil_blend_read_data(BlendDataReader *reader, 
bGPdata *gpd)
   /* relink palettes (old palettes deprecated, only to convert old files) */
   BLO_read_list(reader, &gpd->palettes);
   if (gpd->palettes.first != NULL) {
-LISTBASE_FOREACH (Palette *, palette, &gpd->palettes) {
+LISTBASE_FOREACH (bGPDpalette *, palette, &gpd->palettes) {
   BLO_read_list(reader, &palette->colors);
 }
   }

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


[Bf-blender-cvs] [1bfb584b052] temp-gpencil-bezier-stroke-type: Cleanup: Change variable names

2021-04-06 Thread Antonio Vazquez
Commit: 1bfb584b052b7b5fe3a8ece23ceb4617a90a34d9
Author: Antonio Vazquez
Date:   Tue Apr 6 16:54:30 2021 +0200
Branches: temp-gpencil-bezier-stroke-type
https://developer.blender.org/rB1bfb584b052b7b5fe3a8ece23ceb4617a90a34d9

Cleanup: Change variable names

===

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

===

diff --git a/source/blender/blenkernel/intern/armature_deform.c 
b/source/blender/blenkernel/intern/armature_deform.c
index fdd8d304258..6638a3b8bc8 100644
--- a/source/blender/blenkernel/intern/armature_deform.c
+++ b/source/blender/blenkernel/intern/armature_deform.c
@@ -527,15 +527,17 @@ static void armature_deform_coords_impl(const Object 
*ob_arm,
 if (dverts) {
   dverts_len = gpc->tot_curve_points * 3;
   temp_dverts = MEM_mallocN(sizeof(MDeformVert) * dverts_len, 
__func__);
+  dverts = temp_dverts;
   for (i = 0; i < gpc->tot_curve_points; i++) {
+MDeformVert *dvert_src = &gpc->dvert[i];
 int idx = i * 3;
 for (int w = 0; w < 3; w++) {
-  MDeformVert *dvert = &gpc->dvert[i];
-  MDeformVert *temp_dvert = &temp_dverts[idx + w];
-  memcpy(temp_dvert, dvert, sizeof(MDeformVert));
-  if (dvert->dw) {
-temp_dvert->dw = MEM_mallocN(sizeof(MDeformWeight) * 
dvert->totweight, __func__);
-memcpy(temp_dvert->dw, dvert->dw, sizeof(MDeformWeight) * 
dvert->totweight);
+  MDeformVert *dvert_dst = &temp_dverts[idx + w];
+  memcpy(dvert_dst, dvert_src, sizeof(MDeformVert));
+  if (dvert_src->dw) {
+dvert_dst->dw = MEM_mallocN(sizeof(MDeformWeight) * 
dvert_src->totweight,
+__func__);
+memcpy(dvert_dst->dw, dvert_src->dw, sizeof(MDeformWeight) * 
dvert_src->totweight);
   }
 }
   }

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


[Bf-blender-cvs] [6d5ba885717] temp-gpencil-bezier-stroke-type: GPencil: More work to copy weights

2021-04-06 Thread Antonio Vazquez
Commit: 6d5ba88571755735a4e4e359cdd015ab6012aab4
Author: Antonio Vazquez
Date:   Tue Apr 6 16:52:20 2021 +0200
Branches: temp-gpencil-bezier-stroke-type
https://developer.blender.org/rB6d5ba88571755735a4e4e359cdd015ab6012aab4

GPencil: More work to copy weights

===

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

===

diff --git a/source/blender/blenkernel/intern/armature_deform.c 
b/source/blender/blenkernel/intern/armature_deform.c
index de28aeb47fc..fdd8d304258 100644
--- a/source/blender/blenkernel/intern/armature_deform.c
+++ b/source/blender/blenkernel/intern/armature_deform.c
@@ -527,11 +527,17 @@ static void armature_deform_coords_impl(const Object 
*ob_arm,
 if (dverts) {
   dverts_len = gpc->tot_curve_points * 3;
   temp_dverts = MEM_mallocN(sizeof(MDeformVert) * dverts_len, 
__func__);
-  for (int i = 0; i < gpc->tot_curve_points; i++) {
+  for (i = 0; i < gpc->tot_curve_points; i++) {
 int idx = i * 3;
-MDeformVert *dvert = &gpc->dvert[i];
-MDeformVert *temp_dvert = &temp_dverts[idx];
-// TODO: Here copy the weights
+for (int w = 0; w < 3; w++) {
+  MDeformVert *dvert = &gpc->dvert[i];
+  MDeformVert *temp_dvert = &temp_dverts[idx + w];
+  memcpy(temp_dvert, dvert, sizeof(MDeformVert));
+  if (dvert->dw) {
+temp_dvert->dw = MEM_mallocN(sizeof(MDeformWeight) * 
dvert->totweight, __func__);
+memcpy(temp_dvert->dw, dvert->dw, sizeof(MDeformWeight) * 
dvert->totweight);
+  }
+}
   }
 }
   }

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


[Bf-blender-cvs] [877b76c1821] temp-compositor-scheduling: Small tweaks to comments and definitions.

2021-04-06 Thread Jeroen Bakker
Commit: 877b76c1821643f184fd2e164325f2a060dc0d1b
Author: Jeroen Bakker
Date:   Tue Apr 6 16:36:57 2021 +0200
Branches: temp-compositor-scheduling
https://developer.blender.org/rB877b76c1821643f184fd2e164325f2a060dc0d1b

Small tweaks to comments and definitions.

===

M   source/blender/compositor/intern/COM_Enums.h
M   source/blender/compositor/intern/COM_WorkPackage.h

===

diff --git a/source/blender/compositor/intern/COM_Enums.h 
b/source/blender/compositor/intern/COM_Enums.h
index 6ab2ef51629..6b378770a5f 100644
--- a/source/blender/compositor/intern/COM_Enums.h
+++ b/source/blender/compositor/intern/COM_Enums.h
@@ -67,6 +67,7 @@ enum class eCompositorPriority {
  * \brief the execution state of a chunk in an ExecutionGroup
  * \ingroup Execution
  */
+/* NOTE: Explicit data type due to atomic operations. */
 enum class eWorkPackageState : int32_t {
   /**
* \brief chunk is not yet scheduled
diff --git a/source/blender/compositor/intern/COM_WorkPackage.h 
b/source/blender/compositor/intern/COM_WorkPackage.h
index 9aca3e03248..0c07dd3924b 100644
--- a/source/blender/compositor/intern/COM_WorkPackage.h
+++ b/source/blender/compositor/intern/COM_WorkPackage.h
@@ -79,8 +79,6 @@ struct WorkPackage {
 child->num_parents++;
   }
 
-  std::string str(int indent = 0) const;
-
 #ifdef WITH_CXX_GUARDEDALLOC
   MEM_CXX_CLASS_ALLOC_FUNCS("COM:WorkPackage")
 #endif

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


[Bf-blender-cvs] [f27959ffce1] temp-compositor-scheduling: Remove unused definition.

2021-04-06 Thread Jeroen Bakker
Commit: f27959ffce1d2019390e68f44e4b5bbbfb9a5f0d
Author: Jeroen Bakker
Date:   Tue Apr 6 16:31:14 2021 +0200
Branches: temp-compositor-scheduling
https://developer.blender.org/rBf27959ffce1d2019390e68f44e4b5bbbfb9a5f0d

Remove unused definition.

===

M   source/blender/compositor/intern/COM_ExecutionGroup.h

===

diff --git a/source/blender/compositor/intern/COM_ExecutionGroup.h 
b/source/blender/compositor/intern/COM_ExecutionGroup.h
index 64e7f35aa07..38668013b51 100644
--- a/source/blender/compositor/intern/COM_ExecutionGroup.h
+++ b/source/blender/compositor/intern/COM_ExecutionGroup.h
@@ -71,8 +71,6 @@ struct ExecutionGroupFlags {
 open_cl = false;
 single_threaded = false;
   }
-
-  std::string str() const;
 };
 
 std::ostream &operator<<(std::ostream &os, const ExecutionGroupFlags &flags);

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


[Bf-blender-cvs] [bf689664197] temp-compositor-scheduling: Updated comment.

2021-04-06 Thread Jeroen Bakker
Commit: bf689664197c355417152ccb926365111eb37963
Author: Jeroen Bakker
Date:   Tue Apr 6 15:43:28 2021 +0200
Branches: temp-compositor-scheduling
https://developer.blender.org/rBbf689664197c355417152ccb926365111eb37963

Updated comment.

===

M   source/blender/compositor/COM_defines.h

===

diff --git a/source/blender/compositor/COM_defines.h 
b/source/blender/compositor/COM_defines.h
index f2042f25d4d..b5d14d22c82 100644
--- a/source/blender/compositor/COM_defines.h
+++ b/source/blender/compositor/COM_defines.h
@@ -55,13 +55,13 @@ constexpr int COM_DATA_TYPE_COLOR_CHANNELS = 
COM_data_type_num_channels(DataType
 enum class eSchedulingMode {
   /**
* Input based scheduling mode. Scheduling starts from input nodes. When a 
work package is
-   * finished, other work packages are scheduled where all inputs have been 
executed..
+   * finished, other work packages are checked if they can be scheduled.
*/
   InputToOutput,
 
   /**
* Scheduling mode where outputs are scheduled when all its inputs have been 
completed. When
-   * inputs aren't completed it tries to schedule these inputs recursivly.
+   * inputs aren't completed it tries to schedule these inputs.
*/
   OutputToInput,
 };

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


[Bf-blender-cvs] [6587eb6327f] temp-compositor-scheduling: Compositor use atomics for scheduling.

2021-04-06 Thread Jeroen Bakker
Commit: 6587eb6327ff4757e7dafa7d566cf08fc15642c2
Author: Jeroen Bakker
Date:   Tue Apr 6 16:24:56 2021 +0200
Branches: temp-compositor-scheduling
https://developer.blender.org/rB6587eb6327ff4757e7dafa7d566cf08fc15642c2

Compositor use atomics for scheduling.

===

M   source/blender/compositor/intern/COM_Enums.h
M   source/blender/compositor/intern/COM_ExecutionGroup.cc
M   source/blender/compositor/intern/COM_WorkScheduler.cc

===

diff --git a/source/blender/compositor/intern/COM_Enums.h 
b/source/blender/compositor/intern/COM_Enums.h
index 0ab8a9053c1..6ab2ef51629 100644
--- a/source/blender/compositor/intern/COM_Enums.h
+++ b/source/blender/compositor/intern/COM_Enums.h
@@ -67,7 +67,7 @@ enum class eCompositorPriority {
  * \brief the execution state of a chunk in an ExecutionGroup
  * \ingroup Execution
  */
-enum class eWorkPackageState {
+enum class eWorkPackageState : int32_t {
   /**
* \brief chunk is not yet scheduled
*/
diff --git a/source/blender/compositor/intern/COM_ExecutionGroup.cc 
b/source/blender/compositor/intern/COM_ExecutionGroup.cc
index 5e14df87eb7..0a92c77e8b1 100644
--- a/source/blender/compositor/intern/COM_ExecutionGroup.cc
+++ b/source/blender/compositor/intern/COM_ExecutionGroup.cc
@@ -435,6 +435,8 @@ void ExecutionGroup::finalizeChunkExecution(int 
chunkNumber, MemoryBuffer **memo
 }
   }
 
+  atomic_add_and_fetch_u(&this->m_chunks_finished, 1);
+
   if (memoryBuffers) {
 for (unsigned int index = 0; index < this->m_max_read_buffer_offset; 
index++) {
   MemoryBuffer *buffer = memoryBuffers[index];
@@ -447,8 +449,8 @@ void ExecutionGroup::finalizeChunkExecution(int 
chunkNumber, MemoryBuffer **memo
 }
 MEM_freeN(memoryBuffers);
   }
+
   if (this->m_bTree) {
-atomic_add_and_fetch_u(&this->m_chunks_finished, 1);
 // status report is only performed for top level Execution Groups.
 float progress = this->m_chunks_finished;
 progress /= this->m_chunks_len;
@@ -546,9 +548,14 @@ void ExecutionGroup::link_child_work_packages(WorkPackage 
*child, rcti *area)
 if (!BLI_rcti_isect(&work_package.rect, area, &isect)) {
   continue;
 }
+if (!BLI_rcti_isect(&isect, &m_viewerBorder, &isect)) {
+  continue;
+}
 
-// TODO(jbakker): `BLI_rcti_isect` assumes inclusive. we use exclusive. 
added area check to
-// counteract this.
+/*
+ * NOTE: `BLI_rcti_isect` includes max values. Compositor excludes max 
values.
+ * This area check counter act this.
+ */
 if (BLI_rcti_size_x(&isect) * BLI_rcti_size_y(&isect) > 0) {
   work_package.add_child(child);
 }
diff --git a/source/blender/compositor/intern/COM_WorkScheduler.cc 
b/source/blender/compositor/intern/COM_WorkScheduler.cc
index f23af0f7a52..3421a59bcae 100644
--- a/source/blender/compositor/intern/COM_WorkScheduler.cc
+++ b/source/blender/compositor/intern/COM_WorkScheduler.cc
@@ -446,11 +446,13 @@ void WorkScheduler::schedule(WorkPackage *package)
 return;
   }
 
-  // TODO: race condition. we should add a mutex in the work package.
-  if (package->state != eWorkPackageState::NotScheduled) {
+  eWorkPackageState old_state = static_cast(
+  atomic_cas_int32(reinterpret_cast(&package->state),
+   static_cast(eWorkPackageState::NotScheduled),
+   static_cast(eWorkPackageState::Scheduled)));
+  if (old_state != eWorkPackageState::NotScheduled) {
 return;
   }
-  package->state = eWorkPackageState::Scheduled;
 
   if (COM_is_opencl_enabled()) {
 if (opencl_schedule(package)) {

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


[Bf-blender-cvs] [e9fae9eda15] temp-compositor-scheduling: Merge branch 'master' into temp-compositor-scheduling

2021-04-06 Thread Jeroen Bakker
Commit: e9fae9eda159b36bbd7d84638d230d4d11da9dc6
Author: Jeroen Bakker
Date:   Tue Apr 6 14:43:53 2021 +0200
Branches: temp-compositor-scheduling
https://developer.blender.org/rBe9fae9eda159b36bbd7d84638d230d4d11da9dc6

Merge branch 'master' into temp-compositor-scheduling

===



===

diff --cc release/scripts/addons
index 08e9ab150d1,ebe76f3a7ba..b4d5d760e8c
--- a/release/scripts/addons
+++ b/release/scripts/addons
@@@ -1,1 -1,1 +1,1 @@@
- Subproject commit 08e9ab150d105ba4de2b977b94ab794efd6fd1f2
 -Subproject commit ebe76f3a7ba96b3881567def29b7e2527e018e9a
++Subproject commit b4d5d760e8c1e46aaea046e327955b66fdc91f46
diff --cc source/blender/compositor/COM_defines.h
index 9e3f99cd49d,c5ff2b3adc6..f2042f25d4d
--- a/source/blender/compositor/COM_defines.h
+++ b/source/blender/compositor/COM_defines.h
@@@ -52,69 -52,6 +52,21 @@@ constexpr int COM_data_type_num_channel
  constexpr int COM_DATA_TYPE_VALUE_CHANNELS = 
COM_data_type_num_channels(DataType::Value);
  constexpr int COM_DATA_TYPE_COLOR_CHANNELS = 
COM_data_type_num_channels(DataType::Color);
  
- /**
-  * \brief Possible quality settings
-  * \see CompositorContext.quality
-  * \ingroup Execution
-  */
- enum class CompositorQuality {
-   /** \brief High quality setting */
-   High = 0,
-   /** \brief Medium quality setting */
-   Medium = 1,
-   /** \brief Low quality setting */
-   Low = 2,
- };
- 
- /**
-  * \brief Possible priority settings
-  * \ingroup Execution
-  */
- enum class CompositorPriority {
-   /** \brief High quality setting */
-   High = 2,
-   /** \brief Medium quality setting */
-   Medium = 1,
-   /** \brief Low quality setting */
-   Low = 0,
-   /** No priority set. Is used to mark WorkPackages that aren't used. */
-   Unset = -1,
- };
- 
 +enum class eSchedulingMode {
 +  /**
 +   * Input based scheduling mode. Scheduling starts from input nodes. When a 
work package is
 +   * finished, other work packages are scheduled where all inputs have been 
executed..
 +   */
 +  InputToOutput,
 +
 +  /**
 +   * Scheduling mode where outputs are scheduled when all its inputs have 
been completed. When
 +   * inputs aren't completed it tries to schedule these inputs recursivly.
 +   */
 +  OutputToInput,
 +};
 +static constexpr eSchedulingMode COM_SCHEDULING_MODE = 
eSchedulingMode::OutputToInput;
 +
- /**
-  * \brief the execution state of a chunk in an ExecutionGroup
-  * \ingroup Execution
-  */
- enum class eChunkExecutionState {
-   /**
-* \brief chunk is not yet scheduled
-*/
-   NotScheduled = 0,
-   /**
-* \brief chunk is scheduled, but not yet executed
-*/
-   Scheduled = 1,
-   /**
-* \brief chunk is executed.
-*/
-   Executed = 2,
- };
- 
  // configurable items
  
  // chunk size determination
diff --cc source/blender/compositor/intern/COM_CPUDevice.cc
index fc2543c807c,29a82bec636..18b7b9f351c
--- a/source/blender/compositor/intern/COM_CPUDevice.cc
+++ b/source/blender/compositor/intern/COM_CPUDevice.cc
@@@ -35,7 -35,6 +35,7 @@@ void CPUDevice::execute(WorkPackage *wo
  
executionGroup->getOutputOperation()->executeRegion(&work_package->rect, 
chunkNumber);
executionGroup->finalizeChunkExecution(chunkNumber, nullptr);
-   work_package->state = eChunkExecutionState::Executed;
++  work_package->state = eWorkPackageState::Executed;
  }
  
  }  // namespace blender::compositor
diff --cc source/blender/compositor/intern/COM_Enums.h
index 000,f65ce3e856e..0ab8a9053c1
mode 00,100644..100644
--- a/source/blender/compositor/intern/COM_Enums.h
+++ b/source/blender/compositor/intern/COM_Enums.h
@@@ -1,0 -1,76 +1,88 @@@
+ /*
+  * 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.
+  *
+  * Copyright 2021, Blender Foundation.
+  */
+ 
+ #pragma once
+ 
+ #include "COM_defines.h"
+ 
+ #include 
+ 
+ namespace blender::compositor {
+ 
+ /**
+  * \brief Possible quality settings
+  * \see CompositorContext.quality
+  * \ingroup Execution
+  */
+ enum class eCompositorQuality {
+   /** \brief High quality setting */
+   High = 0,
+   /** \brief Medium quality setting */
+   Medium = 1,
+   /** \brief Low quality setting */
+   Low = 2,
+ };
+ 
+ /**
+  * \brief Possible priority settings
+  * \i

[Bf-blender-cvs] [c8e37577603] temp-compositor-scheduling: Missing case in last commit.

2021-04-06 Thread Jeroen Bakker
Commit: c8e375776034361a275ea248d86c022707afa33d
Author: Jeroen Bakker
Date:   Tue Apr 6 15:43:08 2021 +0200
Branches: temp-compositor-scheduling
https://developer.blender.org/rBc8e375776034361a275ea248d86c022707afa33d

Missing case in last commit.

===

M   source/blender/compositor/intern/COM_Enums.cc

===

diff --git a/source/blender/compositor/intern/COM_Enums.cc 
b/source/blender/compositor/intern/COM_Enums.cc
index d218de92544..711b3278c6f 100644
--- a/source/blender/compositor/intern/COM_Enums.cc
+++ b/source/blender/compositor/intern/COM_Enums.cc
@@ -35,6 +35,10 @@ std::ostream &operator<<(std::ostream &os, const 
eCompositorPriority &priority)
   os << "Priority::Low";
   break;
 }
+case eCompositorPriority::Unset: {
+  os << "Priority::Unset";
+  break;
+}
   }
   return os;
 }

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


[Bf-blender-cvs] [39e1a77fdb4] temp-gpencil-bezier-stroke-type: GPencil: Prepare to copy weights for Armatures

2021-04-06 Thread Antonio Vazquez
Commit: 39e1a77fdb47c7e75c6704af53434e9727dbc988
Author: Antonio Vazquez
Date:   Tue Apr 6 15:58:56 2021 +0200
Branches: temp-gpencil-bezier-stroke-type
https://developer.blender.org/rB39e1a77fdb47c7e75c6704af53434e9727dbc988

GPencil: Prepare to copy weights for Armatures

===

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

===

diff --git a/source/blender/blenkernel/intern/armature_deform.c 
b/source/blender/blenkernel/intern/armature_deform.c
index 439ad333175..de28aeb47fc 100644
--- a/source/blender/blenkernel/intern/armature_deform.c
+++ b/source/blender/blenkernel/intern/armature_deform.c
@@ -484,7 +484,7 @@ static void armature_deform_coords_impl(const Object 
*ob_arm,
   bool use_dverts = false;
   int armature_def_nr;
   int cd_dvert_offset = -1;
-  MDeformVert *temp_dvert = NULL;
+  MDeformVert *temp_dverts = NULL;
 
   /* in editmode, or not an armature */
   if (arm->edbo || (ob_arm->pose == NULL)) {
@@ -526,8 +526,13 @@ static void armature_deform_coords_impl(const Object 
*ob_arm,
 dverts = gpc->dvert;
 if (dverts) {
   dverts_len = gpc->tot_curve_points * 3;
-  temp_dvert = MEM_mallocN(sizeof(MDeformVert) * dverts_len, __func__);
-  // TODO: Here we need copy the weights
+  temp_dverts = MEM_mallocN(sizeof(MDeformVert) * dverts_len, 
__func__);
+  for (int i = 0; i < gpc->tot_curve_points; i++) {
+int idx = i * 3;
+MDeformVert *dvert = &gpc->dvert[i];
+MDeformVert *temp_dvert = &temp_dverts[idx];
+// TODO: Here copy the weights
+  }
 }
   }
   else {
@@ -625,10 +630,10 @@ static void armature_deform_coords_impl(const Object 
*ob_arm,
 MEM_freeN(pchan_from_defbase);
   }
 
-  if (temp_dvert) {
+  if (temp_dverts) {
 bGPDcurve *gpc = gps_target->editcurve;
 for (int i = 0; i < gpc->tot_curve_points * 3; i++) {
-  MDeformVert *dvert = &temp_dvert[i];
+  MDeformVert *dvert = &temp_dverts[i];
   BKE_gpencil_free_point_weights(dvert);
 }
   }

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


[Bf-blender-cvs] [592d356c4a3] temp-gpencil-bezier-stroke-type: GPencil: First phase to make Armature modifier for Bezier type

2021-04-06 Thread Antonio Vazquez
Commit: 592d356c4a35da756eb18b79baf8f93409eacacb
Author: Antonio Vazquez
Date:   Tue Apr 6 15:51:57 2021 +0200
Branches: temp-gpencil-bezier-stroke-type
https://developer.blender.org/rB592d356c4a35da756eb18b79baf8f93409eacacb

GPencil: First phase to make Armature modifier for Bezier type

Still not working because weights array is not loaded.

===

M   source/blender/blenkernel/intern/armature_deform.c
M   source/blender/gpencil_modifiers/intern/MOD_gpencilarmature.c

===

diff --git a/source/blender/blenkernel/intern/armature_deform.c 
b/source/blender/blenkernel/intern/armature_deform.c
index 8711a001e32..439ad333175 100644
--- a/source/blender/blenkernel/intern/armature_deform.c
+++ b/source/blender/blenkernel/intern/armature_deform.c
@@ -49,6 +49,7 @@
 #include "BKE_armature.h"
 #include "BKE_deform.h"
 #include "BKE_editmesh.h"
+#include "BKE_gpencil.h"
 #include "BKE_lattice.h"
 
 #include "DEG_depsgraph_build.h"
@@ -483,6 +484,7 @@ static void armature_deform_coords_impl(const Object 
*ob_arm,
   bool use_dverts = false;
   int armature_def_nr;
   int cd_dvert_offset = -1;
+  MDeformVert *temp_dvert = NULL;
 
   /* in editmode, or not an armature */
   if (arm->edbo || (ob_arm->pose == NULL)) {
@@ -519,9 +521,20 @@ static void armature_deform_coords_impl(const Object 
*ob_arm,
   }
 }
 else if (ob_target->type == OB_GPENCIL) {
-  dverts = gps_target->dvert;
-  if (dverts) {
-dverts_len = gps_target->totpoints;
+  if (GPENCIL_STROKE_TYPE_BEZIER(gps_target)) {
+bGPDcurve *gpc = gps_target->editcurve;
+dverts = gpc->dvert;
+if (dverts) {
+  dverts_len = gpc->tot_curve_points * 3;
+  temp_dvert = MEM_mallocN(sizeof(MDeformVert) * dverts_len, __func__);
+  // TODO: Here we need copy the weights
+}
+  }
+  else {
+dverts = gps_target->dvert;
+if (dverts) {
+  dverts_len = gps_target->totpoints;
+}
   }
 }
   }
@@ -611,6 +624,14 @@ static void armature_deform_coords_impl(const Object 
*ob_arm,
   if (pchan_from_defbase) {
 MEM_freeN(pchan_from_defbase);
   }
+
+  if (temp_dvert) {
+bGPDcurve *gpc = gps_target->editcurve;
+for (int i = 0; i < gpc->tot_curve_points * 3; i++) {
+  MDeformVert *dvert = &temp_dvert[i];
+  BKE_gpencil_free_point_weights(dvert);
+}
+  }
 }
 
 void BKE_armature_deform_coords_with_gpencil_stroke(const Object *ob_arm,
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilarmature.c 
b/source/blender/gpencil_modifiers/intern/MOD_gpencilarmature.c
index e665b9db3b6..1180e49d09f 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilarmature.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilarmature.c
@@ -77,7 +77,9 @@ static void copyData(const GpencilModifierData *md, 
GpencilModifierData *target)
   BKE_gpencil_modifier_copydata_generic(md, target);
 }
 
-static void gpencil_deform_verts(ArmatureGpencilModifierData *mmd, Object 
*target, bGPDstroke *gps)
+static void gpencil_deform_polyline_verts(ArmatureGpencilModifierData *mmd,
+  Object *target,
+  bGPDstroke *gps)
 {
   bGPDspoint *pt = gps->points;
   float(*vert_coords)[3] = MEM_mallocN(sizeof(float[3]) * gps->totpoints, 
__func__);
@@ -110,6 +112,51 @@ static void 
gpencil_deform_verts(ArmatureGpencilModifierData *mmd, Object *targe
   MEM_freeN(vert_coords);
 }
 
+static void gpencil_deform_bezier_verts(ArmatureGpencilModifierData *mmd,
+Object *target,
+bGPDstroke *gps)
+{
+  bGPDcurve *gpc = gps->editcurve;
+  bGPDcurve_point *pt = gpc->curve_points;
+  const int totpoints = gpc->tot_curve_points * 3;
+  float(*vert_coords)[3] = MEM_mallocN(sizeof(float[3]) * totpoints, __func__);
+  int i;
+
+  BKE_gpencil_dvert_ensure(gps);
+
+  /* prepare array of points */
+  for (i = 0; i < gpc->tot_curve_points; i++, pt++) {
+BezTriple *bezt = &pt->bezt;
+int idx = i * 3;
+copy_v3_v3(vert_coords[idx], bezt->vec[0]);
+copy_v3_v3(vert_coords[idx + 1], bezt->vec[1]);
+copy_v3_v3(vert_coords[idx + 2], bezt->vec[2]);
+  }
+
+  /* deform verts */
+  BKE_armature_deform_coords_with_gpencil_stroke(mmd->object,
+ target,
+ vert_coords,
+ NULL,
+ totpoints,
+ mmd->deformflag,
+ mmd->vert_coords_prev,
+ mmd->vgname,
+ gps);
+
+  /* Apply deformed coordinates */
+  pt = gpc

[Bf-blender-cvs] [b93c4458092] master: BLI: return pointer to added resource

2021-04-06 Thread Jacques Lucke
Commit: b93c4458092357dd913477a41e201b425c35a898
Author: Jacques Lucke
Date:   Tue Apr 6 15:49:38 2021 +0200
Branches: master
https://developer.blender.org/rBb93c4458092357dd913477a41e201b425c35a898

BLI: return pointer to added resource

Without this, the caller often has to get the pointer to the
resource before adding it to the resource scope.

===

M   source/blender/blenlib/BLI_resource_scope.hh

===

diff --git a/source/blender/blenlib/BLI_resource_scope.hh 
b/source/blender/blenlib/BLI_resource_scope.hh
index f606dc0c0a1..e5a698f25f1 100644
--- a/source/blender/blenlib/BLI_resource_scope.hh
+++ b/source/blender/blenlib/BLI_resource_scope.hh
@@ -72,38 +72,46 @@ class ResourceScope : NonCopyable, NonMovable {
* Pass ownership of the resource to the ResourceScope. It will be 
destructed and freed when
* the collector is destructed.
*/
-  template void add(std::unique_ptr resource, const char *name)
+  template T *add(std::unique_ptr resource, const char *name)
   {
 BLI_assert(resource.get() != nullptr);
+T *ptr = resource.release();
+if (ptr == nullptr) {
+  return nullptr;
+}
 this->add(
-resource.release(),
+ptr,
 [](void *data) {
   T *typed_data = reinterpret_cast(data);
   delete typed_data;
 },
 name);
+return ptr;
   }
 
   /**
* Pass ownership of the resource to the ResourceScope. It will be 
destructed when the
* collector is destructed.
*/
-  template void add(destruct_ptr resource, const char *name)
+  template T *add(destruct_ptr resource, const char *name)
   {
+T *ptr = resource.release();
+if (ptr == nullptr) {
+  return nullptr;
+}
 /* There is no need to keep track of such types. */
 if (std::is_trivially_destructible_v) {
-  resource.release();
-  return;
+  return ptr;
 }
 
-BLI_assert(resource.get() != nullptr);
 this->add(
-resource.release(),
+ptr,
 [](void *data) {
   T *typed_data = reinterpret_cast(data);
   typed_data->~T();
 },
 name);
+return ptr;
   }
 
   /**

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


[Bf-blender-cvs] [490801ba1d2] master: Fix T86889: Rotation with top plane view glitches

2021-04-06 Thread Germano Cavalcante
Commit: 490801ba1d20bf9b2536ad08b8808393e9957c58
Author: Germano Cavalcante
Date:   Tue Apr 6 09:55:00 2021 -0300
Branches: master
https://developer.blender.org/rB490801ba1d20bf9b2536ad08b8808393e9957c58

Fix T86889: Rotation with top plane view glitches

The `InputAngle` function uses a flawed algorithm to fix precision issues.

This commit refactor the logic of that function by using BLI utilities.

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

===

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

===

diff --git a/source/blender/editors/transform/transform_input.c 
b/source/blender/editors/transform/transform_input.c
index bfeb96d18c4..414199badd7 100644
--- a/source/blender/editors/transform/transform_input.c
+++ b/source/blender/editors/transform/transform_input.c
@@ -186,57 +186,24 @@ struct InputAngle_Data {
 static void InputAngle(TransInfo *UNUSED(t), MouseInput *mi, const double 
mval[2], float output[3])
 {
   struct InputAngle_Data *data = mi->data;
-  double dx2 = mval[0] - (double)mi->center[0];
-  double dy2 = mval[1] - (double)mi->center[1];
-  double B = sqrt(dx2 * dx2 + dy2 * dy2);
+  float dir_prev[2], dir_curr[2], mi_center[2];
+  copy_v2_v2(mi_center, mi->center);
 
-  double dx1 = data->mval_prev[0] - (double)mi->center[0];
-  double dy1 = data->mval_prev[1] - (double)mi->center[1];
-  double A = sqrt(dx1 * dx1 + dy1 * dy1);
+  sub_v2_v2v2(dir_prev, (const float[2]){UNPACK2(data->mval_prev)}, mi_center);
+  sub_v2_v2v2(dir_curr, (const float[2]){UNPACK2(mval)}, mi_center);
 
-  double dx3 = mval[0] - data->mval_prev[0];
-  double dy3 = mval[1] - data->mval_prev[1];
+  if (normalize_v2(dir_prev) && normalize_v2(dir_curr)) {
+float dphi = angle_normalized_v2v2(dir_prev, dir_curr);
 
-  /* use doubles here, to make sure a "1.0" (no rotation)
-   * doesn't become 9.99e-01, which gives 0.02 for acos */
-  double deler = (((dx1 * dx1 + dy1 * dy1) + (dx2 * dx2 + dy2 * dy2) - (dx3 * 
dx3 + dy3 * dy3)) /
-  (2.0 * (((A * B) != 0.0) ? (A * B) : 1.0)));
-  /* ((A * B) ? (A * B) : 1.0) this takes care of potential divide by zero 
errors */
-
-  float dphi;
-
-  dphi = saacos((float)deler);
-  if ((dx1 * dy2 - dx2 * dy1) > 0.0) {
-dphi = -dphi;
-  }
-
-  /* If the angle is zero, because of lack of precision close to the 1.0 value 
in acos
-   * approximate the angle with the opposite side of the normalized triangle
-   * This is a good approximation here since the smallest acos value seems to 
be around
-   * 0.02 degree and lower values don't even have a 0.01% error compared to 
the approximation
-   */
-  if (dphi == 0) {
-double dx, dy;
-
-dx2 /= A;
-dy2 /= A;
-
-dx1 /= B;
-dy1 /= B;
-
-dx = dx1 - dx2;
-dy = dy1 - dy2;
-
-dphi = sqrt(dx * dx + dy * dy);
-if ((dx1 * dy2 - dx2 * dy1) > 0.0) {
+if (cross_v2v2(dir_prev, dir_curr) > 0.0f) {
   dphi = -dphi;
 }
-  }
 
-  data->angle += ((double)dphi) * (mi->precision ? 
(double)mi->precision_factor : 1.0);
+data->angle += ((double)dphi) * (mi->precision ? 
(double)mi->precision_factor : 1.0);
 
-  data->mval_prev[0] = mval[0];
-  data->mval_prev[1] = mval[1];
+data->mval_prev[0] = mval[0];
+data->mval_prev[1] = mval[1];
+  }
 
   output[0] = data->angle;
 }

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


[Bf-blender-cvs] [24d71acd864] master: Fix Cycles rendering files with Simplify wrong after recent changes

2021-04-06 Thread Brecht Van Lommel
Commit: 24d71acd864bae8d7c746c873b034d69383cda4f
Author: Brecht Van Lommel
Date:   Tue Apr 6 15:34:13 2021 +0200
Branches: master
https://developer.blender.org/rB24d71acd864bae8d7c746c873b034d69383cda4f

Fix Cycles rendering files with Simplify wrong after recent changes

The versioning code was not taking into account the old default for AO
bounces.

===

M   intern/cycles/blender/addon/version_update.py

===

diff --git a/intern/cycles/blender/addon/version_update.py 
b/intern/cycles/blender/addon/version_update.py
index 7c57bdf453c..827f84b9873 100644
--- a/intern/cycles/blender/addon/version_update.py
+++ b/intern/cycles/blender/addon/version_update.py
@@ -219,9 +219,12 @@ def do_versions(self):
 
 if version <= (2, 93, 16):
 cscene = scene.cycles
-if scene.render.use_simplify and \
-   (cscene.ao_bounces or cscene.ao_bounces_render):
+ao_bounces = cscene.get("ao_bounces", 0)
+ao_bounces_render = cscene.get("ao_bounces_render", 0)
+if scene.render.use_simplify and (ao_bounces or 
ao_bounces_render):
 cscene.use_fast_gi = True
+cscene.ao_bounces = ao_bounces
+cscene.ao_bounces_render = ao_bounces_render
 else:
 cscene.ao_bounces = 1
 cscene.ao_bounces_render = 1

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


[Bf-blender-cvs] [9676a1f61eb] master: Fix render crash in some .blend files after Persistent Data changes

2021-04-06 Thread Brecht Van Lommel
Commit: 9676a1f61ebeffb3013f8fa0a56ce6e8747fb3c5
Author: Brecht Van Lommel
Date:   Tue Apr 6 15:02:30 2021 +0200
Branches: master
https://developer.blender.org/rB9676a1f61ebeffb3013f8fa0a56ce6e8747fb3c5

Fix render crash in some .blend files after Persistent Data changes

Must always clear recalc flags, even if no editors use them, the depsgraph
execution itself also depends on them.

===

M   source/blender/depsgraph/intern/depsgraph_tag.cc

===

diff --git a/source/blender/depsgraph/intern/depsgraph_tag.cc 
b/source/blender/depsgraph/intern/depsgraph_tag.cc
index 504c3956d03..d658fcce08a 100644
--- a/source/blender/depsgraph/intern/depsgraph_tag.cc
+++ b/source/blender/depsgraph/intern/depsgraph_tag.cc
@@ -828,18 +828,17 @@ void DEG_editors_update(
 Main *bmain, Depsgraph *depsgraph, Scene *scene, ViewLayer *view_layer, 
bool time)
 {
   deg::Depsgraph *graph = (deg::Depsgraph *)depsgraph;
-  if (!graph->use_editors_update) {
-return;
-  }
 
-  bool updated = time || DEG_id_type_any_updated(depsgraph);
+  if (graph->use_editors_update) {
+bool updated = time || DEG_id_type_any_updated(depsgraph);
 
-  DEGEditorUpdateContext update_ctx = {nullptr};
-  update_ctx.bmain = bmain;
-  update_ctx.depsgraph = depsgraph;
-  update_ctx.scene = scene;
-  update_ctx.view_layer = view_layer;
-  deg::deg_editors_scene_update(&update_ctx, updated);
+DEGEditorUpdateContext update_ctx = {nullptr};
+update_ctx.bmain = bmain;
+update_ctx.depsgraph = depsgraph;
+update_ctx.scene = scene;
+update_ctx.view_layer = view_layer;
+deg::deg_editors_scene_update(&update_ctx, updated);
+  }
 
   DEG_ids_clear_recalc(depsgraph);
 }

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


[Bf-blender-cvs] [6b193aee0c7] temp-compositor-single-threaded-operation: Merge branch 'master' into temp-compositor-single-threaded-operation

2021-04-06 Thread Jeroen Bakker
Commit: 6b193aee0c710d701ef5ca703958cb6c6e978694
Author: Jeroen Bakker
Date:   Tue Apr 6 12:09:01 2021 +0200
Branches: temp-compositor-single-threaded-operation
https://developer.blender.org/rB6b193aee0c710d701ef5ca703958cb6c6e978694

Merge branch 'master' into temp-compositor-single-threaded-operation

===



===



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


[Bf-blender-cvs] [0e7e7cf8afd] temp-compositor-single-threaded-operation: Fixing filter_denoise.blend test case.

2021-04-06 Thread Jeroen Bakker
Commit: 0e7e7cf8afdfb3720fa5d770137e0af5e4f3d2f8
Author: Jeroen Bakker
Date:   Tue Apr 6 13:57:37 2021 +0200
Branches: temp-compositor-single-threaded-operation
https://developer.blender.org/rB0e7e7cf8afdfb3720fa5d770137e0af5e4f3d2f8

Fixing filter_denoise.blend test case.

Issue was that the inpaint node was being isolated, and the denoise node
wasn't (yet) the inpaint node thought that the denoise node was the
write operator of the inpaint node. This isn't correct it should add a
new write buffer operator to store its result.

===

M   source/blender/compositor/intern/COM_NodeOperationBuilder.cc

===

diff --git a/source/blender/compositor/intern/COM_NodeOperationBuilder.cc 
b/source/blender/compositor/intern/COM_NodeOperationBuilder.cc
index 25572c91d69..df56bb2ede1 100644
--- a/source/blender/compositor/intern/COM_NodeOperationBuilder.cc
+++ b/source/blender/compositor/intern/COM_NodeOperationBuilder.cc
@@ -494,14 +494,19 @@ void 
NodeOperationBuilder::add_output_buffers(NodeOperation *operation,
   }
 
   WriteBufferOperation *writeOperation = nullptr;
+  /* Check if the current operation can handle writing to buffer.
+   * If this is the case we don't need to add a separate write buffer 
operation. */
   if (operation->get_flags().is_write_buffer_operation) {
 writeOperation = static_cast(operation);
 writeOperation->setbNodeTree(m_context->getbNodeTree());
   }
 
   for (NodeOperationInput *target : targets) {
-/* try to find existing write buffer operation */
-if (target->getOperation().get_flags().is_write_buffer_operation) {
+/* Try to find existing write buffer operation. Don't select complex write 
buffer operation as
+ * they are complex operations that handle their own writing, but haven't 
been isolated with
+ * read operators. */
+NodeOperationFlags target_flags = target->getOperation().get_flags();
+if (target_flags.is_write_buffer_operation && !target_flags.complex) {
   BLI_assert(writeOperation == nullptr); /* there should only be one write 
op connected */
   writeOperation = (WriteBufferOperation *)(&target->getOperation());
 }

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


[Bf-blender-cvs] [b4ebee5e66c] temp-compositor-single-threaded-operation: Merge branch 'master' into temp-compositor-single-threaded-operation

2021-04-06 Thread Jeroen Bakker
Commit: b4ebee5e66c7c30362bd225c450a1cf4072b2886
Author: Jeroen Bakker
Date:   Tue Apr 6 08:40:21 2021 +0200
Branches: temp-compositor-single-threaded-operation
https://developer.blender.org/rBb4ebee5e66c7c30362bd225c450a1cf4072b2886

Merge branch 'master' into temp-compositor-single-threaded-operation

===



===



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


[Bf-blender-cvs] [30eb61c9672] temp-compositor-single-threaded-operation: Merge branch 'master' into temp-compositor-single-threaded-operation

2021-04-06 Thread Jeroen Bakker
Commit: 30eb61c967293e30361164bd7920a6ace3053c2c
Author: Jeroen Bakker
Date:   Tue Apr 6 08:19:40 2021 +0200
Branches: temp-compositor-single-threaded-operation
https://developer.blender.org/rB30eb61c967293e30361164bd7920a6ace3053c2c

Merge branch 'master' into temp-compositor-single-threaded-operation

===



===



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


[Bf-blender-cvs] [19ff2479cf6] master: Compositor: Add Streaming Operator for NodeOperationBuilder.

2021-04-06 Thread Jeroen Bakker
Commit: 19ff2479cf686f32c29120ea8be02eef5c2423a2
Author: Jeroen Bakker
Date:   Tue Apr 6 12:04:47 2021 +0200
Branches: master
https://developer.blender.org/rB19ff2479cf686f32c29120ea8be02eef5c2423a2

Compositor: Add Streaming Operator for NodeOperationBuilder.

For debugging purposes to convert the internal state of the
NodeOperationBuilder to a graphviz.

Usage:

std::cout << *this << "\n";

Inside any method of the NodeOperationBuilder.

===

M   source/blender/compositor/intern/COM_NodeOperation.cc
M   source/blender/compositor/intern/COM_NodeOperation.h
M   source/blender/compositor/intern/COM_NodeOperationBuilder.cc
M   source/blender/compositor/intern/COM_NodeOperationBuilder.h

===

diff --git a/source/blender/compositor/intern/COM_NodeOperation.cc 
b/source/blender/compositor/intern/COM_NodeOperation.cc
index 6c60a858b6c..35e7f1adc7d 100644
--- a/source/blender/compositor/intern/COM_NodeOperation.cc
+++ b/source/blender/compositor/intern/COM_NodeOperation.cc
@@ -259,17 +259,18 @@ std::ostream &operator<<(std::ostream &os, const 
NodeOperation &node_operation)
 {
   NodeOperationFlags flags = node_operation.get_flags();
   os << "NodeOperation(";
+  os << "id=" << node_operation.get_id();
   if (!node_operation.get_name().empty()) {
-os << "name=" << node_operation.get_name() << ",";
+os << ",name=" << node_operation.get_name();
   }
-  os << "flags={" << flags << "},";
+  os << ",flags={" << flags << "}";
   if (flags.is_read_buffer_operation) {
 const ReadBufferOperation *read_operation = (const ReadBufferOperation 
*)&node_operation;
 const MemoryProxy *proxy = read_operation->getMemoryProxy();
 if (proxy) {
   const WriteBufferOperation *write_operation = 
proxy->getWriteBufferOperation();
   if (write_operation) {
-os << "write=" << (NodeOperation &)*write_operation << ",";
+os << ",write=" << (NodeOperation &)*write_operation;
   }
 }
   }
diff --git a/source/blender/compositor/intern/COM_NodeOperation.h 
b/source/blender/compositor/intern/COM_NodeOperation.h
index 783c1fd63c8..d0bfe3c1311 100644
--- a/source/blender/compositor/intern/COM_NodeOperation.h
+++ b/source/blender/compositor/intern/COM_NodeOperation.h
@@ -251,6 +251,7 @@ struct NodeOperationFlags {
  */
 class NodeOperation {
  private:
+  int m_id;
   std::string m_name;
   Vector m_inputs;
   Vector m_outputs;
@@ -307,6 +308,16 @@ class NodeOperation {
 return m_name;
   }
 
+  void set_id(const int id)
+  {
+m_id = id;
+  }
+
+  const int get_id() const
+  {
+return m_id;
+  }
+
   const NodeOperationFlags get_flags() const
   {
 return flags;
diff --git a/source/blender/compositor/intern/COM_NodeOperationBuilder.cc 
b/source/blender/compositor/intern/COM_NodeOperationBuilder.cc
index 59ce56a7cd5..889af4ea39a 100644
--- a/source/blender/compositor/intern/COM_NodeOperationBuilder.cc
+++ b/source/blender/compositor/intern/COM_NodeOperationBuilder.cc
@@ -124,6 +124,7 @@ void 
NodeOperationBuilder::convertToOperations(ExecutionSystem *system)
 
 void NodeOperationBuilder::addOperation(NodeOperation *operation)
 {
+  operation->set_id(m_operations.size());
   m_operations.append(operation);
   if (m_current_node) {
 operation->set_name(m_current_node->getbNode()->name);
@@ -691,4 +692,41 @@ void NodeOperationBuilder::group_operations()
   }
 }
 
+/** Create a graphviz representation of the NodeOperationBuilder. */
+std::ostream &operator<<(std::ostream &os, const NodeOperationBuilder &builder)
+{
+  os << "# Builder start\n";
+  os << "digraph  G {\n";
+  os << "rankdir=LR;\n";
+  os << "node [shape=box];\n";
+  for (const NodeOperation *operation : builder.get_operations()) {
+os << "op" << operation->get_id() << " [label=\"" << *operation << 
"\"];\n";
+  }
+
+  os << "\n";
+  for (const NodeOperationBuilder::Link &link : builder.get_links()) {
+os << "op" << link.from()->getOperation().get_id() << " -> op"
+   << link.to()->getOperation().get_id() << ";\n";
+  }
+  for (const NodeOperation *operation : builder.get_operations()) {
+if (operation->get_flags().is_read_buffer_operation) {
+  const ReadBufferOperation &read_operation = static_cast(
+  *operation);
+  const WriteBufferOperation &write_operation =
+  *read_operation.getMemoryProxy()->getWriteBufferOperation();
+  os << "op" << write_operation.get_id() << " -> op" << 
read_operation.get_id() << ";\n";
+}
+  }
+
+  os << "}\n";
+  os << "# Builder end\n";
+  return os;
+}
+
+std::ostream &operator<<(std::ostream &os, const NodeOperationBuilder::Link 
&link)
+{
+  os << link.from()->getOperation().get_id() << " -> " << 
link.to()->getOperation().get_id();
+  return os;
+}
+
 }  // namespace blender::compositor
diff --git a/source/blender/compositor/intern/COM_NodeOperationBuilder.h 
b/sou

[Bf-blender-cvs] [663a82b10d2] master: Fix T86932: Curve: pick shortest path missing update of active point drawing

2021-04-06 Thread Philipp Oeser
Commit: 663a82b10d23a8fd8468fec314b2d5ba740542e4
Author: Philipp Oeser
Date:   Fri Mar 26 10:42:12 2021 +0100
Branches: master
https://developer.blender.org/rB663a82b10d23a8fd8468fec314b2d5ba740542e4

Fix T86932: Curve: pick shortest path missing update of active point drawing

For curves, we need to tag the curve ID_RECALC_COPY_ON_WRITE for batch
cache update (same as in {rB24b2fe50f3ec}).

Maniphest Tasks: T86932

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

===

M   source/blender/editors/curve/editcurve_select.c

===

diff --git a/source/blender/editors/curve/editcurve_select.c 
b/source/blender/editors/curve/editcurve_select.c
index e3fc8b73172..90cefef38ee 100644
--- a/source/blender/editors/curve/editcurve_select.c
+++ b/source/blender/editors/curve/editcurve_select.c
@@ -1990,7 +1990,7 @@ static int edcu_shortest_path_pick_invoke(bContext *C, 
wmOperator *op, const wmE
 ED_object_base_activate(C, basact);
   }
 
-  DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
+  DEG_id_tag_update(obedit->data, ID_RECALC_SELECT | ID_RECALC_COPY_ON_WRITE);
   WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
   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] [e71408d0d7d] master: Fix T84623: Curve/Surface force not working in normal direction

2021-04-06 Thread Philipp Oeser
Commit: e71408d0d7dea93304476fb6a92e92fb469f73af
Author: Philipp Oeser
Date:   Tue Jan 12 15:14:48 2021 +0100
Branches: master
https://developer.blender.org/rBe71408d0d7dea93304476fb6a92e92fb469f73af

Fix T84623: Curve/Surface force not working in normal direction

Tweaking e.g. a field strength would then not use the curve/surface
normal anymore [but the object center instead].

If a curve has a forcefield with effector shape Curve (in code its shape
is PFIELD_SHAPE_SURFACE then), it wil get a SurfaceModifier.

Changing properties will free the SurfaceModifierData's bvhtree and mesh
And these dont get copied along when doing the CoW copy, these are
explicitly set to NULL. So this was also failing for meshes, not just
curves.

Without the mesh & bvhtree though, get_effector_data() will not set the
EffectorData's normal correctly (it is closest_point_on_surface() which
does this). And without the right EffectorData's normal, the effector
will of course work unexpected.

Going in and out of editmode made this work because that goes down this
route:
- BKE_object_handle_data_update
- BKE_displist_make_curveTypes
- do_makeDispListCurveTypes
- curve_calc_modifiers_post
-- BKE_mesh_new_nomain_from_curve_displist
-- we then have our desired updated mesh from the curve
-- this will also call the SurfaceModifiers deformVerts [which - given we
have a valid mesh - will update the bvhtree properly]

Also note that _animating_ the effector actually works, (have not done
the deep dive why this works, assume the curve geometry is updated in
this case)

So, now just carefully tag the curve ID_RECALC_GEOMETRY in
rna_FieldSettings_update for this specific case.

Maniphest Tasks: T84623

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

===

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

===

diff --git a/source/blender/makesrna/intern/rna_object_force.c 
b/source/blender/makesrna/intern/rna_object_force.c
index 14dd8a68fee..488f177946a 100644
--- a/source/blender/makesrna/intern/rna_object_force.c
+++ b/source/blender/makesrna/intern/rna_object_force.c
@@ -648,6 +648,13 @@ static void rna_FieldSettings_update(Main *UNUSED(bmain), 
Scene *UNUSED(scene),
   ob->pd->tex = NULL;
 }
 
+/* In the case of specific forcefields that are using the EffectorData's 
normal, we need to
+ * rebuild mesh and bhvtree for SurfaceModifier to work correctly. */
+if (ELEM(ob->pd->shape, PFIELD_SHAPE_SURFACE, PFIELD_SHAPE_POINTS) ||
+ob->pd->forcefield == PFIELD_GUIDE) {
+  DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
+}
+
 DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM);
 WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob);
   }

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


[Bf-blender-cvs] [7334c481c03] master: Fix T86175: Missing viewport update when toggling HDRI preview

2021-04-06 Thread Evan Wilson
Commit: 7334c481c03d0b89810925495cec3620760fc7c3
Author: Evan Wilson
Date:   Tue Apr 6 09:56:54 2021 +0200
Branches: master
https://developer.blender.org/rB7334c481c03d0b89810925495cec3620760fc7c3

Fix T86175: Missing viewport update when toggling HDRI preview

Caused by rB0f95f51361d7.

Similar to T85515, T84717, T85543 and their related fixes.
In this case, add missing shading notifier as in rB9274bd457a25.

Reviewed By: brecht, lichtwerk

Maniphest Tasks: T86175

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

===

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

===

diff --git a/source/blender/makesrna/intern/rna_space.c 
b/source/blender/makesrna/intern/rna_space.c
index f9b1816e1ba..df10ef41057 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -4080,7 +4080,7 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna)
   RNA_def_property_boolean_sdna(prop, NULL, "overlay.flag", 
V3D_OVERLAY_LOOK_DEV);
   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
   RNA_def_property_ui_text(prop, "HDRI Preview", "Show HDRI preview spheres");
-  RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+  RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D | 
NS_VIEW3D_SHADING, NULL);
 
   prop = RNA_def_property(srna, "show_wireframes", PROP_BOOLEAN, PROP_NONE);
   RNA_def_property_boolean_sdna(prop, NULL, "overlay.flag", 
V3D_OVERLAY_WIREFRAMES);

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