[Bf-blender-cvs] [1bb2c7dda30] geometry-nodes: Cleanup: Store "is_active" instead of pointer property in panel type

2020-11-30 Thread Hans Goudey
Commit: 1bb2c7dda3005279c43b7bf9db4c63320abc7d04
Author: Hans Goudey
Date:   Mon Nov 30 17:43:14 2020 -0500
Branches: geometry-nodes
https://developer.blender.org/rB1bb2c7dda3005279c43b7bf9db4c63320abc7d04

Cleanup: Store "is_active" instead of pointer property in panel type

This is consistent with the way other panel type fields are stored.

===

M   source/blender/blenkernel/BKE_screen.h
M   source/blender/editors/interface/interface_panel.c
M   source/blender/modifiers/intern/MOD_ui_common.c

===

diff --git a/source/blender/blenkernel/BKE_screen.h 
b/source/blender/blenkernel/BKE_screen.h
index dea9884f508..473a684eaba 100644
--- a/source/blender/blenkernel/BKE_screen.h
+++ b/source/blender/blenkernel/BKE_screen.h
@@ -234,6 +234,8 @@ typedef struct PanelType {
   char category[BKE_ST_MAXNAME];  /* for category tabs */
   char owner_id[BKE_ST_MAXNAME];  /* for work-spaces to selectively show. */
   char parent_id[BKE_ST_MAXNAME]; /* parent idname for sub-panels */
+  /** Boolean property identifier of the panel custom data. Used to draw a 
highlighted border. */
+  char active_property[BKE_ST_MAXNAME];
   short space_type;
   short region_type;
   /* For popovers, 0 for default. */
@@ -251,11 +253,6 @@ typedef struct PanelType {
   /* draw entirely, view changes should be handled here */
   void (*draw)(const struct bContext *C, struct Panel *panel);
 
-  /**
-   * Identifier of a boolean property of the panel custom data. Used to draw a 
highlighted border.
-   */
-  const char *active_property;
-
   /* For instanced panels corresponding to a list: */
 
   /** Reorder function, called when drag and drop finishes. */
diff --git a/source/blender/editors/interface/interface_panel.c 
b/source/blender/editors/interface/interface_panel.c
index d1e5bbcb536..b60fa40f39a 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -589,7 +589,7 @@ static bool panel_use_active_highlight(const Panel *panel)
   BLI_assert(UI_panel_is_active(panel));
   BLI_assert(panel->type != NULL);
 
-  if (panel->type->active_property) {
+  if (panel->type->active_property[0] != '\0') {
 PointerRNA *ptr = UI_panel_custom_data_get(panel);
 if (ptr != NULL && !RNA_pointer_is_null(ptr)) {
   return RNA_boolean_get(ptr, panel->type->active_property);
diff --git a/source/blender/modifiers/intern/MOD_ui_common.c 
b/source/blender/modifiers/intern/MOD_ui_common.c
index 166d77624e8..fa5243c548f 100644
--- a/source/blender/modifiers/intern/MOD_ui_common.c
+++ b/source/blender/modifiers/intern/MOD_ui_common.c
@@ -409,6 +409,7 @@ PanelType *modifier_panel_register(ARegionType 
*region_type, ModifierType type,
   BLI_strncpy(panel_type->label, "", BKE_ST_MAXNAME);
   BLI_strncpy(panel_type->context, "modifier", BKE_ST_MAXNAME);
   BLI_strncpy(panel_type->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA, 
BKE_ST_MAXNAME);
+  BLI_strncpy(panel_type->active_property, "is_active", BKE_ST_MAXNAME);
 
   panel_type->draw_header = modifier_panel_header;
   panel_type->draw = draw;
@@ -417,7 +418,6 @@ PanelType *modifier_panel_register(ARegionType 
*region_type, ModifierType type,
   /* Give the panel the special flag that says it was built here and 
corresponds to a
* modifier rather than a #PanelType. */
   panel_type->flag = PANEL_TYPE_HEADER_EXPAND | PANEL_TYPE_DRAW_BOX | 
PANEL_TYPE_INSTANCED;
-  panel_type->active_property = "is_active";
   panel_type->reorder = modifier_reorder;
   panel_type->get_list_data_expand_flag = get_modifier_expand_flag;
   panel_type->set_list_data_expand_flag = set_modifier_expand_flag;

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


[Bf-blender-cvs] [a0f41a4fd1a] geometry-nodes: Merge branch 'master' into geometry-nodes

2020-11-30 Thread Hans Goudey
Commit: a0f41a4fd1a559bced7f73e4b4c3b051c38c804c
Author: Hans Goudey
Date:   Mon Nov 30 17:36:14 2020 -0500
Branches: geometry-nodes
https://developer.blender.org/rBa0f41a4fd1a559bced7f73e4b4c3b051c38c804c

Merge branch 'master' into geometry-nodes

===



===



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


[Bf-blender-cvs] [645c2bd4d00] master: Fix sculpt transform incorrently flipping displacement in Y and Z axis

2020-11-30 Thread Pablo Dobarro
Commit: 645c2bd4d002d685cf240d6a46c635c00c0c1706
Author: Pablo Dobarro
Date:   Fri Nov 27 01:42:24 2020 +0100
Branches: master
https://developer.blender.org/rB645c2bd4d002d685cf240d6a46c635c00c0c1706

Fix sculpt transform incorrently flipping displacement in Y and Z axis

These functions were only checking the X axis for flipping the
displacement for a symmetry area depending on the initial position of
the pivot.
This affects transform and any other tools that transform vertices and
applies symmetry based on areas (the pose brush, for example).

Reviewed By: sergey

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

===

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

===

diff --git a/source/blender/editors/sculpt_paint/sculpt.c 
b/source/blender/editors/sculpt_paint/sculpt.c
index 1ddfa0b9b17..b9427677745 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -4025,13 +4025,13 @@ void SCULPT_flip_v3_by_symm_area(float v[3],
  const ePaintSymmetryAreas symmarea,
  const float pivot[3])
 {
-  for (char i = 0; i < 3; i++) {
+  for (int i = 0; i < 3; i++) {
 ePaintSymmetryFlags symm_it = 1 << i;
 if (symm & symm_it) {
   if (symmarea & symm_it) {
 flip_v3(v, symm_it);
   }
-  if (pivot[0] < 0) {
+  if (pivot[i] < 0.0f) {
 flip_v3(v, symm_it);
   }
 }
@@ -4043,13 +4043,13 @@ void SCULPT_flip_quat_by_symm_area(float quat[3],
const ePaintSymmetryAreas symmarea,
const float pivot[3])
 {
-  for (char i = 0; i < 3; i++) {
+  for (int i = 0; i < 3; i++) {
 ePaintSymmetryFlags symm_it = 1 << i;
 if (symm & symm_it) {
   if (symmarea & symm_it) {
 flip_qt(quat, symm_it);
   }
-  if (pivot[0] < 0) {
+  if (pivot[i] < 0.0f) {
 flip_qt(quat, symm_it);
   }
 }

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


[Bf-blender-cvs] [ea064133e53] master: UI: Add Sculpt Session info to stats

2020-11-30 Thread Pablo Dobarro
Commit: ea064133e53a11539f3869da010560a4f07826a8
Author: Pablo Dobarro
Date:   Fri Nov 27 00:03:58 2020 +0100
Branches: master
https://developer.blender.org/rBea064133e53a11539f3869da010560a4f07826a8

UI: Add Sculpt Session info to stats

This adds the vertex and face count info to the scene stats in sculpt
mode. These stats count the active vertices and faces in the
sculptsession for the active object. This has the following advantages:
- It is possible to know how many vertices the sculptsession has active
comparted to the vertex count of the entire scene from sculpt mode
- When sculpting with constructive modifiers, these stats will report the
number of vertices that you can actually sculpt with, instead of the
vertex count of the modified mesh and the entire scene.

Reviewed By: sergey, dbystedt

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

===

M   source/blender/blenkernel/BKE_pbvh.h
M   source/blender/blenkernel/intern/pbvh.c
M   source/blender/editors/space_info/info_stats.c

===

diff --git a/source/blender/blenkernel/BKE_pbvh.h 
b/source/blender/blenkernel/BKE_pbvh.h
index cd213b49c5b..fd600a41796 100644
--- a/source/blender/blenkernel/BKE_pbvh.h
+++ b/source/blender/blenkernel/BKE_pbvh.h
@@ -235,6 +235,7 @@ const struct CCGKey *BKE_pbvh_get_grid_key(const PBVH 
*pbvh);
 struct CCGElem **BKE_pbvh_get_grids(const PBVH *pbvh);
 BLI_bitmap **BKE_pbvh_get_grid_visibility(const PBVH *pbvh);
 int BKE_pbvh_get_grid_num_vertices(const PBVH *pbvh);
+int BKE_pbvh_get_grid_num_faces(const PBVH *pbvh);
 
 /* Only valid for type == PBVH_BMESH */
 struct BMesh *BKE_pbvh_get_bmesh(PBVH *pbvh);
diff --git a/source/blender/blenkernel/intern/pbvh.c 
b/source/blender/blenkernel/intern/pbvh.c
index ab87772d844..47d2ae8e283 100644
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@ -1707,6 +1707,12 @@ int BKE_pbvh_get_grid_num_vertices(const PBVH *pbvh)
   return pbvh->totgrid * pbvh->gridkey.grid_area;
 }
 
+int BKE_pbvh_get_grid_num_faces(const PBVH *pbvh)
+{
+  BLI_assert(pbvh->type == PBVH_GRIDS);
+  return pbvh->totgrid * (pbvh->gridkey.grid_size - 1) * 
(pbvh->gridkey.grid_size - 1);
+}
+
 BMesh *BKE_pbvh_get_bmesh(PBVH *pbvh)
 {
   BLI_assert(pbvh->type == PBVH_BMESH);
diff --git a/source/blender/editors/space_info/info_stats.c 
b/source/blender/editors/space_info/info_stats.c
index bf21b383ba6..43d0d4fc425 100644
--- a/source/blender/editors/space_info/info_stats.c
+++ b/source/blender/editors/space_info/info_stats.c
@@ -55,6 +55,7 @@
 #include "BKE_object.h"
 #include "BKE_paint.h"
 #include "BKE_particle.h"
+#include "BKE_pbvh.h"
 #include "BKE_scene.h"
 #include "BKE_subdiv_ccg.h"
 
@@ -69,9 +70,9 @@
 #define MAX_INFO_NUM_LEN 16
 
 typedef struct SceneStats {
-  uint64_t totvert, totvertsel;
+  uint64_t totvert, totvertsel, totvertsculpt;
   uint64_t totedge, totedgesel;
-  uint64_t totface, totfacesel;
+  uint64_t totface, totfacesel, totfacesculpt;
   uint64_t totbone, totbonesel;
   uint64_t totobj, totobjsel;
   uint64_t totlamp, totlampsel;
@@ -81,9 +82,9 @@ typedef struct SceneStats {
 
 typedef struct SceneStatsFmt {
   /* Totals */
-  char totvert[MAX_INFO_NUM_LEN], totvertsel[MAX_INFO_NUM_LEN];
+  char totvert[MAX_INFO_NUM_LEN], totvertsel[MAX_INFO_NUM_LEN], 
totvertsculpt[MAX_INFO_NUM_LEN];
   char totface[MAX_INFO_NUM_LEN], totfacesel[MAX_INFO_NUM_LEN];
-  char totedge[MAX_INFO_NUM_LEN], totedgesel[MAX_INFO_NUM_LEN];
+  char totedge[MAX_INFO_NUM_LEN], totedgesel[MAX_INFO_NUM_LEN], 
totfacesculpt[MAX_INFO_NUM_LEN];
   char totbone[MAX_INFO_NUM_LEN], totbonesel[MAX_INFO_NUM_LEN];
   char totobj[MAX_INFO_NUM_LEN], totobjsel[MAX_INFO_NUM_LEN];
   char totlamp[MAX_INFO_NUM_LEN], totlampsel[MAX_INFO_NUM_LEN];
@@ -350,15 +351,34 @@ static void stats_object_pose(Object *ob, SceneStats 
*stats)
   }
 }
 
-static void stats_object_sculpt_dynamic_topology(Object *ob, SceneStats *stats)
+static bool stats_is_object_dynamic_topology_sculpt(Object *ob, const 
eObjectMode object_mode)
 {
-  stats->totvert = ob->sculpt->bm->totvert;
-  stats->tottri = ob->sculpt->bm->totface;
+  return (ob && (object_mode & OB_MODE_SCULPT) && ob->sculpt && 
ob->sculpt->bm);
 }
 
-static bool stats_is_object_dynamic_topology_sculpt(Object *ob, const 
eObjectMode object_mode)
+static void stats_object_sculpt(Object *ob, SceneStats *stats)
 {
-  return (ob && (object_mode & OB_MODE_SCULPT) && ob->sculpt && 
ob->sculpt->bm);
+
+  SculptSession *ss = ob->sculpt;
+
+  if (!ss) {
+return;
+  }
+
+  switch (BKE_pbvh_type(ss->pbvh)) {
+case PBVH_FACES:
+  stats->totvertsculpt = ss->totvert;
+  stats->totfacesculpt = ss->totfaces;
+  break;
+case PBVH_BMESH:
+  stats->totvertsculpt = ob->sculpt->bm->totvert;
+  stats->tottri = ob->sculpt->bm->totface;
+  break;
+case PBVH_GRIDS:
+  

[Bf-blender-cvs] [7aa47cd6ff8] geometry-nodes: Merge remote-tracking branch 'origin/master' into geometry-nodes

2020-11-30 Thread Dalai Felinto
Commit: 7aa47cd6ff89e11f4158cdfedb2a4a80fdd8d7c5
Author: Dalai Felinto
Date:   Mon Nov 30 20:25:59 2020 +0100
Branches: geometry-nodes
https://developer.blender.org/rB7aa47cd6ff89e11f4158cdfedb2a4a80fdd8d7c5

Merge remote-tracking branch 'origin/master' into geometry-nodes

===



===



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


[Bf-blender-cvs] [6b12dad1901] master: Cleanup: Use LISTBASE_FOREACH for node tree sockets RNA code

2020-11-30 Thread Hans Goudey
Commit: 6b12dad1901e60b5deb28d4de105241f57f99f79
Author: Hans Goudey
Date:   Mon Nov 30 16:39:07 2020 -0500
Branches: master
https://developer.blender.org/rB6b12dad1901e60b5deb28d4de105241f57f99f79

Cleanup: Use LISTBASE_FOREACH for node tree sockets RNA code

===

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 e91b0d860c6..a9924c46fdd 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -1165,11 +1165,9 @@ static void rna_NodeTree_link_clear(bNodeTree *ntree, 
Main *bmain, ReportList *r
 static int rna_NodeTree_active_input_get(PointerRNA *ptr)
 {
   bNodeTree *ntree = (bNodeTree *)ptr->data;
-  bNodeSocket *gsock;
-  int index;
-
-  for (gsock = ntree->inputs.first, index = 0; gsock; gsock = gsock->next, 
index++) {
-if (gsock->flag & SELECT) {
+  int index = 0;
+  LISTBASE_FOREACH_INDEX (bNodeSocket *, socket, >inputs, index) {
+if (socket->flag & SELECT) {
   return index;
 }
   }
@@ -1179,30 +1177,22 @@ static int rna_NodeTree_active_input_get(PointerRNA 
*ptr)
 static void rna_NodeTree_active_input_set(PointerRNA *ptr, int value)
 {
   bNodeTree *ntree = (bNodeTree *)ptr->data;
-  bNodeSocket *gsock;
-  int index;
 
-  for (gsock = ntree->inputs.first, index = 0; gsock; gsock = gsock->next, 
index++) {
-if (index == value) {
-  gsock->flag |= SELECT;
-}
-else {
-  gsock->flag &= ~SELECT;
-}
+  int index = 0;
+  LISTBASE_FOREACH_INDEX (bNodeSocket *, socket, >inputs, index) {
+SET_FLAG_FROM_TEST(socket->flag, index == value, SELECT);
   }
-  for (gsock = ntree->outputs.first; gsock; gsock = gsock->next) {
-gsock->flag &= ~SELECT;
+  LISTBASE_FOREACH (bNodeSocket *, socket, >outputs) {
+socket->flag &= ~SELECT;
   }
 }
 
 static int rna_NodeTree_active_output_get(PointerRNA *ptr)
 {
   bNodeTree *ntree = (bNodeTree *)ptr->data;
-  bNodeSocket *gsock;
-  int index;
-
-  for (gsock = ntree->outputs.first, index = 0; gsock; gsock = gsock->next, 
index++) {
-if (gsock->flag & SELECT) {
+  int index = 0;
+  LISTBASE_FOREACH_INDEX (bNodeSocket *, socket, >outputs, index) {
+if (socket->flag & SELECT) {
   return index;
 }
   }
@@ -1212,32 +1202,24 @@ static int rna_NodeTree_active_output_get(PointerRNA 
*ptr)
 static void rna_NodeTree_active_output_set(PointerRNA *ptr, int value)
 {
   bNodeTree *ntree = (bNodeTree *)ptr->data;
-  bNodeSocket *gsock;
-  int index;
 
-  for (gsock = ntree->inputs.first; gsock; gsock = gsock->next) {
-gsock->flag &= ~SELECT;
+  LISTBASE_FOREACH (bNodeSocket *, socket, >inputs) {
+socket->flag &= ~SELECT;
   }
-  for (gsock = ntree->outputs.first, index = 0; gsock; gsock = gsock->next, 
index++) {
-if (index == value) {
-  gsock->flag |= SELECT;
-}
-else {
-  gsock->flag &= ~SELECT;
-}
+  int index = 0;
+  LISTBASE_FOREACH_INDEX (bNodeSocket *, socket, >outputs, index) {
+SET_FLAG_FROM_TEST(socket->flag, index == value, SELECT);
   }
 }
 
 static bNodeSocket *rna_NodeTree_inputs_new(
 bNodeTree *ntree, Main *bmain, ReportList *reports, const char *type, 
const char *name)
 {
-  bNodeSocket *sock;
-
   if (!rna_NodeTree_check(ntree, reports)) {
 return NULL;
   }
 
-  sock = ntreeAddSocketInterface(ntree, SOCK_IN, type, name);
+  bNodeSocket *sock = ntreeAddSocketInterface(ntree, SOCK_IN, type, name);
 
   ntreeUpdateTree(bmain, ntree);
   WM_main_add_notifier(NC_NODE | NA_EDITED, ntree);
@@ -1248,13 +1230,11 @@ static bNodeSocket *rna_NodeTree_inputs_new(
 static bNodeSocket *rna_NodeTree_outputs_new(
 bNodeTree *ntree, Main *bmain, ReportList *reports, const char *type, 
const char *name)
 {
-  bNodeSocket *sock;
-
   if (!rna_NodeTree_check(ntree, reports)) {
 return NULL;
   }
 
-  sock = ntreeAddSocketInterface(ntree, SOCK_OUT, type, name);
+  bNodeSocket *sock = ntreeAddSocketInterface(ntree, SOCK_OUT, type, name);
 
   ntreeUpdateTree(bmain, ntree);
   WM_main_add_notifier(NC_NODE | NA_EDITED, ntree);
@@ -1284,15 +1264,12 @@ static void rna_NodeTree_socket_remove(bNodeTree *ntree,
 
 static void rna_NodeTree_inputs_clear(bNodeTree *ntree, Main *bmain, 
ReportList *reports)
 {
-  bNodeSocket *sock, *nextsock;
-
   if (!rna_NodeTree_check(ntree, reports)) {
 return;
   }
 
-  for (sock = ntree->inputs.first; sock; sock = nextsock) {
-nextsock = sock->next;
-ntreeRemoveSocketInterface(ntree, sock);
+  LISTBASE_FOREACH_MUTABLE (bNodeSocket *, socket, >inputs) {
+ntreeRemoveSocketInterface(ntree, socket);
   }
 
   ntreeUpdateTree(bmain, ntree);
@@ -1301,15 +1278,12 @@ static void rna_NodeTree_inputs_clear(bNodeTree *ntree, 
Main *bmain, ReportList
 
 static void rna_NodeTree_outputs_clear(bNodeTree *ntree, Main *bmain, 
ReportList 

[Bf-blender-cvs] [007a0e43a01] master: Cleanup: Reduce variable scope in node drawing code

2020-11-30 Thread Hans Goudey
Commit: 007a0e43a01af97a2e393e2f98d9a86469ec4a78
Author: Hans Goudey
Date:   Mon Nov 30 13:56:46 2020 -0500
Branches: master
https://developer.blender.org/rB007a0e43a01af97a2e393e2f98d9a86469ec4a78

Cleanup: Reduce variable scope in node drawing code

Also use LISTBASE_FOREACH in a few places and generally clean up
the code for the two sidebar panels "Sockets" and "Interface".

===

M   source/blender/editors/space_node/node_buttons.c
M   source/blender/editors/space_node/node_draw.c

===

diff --git a/source/blender/editors/space_node/node_buttons.c 
b/source/blender/editors/space_node/node_buttons.c
index 6475e753409..0aba45ceafc 100644
--- a/source/blender/editors/space_node/node_buttons.c
+++ b/source/blender/editors/space_node/node_buttons.c
@@ -68,23 +68,20 @@ static bool node_sockets_poll(const bContext *C, PanelType 
*UNUSED(pt))
 
 static void node_sockets_panel(const bContext *C, Panel *panel)
 {
-  SpaceNode *snode = CTX_wm_space_node(C);
-  bNodeTree *ntree = (snode) ? snode->edittree : NULL;
-  bNode *node = (ntree) ? nodeGetActive(ntree) : NULL;
-  bNodeSocket *sock;
-  uiLayout *layout = panel->layout, *split;
-  char name[UI_MAX_NAME_STR];
-
-  if (ELEM(NULL, ntree, node)) {
+  SpaceNode *snode = CTX_wm_space_node(C); /* NULL checked in poll function. */
+  bNodeTree *ntree = snode->edittree;  /* NULL checked in poll function. */
+  bNode *node = nodeGetActive(ntree);
+  if (node == NULL) {
 return;
   }
 
-  for (sock = node->inputs.first; sock; sock = sock->next) {
-BLI_snprintf(name, sizeof(name), "%s:", sock->name);
+  LISTBASE_FOREACH (bNodeSocket *, socket, >inputs) {
+char name[UI_MAX_NAME_STR];
+BLI_snprintf(name, sizeof(name), "%s:", socket->name);
 
-split = uiLayoutSplit(layout, 0.35f, false);
+uiLayout *split = uiLayoutSplit(panel->layout, 0.35f, false);
 uiItemL(split, name, ICON_NONE);
-uiTemplateNodeLink(split, (bContext *)C, ntree, node, sock);
+uiTemplateNodeLink(split, (bContext *)C, ntree, node, socket);
   }
 }
 
@@ -96,19 +93,20 @@ static bool node_tree_interface_poll(const bContext *C, 
PanelType *UNUSED(pt))
   (snode->edittree->inputs.first || snode->edittree->outputs.first));
 }
 
-static bool node_tree_find_active_socket(bNodeTree *ntree, bNodeSocket 
**r_sock, int *r_in_out)
+static bool node_tree_find_active_socket(bNodeTree *ntree,
+ bNodeSocket **r_sock,
+ eNodeSocketInOut *r_in_out)
 {
-  bNodeSocket *sock;
-  for (sock = ntree->inputs.first; sock; sock = sock->next) {
-if (sock->flag & SELECT) {
-  *r_sock = sock;
+  LISTBASE_FOREACH (bNodeSocket *, socket, >inputs) {
+if (socket->flag & SELECT) {
+  *r_sock = socket;
   *r_in_out = SOCK_IN;
   return true;
 }
   }
-  for (sock = ntree->outputs.first; sock; sock = sock->next) {
-if (sock->flag & SELECT) {
-  *r_sock = sock;
+  LISTBASE_FOREACH (bNodeSocket *, socket, >outputs) {
+if (socket->flag & SELECT) {
+  *r_sock = socket;
   *r_in_out = SOCK_OUT;
   return true;
 }
@@ -121,28 +119,24 @@ static bool node_tree_find_active_socket(bNodeTree 
*ntree, bNodeSocket **r_sock,
 
 static void node_tree_interface_panel(const bContext *C, Panel *panel)
 {
-  SpaceNode *snode = CTX_wm_space_node(C);
-  bNodeTree *ntree = (snode) ? snode->edittree : NULL;
-  bNodeSocket *sock;
-  int in_out;
-  uiLayout *layout = panel->layout, *row, *split, *col;
-  PointerRNA ptr, sockptr, opptr;
-  wmOperatorType *ot;
-
-  if (!ntree) {
-return;
-  }
+  SpaceNode *snode = CTX_wm_space_node(C); /* NULL checked in poll function. */
+  bNodeTree *ntree = snode->edittree;  /* NULL checked in poll function. */
+  uiLayout *layout = panel->layout;
 
+  PointerRNA ptr;
   RNA_id_pointer_create((ID *)ntree, );
 
-  node_tree_find_active_socket(ntree, , _out);
-  RNA_pointer_create((ID *)ntree, _NodeSocketInterface, sock, );
+  bNodeSocket *socket;
+  eNodeSocketInOut in_out;
+  node_tree_find_active_socket(ntree, , _out);
+  PointerRNA sockptr;
+  RNA_pointer_create((ID *)ntree, _NodeSocketInterface, socket, );
 
-  row = uiLayoutRow(layout, false);
+  uiLayout *row = uiLayoutRow(layout, false);
 
-  split = uiLayoutRow(row, true);
-  col = uiLayoutColumn(split, true);
-  ot = WM_operatortype_find("NODE_OT_tree_socket_add", false);
+  uiLayout *split = uiLayoutRow(row, true);
+  uiLayout *col = uiLayoutColumn(split, true);
+  wmOperatorType *ot = WM_operatortype_find("NODE_OT_tree_socket_add", false);
   uiItemL(col, IFACE_("Inputs:"), ICON_NONE);
   uiTemplateList(col,
  (bContext *)C,
@@ -159,6 +153,7 @@ static void node_tree_interface_panel(const bContext *C, 
Panel *panel)
  0,
  false,
  false);
+  PointerRNA opptr;
   uiItemFullO_ptr(col, ot, "", 

[Bf-blender-cvs] [5a35e56bcb7] master: Cleanup: Remove unecessary code.

2020-11-30 Thread Bastien Montagne
Commit: 5a35e56bcb7d48c2a5d6ef03ea8916aff0c9ea4e
Author: Bastien Montagne
Date:   Mon Nov 30 19:46:30 2020 +0100
Branches: master
https://developer.blender.org/rB5a35e56bcb7d48c2a5d6ef03ea8916aff0c9ea4e

Cleanup: Remove unecessary code.

We already `memset` the whole mesh runtime to zero, no need to set some
of its pointer explicitly to NULL afterward.

===

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

===

diff --git a/source/blender/blenkernel/intern/mesh_runtime.c 
b/source/blender/blenkernel/intern/mesh_runtime.c
index f35f4ae3501..b5257983b8c 100644
--- a/source/blender/blenkernel/intern/mesh_runtime.c
+++ b/source/blender/blenkernel/intern/mesh_runtime.c
@@ -51,7 +51,6 @@ void BKE_mesh_runtime_reset(Mesh *mesh)
   memset(>runtime, 0, sizeof(mesh->runtime));
   mesh->runtime.eval_mutex = MEM_mallocN(sizeof(ThreadMutex), "mesh runtime 
eval_mutex");
   BLI_mutex_init(mesh->runtime.eval_mutex);
-  mesh->runtime.bvh_cache = NULL;
 }
 
 /* Clear all pointers which we don't want to be shared on copying the 
datablock.

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


[Bf-blender-cvs] [814b2787cad] master: Fix T83196: bad matrix to quaternion precision near 180 degrees rotation.

2020-11-30 Thread Alexander Gavrilov
Commit: 814b2787caddf5bd81477bd7b5dea8c45c402a72
Author: Alexander Gavrilov
Date:   Mon Nov 30 19:31:21 2020 +0300
Branches: master
https://developer.blender.org/rB814b2787caddf5bd81477bd7b5dea8c45c402a72

Fix T83196: bad matrix to quaternion precision near 180 degrees rotation.

Adjust the threshold for switching from the base case to trace > 0,
based on very similar example code from www.euclideanspace.com to
avoid float precision issues when trace is close to -1.

Also, remove conversions to and from double, because using double
here doesn't really have benefit, especially with the new threshold.

Finally, add quaternion-matrix-quaternion round trip tests with
full coverage for all 4 branches.

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

===

M   source/blender/blenlib/CMakeLists.txt
M   source/blender/blenlib/intern/math_rotation.c
A   source/blender/blenlib/tests/BLI_math_rotation_test.cc

===

diff --git a/source/blender/blenlib/CMakeLists.txt 
b/source/blender/blenlib/CMakeLists.txt
index bcc8c181af4..9736d8f9b3b 100644
--- a/source/blender/blenlib/CMakeLists.txt
+++ b/source/blender/blenlib/CMakeLists.txt
@@ -400,6 +400,7 @@ if(WITH_GTESTS)
 tests/BLI_math_color_test.cc
 tests/BLI_math_geom_test.cc
 tests/BLI_math_matrix_test.cc
+tests/BLI_math_rotation_test.cc
 tests/BLI_math_solvers_test.cc
 tests/BLI_math_vector_test.cc
 tests/BLI_memiter_test.cc
diff --git a/source/blender/blenlib/intern/math_rotation.c 
b/source/blender/blenlib/intern/math_rotation.c
index c8e84cee0a0..a0ee16bee76 100644
--- a/source/blender/blenlib/intern/math_rotation.c
+++ b/source/blender/blenlib/intern/math_rotation.c
@@ -320,47 +320,57 @@ void quat_to_mat4(float m[4][4], const float q[4])
 
 void mat3_normalized_to_quat(float q[4], const float mat[3][3])
 {
-  double tr, s;
-
   BLI_ASSERT_UNIT_M3(mat);
 
-  tr = 0.25 * (double)(1.0f + mat[0][0] + mat[1][1] + mat[2][2]);
+  /* Check the trace of the matrix - bad precision if close to -1. */
+  const float trace = mat[0][0] + mat[1][1] + mat[2][2];
+
+  if (trace > 0) {
+float s = 2.0f * sqrtf(1.0f + trace);
+
+q[0] = 0.25f * s;
 
-  if (tr > (double)1e-4f) {
-s = sqrt(tr);
-q[0] = (float)s;
-s = 1.0 / (4.0 * s);
-q[1] = (float)((double)(mat[1][2] - mat[2][1]) * s);
-q[2] = (float)((double)(mat[2][0] - mat[0][2]) * s);
-q[3] = (float)((double)(mat[0][1] - mat[1][0]) * s);
+s = 1.0f / s;
+
+q[1] = (mat[1][2] - mat[2][1]) * s;
+q[2] = (mat[2][0] - mat[0][2]) * s;
+q[3] = (mat[0][1] - mat[1][0]) * s;
   }
   else {
+/* Find the biggest diagonal element to choose the best formula.
+ * Here trace should also be always >= 0, avoiding bad precision. */
 if (mat[0][0] > mat[1][1] && mat[0][0] > mat[2][2]) {
-  s = 2.0f * sqrtf(1.0f + mat[0][0] - mat[1][1] - mat[2][2]);
-  q[1] = (float)(0.25 * s);
+  float s = 2.0f * sqrtf(1.0f + mat[0][0] - mat[1][1] - mat[2][2]);
+
+  q[1] = 0.25f * s;
 
-  s = 1.0 / s;
-  q[0] = (float)((double)(mat[1][2] - mat[2][1]) * s);
-  q[2] = (float)((double)(mat[1][0] + mat[0][1]) * s);
-  q[3] = (float)((double)(mat[2][0] + mat[0][2]) * s);
+  s = 1.0f / s;
+
+  q[0] = (mat[1][2] - mat[2][1]) * s;
+  q[2] = (mat[1][0] + mat[0][1]) * s;
+  q[3] = (mat[2][0] + mat[0][2]) * s;
 }
 else if (mat[1][1] > mat[2][2]) {
-  s = 2.0f * sqrtf(1.0f + mat[1][1] - mat[0][0] - mat[2][2]);
-  q[2] = (float)(0.25 * s);
+  float s = 2.0f * sqrtf(1.0f + mat[1][1] - mat[0][0] - mat[2][2]);
+
+  q[2] = 0.25f * s;
+
+  s = 1.0f / s;
 
-  s = 1.0 / s;
-  q[0] = (float)((double)(mat[2][0] - mat[0][2]) * s);
-  q[1] = (float)((double)(mat[1][0] + mat[0][1]) * s);
-  q[3] = (float)((double)(mat[2][1] + mat[1][2]) * s);
+  q[0] = (mat[2][0] - mat[0][2]) * s;
+  q[1] = (mat[1][0] + mat[0][1]) * s;
+  q[3] = (mat[2][1] + mat[1][2]) * s;
 }
 else {
-  s = 2.0f * sqrtf(1.0f + mat[2][2] - mat[0][0] - mat[1][1]);
-  q[3] = (float)(0.25 * s);
+  float s = 2.0f * sqrtf(1.0f + mat[2][2] - mat[0][0] - mat[1][1]);
+
+  q[3] = 0.25f * s;
+
+  s = 1.0f / s;
 
-  s = 1.0 / s;
-  q[0] = (float)((double)(mat[0][1] - mat[1][0]) * s);
-  q[1] = (float)((double)(mat[2][0] + mat[0][2]) * s);
-  q[2] = (float)((double)(mat[2][1] + mat[1][2]) * s);
+  q[0] = (mat[0][1] - mat[1][0]) * s;
+  q[1] = (mat[2][0] + mat[0][2]) * s;
+  q[2] = (mat[2][1] + mat[1][2]) * s;
 }
   }
 
diff --git a/source/blender/blenlib/tests/BLI_math_rotation_test.cc 
b/source/blender/blenlib/tests/BLI_math_rotation_test.cc
new file mode 100644
index 000..1b1c4ef24a1
--- /dev/null
+++ b/source/blender/blenlib/tests/BLI_math_rotation_test.cc
@@ -0,0 +1,128 @@
+/* Apache License, Version 2.0 */
+
+#include 

[Bf-blender-cvs] [6022103264c] master: Cleanup: Clang tidy void argument

2020-11-30 Thread Hans Goudey
Commit: 6022103264cf2e23ad884fce6b5dfadf88b24e05
Author: Hans Goudey
Date:   Mon Nov 30 13:44:58 2020 -0500
Branches: master
https://developer.blender.org/rB6022103264cf2e23ad884fce6b5dfadf88b24e05

Cleanup: Clang tidy void argument

===

M   source/blender/gpu/opengl/gl_shader.cc

===

diff --git a/source/blender/gpu/opengl/gl_shader.cc 
b/source/blender/gpu/opengl/gl_shader.cc
index 28b89ad48f5..dd08a67517e 100644
--- a/source/blender/gpu/opengl/gl_shader.cc
+++ b/source/blender/gpu/opengl/gl_shader.cc
@@ -426,7 +426,7 @@ void GLShader::vertformat_from_shader(GPUVertFormat 
*format) const
   }
 }
 
-int GLShader::program_handle_get(void) const
+int GLShader::program_handle_get() const
 {
   return (int)this->shader_program_;
 }

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


[Bf-blender-cvs] [d6c545b356c] geometry-nodes-distribute-points: Merge branch 'geometry-nodes' into geometry-nodes-distribute-points

2020-11-30 Thread Sebastian Parborg
Commit: d6c545b356c060c2b933569717966398555c844d
Author: Sebastian Parborg
Date:   Mon Nov 30 19:18:33 2020 +0100
Branches: geometry-nodes-distribute-points
https://developer.blender.org/rBd6c545b356c060c2b933569717966398555c844d

Merge branch 'geometry-nodes' into geometry-nodes-distribute-points

===



===



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


[Bf-blender-cvs] [dff17b6cc0d] geometry-nodes-distribute-points: Merge branch 'geometry-nodes' into geometry-nodes-distribute-points

2020-11-30 Thread Sebastian Parborg
Commit: dff17b6cc0d639ee24ff22b9d0bd26c802db729a
Author: Sebastian Parborg
Date:   Mon Nov 30 19:17:51 2020 +0100
Branches: geometry-nodes-distribute-points
https://developer.blender.org/rBdff17b6cc0d639ee24ff22b9d0bd26c802db729a

Merge branch 'geometry-nodes' into geometry-nodes-distribute-points

===



===



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


[Bf-blender-cvs] [c0677b662f4] master: Fix T83177: Industry Compatible keymap: MMB-dragging to transform engages axis-constraining on release

2020-11-30 Thread Germano Cavalcante
Commit: c0677b662f4b13429c0738b99ace85403385ff38
Author: Germano Cavalcante
Date:   Mon Nov 30 13:11:46 2020 -0300
Branches: master
https://developer.blender.org/rBc0677b662f4b13429c0738b99ace85403385ff38

Fix T83177: Industry Compatible keymap: MMB-dragging to transform engages 
axis-constraining on release

Release confirm did not consider modal keymap events.

===

M   source/blender/editors/transform/transform.c
M   source/blender/editors/transform/transform.h
M   source/blender/editors/transform/transform_generics.c
M   source/blender/editors/transform/transform_ops.c
M   source/blender/windowmanager/WM_api.h
M   source/blender/windowmanager/intern/wm_event_system.c

===

diff --git a/source/blender/editors/transform/transform.c 
b/source/blender/editors/transform/transform.c
index bba0b750d0c..356ad8643f8 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -818,9 +818,15 @@ int transformEvent(TransInfo *t, const wmEvent *event)
 t->redraw |= handleSnapping(t, event);
 handled = true;
   }
-  /* handle modal keymap first */
-  /* enforce redraw of transform when modifiers are used */
+  else if (event->val == t->release_confirm_event_val &&
+   event->type == t->release_confirm_event_type) {
+/* Confirm transform if launch key is released after mouse move. */
+BLI_assert(t->flag & T_RELEASE_CONFIRM);
+t->state = TRANS_CONFIRM;
+  }
   else if (event->type == EVT_MODAL_MAP) {
+/* Handle modal keymap first. */
+/* Enforce redraw of transform when modifiers are used */
 switch (event->val) {
   case TFM_MODAL_CANCEL:
 t->state = TRANS_CANCEL;
@@ -1122,8 +1128,8 @@ int transformEvent(TransInfo *t, const wmEvent *event)
 break;
 }
   }
-  /* Else do non-mapped events. */
   else if (event->val == KM_PRESS) {
+/* Do non-mapped events. */
 switch (event->type) {
   case EVT_CKEY:
 if (event->is_repeat) {
@@ -1211,11 +1217,6 @@ int transformEvent(TransInfo *t, const wmEvent *event)
 }
 break;
 }
-
-/* confirm transform if launch key is released after mouse move */
-if ((t->flag & T_RELEASE_CONFIRM) && event->type == t->launch_event) {
-  t->state = TRANS_CONFIRM;
-}
   }
 
   /* if we change snap options, get the unsnapped values back */
@@ -1687,17 +1688,6 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator 
*op, const wmEvent *eve
 
   t->mode = mode;
 
-  /* Needed to translate tweak events to mouse buttons. */
-  t->launch_event = event ? 
WM_userdef_event_type_from_keymap_type(event->type) : -1;
-  t->is_launch_event_tweak = event ? ISTWEAK(event->type) : false;
-
-  /* XXX Remove this when wm_operator_call_internal doesn't use 
window->eventstate
-   * (which can have type = 0) */
-  /* For gizmo only, so assume LEFTMOUSE. */
-  if (t->launch_event == 0) {
-t->launch_event = LEFTMOUSE;
-  }
-
   unit_m3(t->spacemtx);
 
   initTransInfo(C, t, op, event);
@@ -1771,37 +1761,6 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator 
*op, const wmEvent *eve
 }
   }
 
-  if (event) {
-/* keymap for shortcut header prints */
-t->keymap = WM_keymap_active(CTX_wm_manager(C), op->type->modalkeymap);
-
-/* Stupid code to have Ctrl-Click on gizmo work ok.
- *
- * Do this only for translation/rotation/resize because only these
- * modes are available from gizmo and doing such check could
- * lead to keymap conflicts for other modes (see T31584)
- */
-if (ELEM(mode, TFM_TRANSLATION, TFM_ROTATION, TFM_RESIZE)) {
-  wmKeyMapItem *kmi;
-
-  for (kmi = t->keymap->items.first; kmi; kmi = kmi->next) {
-if (kmi->flag & KMI_INACTIVE) {
-  continue;
-}
-
-if (kmi->propvalue == TFM_MODAL_SNAP_INV_ON && kmi->val == KM_PRESS) {
-  if ((ELEM(kmi->type, EVT_LEFTCTRLKEY, EVT_RIGHTCTRLKEY) && 
event->ctrl) ||
-  (ELEM(kmi->type, EVT_LEFTSHIFTKEY, EVT_RIGHTSHIFTKEY) && 
event->shift) ||
-  (ELEM(kmi->type, EVT_LEFTALTKEY, EVT_RIGHTALTKEY) && event->alt) 
||
-  ((kmi->type == EVT_OSKEY) && event->oskey)) {
-t->modifiers |= MOD_SNAP_INVERT;
-  }
-  break;
-}
-  }
-}
-  }
-
   initSnapping(t, op); /* Initialize snapping data AFTER mode flags */
 
   initSnapSpatial(t, t->snap_spatial);
diff --git a/source/blender/editors/transform/transform.h 
b/source/blender/editors/transform/transform.h
index 227330e8524..485d5282a62 100644
--- a/source/blender/editors/transform/transform.h
+++ b/source/blender/editors/transform/transform.h
@@ -351,7 +351,8 @@ typedef struct TransInfo {
 
   /*** NEW STUFF */
   /** event type used to launch transform. */
-  short launch_event;
+  short 

[Bf-blender-cvs] [01b63aa266e] asset-browser: Rename some core asset types (breaking file compatibility)

2020-11-30 Thread Julian Eisel
Commit: 01b63aa266e0ebab876347920cb9daaa4115ed82
Author: Julian Eisel
Date:   Mon Nov 30 17:39:56 2020 +0100
Branches: asset-browser
https://developer.blender.org/rB01b63aa266e0ebab876347920cb9daaa4115ed82

Rename some core asset types (breaking file compatibility)

After feedback from review, I decided to change data-structure names
(`AssetData` -> `AssetMetaData`, `CustomTag` -> `AssetTag`).
This will break DNA compatibility so old assets created with this branch won't
be readable.

===

M   source/blender/blenkernel/BKE_asset.h
M   source/blender/blenkernel/intern/asset.c
M   source/blender/blenkernel/intern/lib_id.c
M   source/blender/blenkernel/intern/lib_id_delete.c
M   source/blender/blenloader/BLO_readfile.h
M   source/blender/blenloader/intern/readfile.c
M   source/blender/blenloader/intern/readfile.h
M   source/blender/editors/asset/asset_edit.c
M   source/blender/editors/space_file/filelist.c
M   source/blender/makesdna/DNA_ID.h
M   source/blender/makesdna/DNA_asset_defaults.h
M   source/blender/makesdna/DNA_asset_types.h
M   source/blender/makesdna/DNA_space_types.h
M   source/blender/makesdna/intern/dna_defaults.c
M   source/blender/makesrna/RNA_access.h
M   source/blender/makesrna/intern/rna_asset.c
M   source/blender/makesrna/intern/rna_space.c

===

diff --git a/source/blender/blenkernel/BKE_asset.h 
b/source/blender/blenkernel/BKE_asset.h
index 2e97fcd9dc9..4d467deadfe 100644
--- a/source/blender/blenkernel/BKE_asset.h
+++ b/source/blender/blenkernel/BKE_asset.h
@@ -42,25 +42,25 @@ void BKE_asset_repository_info_update_for_file_read(struct 
AssetRepositoryInfo *
 struct AssetCatalog *BKE_asset_repository_catalog_create(const char *name);
 void BKE_asset_repository_catalog_free(struct AssetCatalog **catalog);
 
-struct AssetData *BKE_asset_data_create(void);
-void BKE_asset_data_free(struct AssetData **asset_data);
+struct AssetMetaData *BKE_asset_metadata_create(void);
+void BKE_asset_metadata_free(struct AssetMetaData **asset_data);
 
-struct CustomTagEnsureResult {
-  struct CustomTag *tag;
+struct AssetTagEnsureResult {
+  struct AssetTag *tag;
   /* Set to false if a tag of this name was already present. */
   bool is_new;
 };
 
-struct CustomTag *BKE_assetdata_tag_add(struct AssetData *asset_data, const 
char *name);
-struct CustomTagEnsureResult BKE_assetdata_tag_ensure(struct AssetData 
*asset_data,
-  const char *name);
-void BKE_assetdata_tag_remove(struct AssetData *asset_data, struct CustomTag 
*tag);
+struct AssetTag *BKE_asset_metadata_tag_add(struct AssetMetaData *asset_data, 
const char *name);
+struct AssetTagEnsureResult BKE_asset_metadata_tag_ensure(struct AssetMetaData 
*asset_data,
+  const char *name);
+void BKE_asset_metadata_tag_remove(struct AssetMetaData *asset_data, struct 
AssetTag *tag);
 
-struct PreviewImage *BKE_assetdata_preview_get_from_id(const struct AssetData 
*asset_data,
-   const struct ID 
*owner_id);
+struct PreviewImage *BKE_asset_metadata_preview_get_from_id(const struct 
AssetMetaData *asset_data,
+const struct ID 
*owner_id);
 
-void BKE_assetdata_write(struct BlendWriter *writer, struct AssetData 
*asset_data);
-void BKE_assetdata_read(struct BlendDataReader *reader, struct AssetData 
*asset_data);
+void BKE_asset_metadata_write(struct BlendWriter *writer, struct AssetMetaData 
*asset_data);
+void BKE_asset_metadata_read(struct BlendDataReader *reader, struct 
AssetMetaData *asset_data);
 
 #ifdef __cplusplus
 }
diff --git a/source/blender/blenkernel/intern/asset.c 
b/source/blender/blenkernel/intern/asset.c
index 5ce3cbc99b4..d352d36ab5d 100644
--- a/source/blender/blenkernel/intern/asset.c
+++ b/source/blender/blenkernel/intern/asset.c
@@ -88,14 +88,14 @@ void BKE_asset_repository_catalog_free(AssetCatalog 
**catalog)
   MEM_SAFE_FREE(*catalog);
 }
 
-AssetData *BKE_asset_data_create(void)
+AssetMetaData *BKE_asset_metadata_create(void)
 {
-  AssetData *asset_data = MEM_callocN(sizeof(AssetData), __func__);
-  memcpy(asset_data, DNA_struct_default_get(AssetData), sizeof(*asset_data));
+  AssetMetaData *asset_data = MEM_callocN(sizeof(AssetMetaData), __func__);
+  memcpy(asset_data, DNA_struct_default_get(AssetMetaData), 
sizeof(*asset_data));
   return asset_data;
 }
 
-void BKE_asset_data_free(AssetData **asset_data)
+void BKE_asset_metadata_free(AssetMetaData **asset_data)
 {
   if ((*asset_data)->properties) {
 IDP_FreeProperty((*asset_data)->properties);
@@ -106,19 +106,19 @@ void BKE_asset_data_free(AssetData **asset_data)
   MEM_SAFE_FREE(*asset_data);
 }
 
-static CustomTag *assetdata_tag_create(const char *const name)

[Bf-blender-cvs] [95441fde674] asset-browser: General cleanup

2020-11-30 Thread Julian Eisel
Commit: 95441fde6749637cbb816b5698afbca768645ca6
Author: Julian Eisel
Date:   Mon Nov 30 17:03:08 2020 +0100
Branches: asset-browser
https://developer.blender.org/rB95441fde6749637cbb816b5698afbca768645ca6

General cleanup

===

M   source/blender/blenkernel/BKE_asset.h
M   source/blender/blenkernel/intern/asset.c
M   source/blender/blenkernel/intern/lib_id_delete.c
M   source/blender/blenloader/intern/readfile.c
M   source/blender/editors/space_file/filelist.c
M   source/blender/windowmanager/intern/wm_operator_type.c

===

diff --git a/source/blender/blenkernel/BKE_asset.h 
b/source/blender/blenkernel/BKE_asset.h
index b87a23c37f0..2e97fcd9dc9 100644
--- a/source/blender/blenkernel/BKE_asset.h
+++ b/source/blender/blenkernel/BKE_asset.h
@@ -40,10 +40,10 @@ void BKE_asset_repository_info_update_for_file_read(struct 
AssetRepositoryInfo *
 #endif
 
 struct AssetCatalog *BKE_asset_repository_catalog_create(const char *name);
-void BKE_asset_repository_catalog_free(struct AssetCatalog *catalog);
+void BKE_asset_repository_catalog_free(struct AssetCatalog **catalog);
 
 struct AssetData *BKE_asset_data_create(void);
-void BKE_asset_data_free(struct AssetData *asset_data);
+void BKE_asset_data_free(struct AssetData **asset_data);
 
 struct CustomTagEnsureResult {
   struct CustomTag *tag;
diff --git a/source/blender/blenkernel/intern/asset.c 
b/source/blender/blenkernel/intern/asset.c
index aa28651399c..5ce3cbc99b4 100644
--- a/source/blender/blenkernel/intern/asset.c
+++ b/source/blender/blenkernel/intern/asset.c
@@ -57,7 +57,7 @@ void BKE_asset_repository_info_free(AssetRepositoryInfo 
**repository_info)
 
   LISTBASE_FOREACH_MUTABLE (AssetCatalog *, catalog, 
&(*repository_info)->catalogs) {
 BLI_remlink(&(*repository_info)->catalogs, catalog);
-BKE_asset_repository_catalog_free(catalog);
+BKE_asset_repository_catalog_free();
   }
   MEM_SAFE_FREE(*repository_info);
 }
@@ -83,9 +83,9 @@ AssetCatalog *BKE_asset_repository_catalog_create(const char 
*name)
   return catalog;
 }
 
-void BKE_asset_repository_catalog_free(AssetCatalog *catalog)
+void BKE_asset_repository_catalog_free(AssetCatalog **catalog)
 {
-  MEM_freeN(catalog);
+  MEM_SAFE_FREE(*catalog);
 }
 
 AssetData *BKE_asset_data_create(void)
@@ -95,15 +95,15 @@ AssetData *BKE_asset_data_create(void)
   return asset_data;
 }
 
-void BKE_asset_data_free(AssetData *asset_data)
+void BKE_asset_data_free(AssetData **asset_data)
 {
-  if (asset_data->properties) {
-IDP_FreeProperty(asset_data->properties);
+  if ((*asset_data)->properties) {
+IDP_FreeProperty((*asset_data)->properties);
   }
-  MEM_SAFE_FREE(asset_data->description);
-  BLI_freelistN(_data->tags);
+  MEM_SAFE_FREE((*asset_data)->description);
+  BLI_freelistN(&(*asset_data)->tags);
 
-  MEM_SAFE_FREE(asset_data);
+  MEM_SAFE_FREE(*asset_data);
 }
 
 static CustomTag *assetdata_tag_create(const char *const name)
diff --git a/source/blender/blenkernel/intern/lib_id_delete.c 
b/source/blender/blenkernel/intern/lib_id_delete.c
index ccbde14b8ff..592807a5b3f 100644
--- a/source/blender/blenkernel/intern/lib_id_delete.c
+++ b/source/blender/blenkernel/intern/lib_id_delete.c
@@ -66,7 +66,7 @@ void BKE_libblock_free_data(ID *id, const bool do_id_user)
   }
 
   if (id->asset_data) {
-BKE_asset_data_free(id->asset_data);
+BKE_asset_data_free(>asset_data);
   }
 
   BKE_animdata_free(id, do_id_user);
diff --git a/source/blender/blenloader/intern/readfile.c 
b/source/blender/blenloader/intern/readfile.c
index 039b9cb9e90..fd83ff7d5e7 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -961,13 +961,13 @@ static BHead *blo_bhead_read_full(FileData *fd, BHead 
*thisblock)
 }
 #endif /* USE_BHEAD_READ_ON_DEMAND */
 
-/* Warning! Caller's responsibility to ensure given bhead **is** and ID one! */
+/* Warning! Caller's responsibility to ensure given bhead **is** an ID one! */
 const char *blo_bhead_id_name(const FileData *fd, const BHead *bhead)
 {
   return (const char *)POINTER_OFFSET(bhead, sizeof(*bhead) + 
fd->id_name_offs);
 }
 
-/* Warning! Caller's responsibility to ensure given bhead **is** and ID one! */
+/* Warning! Caller's responsibility to ensure given bhead **is** an ID one! */
 AssetData *blo_bhead_id_asset_data_address(const FileData *fd, const BHead 
*bhead)
 {
   BLI_assert(BKE_idtype_idcode_is_valid(bhead->code));
diff --git a/source/blender/editors/space_file/filelist.c 
b/source/blender/editors/space_file/filelist.c
index 49bac81d9c8..866bbf9a285 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -1411,7 +1411,7 @@ static void 
filelist_intern_entry_free(FileListInternEntry *entry)
   /* If we own the asset-data (it was generated from external file data), free 
it. */
   if 

[Bf-blender-cvs] [723c76e5d47] asset-browser: Remove preview pointer in asset-data

2020-11-30 Thread Julian Eisel
Commit: 723c76e5d47f838fd4a24cdee93a66ed3db93166
Author: Julian Eisel
Date:   Mon Nov 30 15:30:48 2020 +0100
Branches: asset-browser
https://developer.blender.org/rB723c76e5d47f838fd4a24cdee93a66ed3db93166

Remove preview pointer in asset-data

Not needed, we get the preview via the ID.

===

M   source/blender/blenkernel/intern/asset.c
M   source/blender/editors/asset/asset_edit.c
M   source/blender/makesdna/DNA_asset_types.h

===

diff --git a/source/blender/blenkernel/intern/asset.c 
b/source/blender/blenkernel/intern/asset.c
index 1780439bbfd..aa28651399c 100644
--- a/source/blender/blenkernel/intern/asset.c
+++ b/source/blender/blenkernel/intern/asset.c
@@ -190,5 +190,4 @@ void BKE_assetdata_read(BlendDataReader *reader, AssetData 
*asset_data)
 
   BLO_read_data_address(reader, _data->description);
   BLO_read_list(reader, _data->tags);
-  asset_data->preview = NULL;
 }
diff --git a/source/blender/editors/asset/asset_edit.c 
b/source/blender/editors/asset/asset_edit.c
index c52e8bc7062..318a980bcbd 100644
--- a/source/blender/editors/asset/asset_edit.c
+++ b/source/blender/editors/asset/asset_edit.c
@@ -45,9 +45,6 @@ bool ED_asset_make_for_id(const bContext *C, ID *id)
   id->asset_data = BKE_asset_data_create();
 
   UI_icon_render_id(C, NULL, id, true, true);
-  /* Store reference to the ID's preview. */
-  /* XXX get rid of this? File read will be a hassle and no real need for it 
right now. */
-  id->asset_data->preview = BKE_assetdata_preview_get_from_id(id->asset_data, 
id);
 
   return true;
 }
diff --git a/source/blender/makesdna/DNA_asset_types.h 
b/source/blender/makesdna/DNA_asset_types.h
index 610b78984cc..4ae5f5f07aa 100644
--- a/source/blender/makesdna/DNA_asset_types.h
+++ b/source/blender/makesdna/DNA_asset_types.h
@@ -56,9 +56,6 @@ extern AssetRepositoryInfo *G_asset_repository_info;
  *   more than that from the file. So pointers to other IDs or ID data are 
strictly forbidden.
  */
 typedef struct AssetData {
-  /** Thumbnail image of the data-block. Duplicate of the referenced ID 
preview. */
-  struct PreviewImage *preview;
-
   /** Custom asset meta-data. Cannot store pointers to IDs 
(#STRUCT_NO_DATABLOCK_IDPROPERTIES)! */
   struct IDProperty *properties;

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


[Bf-blender-cvs] [3bdc42f97a8] master: Fix T82996: Library Overrides: Duplicate of overridden collection on Resync

2020-11-30 Thread Bastien Montagne
Commit: 3bdc42f97a837766aec2bcd57917ef631570304f
Author: Bastien Montagne
Date:   Mon Nov 30 17:17:43 2020 +0100
Branches: master
https://developer.blender.org/rB3bdc42f97a837766aec2bcd57917ef631570304f

Fix T82996: Library Overrides: Duplicate of overridden collection on Resync

Properly use given reference pointer in
`lib_override_library_create_post_process` when it is a Collection one
too.

===

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

===

diff --git a/source/blender/blenkernel/intern/lib_override.c 
b/source/blender/blenkernel/intern/lib_override.c
index bcefcd5f001..d82315a0e7f 100644
--- a/source/blender/blenkernel/intern/lib_override.c
+++ b/source/blender/blenkernel/intern/lib_override.c
@@ -551,6 +551,10 @@ static void lib_override_library_create_post_process(
   if (ob_reference != NULL) {
 BKE_collection_add_from_object(bmain, scene, ob_reference, 
collection_new);
   }
+  else if (id_reference != NULL) {
+BKE_collection_add_from_collection(
+bmain, scene, ((Collection *)id_reference), collection_new);
+  }
   else {
 BKE_collection_add_from_collection(bmain, scene, ((Collection 
*)id_root), collection_new);
   }
@@ -841,6 +845,10 @@ bool BKE_lib_override_library_resync(Main *bmain, Scene 
*scene, ViewLayer *view_
   id_root = id_root_reference->newid;
 
   /* Essentially ensures that potentially new overrides of new objects will be 
instantiated. */
+  /* Note: Here 'reference' collection and 'newly added' collection are the 
same, which is fine
+   * since we already relinked old root override collection to new resync'ed 
one above. So this
+   * call is not expected to instantiate this new resync'ed collection 
anywhere, just to ensure
+   * that we do not have any stray objects. */
   lib_override_library_create_post_process(bmain, scene, view_layer, 
id_root_reference, id_root);
 
   /* Cleanup. */

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


[Bf-blender-cvs] [a7cf6ad5471] master: Fix (unreported) broken logic in `BKE_collection_add_from_collection`.

2020-11-30 Thread Bastien Montagne
Commit: a7cf6ad5471e4109d60d99c49b58d7257c95e392
Author: Bastien Montagne
Date:   Mon Nov 30 17:16:11 2020 +0100
Branches: master
https://developer.blender.org/rBa7cf6ad5471e4109d60d99c49b58d7257c95e392

Fix (unreported) broken logic in `BKE_collection_add_from_collection`.

That function was adding given new collection to all ancestors of the
reference one, instead of only to its immediate parents.

===

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

===

diff --git a/source/blender/blenkernel/intern/collection.c 
b/source/blender/blenkernel/intern/collection.c
index ab92480cce2..5eec788255d 100644
--- a/source/blender/blenkernel/intern/collection.c
+++ b/source/blender/blenkernel/intern/collection.c
@@ -452,7 +452,7 @@ void BKE_collection_add_from_collection(Main *bmain,
   bool is_instantiated = false;
 
   FOREACH_SCENE_COLLECTION_BEGIN (scene, collection) {
-if (!ID_IS_LINKED(collection) && BKE_collection_has_collection(collection, 
collection_src)) {
+if (!ID_IS_LINKED(collection) && collection_find_child(collection, 
collection_src)) {
   collection_child_add(collection, collection_dst, 0, true);
   is_instantiated = true;
 }

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


[Bf-blender-cvs] [c760ab0ddad] master: Cleanup: Graph Editor, refactor selection operators

2020-11-30 Thread Maxime Casas
Commit: c760ab0ddade365914196ce2703edad110b38cfd
Author: Maxime Casas
Date:   Mon Nov 30 16:35:42 2020 +0100
Branches: master
https://developer.blender.org/rBc760ab0ddade365914196ce2703edad110b38cfd

Cleanup: Graph Editor, refactor selection operators

Extract initialisation code of box selection into separate functions.

No functional changes.

Reviewed By: zeddb, sybren

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

===

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

===

diff --git a/source/blender/editors/space_graph/graph_select.c 
b/source/blender/editors/space_graph/graph_select.c
index 13f2219d7af..007f99e3ce5 100644
--- a/source/blender/editors/space_graph/graph_select.c
+++ b/source/blender/editors/space_graph/graph_select.c
@@ -501,84 +501,113 @@ void GRAPH_OT_select_all(wmOperatorType *ot)
  * The selection backend is also reused for the Lasso and Circle select 
operators.
  */
 
-/* Box Select only selects keyframes now, as overshooting handles often get 
caught too,
- * which means that they may be inadvertently moved as well. However, 
incl_handles overrides
- * this, and allow handles to be considered independently too.
- * Also, for convenience, handles should get same status as keyframe (if it 
was within bounds).
- */
-static void box_select_graphkeys(bAnimContext *ac,
- const rctf *rectf_view,
- short mode,
- short selectmode,
- bool incl_handles,
- void *data)
-{
-  ListBase anim_data = {NULL, NULL};
-  bAnimListElem *ale;
-  int filter, mapping_flag;
 
-  SpaceGraph *sipo = (SpaceGraph *)ac->sl;
-  KeyframeEditData ked;
-  KeyframeEditFunc ok_cb, select_cb;
-  View2D *v2d = >region->v2d;
-  rctf rectf, scaled_rectf;
+static rctf initialize_box_select_coords(const bAnimContext *ac, const rctf 
*rectf_view)
+{
+  const View2D *v2d = >region->v2d;
+  rctf rectf;
 
   /* Convert mouse coordinates to frame ranges and
* channel coordinates corrected for view pan/zoom. */
   UI_view2d_region_to_view_rctf(v2d, rectf_view, );
+  return rectf;
+}
 
-  /* filter data */
-  filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | 
ANIMFILTER_NODUPLIS);
+static ListBase initialize_box_select_anim_data(const SpaceGraph *sipo, 
bAnimContext *ac)
+{
+  ListBase anim_data = {NULL, NULL};
+
+  int filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | 
ANIMFILTER_NODUPLIS);
   if (sipo->flag & SIPO_SELCUVERTSONLY) {
 filter |= ANIMFILTER_FOREDIT | ANIMFILTER_SELEDIT;
   }
   ANIM_animdata_filter(ac, _data, filter, ac->data, ac->datatype);
 
-  /* get beztriple editing/validation funcs  */
-  select_cb = ANIM_editkeyframes_select(selectmode);
-  ok_cb = ANIM_editkeyframes_ok(mode);
+  return anim_data;
+}
 
-  /* init editing data */
-  memset(, 0, sizeof(KeyframeEditData));
-  if (mode == BEZT_OK_REGION_LASSO) {
-KeyframeEdit_LassoData *data_lasso = data;
-data_lasso->rectf_scaled = _rectf;
-ked.data = data_lasso;
-  }
-  else if (mode == BEZT_OK_REGION_CIRCLE) {
-KeyframeEdit_CircleData *data_circle = data;
-data_circle->rectf_scaled = _rectf;
-ked.data = data;
-  }
-  else {
-ked.data = _rectf;
+static void initialize_box_select_key_editing_data(const SpaceGraph *sipo,
+   const bool incl_handles,
+   const short mode,
+   bAnimContext *ac,
+   void *data,
+   rctf *scaled_rectf,
+   KeyframeEditData *r_ked,
+   int *r_mapping_flag)
+{
+  memset(r_ked, 0, sizeof(KeyframeEditData));
+  switch (mode) {
+case BEZT_OK_REGION_LASSO: {
+  KeyframeEdit_LassoData *data_lasso = data;
+  data_lasso->rectf_scaled = scaled_rectf;
+  r_ked->data = data_lasso;
+  break;
+}
+case BEZT_OK_REGION_CIRCLE: {
+  KeyframeEdit_CircleData *data_circle = data;
+  data_circle->rectf_scaled = scaled_rectf;
+  r_ked->data = data_circle;
+  break;
+}
+default:
+  r_ked->data = scaled_rectf;
+  break;
   }
 
   if (sipo->flag & SIPO_SELVHANDLESONLY) {
-ked.iterflags |= KEYFRAME_ITER_HANDLES_DEFAULT_INVISIBLE;
+r_ked->iterflags |= KEYFRAME_ITER_HANDLES_DEFAULT_INVISIBLE;
   }
 
-  /* treat handles separately? */
+  /* Enable handles selection. (used in keyframes_edit.c > KEYFRAME_OK_CHECKS 
macro) */
   if (incl_handles) {
-ked.iterflags |= KEYFRAME_ITER_INCL_HANDLES;
-mapping_flag = 0;
+r_ked->iterflags |= KEYFRAME_ITER_INCL_HANDLES;
+*r_mapping_flag = 0;
   

[Bf-blender-cvs] [1ecc2b305d7] geometry-nodes: Cleanup: add a comment

2020-11-30 Thread Jacques Lucke
Commit: 1ecc2b305d7dfc78c393f02e8dee075023e16e00
Author: Jacques Lucke
Date:   Mon Nov 30 16:43:08 2020 +0100
Branches: geometry-nodes
https://developer.blender.org/rB1ecc2b305d7dfc78c393f02e8dee075023e16e00

Cleanup: add a comment

===

M   source/blender/nodes/NOD_geometry_exec.hh

===

diff --git a/source/blender/nodes/NOD_geometry_exec.hh 
b/source/blender/nodes/NOD_geometry_exec.hh
index 086ce76c851..2b95f76d06b 100644
--- a/source/blender/nodes/NOD_geometry_exec.hh
+++ b/source/blender/nodes/NOD_geometry_exec.hh
@@ -147,6 +147,7 @@ class GeoNodeExecParams {
   }
 
  private:
+  /* Utilities for detecting common errors at when using this class. */
   void check_extract_input(StringRef identifier, const CPPType *requested_type 
= nullptr) const;
   void check_set_output(StringRef identifier, const CPPType _type) const;
 };

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


[Bf-blender-cvs] [f7d9ec6a40d] geometry-nodes: Merge branch 'master' into geometry-nodes

2020-11-30 Thread Jacques Lucke
Commit: f7d9ec6a40d8595d66e7a76d3d8d9ee8adfa0f71
Author: Jacques Lucke
Date:   Mon Nov 30 16:34:16 2020 +0100
Branches: geometry-nodes
https://developer.blender.org/rBf7d9ec6a40d8595d66e7a76d3d8d9ee8adfa0f71

Merge branch 'master' into geometry-nodes

===



===



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


[Bf-blender-cvs] [7c4c6809b9c] geometry-nodes: Cleanup: correct function name

2020-11-30 Thread Jacques Lucke
Commit: 7c4c6809b9c26e625a575cfa6e37667bedb7429c
Author: Jacques Lucke
Date:   Mon Nov 30 16:33:15 2020 +0100
Branches: geometry-nodes
https://developer.blender.org/rB7c4c6809b9c26e625a575cfa6e37667bedb7429c

Cleanup: correct function name

===

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

===

diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_math.cc 
b/source/blender/nodes/geometry/nodes/node_geo_attribute_math.cc
index d8a7e5df43c..5e2830d2f4e 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_attribute_math.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_math.cc
@@ -49,7 +49,7 @@ static void geo_node_attribute_math_init(bNodeTree 
*UNUSED(tree), bNode *node)
   node->custom2 = GEO_NODE_USE_ATTRIBUTE_A | GEO_NODE_USE_ATTRIBUTE_B;
 }
 
-static void geo_node_random_attribute_update(bNodeTree *UNUSED(ntree), bNode 
*node)
+static void geo_node_attribute_math_update(bNodeTree *UNUSED(ntree), bNode 
*node)
 {
   bNodeSocket *sock_attribute_a = (bNodeSocket *)BLI_findlink(>inputs, 
1);
   bNodeSocket *sock_float_a = sock_attribute_a->next;
@@ -161,7 +161,7 @@ void register_node_type_geo_attribute_math()
   geo_node_type_base(, GEO_NODE_ATTRIBUTE_MATH, "Attribute Math", 0, 0);
   node_type_socket_templates(, geo_node_attribute_math_in, 
geo_node_attribute_math_out);
   ntype.geometry_node_execute = blender::nodes::geo_node_attribute_math_exec;
-  node_type_update(, geo_node_random_attribute_update);
+  node_type_update(, geo_node_attribute_math_update);
   node_type_init(, geo_node_attribute_math_init);
   nodeRegisterType();
 }

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


[Bf-blender-cvs] [13ce25d24c9] master: Tracking: Clarify tracks and options storage once again

2020-11-30 Thread Sergey Sharybin
Commit: 13ce25d24c9d667282784f34fd5e5e875b350c91
Author: Sergey Sharybin
Date:   Mon Nov 30 16:14:06 2020 +0100
Branches: master
https://developer.blender.org/rB13ce25d24c9d667282784f34fd5e5e875b350c91

Tracking: Clarify tracks and options storage once again

This is something not-so-trivial to see from just reading code, which
shown an important of proper comments and clear naming.

Main source of confusion was that it is not immediately clear that
AutoTrack context is to see all tracks, but tracking to only operate on
selected ones.

===

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

===

diff --git a/source/blender/blenkernel/intern/tracking_auto.c 
b/source/blender/blenkernel/intern/tracking_auto.c
index d49d6779d64..edd798b162a 100644
--- a/source/blender/blenkernel/intern/tracking_auto.c
+++ b/source/blender/blenkernel/intern/tracking_auto.c
@@ -76,19 +76,13 @@ typedef struct AutoTrackContext {
   MovieClip *clips[MAX_ACCESSOR_CLIP];
 
   /* Tracks for which the context has been created for.
-   * Most usually this is all track selected in the interface when tracking in 
initialized.
-   *
-   * NOTE: Actually being-tracked tracks is a subset of those, as the tracker 
might loose track of
-   * where markers are. For example, if feature gets occluded, corresponding 
marker can not be
-   * tracked, and hence track is considered finished.
-   *
-   * The need of knowledge of all tracks which might potentially be modified 
during tracking comes
-   * form plane tracks: plane tracks needs adjustment if any of their tracks 
changed during
-   * tracking.
+   * This is a flat array of all tracks coming from all clips, regardless of 
whether track is
+   * actually being tracked or not. This allows the AutoTrack to see a big 
picture of hat is going
+   * on in the scene, and request information it needs.
*
* Indexed by AutoTrackOptions::track_index. */
-  int num_input_tracks;
-  MovieTrackingTrack **input_tracks;
+  int num_all_tracks;
+  MovieTrackingTrack **all_tracks;
 
   /* Dimensions of movie frame, in pixels.
*
@@ -107,6 +101,7 @@ typedef struct AutoTrackContext {
* NOTE: Is accessed from multiple threads at once. */
   struct libmv_AutoTrack *autotrack;
 
+  int num_track_options;
   AutoTrackOptions *track_options; /* Per-tracking track options. */
 
   int sync_frame;
@@ -340,15 +335,17 @@ static void create_per_track_tracking_options(const 
MovieClip *clip,
   /* Count number of trackable tracks. */
   LISTBASE_FOREACH (MovieTrackingTrack *, track, tracksbase) {
 if (check_track_trackable(clip, track, user)) {
-  context->num_input_tracks++;
+  context->num_track_options++;
 }
   }
   /* Allocate required memory. */
-  context->track_options = MEM_callocN(sizeof(AutoTrackOptions) * 
context->num_input_tracks,
+  context->track_options = MEM_callocN(sizeof(AutoTrackOptions) * 
context->num_track_options,
"auto track options");
   /* Fill in all the settings. */
   int i = 0, track_index = 0;
   LISTBASE_FOREACH (MovieTrackingTrack *, track, tracksbase) {
+context->all_tracks[track_index] = track;
+
 if (!check_track_trackable(clip, track, user)) {
   track_index++;
   continue;
@@ -364,7 +361,6 @@ static void create_per_track_tracking_options(const 
MovieClip *clip,
 
 tracking_configure_tracker(track, NULL, 
_options->track_region_options);
 
-context->input_tracks[track_index] = track;
 track_index++;
   }
 }
@@ -390,19 +386,19 @@ AutoTrackContext *BKE_autotrack_context_new(MovieClip 
*clip,
   context->sync_frame = user->framenr;
   context->first_sync = true;
   BLI_spin_init(>spin_lock);
-  const int num_total_tracks = BLI_listbase_count(tracksbase);
-  context->input_tracks = MEM_callocN(sizeof(MovieTrackingTrack *) * 
num_total_tracks,
-  "auto track pointers");
+  context->num_all_tracks = BLI_listbase_count(tracksbase);
+  context->all_tracks = MEM_callocN(sizeof(MovieTrackingTrack *) * 
context->num_all_tracks,
+"auto track pointers");
+  /* Create per-track tracking options. */
+  create_per_track_tracking_options(clip, user, tracksbase, context);
   /* Initialize image accessor. */
   context->image_accessor = tracking_image_accessor_new(
-  context->clips, 1, context->input_tracks, num_total_tracks);
+  context->clips, 1, context->all_tracks, context->num_all_tracks);
   /* Initialize auto track context and provide all information about currently
* tracked markers.
*/
   context->autotrack = 
libmv_autoTrackNew(context->image_accessor->libmv_accessor);
   fill_autotrack_tracks(frame_width, frame_height, tracksbase, is_backwards, 
context->autotrack);
-  /* Create per-track tracking options. */
-  create_per_track_tracking_options(clip, user, tracksbase, 

[Bf-blender-cvs] [0f30edc20c6] master: Tracking: Make image accessor own what it needs

2020-11-30 Thread Sergey Sharybin
Commit: 0f30edc20c6206b40216b162fa435d23562127f8
Author: Sergey Sharybin
Date:   Mon Nov 30 15:55:52 2020 +0100
Branches: master
https://developer.blender.org/rB0f30edc20c6206b40216b162fa435d23562127f8

Tracking: Make image accessor own what it needs

Previously image accessor was sharing array pointer for tracks access.
Now it is possible to pass a temporary array valid only during the
initialization process.

Should be no functional changes.

===

M   source/blender/blenkernel/intern/tracking_util.c
M   source/blender/blenkernel/tracking_private.h

===

diff --git a/source/blender/blenkernel/intern/tracking_util.c 
b/source/blender/blenkernel/intern/tracking_util.c
index 7146be1d521..eb57c28de09 100644
--- a/source/blender/blenkernel/intern/tracking_util.c
+++ b/source/blender/blenkernel/intern/tracking_util.c
@@ -1021,7 +1021,10 @@ TrackingImageAccessor 
*tracking_image_accessor_new(MovieClip *clips[MAX_ACCESSOR
 
   memcpy(accessor->clips, clips, num_clips * sizeof(MovieClip *));
   accessor->num_clips = num_clips;
-  accessor->tracks = tracks;
+
+  accessor->tracks = MEM_malloc_arrayN(
+  num_tracks, sizeof(MovieTrackingTrack *), "image accessor tracks");
+  memcpy(accessor->tracks, tracks, num_tracks * sizeof(MovieTrackingTrack *));
   accessor->num_tracks = num_tracks;
 
   accessor->libmv_accessor = 
libmv_FrameAccessorNew((libmv_FrameAccessorUserData *)accessor,
@@ -1040,5 +1043,6 @@ void 
tracking_image_accessor_destroy(TrackingImageAccessor *accessor)
   IMB_moviecache_free(accessor->cache);
   libmv_FrameAccessorDestroy(accessor->libmv_accessor);
   BLI_spin_end(>cache_lock);
+  MEM_freeN(accessor->tracks);
   MEM_freeN(accessor);
 }
diff --git a/source/blender/blenkernel/tracking_private.h 
b/source/blender/blenkernel/tracking_private.h
index 5bd4baa536d..64db84d5ac3 100644
--- a/source/blender/blenkernel/tracking_private.h
+++ b/source/blender/blenkernel/tracking_private.h
@@ -132,14 +132,25 @@ struct libmv_FrameAccessor;
 #define MAX_ACCESSOR_CLIP 64
 typedef struct TrackingImageAccessor {
   struct MovieCache *cache;
+
   struct MovieClip *clips[MAX_ACCESSOR_CLIP];
   int num_clips;
+
+  /* Array of tracks which are being tracked.
+   * Points to actual track from the `MovieClip` (or multiple of them).
+   * This accessor owns the array, but not the tracks themselves. */
   struct MovieTrackingTrack **tracks;
   int num_tracks;
+
   struct libmv_FrameAccessor *libmv_accessor;
   SpinLock cache_lock;
 } TrackingImageAccessor;
 
+/* Clips are used to access images of an actual footage.
+ * Tracks are used to access masks associated with the tracks.
+ *
+ * NOTE: Both clips and tracks arrays are copied into the image accessor. It 
means that the caller
+ * is allowed to pass temporary arrays which are only valid during 
initialization. */
 TrackingImageAccessor *tracking_image_accessor_new(MovieClip 
*clips[MAX_ACCESSOR_CLIP],
int num_clips,
MovieTrackingTrack **tracks,

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


[Bf-blender-cvs] [69f4088ba1f] geometry-nodes: Geometry Nodes: Change modifier name

2020-11-30 Thread Hans Goudey
Commit: 69f4088ba1f598394d4d599f996772a7b183aad7
Author: Hans Goudey
Date:   Mon Nov 30 10:23:57 2020 -0500
Branches: geometry-nodes
https://developer.blender.org/rB69f4088ba1f598394d4d599f996772a7b183aad7

Geometry Nodes: Change modifier name

The modifier was called "Empty", which reflects the fact that the modifier
doesn't do anything when you add it. However, that is not true after you
change the modifier's node group, and the fact that the modifier uses
nodes is the one thing that distinguishes it at this point. This commit
changes the name to "Geometry Nodes", which is simple and consistent
with the "Geometry Node Editor" and the naming of the project so far.

===

M   source/blender/makesrna/intern/rna_modifier.c
M   source/blender/modifiers/intern/MOD_nodes.cc

===

diff --git a/source/blender/makesrna/intern/rna_modifier.c 
b/source/blender/makesrna/intern/rna_modifier.c
index b84859543b7..fb2692910c5 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -143,7 +143,7 @@ const EnumPropertyItem 
rna_enum_object_modifier_type_items[] = {
  ICON_MOD_EDGESPLIT,
  "Edge Split",
  "Split away joined faces at the edges"},
-{eModifierType_Nodes, "NODES", ICON_NODETREE, "Empty", ""},
+{eModifierType_Nodes, "NODES", ICON_NODETREE, "Geometry Nodes", ""},
 {eModifierType_Mask,
  "MASK",
  ICON_MOD_MASK,
diff --git a/source/blender/modifiers/intern/MOD_nodes.cc 
b/source/blender/modifiers/intern/MOD_nodes.cc
index f9f523ce2d4..fd8084d933c 100644
--- a/source/blender/modifiers/intern/MOD_nodes.cc
+++ b/source/blender/modifiers/intern/MOD_nodes.cc
@@ -1044,7 +1044,7 @@ static void freeData(ModifierData *md)
 }
 
 ModifierTypeInfo modifierType_Nodes = {
-/* name */ "Empty",
+/* name */ "GeometryNodes",
 /* structName */ "NodesModifierData",
 /* structSize */ sizeof(NodesModifierData),
 /* srna */ _NodesModifier,

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


[Bf-blender-cvs] [83c872085dc] master: Windows/Ninja: allow parameters for rebuild.cmd

2020-11-30 Thread Ray Molenkamp
Commit: 83c872085dc399f0f9e80bb2926f48f313d3b358
Author: Ray Molenkamp
Date:   Mon Nov 30 08:22:50 2020 -0700
Branches: master
https://developer.blender.org/rB83c872085dc399f0f9e80bb2926f48f313d3b358

Windows/Ninja: allow parameters for rebuild.cmd

The windows build leaves a convenience helper script
in the build folder called, rebuild.cmd. This change
passes any parameters you give rebuild.cmd to ninja
so you can easily pass it additional parameters without
having to edit the batch file manually.

===

M   build_files/windows/configure_ninja.cmd

===

diff --git a/build_files/windows/configure_ninja.cmd 
b/build_files/windows/configure_ninja.cmd
index 20692847bef..d68d94a3bcf 100644
--- a/build_files/windows/configure_ninja.cmd
+++ b/build_files/windows/configure_ninja.cmd
@@ -92,5 +92,5 @@ echo if "%%VSCMD_VER%%" == "" ^( >> %BUILD_DIR%\rebuild.cmd
 echo   call "%VCVARS%" %BUILD_ARCH% >> %BUILD_DIR%\rebuild.cmd
 echo ^) >> %BUILD_DIR%\rebuild.cmd
 echo echo %%TIME%% ^> buildtime.txt >> %BUILD_DIR%\rebuild.cmd
-echo ninja install >> %BUILD_DIR%\rebuild.cmd 
+echo ninja install %%* >> %BUILD_DIR%\rebuild.cmd
 echo echo %%TIME%% ^>^> buildtime.txt >> %BUILD_DIR%\rebuild.cmd
\ No newline at end of file

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


[Bf-blender-cvs] [9081b80d15b] master: GPencil: New operator to reset Vertex Colors

2020-11-30 Thread Antonio Vazquez
Commit: 9081b80d15b3446f80ef76d10287de7d1281bd74
Author: Antonio Vazquez
Date:   Wed Nov 25 17:04:22 2020 +0100
Branches: master
https://developer.blender.org/rB9081b80d15b3446f80ef76d10287de7d1281bd74

GPencil: New operator to reset Vertex Colors

This operators reset the vertex color information of the strokes.

If nothing is selected, all strokes are reset. If any is selected, only 
selected strokes are reset.

Also added a new menu Paint in Vertex Color mode.

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

===

M   release/scripts/startup/bl_ui/space_view3d.py
M   source/blender/editors/gpencil/gpencil_edit.c
M   source/blender/editors/gpencil/gpencil_intern.h
M   source/blender/editors/gpencil/gpencil_ops.c

===

diff --git a/release/scripts/startup/bl_ui/space_view3d.py 
b/release/scripts/startup/bl_ui/space_view3d.py
index e0c28983544..07a7d815c53 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -870,13 +870,15 @@ class VIEW3D_MT_editor_menus(Menu):
 
 if gp_edit:
 if obj and obj.mode == 'PAINT_GPENCIL':
-layout.menu("VIEW3D_MT_paint_gpencil")
+layout.menu("VIEW3D_MT_draw_gpencil")
 elif obj and obj.mode == 'EDIT_GPENCIL':
 layout.menu("VIEW3D_MT_edit_gpencil")
 layout.menu("VIEW3D_MT_edit_gpencil_stroke")
 layout.menu("VIEW3D_MT_edit_gpencil_point")
 elif obj and obj.mode == 'WEIGHT_GPENCIL':
 layout.menu("VIEW3D_MT_weight_gpencil")
+if obj and obj.mode == 'VERTEX_GPENCIL':
+layout.menu("VIEW3D_MT_paint_gpencil")
 
 elif edit_object:
 layout.menu("VIEW3D_MT_edit_%s" % edit_object.type.lower())
@@ -1820,6 +1822,15 @@ class VIEW3D_MT_select_edit_armature(Menu):
 layout.operator("object.select_pattern", text="Select Pattern...")
 
 
+class VIEW3D_MT_paint_gpencil(Menu):
+bl_label = "Paint"
+
+def draw(self, context):
+layout = self.layout
+
+layout.operator("gpencil.stroke_reset_vertex_color")
+
+
 class VIEW3D_MT_select_gpencil(Menu):
 bl_label = "Select"
 
@@ -4853,7 +4864,7 @@ class VIEW3D_MT_gpencil_simplify(Menu):
 layout.operator("gpencil.stroke_sample", text="Sample")
 
 
-class VIEW3D_MT_paint_gpencil(Menu):
+class VIEW3D_MT_draw_gpencil(Menu):
 bl_label = "Draw"
 
 def draw(self, _context):
@@ -7588,6 +7599,7 @@ classes = (
 VIEW3D_MT_edit_mesh_split,
 VIEW3D_MT_edit_mesh_showhide,
 VIEW3D_MT_paint_gpencil,
+VIEW3D_MT_draw_gpencil,
 VIEW3D_MT_assign_material,
 VIEW3D_MT_edit_gpencil,
 VIEW3D_MT_edit_gpencil_stroke,
diff --git a/source/blender/editors/gpencil/gpencil_edit.c 
b/source/blender/editors/gpencil/gpencil_edit.c
index 8ce3d176525..15162f491d5 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -5205,5 +5205,159 @@ void GPENCIL_OT_stroke_merge_by_distance(wmOperatorType 
*ot)
   ot->srna, "use_unselected", 0, "Unselected", "Use whole stroke, not only 
selected points");
   RNA_def_property_flag(prop, PROP_SKIP_SAVE);
 }
+/** \} */
+
+/*  */
+/** \name Reset Stroke Vertex Color Operator
+ * \{ */
+
+static void gpencil_reset_vertex(bGPDstroke *gps, eGp_Vertex_Mode mode)
+{
+  if (mode != GPPAINT_MODE_STROKE) {
+zero_v4(gps->vert_color_fill);
+  }
+
+  if (mode != GPPAINT_MODE_FILL) {
+bGPDspoint *pt;
+for (int i = 0; i < gps->totpoints; i++) {
+  pt = >points[i];
+  zero_v4(pt->vert_color);
+}
+  }
+}
+
+static int gpencil_stroke_reset_vertex_color_exec(bContext *C, wmOperator *op)
+{
+  Object *obact = CTX_data_active_object(C);
+  bGPdata *gpd = (bGPdata *)obact->data;
+  const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd);
+  const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd);
+  bGPDstroke *gps = NULL;
+
+  if (gpd == NULL) {
+BKE_report(op->reports, RPT_ERROR, "No Grease Pencil data");
+return OPERATOR_CANCELLED;
+  }
+  eGp_Vertex_Mode mode = RNA_enum_get(op->ptr, "mode");
+
+  /* First need to check if there are something selected. If not, apply to all 
strokes. */
+  bool all_strokes = true;
+  CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) {
+bGPDframe *init_gpf = (is_multiedit) ? gpl->frames.first : gpl->actframe;
+for (bGPDframe *gpf = init_gpf; gpf; gpf = gpf->next) {
+  if ((gpf == gpl->actframe) || ((gpf->flag & GP_FRAME_SELECT) && 
(is_multiedit))) {
+if (gpf == NULL) {
+  continue;
+}
+for (gps = gpf->strokes.first; gps; gps = gps->next) {
+  /* skip strokes that are invalid for current view */
+  if 

[Bf-blender-cvs] [ba3bf822a1e] master: Tracking: Cleanup, remove unused field

2020-11-30 Thread Sergey Sharybin
Commit: ba3bf822a1edb10cec02a36a79170902a86a2eef
Author: Sergey Sharybin
Date:   Mon Nov 30 15:44:42 2020 +0100
Branches: master
https://developer.blender.org/rBba3bf822a1edb10cec02a36a79170902a86a2eef

Tracking: Cleanup, remove unused field

Was re-introduced after previous round of cleanups when was merging
refactor and master branches.

===

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

===

diff --git a/source/blender/blenkernel/intern/tracking_auto.c 
b/source/blender/blenkernel/intern/tracking_auto.c
index 2027d4b2dd1..0bbfa4d6d8e 100644
--- a/source/blender/blenkernel/intern/tracking_auto.c
+++ b/source/blender/blenkernel/intern/tracking_auto.c
@@ -71,9 +71,6 @@ typedef struct AutoTrackContext {
   /* True when tracking backwards (from higher frame number to lower frame 
number.) */
   bool is_backwards;
 
-  /* True when entire sequence is being tracked. */
-  bool is_sequence;
-
   /* Movie clips used during the trackign process. */
   int num_clips;
   MovieClip *clips[MAX_ACCESSOR_CLIP];

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


[Bf-blender-cvs] [f280300b6ac] master: Tracking: Cleanup, remove unused argument from image accessor

2020-11-30 Thread Sergey Sharybin
Commit: f280300b6ac9a6cacfc91bee79ac7a10bd048d39
Author: Sergey Sharybin
Date:   Mon Nov 30 15:50:21 2020 +0100
Branches: master
https://developer.blender.org/rBf280300b6ac9a6cacfc91bee79ac7a10bd048d39

Tracking: Cleanup, remove unused argument from image accessor

===

M   source/blender/blenkernel/intern/tracking_auto.c
M   source/blender/blenkernel/intern/tracking_util.c
M   source/blender/blenkernel/tracking_private.h

===

diff --git a/source/blender/blenkernel/intern/tracking_auto.c 
b/source/blender/blenkernel/intern/tracking_auto.c
index 0bbfa4d6d8e..d49d6779d64 100644
--- a/source/blender/blenkernel/intern/tracking_auto.c
+++ b/source/blender/blenkernel/intern/tracking_auto.c
@@ -395,7 +395,7 @@ AutoTrackContext *BKE_autotrack_context_new(MovieClip *clip,
   "auto track pointers");
   /* Initialize image accessor. */
   context->image_accessor = tracking_image_accessor_new(
-  context->clips, 1, context->input_tracks, num_total_tracks, 
user->framenr);
+  context->clips, 1, context->input_tracks, num_total_tracks);
   /* Initialize auto track context and provide all information about currently
* tracked markers.
*/
diff --git a/source/blender/blenkernel/intern/tracking_util.c 
b/source/blender/blenkernel/intern/tracking_util.c
index c7e4e0d5c08..7146be1d521 100644
--- a/source/blender/blenkernel/intern/tracking_util.c
+++ b/source/blender/blenkernel/intern/tracking_util.c
@@ -1009,8 +1009,7 @@ static void accessor_release_mask_callback(libmv_CacheKey 
cache_key)
 TrackingImageAccessor *tracking_image_accessor_new(MovieClip 
*clips[MAX_ACCESSOR_CLIP],
int num_clips,
MovieTrackingTrack **tracks,
-   int num_tracks,
-   int start_frame)
+   int num_tracks)
 {
   TrackingImageAccessor *accessor = MEM_callocN(sizeof(TrackingImageAccessor),
 "tracking image accessor");
@@ -1024,7 +1023,6 @@ TrackingImageAccessor 
*tracking_image_accessor_new(MovieClip *clips[MAX_ACCESSOR
   accessor->num_clips = num_clips;
   accessor->tracks = tracks;
   accessor->num_tracks = num_tracks;
-  accessor->start_frame = start_frame;
 
   accessor->libmv_accessor = 
libmv_FrameAccessorNew((libmv_FrameAccessorUserData *)accessor,
 
accessor_get_image_callback,
diff --git a/source/blender/blenkernel/tracking_private.h 
b/source/blender/blenkernel/tracking_private.h
index 0965cef0d9b..5bd4baa536d 100644
--- a/source/blender/blenkernel/tracking_private.h
+++ b/source/blender/blenkernel/tracking_private.h
@@ -136,7 +136,6 @@ typedef struct TrackingImageAccessor {
   int num_clips;
   struct MovieTrackingTrack **tracks;
   int num_tracks;
-  int start_frame;
   struct libmv_FrameAccessor *libmv_accessor;
   SpinLock cache_lock;
 } TrackingImageAccessor;
@@ -144,8 +143,7 @@ typedef struct TrackingImageAccessor {
 TrackingImageAccessor *tracking_image_accessor_new(MovieClip 
*clips[MAX_ACCESSOR_CLIP],
int num_clips,
MovieTrackingTrack **tracks,
-   int num_tracks,
-   int start_frame);
+   int num_tracks);
 void tracking_image_accessor_destroy(TrackingImageAccessor *accessor);
 
 #ifdef __cplusplus

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


[Bf-blender-cvs] [ecfacb77061] master: Tracking: Cleanup, use explicit frame match option

2020-11-30 Thread Sergey Sharybin
Commit: ecfacb77061a330dddb5794242607709e06843bc
Author: Sergey Sharybin
Date:   Mon Nov 30 15:03:31 2020 +0100
Branches: master
https://developer.blender.org/rBecfacb77061a330dddb5794242607709e06843bc

Tracking: Cleanup, use explicit frame match option

No functional changes, just allows to potentially extend the options
in the future, and also makes code more explicit.

===

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

===

diff --git a/source/blender/blenkernel/intern/tracking_auto.c 
b/source/blender/blenkernel/intern/tracking_auto.c
index faa1f207788..2027d4b2dd1 100644
--- a/source/blender/blenkernel/intern/tracking_auto.c
+++ b/source/blender/blenkernel/intern/tracking_auto.c
@@ -46,7 +46,9 @@ typedef struct AutoTrackOptions {
   int track_index;   /* Index of the track in AutoTrack tracks 
structure. */
   MovieTrackingTrack *track; /* Pointer to an original track/ */
   libmv_TrackRegionOptions track_region_options; /* Options for the region 
tracker. */
-  bool use_keyframe_match;   /* Keyframe pattern matching. 
*/
+
+  /* Define which frame is used for reference marker. */
+  eTrackFrameMatch frame_match;
 
   /* TODO(sergey): A bit awkward to keep it in here, only used to
* place a disabled marker once the tracking fails,
@@ -361,7 +363,7 @@ static void create_per_track_tracking_options(const 
MovieClip *clip,
 track_options->clip_index = 0;
 track_options->track_index = track_index;
 track_options->track = track;
-track_options->use_keyframe_match = (track->pattern_match == 
TRACK_MATCH_KEYFRAME);
+track_options->frame_match = track->pattern_match;
 
 tracking_configure_tracker(track, NULL, 
_options->track_region_options);
 
@@ -445,7 +447,7 @@ static void autotrack_context_step_cb(void *__restrict 
userdata,
   libmv_tracked_marker = libmv_current_marker;
   libmv_tracked_marker.frame = frame + frame_delta;
   /* Update reference frame. */
-  if (track_options->use_keyframe_match) {
+  if (track_options->frame_match == TRACK_MATCH_KEYFRAME) {
 libmv_tracked_marker.reference_frame = 
libmv_current_marker.reference_frame;
 libmv_autoTrackGetMarker(context->autotrack,
  track_options->clip_index,
@@ -454,6 +456,7 @@ static void autotrack_context_step_cb(void *__restrict 
userdata,
  _reference_marker);
   }
   else {
+BLI_assert(track_options->frame_match == TRACK_MATCH_PREVIOS_FRAME);
 libmv_tracked_marker.reference_frame = frame;
 libmv_reference_marker = libmv_current_marker;
   }

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


[Bf-blender-cvs] [c949062c6ee] master: Tracking: Cleanup pattern match DNA definition

2020-11-30 Thread Sergey Sharybin
Commit: c949062c6eeedf7c6b0fb3029217effd301575c5
Author: Sergey Sharybin
Date:   Mon Nov 30 14:56:47 2020 +0100
Branches: master
https://developer.blender.org/rBc949062c6eeedf7c6b0fb3029217effd301575c5

Tracking: Cleanup pattern match DNA definition

Wrong comment was used for enumerator.

Also made it a real typed enumerator to ease use in the implementation
code.

Should be no functional changes.

===

M   source/blender/makesdna/DNA_tracking_types.h
M   source/blender/makesrna/intern/rna_tracking.c

===

diff --git a/source/blender/makesdna/DNA_tracking_types.h 
b/source/blender/makesdna/DNA_tracking_types.h
index 8ec9a260e18..5b6b706c83c 100644
--- a/source/blender/makesdna/DNA_tracking_types.h
+++ b/source/blender/makesdna/DNA_tracking_types.h
@@ -165,7 +165,8 @@ typedef struct MovieTrackingTrack {
   short frames_limit;
   /** Margin from frame boundaries. */
   short margin;
-  /** Re-adjust every N frames. */
+  /** Denotes which frame is used for the reference during tracking.
+   * An enumerator of `eTrackFrameMatch`. */
   short pattern_match;
 
   /* tracking parameters */
@@ -268,7 +269,8 @@ typedef struct MovieTrackingSettings {
   short default_frames_limit;
   /** Margin from frame boundaries. */
   short default_margin;
-  /** Re-adjust every N frames. */
+  /** Denotes which frame is used for the reference during tracking.
+   * An enumerator of `eTrackFrameMatch`. */
   short default_pattern_match;
   /** Default flags like color channels used by default. */
   short default_flag;
@@ -518,11 +520,11 @@ enum {
   TRACK_ALGORITHM_FLAG_USE_MASK = (1 << 3),
 };
 
-/* MovieTrackingTrack->adjframes */
-enum {
+/* MovieTrackingTrack->pattern_match */
+typedef enum eTrackFrameMatch {
   TRACK_MATCH_KEYFRAME = 0,
-  TRACK_MATCH_PREVFRAME = 1,
-};
+  TRACK_MATCH_PREVIOS_FRAME = 1,
+} eTrackFrameMatch;
 
 /* MovieTrackingSettings->flag */
 enum {
diff --git a/source/blender/makesrna/intern/rna_tracking.c 
b/source/blender/makesrna/intern/rna_tracking.c
index f9597fdd7af..1870c660efd 100644
--- a/source/blender/makesrna/intern/rna_tracking.c
+++ b/source/blender/makesrna/intern/rna_tracking.c
@@ -856,7 +856,7 @@ static const EnumPropertyItem tracker_motion_model[] = {
 
 static const EnumPropertyItem pattern_match_items[] = {
 {TRACK_MATCH_KEYFRAME, "KEYFRAME", 0, "Keyframe", "Track pattern from 
keyframe to next frame"},
-{TRACK_MATCH_PREVFRAME,
+{TRACK_MATCH_PREVIOS_FRAME,
  "PREV_FRAME",
  0,
  "Previous frame",

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


[Bf-blender-cvs] [6fba2726c77] master: Tracking: Cleanup, finish pass of comments in the context

2020-11-30 Thread Sergey Sharybin
Commit: 6fba2726c77167f8a4746312cb0d522fd43e4c63
Author: Sergey Sharybin
Date:   Mon Nov 30 14:48:48 2020 +0100
Branches: master
https://developer.blender.org/rB6fba2726c77167f8a4746312cb0d522fd43e4c63

Tracking: Cleanup, finish pass of comments in the context

Some fields are still not really documented, but they are subject of
refactor/fix which will happen shortly.

===

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

===

diff --git a/source/blender/blenkernel/intern/tracking_auto.c 
b/source/blender/blenkernel/intern/tracking_auto.c
index 995e25a1536..faa1f207788 100644
--- a/source/blender/blenkernel/intern/tracking_auto.c
+++ b/source/blender/blenkernel/intern/tracking_auto.c
@@ -91,11 +91,23 @@ typedef struct AutoTrackContext {
   int num_input_tracks;
   MovieTrackingTrack **input_tracks;
 
+  /* Dimensions of movie frame, in pixels.
+   *
+   * NOTE: All clips and frames within a clip are expected to have match3ed 
dimensions.
+   *
+   * TODO(sergey): Make it more flexible to fully support multiple-clip 
tracking. Could either be
+   * stored as a `pair` or even be replaced with actual 
frame size access
+   * to support variadic frame dimensions. */
   int frame_width, frame_height;
 
-  struct libmv_AutoTrack *autotrack;
+  /* Accessor for images of clip. Used by the autotrack context. */
   TrackingImageAccessor *image_accessor;
 
+  /* Auto-track context.
+   *
+   * NOTE: Is accessed from multiple threads at once. */
+  struct libmv_AutoTrack *autotrack;
+
   AutoTrackOptions *track_options; /* Per-tracking track options. */
 
   int sync_frame;

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


[Bf-blender-cvs] [2f08906c476] master: Tracking: Cleanup, replace clip user with frame number

2020-11-30 Thread Sergey Sharybin
Commit: 2f08906c4766f84685365ee681d04649c9ca13c5
Author: Sergey Sharybin
Date:   Mon Nov 30 14:44:51 2020 +0100
Branches: master
https://developer.blender.org/rB2f08906c4766f84685365ee681d04649c9ca13c5

Tracking: Cleanup, replace clip user with frame number

Makes it more clear from intent and usage point of view.
The user was not used for anything else than frame number.

===

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

===

diff --git a/source/blender/blenkernel/intern/tracking_auto.c 
b/source/blender/blenkernel/intern/tracking_auto.c
index 875299059da..995e25a1536 100644
--- a/source/blender/blenkernel/intern/tracking_auto.c
+++ b/source/blender/blenkernel/intern/tracking_auto.c
@@ -62,6 +62,10 @@ typedef struct AutoTrackContext {
* NOTE: Measured in scene time frames, */
   int start_scene_frame;
 
+  /* Scene frame number from which tracker will perform the trackign step.
+   * The direction of the step is denoted by `is_backwards`. */
+  int current_scene_frame;
+
   /* True when tracking backwards (from higher frame number to lower frame 
number.) */
   bool is_backwards;
 
@@ -87,7 +91,6 @@ typedef struct AutoTrackContext {
   int num_input_tracks;
   MovieTrackingTrack **input_tracks;
 
-  MovieClipUser user;
   int frame_width, frame_height;
 
   struct libmv_AutoTrack *autotrack;
@@ -368,9 +371,7 @@ AutoTrackContext *BKE_autotrack_context_new(MovieClip *clip,
   /* TODO(sergey): Currently using only a single clip. */
   context->clips[0] = clip;
   context->num_clips = 1;
-  context->user = *user;
-  context->user.render_size = MCLIP_PROXY_RENDER_SIZE_FULL;
-  context->user.render_flag = 0;
+  context->current_scene_frame = user->framenr;
   context->frame_width = frame_width;
   context->frame_height = frame_height;
   context->is_backwards = is_backwards;
@@ -413,7 +414,7 @@ static void autotrack_context_step_cb(void *__restrict 
userdata,
   libmv_TrackRegionResult libmv_result;
 
   MovieClip *clip = context->clips[clip_index];
-  const int frame = BKE_movieclip_remap_scene_to_clip_frame(clip, 
context->user.framenr);
+  const int frame = BKE_movieclip_remap_scene_to_clip_frame(clip, 
context->current_scene_frame);
   BLI_spin_lock(>spin_lock);
   const bool has_marker = libmv_autoTrackGetMarker(
   context->autotrack, clip_index, frame, track_index, 
_current_marker);
@@ -478,7 +479,7 @@ bool BKE_autotrack_context_step(AutoTrackContext *context)
 
   /* Advance the frame. */
   BLI_spin_lock(>spin_lock);
-  context->user.framenr += frame_delta;
+  context->current_scene_frame += frame_delta;
   BLI_spin_unlock(>spin_lock);
   return context->step_ok;
 }
@@ -488,7 +489,7 @@ void BKE_autotrack_context_sync(AutoTrackContext *context)
   int newframe, frame_delta = context->is_backwards ? -1 : 1;
 
   BLI_spin_lock(>spin_lock);
-  newframe = context->user.framenr;
+  newframe = context->current_scene_frame;
   for (int frame = context->sync_frame;
frame != (context->is_backwards ? newframe - 1 : newframe + 1);
frame += frame_delta) {

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


[Bf-blender-cvs] [d61a6a8cc3b] master: Tracking: Fix missing frame remap for plane tracks

2020-11-30 Thread Sergey Sharybin
Commit: d61a6a8cc3b1eab306f3795f2b91276aaaeed231
Author: Sergey Sharybin
Date:   Mon Nov 30 14:36:03 2020 +0100
Branches: master
https://developer.blender.org/rBd61a6a8cc3b1eab306f3795f2b91276aaaeed231

Tracking: Fix missing frame remap for plane tracks

Tracking track which is used for plane track and movie clip having
a scene frame offset would have trigger re-calculation from a wrong
frame.

===

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

===

diff --git a/source/blender/blenkernel/intern/tracking_auto.c 
b/source/blender/blenkernel/intern/tracking_auto.c
index deeaa85fa80..1dc047be7bf 100644
--- a/source/blender/blenkernel/intern/tracking_auto.c
+++ b/source/blender/blenkernel/intern/tracking_auto.c
@@ -59,7 +59,7 @@ typedef struct AutoTrackOptions {
 
 typedef struct AutoTrackContext {
   /* Frame at which tracking process started.
-   * TODO(sergey): Disambiguate whether it is a scene or clip frame. */
+   * NOTE: Measured in scene time frames, */
   int start_frame;
 
   /* True when tracking backwards (from higher frame number to lower frame 
number.) */
@@ -554,6 +554,8 @@ void BKE_autotrack_context_finish(AutoTrackContext *context)
   for (int clip_index = 0; clip_index < context->num_clips; clip_index++) {
 MovieClip *clip = context->clips[clip_index];
 ListBase *plane_tracks_base = 
BKE_tracking_get_active_plane_tracks(>tracking);
+const int start_clip_frame = BKE_movieclip_remap_scene_to_clip_frame(clip,
+ 
context->start_frame);
 
 LISTBASE_FOREACH (MovieTrackingPlaneTrack *, plane_track, 
plane_tracks_base) {
   if ((plane_track->flag & PLANE_TRACK_AUTOKEY)) {
@@ -563,7 +565,7 @@ void BKE_autotrack_context_finish(AutoTrackContext *context)
 const AutoTrackOptions *track_options = >track_options[i];
 MovieTrackingTrack *track = track_options->track;
 if (BKE_tracking_plane_track_has_point_track(plane_track, track)) {
-  BKE_tracking_track_plane_from_existing_motion(plane_track, 
context->start_frame);
+  BKE_tracking_track_plane_from_existing_motion(plane_track, 
start_clip_frame);
   break;
 }
   }

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


[Bf-blender-cvs] [9d3b6f75a13] master: Tracking: Cleanup, more clear variable naming

2020-11-30 Thread Sergey Sharybin
Commit: 9d3b6f75a1343c126c6d99689d41a09fd77b2c10
Author: Sergey Sharybin
Date:   Mon Nov 30 14:40:00 2020 +0100
Branches: master
https://developer.blender.org/rB9d3b6f75a1343c126c6d99689d41a09fd77b2c10

Tracking: Cleanup, more clear variable naming

A no-functional-followup of the previous commit.

===

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

===

diff --git a/source/blender/blenkernel/intern/tracking_auto.c 
b/source/blender/blenkernel/intern/tracking_auto.c
index 1dc047be7bf..875299059da 100644
--- a/source/blender/blenkernel/intern/tracking_auto.c
+++ b/source/blender/blenkernel/intern/tracking_auto.c
@@ -60,7 +60,7 @@ typedef struct AutoTrackOptions {
 typedef struct AutoTrackContext {
   /* Frame at which tracking process started.
* NOTE: Measured in scene time frames, */
-  int start_frame;
+  int start_scene_frame;
 
   /* True when tracking backwards (from higher frame number to lower frame 
number.) */
   bool is_backwards;
@@ -374,7 +374,7 @@ AutoTrackContext *BKE_autotrack_context_new(MovieClip *clip,
   context->frame_width = frame_width;
   context->frame_height = frame_height;
   context->is_backwards = is_backwards;
-  context->start_frame = user->framenr;
+  context->start_scene_frame = user->framenr;
   context->sync_frame = user->framenr;
   context->first_sync = true;
   BLI_spin_init(>spin_lock);
@@ -554,8 +554,8 @@ void BKE_autotrack_context_finish(AutoTrackContext *context)
   for (int clip_index = 0; clip_index < context->num_clips; clip_index++) {
 MovieClip *clip = context->clips[clip_index];
 ListBase *plane_tracks_base = 
BKE_tracking_get_active_plane_tracks(>tracking);
-const int start_clip_frame = BKE_movieclip_remap_scene_to_clip_frame(clip,
- 
context->start_frame);
+const int start_clip_frame = BKE_movieclip_remap_scene_to_clip_frame(
+clip, context->start_scene_frame);
 
 LISTBASE_FOREACH (MovieTrackingPlaneTrack *, plane_track, 
plane_tracks_base) {
   if ((plane_track->flag & PLANE_TRACK_AUTOKEY)) {

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


[Bf-blender-cvs] [88289d8f844] master: Tracking: Cleanup, clear variable names and indentation

2020-11-30 Thread Sergey Sharybin
Commit: 88289d8f844d802c5f06da8b69f42d25e7e33b44
Author: Sergey Sharybin
Date:   Mon Nov 30 12:35:51 2020 +0100
Branches: master
https://developer.blender.org/rB88289d8f844d802c5f06da8b69f42d25e7e33b44

Tracking: Cleanup, clear variable names and indentation

Should be no functional changes.

===

M   source/blender/blenkernel/BKE_tracking.h
M   source/blender/blenkernel/intern/tracking_auto.c

===

diff --git a/source/blender/blenkernel/BKE_tracking.h 
b/source/blender/blenkernel/BKE_tracking.h
index 2dab0a1030e..4dbc22ae18f 100644
--- a/source/blender/blenkernel/BKE_tracking.h
+++ b/source/blender/blenkernel/BKE_tracking.h
@@ -326,7 +326,7 @@ void BKE_tracking_refine_marker(struct MovieClip *clip,
 
 struct AutoTrackContext *BKE_autotrack_context_new(struct MovieClip *clip,
struct MovieClipUser *user,
-   const bool backwards);
+   const bool is_backwards);
 bool BKE_autotrack_context_step(struct AutoTrackContext *context);
 void BKE_autotrack_context_sync(struct AutoTrackContext *context);
 void BKE_autotrack_context_sync_user(struct AutoTrackContext *context, struct 
MovieClipUser *user);
diff --git a/source/blender/blenkernel/intern/tracking_auto.c 
b/source/blender/blenkernel/intern/tracking_auto.c
index 7222f7346fc..deeaa85fa80 100644
--- a/source/blender/blenkernel/intern/tracking_auto.c
+++ b/source/blender/blenkernel/intern/tracking_auto.c
@@ -58,8 +58,34 @@ typedef struct AutoTrackOptions {
 } AutoTrackOptions;
 
 typedef struct AutoTrackContext {
-  MovieClip *clips[MAX_ACCESSOR_CLIP];
+  /* Frame at which tracking process started.
+   * TODO(sergey): Disambiguate whether it is a scene or clip frame. */
+  int start_frame;
+
+  /* True when tracking backwards (from higher frame number to lower frame 
number.) */
+  bool is_backwards;
+
+  /* True when entire sequence is being tracked. */
+  bool is_sequence;
+
+  /* Movie clips used during the trackign process. */
   int num_clips;
+  MovieClip *clips[MAX_ACCESSOR_CLIP];
+
+  /* Tracks for which the context has been created for.
+   * Most usually this is all track selected in the interface when tracking in 
initialized.
+   *
+   * NOTE: Actually being-tracked tracks is a subset of those, as the tracker 
might loose track of
+   * where markers are. For example, if feature gets occluded, corresponding 
marker can not be
+   * tracked, and hence track is considered finished.
+   *
+   * The need of knowledge of all tracks which might potentially be modified 
during tracking comes
+   * form plane tracks: plane tracks needs adjustment if any of their tracks 
changed during
+   * tracking.
+   *
+   * Indexed by AutoTrackOptions::track_index. */
+  int num_input_tracks;
+  MovieTrackingTrack **input_tracks;
 
   MovieClipUser user;
   int frame_width, frame_height;
@@ -67,14 +93,8 @@ typedef struct AutoTrackContext {
   struct libmv_AutoTrack *autotrack;
   TrackingImageAccessor *image_accessor;
 
-  int num_tracks;/* Number of tracks being tracked. */
-  AutoTrackOptions *options; /* Per-tracking track options. */
-
-  /* Array of all tracks, indexed by track_index. */
-  MovieTrackingTrack **tracks;
+  AutoTrackOptions *track_options; /* Per-tracking track options. */
 
-  bool backwards;
-  int first_frame;
   int sync_frame;
   bool first_sync;
   SpinLock spin_lock;
@@ -306,12 +326,12 @@ static void create_per_track_tracking_options(const 
MovieClip *clip,
   /* Count number of trackable tracks. */
   LISTBASE_FOREACH (MovieTrackingTrack *, track, tracksbase) {
 if (check_track_trackable(clip, track, user)) {
-  context->num_tracks++;
+  context->num_input_tracks++;
 }
   }
   /* Allocate required memory. */
-  context->options = MEM_callocN(sizeof(AutoTrackOptions) * 
context->num_tracks,
- "auto track options");
+  context->track_options = MEM_callocN(sizeof(AutoTrackOptions) * 
context->num_input_tracks,
+   "auto track options");
   /* Fill in all the settings. */
   int i = 0, track_index = 0;
   LISTBASE_FOREACH (MovieTrackingTrack *, track, tracksbase) {
@@ -319,21 +339,25 @@ static void create_per_track_tracking_options(const 
MovieClip *clip,
   track_index++;
   continue;
 }
-AutoTrackOptions *options = >options[i++];
+
+AutoTrackOptions *track_options = >track_options[i++];
+
 /* TODO(sergey): Single clip only for now. */
-options->clip_index = 0;
-options->track_index = track_index;
-options->track = track;
-tracking_configure_tracker(track, NULL, >track_region_options);
-options->use_keyframe_match = track->pattern_match == TRACK_MATCH_KEYFRAME;
-context->tracks[track_index] = track;
+

[Bf-blender-cvs] [8dac88b54a6] master: Tracking: Cleanup, unused field in autotrack context

2020-11-30 Thread Sergey Sharybin
Commit: 8dac88b54a68671afee4e77d7038cba915ff0992
Author: Sergey Sharybin
Date:   Mon Nov 30 14:13:03 2020 +0100
Branches: master
https://developer.blender.org/rB8dac88b54a68671afee4e77d7038cba915ff0992

Tracking: Cleanup, unused field in autotrack context

Was only assigned to truth, always. Never read back.

===

M   source/blender/blenkernel/BKE_tracking.h
M   source/blender/blenkernel/intern/tracking_auto.c
M   source/blender/editors/space_clip/tracking_ops_track.c

===

diff --git a/source/blender/blenkernel/BKE_tracking.h 
b/source/blender/blenkernel/BKE_tracking.h
index f92cd784ee0..2dab0a1030e 100644
--- a/source/blender/blenkernel/BKE_tracking.h
+++ b/source/blender/blenkernel/BKE_tracking.h
@@ -326,8 +326,7 @@ void BKE_tracking_refine_marker(struct MovieClip *clip,
 
 struct AutoTrackContext *BKE_autotrack_context_new(struct MovieClip *clip,
struct MovieClipUser *user,
-   const bool backwards,
-   const bool sequence);
+   const bool backwards);
 bool BKE_autotrack_context_step(struct AutoTrackContext *context);
 void BKE_autotrack_context_sync(struct AutoTrackContext *context);
 void BKE_autotrack_context_sync_user(struct AutoTrackContext *context, struct 
MovieClipUser *user);
diff --git a/source/blender/blenkernel/intern/tracking_auto.c 
b/source/blender/blenkernel/intern/tracking_auto.c
index e7a98ba1c3f..7222f7346fc 100644
--- a/source/blender/blenkernel/intern/tracking_auto.c
+++ b/source/blender/blenkernel/intern/tracking_auto.c
@@ -74,7 +74,6 @@ typedef struct AutoTrackContext {
   MovieTrackingTrack **tracks;
 
   bool backwards;
-  bool sequence;
   int first_frame;
   int sync_frame;
   bool first_sync;
@@ -334,8 +333,7 @@ static void create_per_track_tracking_options(const 
MovieClip *clip,
 
 AutoTrackContext *BKE_autotrack_context_new(MovieClip *clip,
 MovieClipUser *user,
-const bool backwards,
-const bool sequence)
+const bool backwards)
 {
   AutoTrackContext *context = MEM_callocN(sizeof(AutoTrackContext), "autotrack 
context");
   MovieTracking *tracking = >tracking;
@@ -352,7 +350,6 @@ AutoTrackContext *BKE_autotrack_context_new(MovieClip *clip,
   context->frame_width = frame_width;
   context->frame_height = frame_height;
   context->backwards = backwards;
-  context->sequence = sequence;
   context->first_frame = user->framenr;
   context->sync_frame = user->framenr;
   context->first_sync = true;
diff --git a/source/blender/editors/space_clip/tracking_ops_track.c 
b/source/blender/editors/space_clip/tracking_ops_track.c
index 9527929..585b13b426e 100644
--- a/source/blender/editors/space_clip/tracking_ops_track.c
+++ b/source/blender/editors/space_clip/tracking_ops_track.c
@@ -185,7 +185,7 @@ static bool track_markers_initjob(bContext *C, 
TrackMarkersJob *tmj, bool backwa
 }
   }
 
-  tmj->context = BKE_autotrack_context_new(clip, >user, backwards, true);
+  tmj->context = BKE_autotrack_context_new(clip, >user, backwards);
 
   clip->tracking_context = tmj->context;

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


[Bf-blender-cvs] [0fd64c652c0] asset-browser: Cleanup: Use C++ scope based mutex locks

2020-11-30 Thread Julian Eisel
Commit: 0fd64c652c0d29592352c261c5852b1679778ae6
Author: Julian Eisel
Date:   Mon Nov 30 14:06:28 2020 +0100
Branches: asset-browser
https://developer.blender.org/rB0fd64c652c0d29592352c261c5852b1679778ae6

Cleanup: Use C++ scope based mutex locks

Rather than verbose and unsafe (in case of early exits or exceptions) explicit
lock/unlock pairs, use RAII based locks which explicitly unlock on stack
unwinding.

===

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

===

diff --git a/source/blender/blenkernel/intern/icons.cc 
b/source/blender/blenkernel/intern/icons.cc
index de6352ed5c6..c5ca567ba46 100644
--- a/source/blender/blenkernel/intern/icons.cc
+++ b/source/blender/blenkernel/intern/icons.cc
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "CLG_log.h"
 
@@ -76,13 +77,16 @@ enum {
 
 static CLG_LogRef LOG = {"bke.icons"};
 
+/* Protected by gIconMutex. */
 static GHash *gIcons = NULL;
 
+/* Protected by gIconMutex. */
 static int gNextIconId = 1;
 
+/* Protected by gIconMutex. */
 static int gFirstIconId = 1;
 
-SpinLock gIconMutex;
+std::mutex gIconMutex;
 
 /* Not mutex-protected! */
 static GHash *gCachedPreviews = NULL;
@@ -92,7 +96,7 @@ typedef struct DeferredIconDeleteNode {
   struct DeferredIconDeleteNode *next;
   int icon_id;
 } DeferredIconDeleteNode;
-/* Also protected with gIconMutex. */
+/* Protected by gIconMutex. */
 static LockfreeLinkList g_icon_delete_queue;
 
 static void icon_free(void *val)
@@ -156,39 +160,33 @@ static void icon_free_data(int icon_id, Icon *icon)
 
 static Icon *icon_ghash_lookup(int icon_id)
 {
-  Icon *icon;
-  BLI_spin_lock();
-  icon = (Icon *)BLI_ghash_lookup(gIcons, POINTER_FROM_INT(icon_id));
-  BLI_spin_unlock();
-  return icon;
+  std::scoped_lock lock(gIconMutex);
+  return (Icon *)BLI_ghash_lookup(gIcons, POINTER_FROM_INT(icon_id));
 }
 
 /* create an id for a new icon and make sure that ids from deleted icons get 
reused
  * after the integer number range is used up */
 static int get_next_free_id(void)
 {
-  BLI_spin_lock();
+  std::scoped_lock lock(gIconMutex);
   int startId = gFirstIconId;
 
   /* if we haven't used up the int number range, we just return the next int */
   if (gNextIconId >= gFirstIconId) {
 int next_id = gNextIconId++;
-BLI_spin_unlock();
 return next_id;
   }
 
   /* Now we try to find the smallest icon id not stored in the gIcons hash.
-   * Don't use icon_ghash_lookup here, it would lock recursively 
(thread-lock). */
+   * Don't use icon_ghash_lookup here, it would lock recursively (dead-lock). 
*/
   while (BLI_ghash_lookup(gIcons, POINTER_FROM_INT(startId)) && startId >= 
gFirstIconId) {
 startId++;
   }
 
   /* if we found a suitable one that isn't used yet, return it */
   if (startId >= gFirstIconId) {
-BLI_spin_unlock();
 return startId;
   }
-  BLI_spin_unlock();
 
   /* fail */
   return 0;
@@ -203,7 +201,6 @@ void BKE_icons_init(int first_dyn_id)
 
   if (!gIcons) {
 gIcons = BLI_ghash_int_new(__func__);
-BLI_spin_init();
 BLI_linklist_lockfree_init(_icon_delete_queue);
   }
 
@@ -217,7 +214,6 @@ void BKE_icons_free(void)
   BLI_assert(BLI_thread_is_main());
 
   if (gIcons) {
-BLI_spin_end();
 BLI_ghash_free(gIcons, NULL, icon_free);
 gIcons = NULL;
   }
@@ -232,7 +228,7 @@ void BKE_icons_free(void)
 
 void BKE_icons_deferred_free(void)
 {
-  BLI_spin_lock();
+  std::scoped_lock lock(gIconMutex);
 
   for (DeferredIconDeleteNode *node =
(DeferredIconDeleteNode 
*)BLI_linklist_lockfree_begin(_icon_delete_queue);
@@ -241,8 +237,6 @@ void BKE_icons_deferred_free(void)
 BLI_ghash_remove(gIcons, POINTER_FROM_INT(node->icon_id), NULL, icon_free);
   }
   BLI_linklist_lockfree_clear(_icon_delete_queue, MEM_freeN);
-
-  BLI_spin_unlock();
 }
 
 static PreviewImage *previewimg_create_ex(size_t deferred_data_size)
@@ -713,9 +707,10 @@ static Icon *icon_create(int icon_id, int obj_type, void 
*obj)
   new_icon->drawinfo = NULL;
   new_icon->drawinfo_free = NULL;
 
-  BLI_spin_lock();
-  BLI_ghash_insert(gIcons, POINTER_FROM_INT(icon_id), new_icon);
-  BLI_spin_unlock();
+  {
+std::scoped_lock lock(gIconMutex);
+BLI_ghash_insert(gIcons, POINTER_FROM_INT(icon_id), new_icon);
+  }
 
   return new_icon;
 }
@@ -892,13 +887,11 @@ void BKE_icon_set(const int icon_id, struct Icon *icon)
 {
   void **val_p;
 
-  BLI_spin_lock();
+  std::scoped_lock lock(gIconMutex);
   if (BLI_ghash_ensure_p(gIcons, POINTER_FROM_INT(icon_id), _p)) {
 CLOG_ERROR(, "icon already set: %d", icon_id);
-BLI_spin_unlock();
 return;
   }
-  BLI_spin_unlock();
 
   *val_p = icon;
 }
@@ -926,9 +919,8 @@ void BKE_icon_id_delete(struct ID *id)
   }
 
   BKE_icons_deferred_free();
-  BLI_spin_lock();
+  std::scoped_lock lock(gIconMutex);
   BLI_ghash_remove(gIcons, POINTER_FROM_INT(icon_id), NULL, icon_free);
-  

[Bf-blender-cvs] [62e06f1c892] asset-browser: Compile BKE icons source file with C++

2020-11-30 Thread Julian Eisel
Commit: 62e06f1c892028323653a43e6d8b75a298b99e11
Author: Julian Eisel
Date:   Mon Nov 30 13:41:01 2020 +0100
Branches: asset-browser
https://developer.blender.org/rB62e06f1c892028323653a43e6d8b75a298b99e11

Compile BKE icons source file with C++

That way we can use scoped mutex locks, which should make code cleaner/saver
and avoids the annoying unlock calls for every early-exit. Will happen in a
followup commit.

Mostly had to address casts from `void *` of course. Used C style casts, almost
all of the file still uses C style coding anyway.
`BKE_icon_geom_from_memory()` was using `goto`s for cleanup logic which
wouldn't compile with C++. Changed to RAII based resource handling.

===

M   source/blender/blenkernel/CMakeLists.txt
R091source/blender/blenkernel/intern/icons.c
source/blender/blenkernel/intern/icons.cc

===

diff --git a/source/blender/blenkernel/CMakeLists.txt 
b/source/blender/blenkernel/CMakeLists.txt
index 88ce2f7a0e8..3e8422397b4 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -130,7 +130,7 @@ set(SRC
   intern/gpencil_geom.c
   intern/gpencil_modifier.c
   intern/hair.c
-  intern/icons.c
+  intern/icons.cc
   intern/icons_rasterize.c
   intern/idprop.c
   intern/idprop_utils.c
diff --git a/source/blender/blenkernel/intern/icons.c 
b/source/blender/blenkernel/intern/icons.cc
similarity index 91%
rename from source/blender/blenkernel/intern/icons.c
rename to source/blender/blenkernel/intern/icons.cc
index 16cf3028e1d..de6352ed5c6 100644
--- a/source/blender/blenkernel/intern/icons.c
+++ b/source/blender/blenkernel/intern/icons.cc
@@ -1,4 +1,4 @@
-/*
+/*
  * 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
@@ -21,9 +21,9 @@
  * \ingroup bke
  */
 
-#include 
-#include 
-#include 
+#include 
+#include 
+#include 
 
 #include "CLG_log.h"
 
@@ -46,6 +46,7 @@
 #include "BLI_string.h"
 #include "BLI_threads.h"
 #include "BLI_utildefines.h"
+#include "BLI_vector.hh"
 
 #include "BKE_global.h" /* only for G.background test */
 #include "BKE_icons.h"
@@ -96,11 +97,11 @@ static LockfreeLinkList g_icon_delete_queue;
 
 static void icon_free(void *val)
 {
-  Icon *icon = val;
+  Icon *icon = (Icon *)val;
 
   if (icon) {
 if (icon->obj_type == ICON_DATA_GEOM) {
-  struct Icon_Geom *obj = icon->obj;
+  struct Icon_Geom *obj = (struct Icon_Geom *)icon->obj;
   if (obj->mem) {
 /* coords & colors are part of this memory. */
 MEM_freeN((void *)obj->mem);
@@ -128,7 +129,7 @@ static void icon_free_data(int icon_id, Icon *icon)
 ((ID *)(icon->obj))->icon_id = 0;
   }
   else if (icon->obj_type == ICON_DATA_IMBUF) {
-ImBuf *imbuf = icon->obj;
+ImBuf *imbuf = (ImBuf *)icon->obj;
 if (imbuf) {
   IMB_freeImBuf(imbuf);
 }
@@ -143,7 +144,7 @@ static void icon_free_data(int icon_id, Icon *icon)
 ((struct Icon_Geom *)(icon->obj))->icon_id = 0;
   }
   else if (icon->obj_type == ICON_DATA_STUDIOLIGHT) {
-StudioLight *sl = icon->obj;
+StudioLight *sl = (StudioLight *)icon->obj;
 if (sl != NULL) {
   BKE_studiolight_unset_icon_id(sl, icon_id);
 }
@@ -157,7 +158,7 @@ static Icon *icon_ghash_lookup(int icon_id)
 {
   Icon *icon;
   BLI_spin_lock();
-  icon = BLI_ghash_lookup(gIcons, POINTER_FROM_INT(icon_id));
+  icon = (Icon *)BLI_ghash_lookup(gIcons, POINTER_FROM_INT(icon_id));
   BLI_spin_unlock();
   return icon;
 }
@@ -246,7 +247,8 @@ void BKE_icons_deferred_free(void)
 
 static PreviewImage *previewimg_create_ex(size_t deferred_data_size)
 {
-  PreviewImage *prv_img = MEM_mallocN(sizeof(PreviewImage) + 
deferred_data_size, "img_prv");
+  PreviewImage *prv_img = (PreviewImage *)MEM_mallocN(sizeof(PreviewImage) + 
deferred_data_size,
+  "img_prv");
   memset(prv_img, 0, sizeof(*prv_img)); /* leave deferred data dirty */
 
   if (deferred_data_size) {
@@ -267,7 +269,7 @@ static PreviewImage *previewimg_defered_create(const char 
*path, int source)
   char *deferred_data;
 
   PreviewImage *prv = previewimg_create_ex(deferred_data_size);
-  deferred_data = PRV_DEFERRED_DATA(prv);
+  deferred_data = (char *)PRV_DEFERRED_DATA(prv);
   deferred_data[0] = source;
   memcpy(_data[1], path, deferred_data_size - 1);
 
@@ -319,7 +321,7 @@ void BKE_previewimg_clear_single(struct PreviewImage *prv, 
enum eIconSizes size)
 void BKE_previewimg_clear(struct PreviewImage *prv)
 {
   for (int i = 0; i < NUM_ICON_SIZES; i++) {
-BKE_previewimg_clear_single(prv, i);
+BKE_previewimg_clear_single(prv, (eIconSizes)i);
   }
 }
 
@@ -328,10 +330,10 @@ PreviewImage *BKE_previewimg_copy(const PreviewImage *prv)
   PreviewImage *prv_img = NULL;
 
   if (prv) {
-

[Bf-blender-cvs] [9306e01b10c] master: Fix T82870: on macOS, continuous grab jumps when crossing editor border

2020-11-30 Thread Yevgeny Makarov
Commit: 9306e01b10cd0cad50179f68fe8c8fed1c86e4a1
Author: Yevgeny Makarov
Date:   Sun Nov 29 17:35:33 2020 +0100
Branches: master
https://developer.blender.org/rB9306e01b10cd0cad50179f68fe8c8fed1c86e4a1

Fix T82870: on macOS, continuous grab jumps when crossing editor border

The event queue can contain events from before pointer warping, ignore those
now. This is an old issue, but became more common now that we disabled event
coalescing and started using the event mouse location rather than the current
mouse location.

Thanks to Yevgeny Makarov and Nicholas Rishel for helping solve this.

Ref D9662

===

M   intern/ghost/intern/GHOST_SystemCocoa.h
M   intern/ghost/intern/GHOST_SystemCocoa.mm

===

diff --git a/intern/ghost/intern/GHOST_SystemCocoa.h 
b/intern/ghost/intern/GHOST_SystemCocoa.h
index 5637dfb0565..cee6398b5a6 100644
--- a/intern/ghost/intern/GHOST_SystemCocoa.h
+++ b/intern/ghost/intern/GHOST_SystemCocoa.h
@@ -311,4 +311,7 @@ class GHOST_SystemCocoa : public GHOST_System {
   bool m_ignoreMomentumScroll;
   /** Is the scroll wheel event generated by a multitouch trackpad or mouse? */
   bool m_multiTouchScroll;
+  /** To prevent multiple warp, we store the time of the last warp event
+   * and ignore mouse moved events generated before that. */
+  double m_last_warp_timestamp;
 };
diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm 
b/intern/ghost/intern/GHOST_SystemCocoa.mm
index 2a3f6e0b0b9..d5b8311349b 100644
--- a/intern/ghost/intern/GHOST_SystemCocoa.mm
+++ b/intern/ghost/intern/GHOST_SystemCocoa.mm
@@ -53,6 +53,8 @@
 #include 
 #include 
 
+#include 
+
 #pragma mark KeyMap, mouse converters
 
 static GHOST_TButtonMask convertButton(int button)
@@ -537,6 +539,7 @@ GHOST_SystemCocoa::GHOST_SystemCocoa()
   m_ignoreWindowSizedMessages = false;
   m_ignoreMomentumScroll = false;
   m_multiTouchScroll = false;
+  m_last_warp_timestamp = 0;
 }
 
 GHOST_SystemCocoa::~GHOST_SystemCocoa()
@@ -1590,6 +1593,13 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void 
*eventPtr)
 }
 case GHOST_kGrabWrap:  // Wrap cursor at area/window boundaries
 {
+  NSTimeInterval timestamp = [event timestamp];
+  if (timestamp < m_last_warp_timestamp) {
+/* After warping we can still receive older unwarped mouse events,
+ * ignore those. */
+break;
+  }
+
   NSPoint mousePos = [event locationInWindow];
   GHOST_TInt32 x_mouse = mousePos.x;
   GHOST_TInt32 y_mouse = mousePos.y;
@@ -1625,6 +1635,9 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void 
*eventPtr)
 setMouseCursorPosition(warped_x, warped_y); /* wrap */
 window->setCursorGrabAccum(x_accum + (x_mouse - warped_x_mouse),
y_accum + (y_mouse - warped_y_mouse));
+
+/* This is the current time that matches NSEvent timestamp. */
+m_last_warp_timestamp = mach_absolute_time() * 1e-9;
   }
 
   // Generate event

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


[Bf-blender-cvs] [2a430a670cc] master: Tests: blacklist failing tests for Cycles CUDA and OptiX devices

2020-11-30 Thread Brecht Van Lommel
Commit: 2a430a670cc833033f2f140b017b2004003d49a2
Author: Brecht Van Lommel
Date:   Fri Nov 27 16:40:16 2020 +0100
Branches: master
https://developer.blender.org/rB2a430a670cc833033f2f140b017b2004003d49a2

Tests: blacklist failing tests for Cycles CUDA and OptiX devices

Blacklist a bunch of tests on the GPU, which are known to currently have
differences with CPU. These can be enabled as they are fixed or the test
is modified to give compatible results when there are known limitations.

OSL tests were also moved to their own directory since those are not
supported on the GPU.

Ref T82193

===

M   tests/python/CMakeLists.txt
M   tests/python/modules/render_report.py

===

diff --git a/tests/python/CMakeLists.txt b/tests/python/CMakeLists.txt
index 52dafa83c7a..97f5df3ec09 100644
--- a/tests/python/CMakeLists.txt
+++ b/tests/python/CMakeLists.txt
@@ -602,7 +602,7 @@ if(WITH_CYCLES OR WITH_OPENGL_RENDER_TESTS)
 if(WITH_CYCLES)
   foreach(_cycles_device ${CYCLES_TEST_DEVICES})
 string(TOLOWER "${_cycles_device}" _cycles_device_lower)
-set(_cycles_render_tests bake;${render_tests})
+set(_cycles_render_tests bake;${render_tests};osl)
 
 foreach(render_test ${_cycles_render_tests})
   add_python_test(
diff --git a/tests/python/modules/render_report.py 
b/tests/python/modules/render_report.py
index 24d0164adf1..9db2162b1ff 100755
--- a/tests/python/modules/render_report.py
+++ b/tests/python/modules/render_report.py
@@ -29,9 +29,54 @@ class COLORS_DUMMY:
 COLORS = COLORS_DUMMY
 
 
-# NOTE: Keep everything lowercase.
+# List of .blend files that are known to be failing and are not ready to be
+# tested, or that only make sense on some devices. Accepts regular expressions.
 BLACKLIST = (
-# 'file_to_blacklist.blend',
+# OSL only supported on CPU.
+('.*_osl.blend', '(?!CPU)'),
+('osl_.*.blend', '(?!CPU)'),
+
+# No baking, branched path and shader raytrace on Optix.
+('bake_.*.blend', 'OPTIX'),
+('ambient_occlusion.blend', 'OPTIX'),
+('ambient_occlusion_only_local.blend', 'OPTIX'),
+('bevel.blend', 'OPTIX'),
+('bevel_mblur.blend', 'OPTIX'),
+('T53854.blend', 'OPTIX'),
+('T50164.blend', 'OPTIX'),
+('portal.blend', 'OPTIX'),
+('denoise_sss.blend', 'OPTIX'),
+('denoise_passes.blend', 'OPTIX'),
+('distant_light.blend', 'OPTIX'),
+('aov_position.blend', 'OPTIX'),
+('subsurface_branched_path.blend', 'OPTIX'),
+
+# Missing equiangular sampling on GPU.
+('area_light.blend', '(?!CPU)'),
+('denoise_hair.blend', '(?!CPU)'),
+('point_density_.*.blend', '(?!CPU)'),
+('point_light.blend', '(?!CPU)'),
+('shadow_catcher_bpt_.*.blend', '(?!CPU)'),
+('sphere_light.blend', '(?!CPU)'),
+('spot_light.blend', '(?!CPU)'),
+('T48346.blend', '(?!CPU)'),
+('world_volume.blend', '(?!CPU)'),
+
+# Inconsistency between Embree and Hair primitive on GPU.
+('hair_basemesh_intercept.blend', '(?!CPU)'),
+('hair_instancer_uv.blend', '(?!CPU)'),
+('hair_particle_random.blend', '(?!CPU)'),
+('principled_hair_.*.blend', '(?!CPU)'),
+('transparent_shadow_hair.*.blend', '(?!CPU)'),
+
+# Uninvestigated differences with GPU.
+('image_log.blend', '(?!CPU)'),
+('subsurface_behind_glass_branched.blend', '(?!CPU)'),
+('T40964.blend', '(?!CPU)'),
+('T45609.blend', '(?!CPU)'),
+('T48860.blend', '(?!CPU)'),
+('smoke_color.blend', '(?!CPU)'),
+('T43865.blend', 'OPTIX')
 )
 
 
@@ -58,13 +103,23 @@ def print_message(message, type=None, status=''):
 sys.stdout.flush()
 
 
-def blend_list(dirpath):
+def blend_list(dirpath, device):
+import re
+
 for root, dirs, files in os.walk(dirpath):
 for filename in files:
-filename_lower = filename.lower()
-if filename_lower in BLACKLIST:
+if not filename.lower().endswith(".blend"):
 continue
-if filename_lower.endswith(".blend"):
+
+skip = False
+for blacklist in BLACKLIST:
+if not re.match(blacklist[0], filename):
+continue
+if device and blacklist[1] and not re.match(blacklist[1], 
device):
+continue
+skip = True
+
+if not skip:
 filepath = os.path.join(root, filename)
 yield filepath
 
@@ -520,7 +575,7 @@ class Report:
 def _run_all_tests(self, dirname, dirpath, blender, arguments_cb, batch):
 passed_tests = []
 failed_tests = []
-all_files = list(blend_list(dirpath))
+all_files = list(blend_list(dirpath, self.device))
 all_files.sort()
 print_message("Running {} tests from 1 test case." .
   format(len(all_files)),

___

[Bf-blender-cvs] [dd391d38f6e] master: Tests: add CMake option to run Cycles regression tests on GPU devices

2020-11-30 Thread Brecht Van Lommel
Commit: dd391d38f6ef2165bc76a1e69da52e1bd1208e53
Author: Brecht Van Lommel
Date:   Wed Oct 28 16:19:03 2020 +0100
Branches: master
https://developer.blender.org/rBdd391d38f6ef2165bc76a1e69da52e1bd1208e53

Tests: add CMake option to run Cycles regression tests on GPU devices

CYCLES_TEST_DEVICES is a list of devices (CPU, CUDA, OPTIX, OPENCL). It is set
to CPU only by default.

Test output is now writen to build/tests/cycles/, and the HTML report
has separate report pages for the different devices, with option to compare
between CPU and GPU renders.

Various GPU tests are still failing due to CPU/GPU differences, these are to be
fixed or blacklisted still.

Ref T82193

===

M   CMakeLists.txt
M   tests/python/CMakeLists.txt
M   tests/python/cycles_render_tests.py
M   tests/python/eevee_render_tests.py
M   tests/python/modules/global_report.py
M   tests/python/modules/render_report.py
M   tests/python/workbench_render_tests.py

===

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 90f9e432878..580aa1e8d79 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -380,6 +380,7 @@ option(WITH_CYCLES_CUDA_BINARIES"Build Cycles CUDA 
binaries" OFF)
 option(WITH_CYCLES_CUBIN_COMPILER   "Build cubins with nvrtc based compiler 
instead of nvcc" OFF)
 option(WITH_CYCLES_CUDA_BUILD_SERIAL "Build cubins one after another (useful 
on machines with limited RAM)" OFF)
 mark_as_advanced(WITH_CYCLES_CUDA_BUILD_SERIAL)
+set(CYCLES_TEST_DEVICES CPU CACHE STRING "Run regression tests on the 
specified device types (CPU CUDA OPTIX OPENCL)" )
 set(CYCLES_CUDA_BINARIES_ARCH sm_30 sm_35 sm_37 sm_50 sm_52 sm_60 sm_61 sm_70 
sm_75 sm_86 compute_75 CACHE STRING "CUDA architectures to build binaries for")
 mark_as_advanced(CYCLES_CUDA_BINARIES_ARCH)
 unset(PLATFORM_DEFAULT)
diff --git a/tests/python/CMakeLists.txt b/tests/python/CMakeLists.txt
index 22426a6d6fc..52dafa83c7a 100644
--- a/tests/python/CMakeLists.txt
+++ b/tests/python/CMakeLists.txt
@@ -598,20 +598,28 @@ if(WITH_CYCLES OR WITH_OPENGL_RENDER_TESTS)
   list(APPEND render_tests grease_pencil)
 endif()
 
+# Cycles
 if(WITH_CYCLES)
-  foreach(render_test bake;${render_tests})
-add_python_test(
-  cycles_${render_test}
-  ${CMAKE_CURRENT_LIST_DIR}/cycles_render_tests.py
-  -blender "${TEST_BLENDER_EXE}"
-  -testdir "${TEST_SRC_DIR}/render/${render_test}"
-  -idiff "${OPENIMAGEIO_IDIFF}"
-  -outdir "${TEST_OUT_DIR}/cycles"
-)
+  foreach(_cycles_device ${CYCLES_TEST_DEVICES})
+string(TOLOWER "${_cycles_device}" _cycles_device_lower)
+set(_cycles_render_tests bake;${render_tests})
+
+foreach(render_test ${_cycles_render_tests})
+  add_python_test(
+cycles_${render_test}_${_cycles_device_lower}
+${CMAKE_CURRENT_LIST_DIR}/cycles_render_tests.py
+-blender "${TEST_BLENDER_EXE}"
+-testdir "${TEST_SRC_DIR}/render/${render_test}"
+-idiff "${OPENIMAGEIO_IDIFF}"
+-outdir "${TEST_OUT_DIR}/cycles"
+-device ${_cycles_device}
+  )
+endforeach()
   endforeach()
 endif()
 
 if(WITH_OPENGL_RENDER_TESTS)
+  # Eevee
   foreach(render_test ${render_tests})
 add_python_test(
   eevee_${render_test}_test
@@ -624,6 +632,7 @@ if(WITH_CYCLES OR WITH_OPENGL_RENDER_TESTS)
   endforeach()
 
   foreach(render_test ${render_tests})
+# Workbench
 add_python_test(
   workbench_${render_test}_test
   ${CMAKE_CURRENT_LIST_DIR}/workbench_render_tests.py
diff --git a/tests/python/cycles_render_tests.py 
b/tests/python/cycles_render_tests.py
index 3c597b39cb8..9153a2732b5 100644
--- a/tests/python/cycles_render_tests.py
+++ b/tests/python/cycles_render_tests.py
@@ -50,6 +50,7 @@ def create_argparse():
 parser.add_argument("-testdir", nargs=1)
 parser.add_argument("-outdir", nargs=1)
 parser.add_argument("-idiff", nargs=1)
+parser.add_argument("-device", nargs=1)
 return parser
 
 
@@ -61,12 +62,16 @@ def main():
 test_dir = args.testdir[0]
 idiff = args.idiff[0]
 output_dir = args.outdir[0]
+device = args.device[0]
 
 from modules import render_report
-report = render_report.Report("Cycles", output_dir, idiff)
+report = render_report.Report('Cycles', output_dir, idiff, device)
 report.set_pixelated(True)
 report.set_reference_dir("cycles_renders")
-report.set_compare_engines('cycles', 'eevee')
+if device == 'CPU':
+report.set_compare_engine('eevee')
+else:
+report.set_compare_engine('cycles', 'CPU')
 
 # Increase threshold for motion blur, see T78777.
 test_dir_name = Path(test_dir).name
diff --git a/tests/python/eevee_render_tests.py 
b/tests/python/eevee_render_tests.py
index 

[Bf-blender-cvs] [c986e46be70] master: Cleanup: avoid harmless but unnecessary float division by zero

2020-11-30 Thread Brecht Van Lommel
Commit: c986e46be708f6885a9504d87f58a99259ac63c7
Author: Brecht Van Lommel
Date:   Mon Nov 30 12:21:44 2020 +0100
Branches: master
https://developer.blender.org/rBc986e46be708f6885a9504d87f58a99259ac63c7

Cleanup: avoid harmless but unnecessary float division by zero

===

M   intern/cycles/render/light.cpp

===

diff --git a/intern/cycles/render/light.cpp b/intern/cycles/render/light.cpp
index 80190dcbf82..2bde3242b26 100644
--- a/intern/cycles/render/light.cpp
+++ b/intern/cycles/render/light.cpp
@@ -551,17 +551,19 @@ static void background_cdf(
   cond_cdf[i * cdf_width + j - 1].x / 
res_x;
 }
 
-float cdf_total = cond_cdf[i * cdf_width + res_x - 1].y +
-  cond_cdf[i * cdf_width + res_x - 1].x / res_x;
-float cdf_total_inv = 1.0f / cdf_total;
+const float cdf_total = cond_cdf[i * cdf_width + res_x - 1].y +
+cond_cdf[i * cdf_width + res_x - 1].x / res_x;
 
 /* stuff the total into the brightness value for the last entry, because
  * we are going to normalize the CDFs to 0.0 to 1.0 afterwards */
 cond_cdf[i * cdf_width + res_x].x = cdf_total;
 
-if (cdf_total > 0.0f)
-  for (int j = 1; j < res_x; j++)
+if (cdf_total > 0.0f) {
+  const float cdf_total_inv = 1.0f / cdf_total;
+  for (int j = 1; j < res_x; j++) {
 cond_cdf[i * cdf_width + j].y *= cdf_total_inv;
+  }
+}
 
 cond_cdf[i * cdf_width + res_x].y = 1.0f;
   }

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


[Bf-blender-cvs] [0f0c982ff4a] master: Libmv: Add build configuration header

2020-11-30 Thread Sergey Sharybin
Commit: 0f0c982ff4a9538750e514fab4d5da7be8c7f762
Author: Sergey Sharybin
Date:   Fri Nov 27 15:43:44 2020 +0100
Branches: master
https://developer.blender.org/rB0f0c982ff4a9538750e514fab4d5da7be8c7f762

Libmv: Add build configuration header

Allows to easily access build platform information, such as bitness,
compiler, supported C++ version and so on.

===

M   intern/libmv/files.txt
A   intern/libmv/libmv/build/build_config.h

===

diff --git a/intern/libmv/files.txt b/intern/libmv/files.txt
index 0ccd4f78f2a..985074bfe50 100644
--- a/intern/libmv/files.txt
+++ b/intern/libmv/files.txt
@@ -23,6 +23,7 @@ libmv/base/scoped_ptr_test.cc
 libmv/base/vector.h
 libmv/base/vector_test.cc
 libmv/base/vector_utils.h
+libmv/build/build_config.h
 libmv/image/array_nd.cc
 libmv/image/array_nd.h
 libmv/image/array_nd_test.cc
diff --git a/intern/libmv/libmv/build/build_config.h 
b/intern/libmv/libmv/build/build_config.h
new file mode 100644
index 000..7029a36a7dd
--- /dev/null
+++ b/intern/libmv/libmv/build/build_config.h
@@ -0,0 +1,382 @@
+// Copyright (c) 2020 libmv authors.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+
+#ifndef LIBMV_BUILD_BUILD_CONFIG_H_
+#define LIBMV_BUILD_BUILD_CONFIG_H_
+
+#include 
+#include 
+
+// Initially is based on Chromium's build_config.h, with tweaks and extensions
+// needed for this project.
+//
+// NOTE: All commonly used symbols (which are checked on a "top" level, from
+// outside of any platform-specific ifdef block) are to be explicitly defined
+// to 0 when they are not "active". This is extra lines of code in this file,
+// but is not being edited that often. Such approach helps catching cases when
+// one attempted to access build configuration variable without including the
+// header by simply using -Wundef compiler attribute.
+//
+// NOTE: Not having things explicitly defined to 0 is harmless (in terms it
+// follows same rules as Google projects) and will simply cause compiler to
+// become more noisy, which is simple to correct.
+
+
+// A set of macros to use for platform detection.
+
+#if defined(__native_client__)
+// __native_client__ must be first, so that other OS_ defines are not set.
+#  define OS_NACL 1
+// OS_NACL comes in two sandboxing technology flavors, SFI or Non-SFI.
+// PNaCl toolchain defines __native_client_nonsfi__ macro in Non-SFI build
+// mode, while it does not in SFI build mode.
+#  if defined(__native_client_nonsfi__)
+#define OS_NACL_NONSFI
+#  else
+#define OS_NACL_SFI
+#  endif
+#elif defined(_AIX)
+#  define OS_AIX 1
+#elif defined(ANDROID)
+#  define OS_ANDROID 1
+#elif defined(__APPLE__)
+// Only include TargetConditions after testing ANDROID as some android builds
+// on mac don't have this header available and it's not needed unless the 
target
+// is really mac/ios.
+#  include 
+#  define OS_MACOSX 1
+#  if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
+#define OS_IOS 1
+#  endif  // defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
+#elif defined(__HAIKU__)
+#  define OS_HAIKU 1
+#elif defined(__hpux)
+#  define OS_HPUX 1
+#elif defined(__linux__)
+#  define OS_LINUX 1
+// Include a system header to pull in features.h for glibc/uclibc macros.
+#  include 
+#  if defined(__GLIBC__) && !defined(__UCLIBC__)
+// We really are using glibc, not uClibc pretending to be glibc.
+#define LIBC_GLIBC 1
+#  endif
+#elif defined(__sgi)
+#  define OS_IRIX 1
+#elif defined(_WIN32)
+#  define OS_WIN 1
+#elif defined(__Fuchsia__)
+#  define OS_FUCHSIA 1
+#elif defined(__FreeBSD__)
+#  define OS_FREEBSD 1
+#elif defined(__NetBSD__)
+#  define OS_NETBSD 1
+#elif defined(__OpenBSD__)
+#  define OS_OPENBSD 1
+#elif defined(__sun)
+#  define OS_SOLARIS 1
+#elif defined(__QNXNTO__)
+#  define OS_QNX 

[Bf-blender-cvs] [057c15b5495] master: Libmv: Add threading primitives

2020-11-30 Thread Sergey Sharybin
Commit: 057c15b5495d61a14b948b203c0d68b03b7988c7
Author: Sergey Sharybin
Date:   Fri Nov 27 15:58:55 2020 +0100
Branches: master
https://developer.blender.org/rB057c15b5495d61a14b948b203c0d68b03b7988c7

Libmv: Add threading primitives

Allows to use mutex, scoped_lock, and conditional_variable from within
the libmv namespace.

Implementation is coming from C++11. Other configurations are easy to
implement, but currently C++11 is the way to go.

===

A   intern/libmv/libmv/threading/threading.h

===

diff --git a/intern/libmv/libmv/threading/threading.h 
b/intern/libmv/libmv/threading/threading.h
new file mode 100644
index 000..f23bf6f172c
--- /dev/null
+++ b/intern/libmv/libmv/threading/threading.h
@@ -0,0 +1,43 @@
+// Copyright (c) 2020 libmv authors.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+
+#ifndef LIBMV_THREADING_THREADING_H_
+#define LIBMV_THREADING_THREADING_H_
+
+#include "libmv/build/build_config.h"
+
+#if COMPILER_SUPPORTS_CXX11
+#  include 
+#  include 
+#endif
+
+namespace libmv {
+
+#if COMPILER_SUPPORTS_CXX11
+using mutex =  std::mutex;
+using scoped_lock = std::unique_lock;
+using condition_variable = std::condition_variable;
+#else
+#  error Please add support for threading in threading/threading.h
+#endif
+
+}  // namespace libmv
+
+#endif  // LIBMV_THREADING_THREADING_H_

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


[Bf-blender-cvs] [d3dd61aab36] master: Libmv: add missing files to bundler

2020-11-30 Thread Sergey Sharybin
Commit: d3dd61aab36ce6300f472dee1783478936a12203
Author: Sergey Sharybin
Date:   Fri Nov 27 15:05:00 2020 +0100
Branches: master
https://developer.blender.org/rBd3dd61aab36ce6300f472dee1783478936a12203

Libmv: add missing files to bundler

Bundler wouldn't be able to pull changes form upstream until all the
changes are upstreamed, but is better to have information consistent.

===

M   intern/libmv/files.txt

===

diff --git a/intern/libmv/files.txt b/intern/libmv/files.txt
index 0ec90ec041f..0ccd4f78f2a 100644
--- a/intern/libmv/files.txt
+++ b/intern/libmv/files.txt
@@ -15,6 +15,7 @@ libmv/autotrack/tracks.h
 libmv/autotrack/tracks_test.cc
 libmv/base/aligned_malloc.cc
 libmv/base/aligned_malloc.h
+libmv/base/array.h
 libmv/base/id_generator.h
 libmv/base/map.h
 libmv/base/scoped_ptr.h
@@ -104,6 +105,8 @@ libmv/simple_pipeline/keyframe_selection_test.cc
 libmv/simple_pipeline/modal_solver.cc
 libmv/simple_pipeline/modal_solver.h
 libmv/simple_pipeline/modal_solver_test.cc
+libmv/simple_pipeline/packed_intrinsics.cc
+libmv/simple_pipeline/packed_intrinsics.h
 libmv/simple_pipeline/pipeline.cc
 libmv/simple_pipeline/pipeline.h
 libmv/simple_pipeline/reconstruction.cc

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


[Bf-blender-cvs] [709831e5dd3] asset-browser: Fix thread-lock when re-generating material preview icon

2020-11-30 Thread Julian Eisel
Commit: 709831e5dd3d315ef6f94414eea823b27f27497d
Author: Julian Eisel
Date:   Mon Nov 30 11:40:24 2020 +0100
Branches: asset-browser
https://developer.blender.org/rB709831e5dd3d315ef6f94414eea823b27f27497d

Fix thread-lock when re-generating material preview icon

Thought the spin lock supported recursion, it doesn't.

===

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

===

diff --git a/source/blender/blenkernel/intern/icons.c 
b/source/blender/blenkernel/intern/icons.c
index 27c05630a0a..16cf3028e1d 100644
--- a/source/blender/blenkernel/intern/icons.c
+++ b/source/blender/blenkernel/intern/icons.c
@@ -176,8 +176,9 @@ static int get_next_free_id(void)
 return next_id;
   }
 
-  /* now we try to find the smallest icon id not stored in the gIcons hash */
-  while (icon_ghash_lookup(startId) && startId >= gFirstIconId) {
+  /* Now we try to find the smallest icon id not stored in the gIcons hash.
+   * Don't use icon_ghash_lookup here, it would lock recursively 
(thread-lock). */
+  while (BLI_ghash_lookup(gIcons, POINTER_FROM_INT(startId)) && startId >= 
gFirstIconId) {
 startId++;
   }
 
@@ -675,7 +676,6 @@ void BKE_icon_changed(const int icon_id)
 return;
   }
 
-  BLI_spin_lock();
   icon = icon_ghash_lookup(icon_id);
 
   if (icon) {
@@ -696,8 +696,6 @@ void BKE_icon_changed(const int icon_id)
   }
 }
   }
-
-  BLI_spin_unlock();
 }
 
 static Icon *icon_create(int icon_id, int obj_type, void *obj)

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


[Bf-blender-cvs] [06d61d459f2] soc-2020-io-performance: Merge branch 'master' into soc-2020-io-performance

2020-11-30 Thread Ankit Meel
Commit: 06d61d459f2ac5e462e87bb538d0280ded28ab80
Author: Ankit Meel
Date:   Sun Nov 29 17:29:57 2020 +0530
Branches: soc-2020-io-performance
https://developer.blender.org/rB06d61d459f2ac5e462e87bb538d0280ded28ab80

Merge branch 'master' into soc-2020-io-performance

===



===



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


[Bf-blender-cvs] [eb9402996ef] geometry-nodes: Merge branch 'master' into geometry-nodes

2020-11-30 Thread Jacques Lucke
Commit: eb9402996efd1dbf6a94062dd1792ab186da9f72
Author: Jacques Lucke
Date:   Mon Nov 30 10:27:15 2020 +0100
Branches: geometry-nodes
https://developer.blender.org/rBeb9402996efd1dbf6a94062dd1792ab186da9f72

Merge branch 'master' into geometry-nodes

===



===



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