[Bf-blender-cvs] [9927e833f3f] temp-lineart-contained: Lineart: Clean up cache patch.

2021-06-14 Thread YimingWu
Commit: 9927e833f3f6e9d124cb885c212502484fb77ed3
Author: YimingWu
Date:   Mon Jun 14 20:46:35 2021 +0800
Branches: temp-lineart-contained
https://developer.blender.org/rB9927e833f3f6e9d124cb885c212502484fb77ed3

Lineart: Clean up cache patch.

===

M   source/blender/blenkernel/BKE_gpencil_modifier.h
M   source/blender/blenkernel/intern/gpencil_modifier.c
M   source/blender/blenloader/intern/versioning_300.c
M   source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
M   source/blender/gpencil_modifiers/intern/lineart/lineart_ops.c
M   source/blender/makesrna/intern/rna_gpencil_modifier.c

===

diff --git a/source/blender/blenkernel/BKE_gpencil_modifier.h 
b/source/blender/blenkernel/BKE_gpencil_modifier.h
index b49a6fa244c..80d632ca9e2 100644
--- a/source/blender/blenkernel/BKE_gpencil_modifier.h
+++ b/source/blender/blenkernel/BKE_gpencil_modifier.h
@@ -300,12 +300,12 @@ typedef struct GpencilLineartLimitInfo {
   short edge_types;
 } GpencilLineartLimitInfo;
 
-void BKE_gpencil_get_lineart_global_limits(struct Object *ob,
-   struct GpencilLineartLimitInfo 
*info);
+void BKE_gpencil_get_lineart_modifier_limits(struct Object *ob,
+ struct GpencilLineartLimitInfo 
*info);
 
-void BKE_gpencil_assign_lineart_global_limits(struct GpencilModifierData *md,
-  struct GpencilLineartLimitInfo 
*info);
-bool BKE_gpencil_lineart_is_first_run(struct Object *ob, struct 
GpencilModifierData *md);
+void BKE_gpencil_set_lineart_global_limits(struct GpencilModifierData *md,
+   struct GpencilLineartLimitInfo 
*info);
+bool BKE_gpencil_is_first_lineart_in_stack(struct Object *ob, struct 
GpencilModifierData *md);
 
 void BKE_gpencil_lattice_init(struct Object *ob);
 void BKE_gpencil_lattice_clear(struct Object *ob);
diff --git a/source/blender/blenkernel/intern/gpencil_modifier.c 
b/source/blender/blenkernel/intern/gpencil_modifier.c
index 83c7938a2ad..f9a91268e09 100644
--- a/source/blender/blenkernel/intern/gpencil_modifier.c
+++ b/source/blender/blenkernel/intern/gpencil_modifier.c
@@ -203,7 +203,7 @@ bool BKE_gpencil_has_transform_modifiers(Object *ob)
   return false;
 }
 
-void BKE_gpencil_get_lineart_global_limits(Object *ob, struct 
GpencilLineartLimitInfo *info)
+void BKE_gpencil_get_lineart_modifier_limits(Object *ob, struct 
GpencilLineartLimitInfo *info)
 {
   LISTBASE_FOREACH (GpencilModifierData *, md, &ob->greasepencil_modifiers) {
 if (md->type == eGpencilModifierType_Lineart) {
@@ -216,16 +216,17 @@ void BKE_gpencil_get_lineart_global_limits(Object *ob, 
struct GpencilLineartLimi
   }
 }
 
-void BKE_gpencil_assign_lineart_global_limits(GpencilModifierData *md,
-  struct GpencilLineartLimitInfo 
*info)
+void BKE_gpencil_set_lineart_global_limits(GpencilModifierData *md,
+   struct GpencilLineartLimitInfo 
*info)
 {
+  BLI_assert(md->type == eGpencilModifierType_Lineart);
   LineartGpencilModifierData *lmd = (LineartGpencilModifierData *)md;
   lmd->level_start_override = info->min_level;
   lmd->level_end_override = info->max_level;
   lmd->edge_types_override = info->edge_types;
 }
 
-bool BKE_gpencil_lineart_is_first_run(Object *ob, GpencilModifierData *md)
+bool BKE_gpencil_is_first_lineart_in_stack(Object *ob, GpencilModifierData *md)
 {
   if (md->type != eGpencilModifierType_Lineart) {
 return false;
@@ -813,7 +814,7 @@ void BKE_gpencil_modifiers_calc(Depsgraph *depsgraph, Scene 
*scene, Object *ob)
 
   const bool time_remap = BKE_gpencil_has_time_modifiers(ob);
   GpencilLineartLimitInfo info = {0};
-  BKE_gpencil_get_lineart_global_limits(ob, &info);
+  BKE_gpencil_get_lineart_modifier_limits(ob, &info);
 
   LISTBASE_FOREACH (GpencilModifierData *, md, &ob->greasepencil_modifiers) {
 
@@ -825,7 +826,7 @@ void BKE_gpencil_modifiers_calc(Depsgraph *depsgraph, Scene 
*scene, Object *ob)
   }
 
   if (md->type == eGpencilModifierType_Lineart) {
-BKE_gpencil_assign_lineart_global_limits(md, &info);
+BKE_gpencil_set_lineart_global_limits(md, &info);
   }
 
   /* Apply geometry modifiers (add new geometry). */
diff --git a/source/blender/blenloader/intern/versioning_300.c 
b/source/blender/blenloader/intern/versioning_300.c
index 52dfc96b2ec..268598ccc51 100644
--- a/source/blender/blenloader/intern/versioning_300.c
+++ b/source/blender/blenloader/intern/versioning_300.c
@@ -27,7 +27,6 @@
 
 #include "DNA_brush_types.h"
 #include "DNA_genfile.h"
-#include "DNA_gpencil_modifier_types.h"
 #include "DNA_listBase.h"
 #include "DNA_modifier_types.h"
 #include "DNA_text_types.h"
@@ -203,21 +202,6 @@ void blo_do_versions_300(FileData *fd, Library 
*UNUSED(lib), Main *bm

[Bf-blender-cvs] [481ff6e7f1d] temp-lineart-contained: Merge remote-tracking branch 'origin/master' into temp-lineart-contained

2021-06-14 Thread YimingWu
Commit: 481ff6e7f1de12db341ea2bd548b1de8f27dca76
Author: YimingWu
Date:   Tue Jun 15 13:42:47 2021 +0800
Branches: temp-lineart-contained
https://developer.blender.org/rB481ff6e7f1de12db341ea2bd548b1de8f27dca76

Merge remote-tracking branch 'origin/master' into temp-lineart-contained

===



===



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


[Bf-blender-cvs] [2c4d682eddc] temp-lineart-contained: LineArt: First run cache bug.

2021-06-14 Thread YimingWu
Commit: 2c4d682eddc57f7bad1c7b3eb729926e1da60e70
Author: YimingWu
Date:   Tue Jun 15 13:15:03 2021 +0800
Branches: temp-lineart-contained
https://developer.blender.org/rB2c4d682eddc57f7bad1c7b3eb729926e1da60e70

LineArt: First run cache bug.

===

M   source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
M   source/blender/gpencil_modifiers/intern/lineart/lineart_ops.c

===

diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c 
b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
index 8ed527c0bcb..425a1d801f1 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
@@ -178,7 +178,9 @@ static void generateStrokes(GpencilModifierData *md, 
Depsgraph *depsgraph, Objec
 
   if (!(lmd->flags & LRT_GPENCIL_USE_CACHE)) {
 /* Clear local cache. */
-MOD_lineart_clear_cache(&local_lc);
+if (local_lc != gpd->runtime.lineart_cache) {
+  MOD_lineart_clear_cache(&local_lc);
+}
 /* Restore the original cache pointer so the modifiers below still have 
access to the "global"
  * cache. */
 lmd->cache = gpd->runtime.lineart_cache;
diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_ops.c 
b/source/blender/gpencil_modifiers/intern/lineart/lineart_ops.c
index 0dda993fce2..778aec98e48 100644
--- a/source/blender/gpencil_modifiers/intern/lineart/lineart_ops.c
+++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_ops.c
@@ -88,8 +88,12 @@ static void clear_strokes(Object *ob, GpencilModifierData 
*md, int frame)
   BKE_gpencil_layer_frame_delete(gpl, gpf);
 }
 
-static bool bake_strokes(
-Object *ob, Depsgraph *dg, LineartCache **lc, GpencilModifierData *md, int 
frame)
+static bool bake_strokes(Object *ob,
+ Depsgraph *dg,
+ LineartCache **lc,
+ GpencilModifierData *md,
+ int frame,
+ bool is_first)
 {
   /* Modifier data sanity check. */
   if (lineart_mod_is_disabled(md)) {
@@ -118,7 +122,7 @@ static bool bake_strokes(
 MOD_lineart_destroy_render_data(lmd);
   }
   else {
-if (!(lmd->flags & LRT_GPENCIL_USE_CACHE)) {
+if (is_first || (!(lmd->flags & LRT_GPENCIL_USE_CACHE))) {
   MOD_lineart_compute_feature_lines(dg, lmd, &local_lc, (!(ob->dtx & 
OB_DRAW_IN_FRONT)));
   MOD_lineart_destroy_render_data(lmd);
 }
@@ -150,7 +154,9 @@ static bool bake_strokes(
 
   if (!(lmd->flags & LRT_GPENCIL_USE_CACHE)) {
 /* Clear local cache. */
-MOD_lineart_clear_cache(&local_lc);
+if (!is_first) {
+  MOD_lineart_clear_cache(&local_lc);
+}
 /* Restore the original cache pointer so the modifiers below still have 
access to the "global"
  * cache. */
 lmd->cache = gpd->runtime.lineart_cache;
@@ -196,14 +202,16 @@ static bool 
lineart_gpencil_bake_single_target(LineartBakeJob *bj, Object *ob, i
   GpencilLineartLimitInfo info = {0};
   BKE_gpencil_get_lineart_modifier_limits(ob, &info);
 
-  LineartCache *lc;
+  LineartCache *lc = NULL;
+  bool is_first = true;
   LISTBASE_FOREACH (GpencilModifierData *, md, &ob->greasepencil_modifiers) {
 if (md->type != eGpencilModifierType_Lineart) {
   continue;
 }
 BKE_gpencil_set_lineart_global_limits(md, &info);
-if (bake_strokes(ob, bj->dg, &lc, md, frame)) {
+if (bake_strokes(ob, bj->dg, &lc, md, frame, is_first)) {
   touched = true;
+  is_first = false;
 }
   }
   MOD_lineart_clear_cache(&lc);

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


[Bf-blender-cvs] [819152527fd] master: BMesh: assert that face normals have been updated for tessellation

2021-06-14 Thread Campbell Barton
Commit: 819152527fd425fef54107bd6841887ace51e66e
Author: Campbell Barton
Date:   Tue Jun 15 14:51:48 2021 +1000
Branches: master
https://developer.blender.org/rB819152527fd425fef54107bd6841887ace51e66e

BMesh: assert that face normals have been updated for tessellation

This catches missing normal updates that may cause invalid tessellation.

===

M   source/blender/bmesh/intern/bmesh_mesh_tessellate.c

===

diff --git a/source/blender/bmesh/intern/bmesh_mesh_tessellate.c 
b/source/blender/bmesh/intern/bmesh_mesh_tessellate.c
index ca1218c97f6..2f9d5758385 100644
--- a/source/blender/bmesh/intern/bmesh_mesh_tessellate.c
+++ b/source/blender/bmesh/intern/bmesh_mesh_tessellate.c
@@ -58,6 +58,13 @@ BLI_INLINE void mesh_calc_tessellation_for_face_impl(BMLoop 
*(*looptris)[3],
  MemArena **pf_arena_p,
  const bool face_normal)
 {
+#ifdef DEBUG
+  /* The face normal is used for projecting faces into 2D space for 
tessellation.
+   * Invalid normals may result in invalid tessellation.
+   * Either `face_normal` should be true or normals should be updated first. */
+  BLI_assert(face_normal || BM_face_is_normal_valid(efa));
+#endif
+
   switch (efa->len) {
 case 3: {
   /* `0 1 2` -> `0 1 2` */

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


[Bf-blender-cvs] [89e2b441ede] master: Cleanup: remove return value from face normal calculation

2021-06-14 Thread Campbell Barton
Commit: 89e2b441ede8b4ef1412ad548d4df689d82f6d1c
Author: Campbell Barton
Date:   Tue Jun 15 14:38:10 2021 +1000
Branches: master
https://developer.blender.org/rB89e2b441ede8b4ef1412ad548d4df689d82f6d1c

Cleanup: remove return value from face normal calculation

This value is always 'sides - 2', no need to return this value.

===

M   source/blender/bmesh/intern/bmesh_mesh_tessellate.c

===

diff --git a/source/blender/bmesh/intern/bmesh_mesh_tessellate.c 
b/source/blender/bmesh/intern/bmesh_mesh_tessellate.c
index 4092ad22ef9..ca1218c97f6 100644
--- a/source/blender/bmesh/intern/bmesh_mesh_tessellate.c
+++ b/source/blender/bmesh/intern/bmesh_mesh_tessellate.c
@@ -53,10 +53,10 @@
 /**
  * \param face_normal: This will be optimized out as a constant.
  */
-BLI_INLINE int mesh_calc_tessellation_for_face_impl(BMLoop *(*looptris)[3],
-BMFace *efa,
-MemArena **pf_arena_p,
-const bool face_normal)
+BLI_INLINE void mesh_calc_tessellation_for_face_impl(BMLoop *(*looptris)[3],
+ BMFace *efa,
+ MemArena **pf_arena_p,
+ const bool face_normal)
 {
   switch (efa->len) {
 case 3: {
@@ -69,7 +69,7 @@ BLI_INLINE int mesh_calc_tessellation_for_face_impl(BMLoop 
*(*looptris)[3],
   if (face_normal) {
 normal_tri_v3(efa->no, l_ptr[0]->v->co, l_ptr[1]->v->co, 
l_ptr[2]->v->co);
   }
-  return 1;
+  break;
 }
 case 4: {
   /* `0 1 2 3` -> (`0 1 2`, `0 2 3`) */
@@ -92,7 +92,7 @@ BLI_INLINE int mesh_calc_tessellation_for_face_impl(BMLoop 
*(*looptris)[3],
 l_ptr_a[2] = l_ptr_b[2];
 l_ptr_b[0] = l_ptr_a[1];
   }
-  return 2;
+  break;
 }
 default: {
   if (face_normal) {
@@ -139,21 +139,21 @@ BLI_INLINE int 
mesh_calc_tessellation_for_face_impl(BMLoop *(*looptris)[3],
   }
 
   BLI_memarena_clear(pf_arena);
-  return tris_len;
+  break;
 }
   }
 }
 
-static int mesh_calc_tessellation_for_face(BMLoop *(*looptris)[3],
-   BMFace *efa,
-   MemArena **pf_arena_p)
+static void mesh_calc_tessellation_for_face(BMLoop *(*looptris)[3],
+BMFace *efa,
+MemArena **pf_arena_p)
 {
   return mesh_calc_tessellation_for_face_impl(looptris, efa, pf_arena_p, 
false);
 }
 
-static int mesh_calc_tessellation_for_face_with_normal(BMLoop *(*looptris)[3],
-   BMFace *efa,
-   MemArena **pf_arena_p)
+static void mesh_calc_tessellation_for_face_with_normal(BMLoop *(*looptris)[3],
+BMFace *efa,
+MemArena **pf_arena_p)
 {
   return mesh_calc_tessellation_for_face_impl(looptris, efa, pf_arena_p, true);
 }
@@ -182,13 +182,15 @@ static void 
bm_mesh_calc_tessellation__single_threaded(BMesh *bm,
 BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
   BLI_assert(efa->len >= 3);
   BM_face_calc_normal(efa, efa->no);
-  i += mesh_calc_tessellation_for_face_with_normal(looptris + i, efa, 
&pf_arena);
+  mesh_calc_tessellation_for_face_with_normal(looptris + i, efa, 
&pf_arena);
+  i += efa->len - 2;
 }
   }
   else {
 BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
   BLI_assert(efa->len >= 3);
-  i += mesh_calc_tessellation_for_face(looptris + i, efa, &pf_arena);
+  mesh_calc_tessellation_for_face(looptris + i, efa, &pf_arena);
+  i += efa->len - 2;
 }
   }

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


[Bf-blender-cvs] [ae348081145] master: Fix missing normal update in edit-mesh blend-from shape operator

2021-06-14 Thread Campbell Barton
Commit: ae348081145110f03825f48adbdd97b14a166af3
Author: Campbell Barton
Date:   Tue Jun 15 14:35:43 2021 +1000
Branches: master
https://developer.blender.org/rBae348081145110f03825f48adbdd97b14a166af3

Fix missing normal update in edit-mesh blend-from shape operator

===

M   source/blender/editors/mesh/editmesh_tools.c

===

diff --git a/source/blender/editors/mesh/editmesh_tools.c 
b/source/blender/editors/mesh/editmesh_tools.c
index 7e8f0c5ea8e..d4491721689 100644
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@ -3817,7 +3817,7 @@ static int edbm_blend_from_shape_exec(bContext *C, 
wmOperator *op)
   EDBM_update(me,
   &(const struct EDBMUpdate_Params){
   .calc_looptri = true,
-  .calc_normals = false,
+  .calc_normals = true,
   .is_destructive = false,
   });
 }

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


[Bf-blender-cvs] [fdad77d73d0] master: BMesh: use faster normal update method for edit-mesh coordinates

2021-06-14 Thread Campbell Barton
Commit: fdad77d73d0507cabc5181d553d6f108b9df0907
Author: Campbell Barton
Date:   Tue Jun 15 13:52:00 2021 +1000
Branches: master
https://developer.blender.org/rBfdad77d73d0507cabc5181d553d6f108b9df0907

BMesh: use faster normal update method for edit-mesh coordinates

This wasn't included in the previous fix so it'd be 2.93 compatible.

===

M   source/blender/editors/space_view3d/view3d_buttons.c

===

diff --git a/source/blender/editors/space_view3d/view3d_buttons.c 
b/source/blender/editors/space_view3d/view3d_buttons.c
index 1cdc74b801a..60e1c780b9e 100644
--- a/source/blender/editors/space_view3d/view3d_buttons.c
+++ b/source/blender/editors/space_view3d/view3d_buttons.c
@@ -927,8 +927,9 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D 
*v3d, Object *ob, float
   }
 
   if (apply_vcos) {
-EDBM_mesh_normals_update(em);
-BKE_editmesh_looptri_calc(em);
+/* TODO: use the #BKE_editmesh_looptri_and_normals_calc_with_partial
+ * This requires begin/end states for UI interaction (which currently 
aren't supported). */
+BKE_editmesh_looptri_and_normals_calc(em);
   }
 
   /* Edges */

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


[Bf-blender-cvs] [0a361eb5ecd] master: Fix outdated face tessellation use when editing edit-mesh coodinates

2021-06-14 Thread Campbell Barton
Commit: 0a361eb5ecd732c399bbc2a4648e9714f9cd8817
Author: Campbell Barton
Date:   Tue Jun 15 13:28:44 2021 +1000
Branches: master
https://developer.blender.org/rB0a361eb5ecd732c399bbc2a4648e9714f9cd8817

Fix outdated face tessellation use when editing edit-mesh coodinates

===

M   source/blender/editors/space_view3d/view3d_buttons.c

===

diff --git a/source/blender/editors/space_view3d/view3d_buttons.c 
b/source/blender/editors/space_view3d/view3d_buttons.c
index e42f6b5faac..1cdc74b801a 100644
--- a/source/blender/editors/space_view3d/view3d_buttons.c
+++ b/source/blender/editors/space_view3d/view3d_buttons.c
@@ -928,6 +928,7 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D 
*v3d, Object *ob, float
 
   if (apply_vcos) {
 EDBM_mesh_normals_update(em);
+BKE_editmesh_looptri_calc(em);
   }
 
   /* Edges */

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


[Bf-blender-cvs] [2ba804d7b7d] master: Screen: clear runtime structures on file-read & data-copy

2021-06-14 Thread Campbell Barton
Commit: 2ba804d7b7dc9612540ff0d15a89cc1fc8c0bffa
Author: Campbell Barton
Date:   Tue Jun 15 12:50:08 2021 +1000
Branches: master
https://developer.blender.org/rB2ba804d7b7dc9612540ff0d15a89cc1fc8c0bffa

Screen: clear runtime structures on file-read & data-copy

Clear the runtime data structs instead of individual members,
this simplifies adding new runtime members as there are at least
two places they would need to be cleared.

Resolves error in D8883.

===

M   source/blender/blenkernel/intern/screen.c
M   source/blender/editors/space_action/space_action.c
M   source/blender/editors/space_graph/space_graph.c
M   source/blender/editors/space_view3d/space_view3d.c

===

diff --git a/source/blender/blenkernel/intern/screen.c 
b/source/blender/blenkernel/intern/screen.c
index d0d63192ebf..2d59e978a81 100644
--- a/source/blender/blenkernel/intern/screen.c
+++ b/source/blender/blenkernel/intern/screen.c
@@ -467,7 +467,7 @@ static void panel_list_copy(ListBase *newlb, const ListBase 
*lb)
   Panel *panel = lb->first;
   for (; new_panel; new_panel = new_panel->next, panel = panel->next) {
 new_panel->activedata = NULL;
-new_panel->runtime.custom_data_ptr = NULL;
+memset(&new_panel->runtime, 0x0, sizeof(new_panel->runtime));
 panel_list_copy(&new_panel->children, &panel->children);
   }
 }
@@ -476,6 +476,8 @@ ARegion *BKE_area_region_copy(const SpaceType *st, const 
ARegion *region)
 {
   ARegion *newar = MEM_dupallocN(region);
 
+  memset(&newar->runtime, 0x0, sizeof(newar->runtime));
+
   newar->prev = newar->next = NULL;
   BLI_listbase_clear(&newar->handlers);
   BLI_listbase_clear(&newar->uiblocks);
@@ -1419,6 +1421,8 @@ static void direct_link_panel_list(BlendDataReader 
*reader, ListBase *lb)
 
 static void direct_link_region(BlendDataReader *reader, ARegion *region, int 
spacetype)
 {
+  memset(®ion->runtime, 0x0, sizeof(region->runtime));
+
   direct_link_panel_list(reader, ®ion->panels);
 
   BLO_read_list(reader, ®ion->panels_category_active);
@@ -1560,16 +1564,15 @@ static void direct_link_area(BlendDataReader *reader, 
ScrArea *area)
 
 if (sl->spacetype == SPACE_VIEW3D) {
   View3D *v3d = (View3D *)sl;
+
+  memset(&v3d->runtime, 0x0, sizeof(v3d->runtime));
+
   if (v3d->gpd) {
 BLO_read_data_address(reader, &v3d->gpd);
 BKE_gpencil_blend_read_data(reader, v3d->gpd);
   }
   BLO_read_data_address(reader, &v3d->localvd);
 
-  /* Runtime data */
-  v3d->runtime.properties_storage = NULL;
-  v3d->runtime.flag = 0;
-
   /* render can be quite heavy, set to solid on load */
   if (v3d->shading.type == OB_RENDER) {
 v3d->shading.type = OB_SOLID;
@@ -1584,7 +1587,7 @@ static void direct_link_area(BlendDataReader *reader, 
ScrArea *area)
   SpaceGraph *sipo = (SpaceGraph *)sl;
 
   BLO_read_data_address(reader, &sipo->ads);
-  BLI_listbase_clear(&sipo->runtime.ghost_curves);
+  memset(&sipo->runtime, 0x0, sizeof(sipo->runtime));
 }
 else if (sl->spacetype == SPACE_NLA) {
   SpaceNla *snla = (SpaceNla *)sl;
@@ -1652,7 +1655,7 @@ static void direct_link_area(BlendDataReader *reader, 
ScrArea *area)
 }
 else if (sl->spacetype == SPACE_TEXT) {
   SpaceText *st = (SpaceText *)sl;
-  memset(&st->runtime, 0, sizeof(st->runtime));
+  memset(&st->runtime, 0x0, sizeof(st->runtime));
 }
 else if (sl->spacetype == SPACE_SEQ) {
   SpaceSeq *sseq = (SpaceSeq *)sl;
@@ -1724,6 +1727,11 @@ static void direct_link_area(BlendDataReader *reader, 
ScrArea *area)
   BLO_read_data_address(reader, &sfile->params);
   BLO_read_data_address(reader, &sfile->asset_params);
 }
+else if (sl->spacetype == SPACE_ACTION) {
+  SpaceAction *saction = (SpaceAction *)sl;
+
+  memset(&saction->runtime, 0x0, sizeof(saction->runtime));
+}
 else if (sl->spacetype == SPACE_CLIP) {
   SpaceClip *sclip = (SpaceClip *)sl;
 
diff --git a/source/blender/editors/space_action/space_action.c 
b/source/blender/editors/space_action/space_action.c
index f6af2f79890..26b087168f9 100644
--- a/source/blender/editors/space_action/space_action.c
+++ b/source/blender/editors/space_action/space_action.c
@@ -153,6 +153,8 @@ static SpaceLink *action_duplicate(SpaceLink *sl)
 {
   SpaceAction *sactionn = MEM_dupallocN(sl);
 
+  memset(&sactionn->runtime, 0x0, sizeof(sactionn->runtime));
+
   /* clear or remove stuff from old */
 
   return (SpaceLink *)sactionn;
diff --git a/source/blender/editors/space_graph/space_graph.c 
b/source/blender/editors/space_graph/space_graph.c
index 9f01773eadf..0c6d904de01 100644
--- a/source/blender/editors/space_graph/space_graph.c
+++ b/source/blender/editors/space_graph/space_graph.c
@@ -172,6 +172,8 @@ static SpaceLink *graph_duplicate(SpaceLink *sl)
 {
   SpaceGraph *sipon = MEM_dupallocN(sl);
 
+  memset(&sipon->r

[Bf-blender-cvs] [5dc0fd08a70] master: Cleanup: correct incomplete comment

2021-06-14 Thread Campbell Barton
Commit: 5dc0fd08a70b123e5d17057e1cbc1462bef0d8d8
Author: Campbell Barton
Date:   Tue Jun 15 10:59:31 2021 +1000
Branches: master
https://developer.blender.org/rB5dc0fd08a70b123e5d17057e1cbc1462bef0d8d8

Cleanup: correct incomplete comment

===

M   source/blender/draw/engines/gpencil/gpencil_shader_fx.c

===

diff --git a/source/blender/draw/engines/gpencil/gpencil_shader_fx.c 
b/source/blender/draw/engines/gpencil/gpencil_shader_fx.c
index 21d55357a2a..315133186da 100644
--- a/source/blender/draw/engines/gpencil/gpencil_shader_fx.c
+++ b/source/blender/draw/engines/gpencil/gpencil_shader_fx.c
@@ -397,7 +397,7 @@ static void gpencil_vfx_shadow(ShadowShaderFxData *fx, 
Object *ob, gpIterVfxData
   unit_m4(uv_mat);
   zero_v2(wave_ofs);
 
-  /* We reset the uv_mat so we need to account for the rotation in the  */
+  /* Reset the `uv_mat` to account for rotation in the Y-axis (Shadow-V 
parameter). */
   copy_v2_fl2(tmp, 0.0f, blur_size[1]);
   rotate_v2_v2fl(blur_dir, tmp, -fx->rotation);
   mul_v2_v2(blur_dir, vp_size_inv);

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


[Bf-blender-cvs] [013fc69ea8f] master: Cleanup: unused argument & variable warnings

2021-06-14 Thread Campbell Barton
Commit: 013fc69ea8feba0dfcb35ae6b8f5207753af3202
Author: Campbell Barton
Date:   Tue Jun 15 10:44:08 2021 +1000
Branches: master
https://developer.blender.org/rB013fc69ea8feba0dfcb35ae6b8f5207753af3202

Cleanup: unused argument & variable warnings

===

M   release/scripts/modules/bl_i18n_utils/utils.py
M   release/scripts/modules/bl_i18n_utils/utils_cli.py
M   release/scripts/modules/bl_i18n_utils/utils_rtl.py
M   release/scripts/modules/keyingsets_utils.py
M   release/scripts/startup/bl_app_templates_system/2D_Animation/__init__.py
M   release/scripts/startup/bl_app_templates_system/Sculpting/__init__.py
M   
release/scripts/startup/bl_app_templates_system/Video_Editing/__init__.py
M   release/scripts/startup/bl_ui/space_userpref.py
M   release/scripts/startup/bl_ui/space_view3d.py
M   release/scripts/startup/keyingsets_builtins.py
M   release/scripts/startup/nodeitems_builtins.py

===

diff --git a/release/scripts/modules/bl_i18n_utils/utils.py 
b/release/scripts/modules/bl_i18n_utils/utils.py
index b17c9eeebc5..f63b6990cdd 100644
--- a/release/scripts/modules/bl_i18n_utils/utils.py
+++ b/release/scripts/modules/bl_i18n_utils/utils.py
@@ -1572,7 +1572,7 @@ class I18n:
 if not os.path.isfile(dst):
 print("WARNING: trying to write as python code into {}, which 
is not a file! Aborting.".format(dst))
 return
-prev, txt, nxt, has_trans = self._parser_check_file(dst)
+prev, txt, nxt, _has_trans = self._parser_check_file(dst)
 if prev is None and nxt is None:
 print("WARNING: Looks like given python file {} has no 
auto-generated translations yet, will be added "
   "at the end of the file, you can move that section later 
if needed...".format(dst))
diff --git a/release/scripts/modules/bl_i18n_utils/utils_cli.py 
b/release/scripts/modules/bl_i18n_utils/utils_cli.py
index 76dd8a740c5..d3750d5e9a4 100644
--- a/release/scripts/modules/bl_i18n_utils/utils_cli.py
+++ b/release/scripts/modules/bl_i18n_utils/utils_cli.py
@@ -71,7 +71,7 @@ def rtl_process_po(args, settings):
 po.write(kind="PO", dest=args.dst)
 
 
-def language_menu(args, settings):
+def language_menu(_args, settings):
 # 'DEFAULT' and en_US are always valid, fully-translated "languages"!
 stats = {"DEFAULT": 1.0, "en_US": 1.0}
 
diff --git a/release/scripts/modules/bl_i18n_utils/utils_rtl.py 
b/release/scripts/modules/bl_i18n_utils/utils_rtl.py
index 8da1417c468..4b874efa2da 100755
--- a/release/scripts/modules/bl_i18n_utils/utils_rtl.py
+++ b/release/scripts/modules/bl_i18n_utils/utils_rtl.py
@@ -84,10 +84,10 @@ def protect_format_seq(msg):
 #LRM = "\u200E"
 #RLM = "\u200F"
 LRE = "\u202A"
-RLE = "\u202B"
+#RLE = "\u202B"
 PDF = "\u202C"
 LRO = "\u202D"
-RLO = "\u202E"
+#RLO = "\u202E"
 # uctrl = {LRE, RLE, PDF, LRO, RLO}
 # Most likely incomplete, but seems to cover current needs.
 format_codes = set("tslfd")
diff --git a/release/scripts/modules/keyingsets_utils.py 
b/release/scripts/modules/keyingsets_utils.py
index b7a15bbbc19..de0b1435803 100644
--- a/release/scripts/modules/keyingsets_utils.py
+++ b/release/scripts/modules/keyingsets_utils.py
@@ -240,7 +240,7 @@ def RKS_GEN_custom_props(_ksi, _context, ks, data):
 prop_path = '["%s"]' % bpy.utils.escape_identifier(cprop_name)
 try:
 rna_property = data.path_resolve(prop_path, False)
-except ValueError as ex:
+except ValueError:
 # This happens when a custom property is set to None. In that case 
it cannot
 # be converted to an FCurve-compatible value, so we can't keyframe 
it anyway.
 continue
diff --git 
a/release/scripts/startup/bl_app_templates_system/2D_Animation/__init__.py 
b/release/scripts/startup/bl_app_templates_system/2D_Animation/__init__.py
index 192ba2cf5b5..40dd0729fec 100644
--- a/release/scripts/startup/bl_app_templates_system/2D_Animation/__init__.py
+++ b/release/scripts/startup/bl_app_templates_system/2D_Animation/__init__.py
@@ -23,7 +23,7 @@ from bpy.app.handlers import persistent
 
 
 @persistent
-def load_handler(dummy):
+def load_handler(_):
 import bpy
 
 # 2D Animation
diff --git 
a/release/scripts/startup/bl_app_templates_system/Sculpting/__init__.py 
b/release/scripts/startup/bl_app_templates_system/Sculpting/__init__.py
index 4d1361ed22a..ef085bcd688 100644
--- a/release/scripts/startup/bl_app_templates_system/Sculpting/__init__.py
+++ b/release/scripts/startup/bl_app_templates_system/Sculpting/__init__.py
@@ -21,7 +21,7 @@ from bpy.app.handlers import persistent
 
 
 @persistent
-def load_handler(dummy):
+def load_handler(_):
 import bpy
 # Apply subdivision modifier on startup
 bpy.ops.object.mode_set(mode='OBJECT')
diff -

[Bf-blender-cvs] [2053e1f533b] master: Fix image space missing mask display panel

2021-06-14 Thread Campbell Barton
Commit: 2053e1f533b3772f38a19426f22d5c5e10c6bafb
Author: Campbell Barton
Date:   Tue Jun 15 10:50:48 2021 +1000
Branches: master
https://developer.blender.org/rB2053e1f533b3772f38a19426f22d5c5e10c6bafb

Fix image space missing mask display panel

===

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

===

diff --git a/release/scripts/startup/bl_ui/space_image.py 
b/release/scripts/startup/bl_ui/space_image.py
index 11eaf55a98b..3fafa328289 100644
--- a/release/scripts/startup/bl_ui/space_image.py
+++ b/release/scripts/startup/bl_ui/space_image.py
@@ -914,6 +914,12 @@ class IMAGE_PT_active_mask_point(MASK_PT_point, Panel):
 bl_category = "Mask"
 
 
+class IMAGE_PT_mask_display(MASK_PT_display, Panel):
+bl_space_type = 'IMAGE_EDITOR'
+bl_region_type = 'UI'
+bl_category = "Mask"
+
+
 # --- end mask ---
 
 class IMAGE_PT_snapping(Panel):
@@ -1616,6 +1622,7 @@ classes = (
 IMAGE_PT_active_tool,
 IMAGE_PT_mask,
 IMAGE_PT_mask_layers,
+IMAGE_PT_mask_display,
 IMAGE_PT_active_mask_spline,
 IMAGE_PT_active_mask_point,
 IMAGE_PT_snapping,

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


[Bf-blender-cvs] [4ae06b61230] master: Cleanup: remove "_" prefix for used arguments

2021-06-14 Thread Campbell Barton
Commit: 4ae06b61230dea251326b014be2002f894970246
Author: Campbell Barton
Date:   Tue Jun 15 10:49:46 2021 +1000
Branches: master
https://developer.blender.org/rB4ae06b61230dea251326b014be2002f894970246

Cleanup: remove "_" prefix for used arguments

===

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

===

diff --git a/release/scripts/startup/bl_ui/space_dopesheet.py 
b/release/scripts/startup/bl_ui/space_dopesheet.py
index e7893b8c448..ffb7b9e5c20 100644
--- a/release/scripts/startup/bl_ui/space_dopesheet.py
+++ b/release/scripts/startup/bl_ui/space_dopesheet.py
@@ -594,9 +594,9 @@ class DOPESHEET_MT_delete(Menu):
 class DOPESHEET_MT_context_menu(Menu):
 bl_label = "Dope Sheet Context Menu"
 
-def draw(self, _context):
+def draw(self, context):
 layout = self.layout
-st = _context.space_data
+st = context.space_data
 
 layout.operator_context = 'INVOKE_DEFAULT'

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


[Bf-blender-cvs] [9ce49af32e1] master: Cleanup: use doxygen comments for DNA_color_types

2021-06-14 Thread Campbell Barton
Commit: 9ce49af32e1c9dab360317443b5e60cf114af57a
Author: Campbell Barton
Date:   Tue Jun 15 09:33:57 2021 +1000
Branches: master
https://developer.blender.org/rB9ce49af32e1c9dab360317443b5e60cf114af57a

Cleanup: use doxygen comments for DNA_color_types

Also use enum instead of defines for Scopes.wavefrm_mode

===

M   source/blender/makesdna/DNA_color_types.h

===

diff --git a/source/blender/makesdna/DNA_color_types.h 
b/source/blender/makesdna/DNA_color_types.h
index e4f6a1eea41..debf2c3475e 100644
--- a/source/blender/makesdna/DNA_color_types.h
+++ b/source/blender/makesdna/DNA_color_types.h
@@ -43,7 +43,7 @@ typedef struct CurveMapPoint {
   short flag, shorty;
 } CurveMapPoint;
 
-/* curvepoint->flag */
+/** #CurveMapPoint.flag */
 enum {
   CUMA_SELECT = (1 << 0),
   CUMA_HANDLE_VECTOR = (1 << 1),
@@ -95,19 +95,18 @@ typedef struct CurveMapping {
   char _pad[6];
 } CurveMapping;
 
-/* CurveMapping.flag */
+/** #CurveMapping.flag */
 typedef enum eCurveMappingFlags {
   CUMA_DO_CLIP = (1 << 0),
   CUMA_PREMULLED = (1 << 1),
   CUMA_DRAW_CFRA = (1 << 2),
   CUMA_DRAW_SAMPLE = (1 << 3),
 
-  /* The curve is extended by extrapolation. When not set the curve is extended
-   * Horizontally */
+  /** The curve is extended by extrapolation. When not set the curve is 
extended horizontally. */
   CUMA_EXTEND_EXTRAPOLATE = (1 << 4),
 } eCurveMappingFlags;
 
-/* cumapping->preset */
+/** #CurveMapping.preset */
 typedef enum eCurveMappingPreset {
   CURVE_PRESET_LINE = 0,
   CURVE_PRESET_SHARP = 1,
@@ -120,13 +119,13 @@ typedef enum eCurveMappingPreset {
   CURVE_PRESET_BELL = 8,
 } eCurveMappingPreset;
 
-/* CurveMapping->tone */
+/** #CurveMapping.tone */
 typedef enum eCurveMappingTone {
   CURVE_TONE_STANDARD = 0,
   CURVE_TONE_FILMLIKE = 2,
 } eCurveMappingTone;
 
-/* histogram->mode */
+/** #Histogram.mode */
 enum {
   HISTO_MODE_LUMA = 0,
   HISTO_MODE_RGB = 1,
@@ -154,8 +153,7 @@ typedef struct Histogram {
   short flag;
   int height;
 
-  /* sample line only */
-  /* image coords src -> dst */
+  /** Sample line only (image coords: source -> destination). */
   float co[2][2];
 } Histogram;
 
@@ -180,13 +178,15 @@ typedef struct Scopes {
   char _pad[4];
 } Scopes;
 
-/* scopes->wavefrm_mode */
-#define SCOPES_WAVEFRM_LUMA 0
-#define SCOPES_WAVEFRM_RGB_PARADE 1
-#define SCOPES_WAVEFRM_YCC_601 2
-#define SCOPES_WAVEFRM_YCC_709 3
-#define SCOPES_WAVEFRM_YCC_JPEG 4
-#define SCOPES_WAVEFRM_RGB 5
+/** #Scopes.wavefrm_mode */
+enum {
+  SCOPES_WAVEFRM_LUMA = 0,
+  SCOPES_WAVEFRM_RGB_PARADE = 1,
+  SCOPES_WAVEFRM_YCC_601 = 2,
+  SCOPES_WAVEFRM_YCC_709 = 3,
+  SCOPES_WAVEFRM_YCC_JPEG = 4,
+  SCOPES_WAVEFRM_RGB = 5,
+};
 
 typedef struct ColorManagedViewSettings {
   int flag;
@@ -214,7 +214,7 @@ typedef struct ColorManagedColorspaceSettings {
   char name[64];
 } ColorManagedColorspaceSettings;
 
-/* ColorManagedViewSettings->flag */
+/** #ColorManagedViewSettings.flag */
 enum {
   COLORMANAGE_VIEW_USE_CURVES = (1 << 0),
 };

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


[Bf-blender-cvs] [3bf98d1cec1] master: Cleanup: use private methods for internal operator utilities

2021-06-14 Thread Campbell Barton
Commit: 3bf98d1cec1821749c986288508b4fb787a32633
Author: Campbell Barton
Date:   Tue Jun 15 10:08:57 2021 +1000
Branches: master
https://developer.blender.org/rB3bf98d1cec1821749c986288508b4fb787a32633

Cleanup: use private methods for internal operator utilities

Also remove unused argument.

===

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

===

diff --git a/release/scripts/startup/bl_operators/node.py 
b/release/scripts/startup/bl_operators/node.py
index 6150789ea10..3cefaf6929b 100644
--- a/release/scripts/startup/bl_operators/node.py
+++ b/release/scripts/startup/bl_operators/node.py
@@ -331,14 +331,15 @@ class NODE_OT_active_preview_toggle(Operator):
 active_node = ntree.nodes.active
 
 if active_node.active_preview:
-self.disable_preview(context, ntree, active_node)
+self._disable_preview(context, active_node)
 else:
-self.enable_preview(context, node_editor, ntree, active_node)
+self._enable_preview(context, node_editor, ntree, active_node)
 
 return {'FINISHED'}
 
-def enable_preview(self, context, node_editor, ntree, active_node):
-spreadsheets = self.find_unpinned_spreadsheets(context)
+@classmethod
+def _enable_preview(cls, context, node_editor, ntree, active_node):
+spreadsheets = cls._find_unpinned_spreadsheets(context)
 
 for spreadsheet in spreadsheets:
 spreadsheet.set_geometry_node_context(node_editor, active_node)
@@ -347,14 +348,16 @@ class NODE_OT_active_preview_toggle(Operator):
 node.active_preview = False
 active_node.active_preview = True
 
-def disable_preview(self, context, ntree, active_node):
-spreadsheets = self.find_unpinned_spreadsheets(context)
+@classmethod
+def _disable_preview(cls, context, active_node):
+spreadsheets = cls._find_unpinned_spreadsheets(context)
 for spreadsheet in spreadsheets:
 spreadsheet.context_path.clear()
 
 active_node.active_preview = False
 
-def find_unpinned_spreadsheets(self, context):
+@staticmethod
+def _find_unpinned_spreadsheets(context):
 spreadsheets = []
 for window in context.window_manager.windows:
 for area in window.screen.areas:

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


[Bf-blender-cvs] [1f251b7a27d] master: Win8 cleanup, remove dead function pointer and macro.

2021-06-14 Thread Nicholas Rishel
Commit: 1f251b7a27dfbcb0ff3e716b270a1c8869c8664d
Author: Nicholas Rishel
Date:   Thu Mar 4 15:48:48 2021 -0800
Branches: master
https://developer.blender.org/rB1f251b7a27dfbcb0ff3e716b270a1c8869c8664d

Win8 cleanup, remove dead function pointer and macro.

===

M   intern/ghost/intern/GHOST_SystemWin32.cpp
M   intern/ghost/intern/GHOST_WindowWin32.h

===

diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp 
b/intern/ghost/intern/GHOST_SystemWin32.cpp
index c3a243cc22c..45b9e88f884 100644
--- a/intern/ghost/intern/GHOST_SystemWin32.cpp
+++ b/intern/ghost/intern/GHOST_SystemWin32.cpp
@@ -139,7 +139,6 @@ static void initRawInput()
 #undef DEVICE_COUNT
 }
 
-typedef HRESULT(API 
*GHOST_WIN32_SetProcessDpiAwareness)(PROCESS_DPI_AWARENESS);
 typedef BOOL(API *GHOST_WIN32_EnableNonClientDpiScaling)(HWND);
 
 GHOST_SystemWin32::GHOST_SystemWin32()
diff --git a/intern/ghost/intern/GHOST_WindowWin32.h 
b/intern/ghost/intern/GHOST_WindowWin32.h
index a13bd876667..c261dffc578 100644
--- a/intern/ghost/intern/GHOST_WindowWin32.h
+++ b/intern/ghost/intern/GHOST_WindowWin32.h
@@ -55,9 +55,6 @@ typedef BOOL(API *GHOST_WIN32_WTOverlap)(HCTX, BOOL);
 
 // typedefs for user32 functions to allow dynamic loading of Windows 10 DPI 
scaling functions
 typedef UINT(API *GHOST_WIN32_GetDpiForWindow)(HWND);
-#ifndef USER_DEFAULT_SCREEN_DPI
-#  define USER_DEFAULT_SCREEN_DPI 96
-#endif  // USER_DEFAULT_SCREEN_DPI
 
 struct GHOST_PointerInfoWin32 {
   GHOST_TInt32 pointerId;

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


[Bf-blender-cvs] [61fdc450342] master: Geometry Nodes: Join dynamic curve attributes in the join geometry node

2021-06-14 Thread Hans Goudey
Commit: 61fdc450342e28007faea2e1696afc2ff034d6b9
Author: Hans Goudey
Date:   Mon Jun 14 15:13:43 2021 -0500
Branches: master
https://developer.blender.org/rB61fdc450342e28007faea2e1696afc2ff034d6b9

Geometry Nodes: Join dynamic curve attributes in the join geometry node

This commit lets the join geometry node transfer dynamic attributes
to the result, the same way that point cloud and mesh attributes are
joined. The implementation is different though, because of an
optimization implemented for curves to avoid copying splines.

The result attribute is added with the highest priority domain (points
over splines), and the highest complexity data type. If one curve had
the attribute on the spline domain but not others, the point domain
values will be used.

Generally this is a bit lower level than I would have liked this code
to be, but should be efficient, and it's really not too complicated.

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

===

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

===

diff --git a/source/blender/nodes/geometry/nodes/node_geo_join_geometry.cc 
b/source/blender/nodes/geometry/nodes/node_geo_join_geometry.cc
index 66199769586..8bcd7d69bc5 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_join_geometry.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_join_geometry.cc
@@ -23,8 +23,12 @@
 #include "DNA_mesh_types.h"
 #include "DNA_meshdata_types.h"
 
+#include "NOD_type_conversions.hh"
+
 #include "node_geometry_util.hh"
 
+using blender::fn::GVArray_For_GSpan;
+
 static bNodeSocketTemplate geo_node_join_geometry_in[] = {
 {SOCK_GEOMETRY,
  N_("Geometry"),
@@ -298,6 +302,127 @@ static void join_components(Span 
src_components, Geomet
   UNUSED_VARS(src_components, dst_component);
 }
 
+/**
+ * \note This takes advantage of the fact that creating attributes on joined 
curves never
+ * changes a point attribute into a spline attribute; it is always the other 
way around.
+ */
+static void ensure_control_point_attribute(const StringRef name,
+   const CustomDataType data_type,
+   Span 
src_components,
+   CurveEval &result)
+{
+  MutableSpan splines = result.splines();
+  const CPPType &type = *bke::custom_data_type_to_cpp_type(data_type);
+
+  /* In order to fill point attributes with spline domain attribute values 
where necessary, keep
+   * track of the curve each spline came from while iterating over the splines 
in the result. */
+  int src_component_index = 0;
+  int spline_index_in_component = 0;
+  const CurveEval *current_curve = 
src_components[src_component_index]->get_for_read();
+
+  for (SplinePtr &spline : splines) {
+std::optional attribute = spline->attributes.get_for_read(name);
+
+if (attribute) {
+  if (attribute->type() != type) {
+/* In this case, the attribute exists, but it has the wrong type. So 
create a buffer
+ * for the converted values, do the conversion, and then replace the 
attribute. */
+void *converted_buffer = MEM_mallocN_aligned(
+spline->size() * type.size(), type.alignment(), __func__);
+
+const DataTypeConversions &conversions = 
blender::nodes::get_implicit_type_conversions();
+
conversions.try_convert(std::make_unique(*attribute), type)
+->materialize(converted_buffer);
+
+spline->attributes.remove(name);
+spline->attributes.create_by_move(name, data_type, converted_buffer);
+  }
+}
+else {
+  spline->attributes.create(name, data_type);
+
+  if (current_curve->attributes.get_for_read(name)) {
+/* In this case the attribute did not exist, but there is a spline 
domain attribute
+ * we can retrieve a value from, as a spline to point domain 
conversion. So fill the
+ * new attribute with the value for this spline. */
+GVArrayPtr current_curve_attribute = 
current_curve->attributes.get_for_read(
+name, data_type, nullptr);
+
+BLI_assert(spline->attributes.get_for_read(name));
+std::optional new_attribute = 
spline->attributes.get_for_write(name);
+
+BUFFER_FOR_CPP_TYPE_VALUE(type, buffer);
+current_curve_attribute->get(spline_index_in_component, buffer);
+type.fill_initialized(buffer, new_attribute->data(), 
new_attribute->size());
+  }
+}
+
+/* Move to the next spline and maybe the next input component. */
+spline_index_in_component++;
+if (spline != splines.last() && spline_index_in_component >= 
current_curve->splines().size()) {
+  src_component_index++;
+  spline_index_in_component = 0;
+
+  current_curve = src_components[src_component_index]->get_for_read();
+}
+  }
+}
+
+/**
+ * Fill data for an attribute on the ne

[Bf-blender-cvs] [bf7f918a0ef] master: Geometry Nodes: Parallelize curve reverse node

2021-06-14 Thread Hans Goudey
Commit: bf7f918a0ef7144f1015905fae22203528cc9100
Author: Hans Goudey
Date:   Mon Jun 14 14:28:57 2021 -0500
Branches: master
https://developer.blender.org/rBbf7f918a0ef7144f1015905fae22203528cc9100

Geometry Nodes: Parallelize curve reverse node

Each spline can be handled separately here. This gives approximately a
2x speedup on my 8 core processor on an input of 8 2 point splines.

===

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

===

diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_reverse.cc 
b/source/blender/nodes/geometry/nodes/node_geo_curve_reverse.cc
index f268f3f7ff1..47704df5b92 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_curve_reverse.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_curve_reverse.cc
@@ -14,6 +14,8 @@
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
+#include "BLI_task.hh"
+
 #include "BKE_spline.hh"
 
 #include "node_geometry_util.hh"
@@ -74,44 +76,46 @@ static void geo_node_curve_reverse_exec(GeoNodeExecParams 
params)
   GVArray_Typed selection = curve_component.attribute_get_for_read(
   selection_name, ATTR_DOMAIN_CURVE, true);
 
-  for (const int i : splines.index_range()) {
-if (!selection[i]) {
-  continue;
-}
-
-reverse_data(splines[i]->positions());
-reverse_data(splines[i]->radii());
-reverse_data(splines[i]->tilts());
-
-splines[i]->attributes.foreach_attribute(
-[&](StringRefNull name, const AttributeMetaData &meta_data) {
-  std::optional output_attribute =
-  splines[i]->attributes.get_for_write(name);
-  if (!output_attribute) {
-BLI_assert_unreachable();
-return false;
-  }
-  attribute_math::convert_to_static_type(meta_data.data_type, [&](auto 
dummy) {
-using T = decltype(dummy);
-reverse_data(output_attribute->typed());
-  });
-  return true;
-},
-ATTR_DOMAIN_POINT);
-
-/* Deal with extra info on derived types. */
-if (BezierSpline *spline = dynamic_cast(splines[i].get())) 
{
-  reverse_data(spline->handle_types_left());
-  reverse_data(spline->handle_types_right());
-  reverse_data(spline->handle_positions_left(), 
spline->handle_positions_right());
+  parallel_for(splines.index_range(), 128, [&](IndexRange range) {
+for (const int i : range) {
+  if (!selection[i]) {
+continue;
+  }
+
+  reverse_data(splines[i]->positions());
+  reverse_data(splines[i]->radii());
+  reverse_data(splines[i]->tilts());
+
+  splines[i]->attributes.foreach_attribute(
+  [&](StringRefNull name, const AttributeMetaData &meta_data) {
+std::optional output_attribute =
+splines[i]->attributes.get_for_write(name);
+if (!output_attribute) {
+  BLI_assert_unreachable();
+  return false;
+}
+attribute_math::convert_to_static_type(meta_data.data_type, 
[&](auto dummy) {
+  using T = decltype(dummy);
+  reverse_data(output_attribute->typed());
+});
+return true;
+  },
+  ATTR_DOMAIN_POINT);
+
+  /* Deal with extra info on derived types. */
+  if (BezierSpline *spline = dynamic_cast(splines[i].get())) {
+reverse_data(spline->handle_types_left());
+reverse_data(spline->handle_types_right());
+reverse_data(spline->handle_positions_left(), 
spline->handle_positions_right());
+  }
+  else if (NURBSpline *spline = dynamic_cast(splines[i].get())) {
+reverse_data(spline->weights());
+  }
+  /* Nothing to do for poly splines. */
+
+  splines[i]->mark_cache_invalid();
 }
-else if (NURBSpline *spline = dynamic_cast(splines[i].get())) {
-  reverse_data(spline->weights());
-}
-/* Nothing to do for poly splines. */
-
-splines[i]->mark_cache_invalid();
-  }
+  });
 
   params.set_output("Curve", geometry_set);
 }

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


[Bf-blender-cvs] [fe0fa7cec66] master: Cleanup: Refactor join geometry node attribute gathering

2021-06-14 Thread Hans Goudey
Commit: fe0fa7cec66bc38e1bdd617b3e4012aef13c6bf9
Author: Hans Goudey
Date:   Mon Jun 14 13:58:02 2021 -0500
Branches: master
https://developer.blender.org/rBfe0fa7cec66bc38e1bdd617b3e4012aef13c6bf9

Cleanup: Refactor join geometry node attribute gathering

Instead of building a set and then determining the final domain and
type for every attribute separately in the loop, construct a map with
the necessary data in the first place. This is simpler and should be
slightly more efficient.

Split from D11491

===

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

===

diff --git a/source/blender/nodes/geometry/nodes/node_geo_join_geometry.cc 
b/source/blender/nodes/geometry/nodes/node_geo_join_geometry.cc
index adfd924f185..66199769586 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_join_geometry.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_join_geometry.cc
@@ -157,35 +157,30 @@ static Array 
to_base_components(Span find_all_attribute_names(Span components)
+static Map get_final_attribute_info(
+Span components, Span 
ignored_attributes)
 {
-  Set attribute_names;
-  for (const GeometryComponent *component : components) {
-Set names = component->attribute_names();
-for (const std::string &name : names) {
-  attribute_names.add(name);
-}
-  }
-  return attribute_names;
-}
+  Map info;
 
-static void determine_final_data_type_and_domain(Span components,
- StringRef attribute_name,
- CustomDataType *r_type,
- AttributeDomain *r_domain)
-{
-  Vector data_types;
-  Vector domains;
   for (const GeometryComponent *component : components) {
-ReadAttributeLookup attribute = 
component->attribute_try_get_for_read(attribute_name);
-if (attribute) {
-  
data_types.append(bke::cpp_type_to_custom_data_type(attribute.varray->type()));
-  domains.append(attribute.domain);
-}
+component->attribute_foreach([&](StringRefNull name, const 
AttributeMetaData &meta_data) {
+  if (ignored_attributes.contains(name)) {
+return true;
+  }
+  info.add_or_modify(
+  name,
+  [&](AttributeMetaData *meta_data_final) { *meta_data_final = 
meta_data; },
+  [&](AttributeMetaData *meta_data_final) {
+meta_data_final->data_type = 
blender::bke::attribute_data_type_highest_complexity(
+{meta_data_final->data_type, meta_data.data_type});
+meta_data_final->domain = 
blender::bke::attribute_domain_highest_priority(
+{meta_data_final->domain, meta_data.domain});
+  });
+  return true;
+});
   }
 
-  *r_type = bke::attribute_data_type_highest_complexity(data_types);
-  *r_domain = bke::attribute_domain_highest_priority(domains);
+  return info;
 }
 
 static void fill_new_attribute(Span src_components,
@@ -219,23 +214,20 @@ static void join_attributes(Span src_components,
 GeometryComponent &result,
 Span ignored_attributes = {})
 {
-  Set attribute_names = find_all_attribute_names(src_components);
-  for (StringRef name : ignored_attributes) {
-attribute_names.remove(name);
-  }
+  const Map info = 
get_final_attribute_info(src_components,
+
ignored_attributes);
 
-  for (const std::string &attribute_name : attribute_names) {
-CustomDataType data_type;
-AttributeDomain domain;
-determine_final_data_type_and_domain(src_components, attribute_name, 
&data_type, &domain);
+  for (const Map::Item &item : info.items()) {
+const StringRef name = item.key;
+const AttributeMetaData &meta_data = item.value;
 
 OutputAttribute write_attribute = result.attribute_try_get_for_output_only(
-attribute_name, domain, data_type);
+name, meta_data.domain, meta_data.data_type);
 if (!write_attribute) {
   continue;
 }
 GMutableSpan dst_span = write_attribute.as_span();
-fill_new_attribute(src_components, attribute_name, data_type, domain, 
dst_span);
+fill_new_attribute(src_components, name, meta_data.data_type, 
meta_data.domain, dst_span);
 write_attribute.save();
   }
 }

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


[Bf-blender-cvs] [85defa5e2c5] wintab-high-frequency: Refactor of Wintab to use Wintab supplied mouse movement once verified against system input.

2021-06-14 Thread Nicholas Rishel
Commit: 85defa5e2c5d4ef15a1ade1d052fcded501fbc39
Author: Nicholas Rishel
Date:   Thu Mar 4 15:48:48 2021 -0800
Branches: wintab-high-frequency
https://developer.blender.org/rB85defa5e2c5d4ef15a1ade1d052fcded501fbc39

Refactor of Wintab to use Wintab supplied mouse movement once verified against 
system input.

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

===

M   intern/ghost/CMakeLists.txt
M   intern/ghost/intern/GHOST_System.h
M   intern/ghost/intern/GHOST_SystemWin32.cpp
M   intern/ghost/intern/GHOST_SystemWin32.h
M   intern/ghost/intern/GHOST_WindowWin32.cpp
M   intern/ghost/intern/GHOST_WindowWin32.h
A   intern/ghost/intern/GHOST_Wintab.cpp
A   intern/ghost/intern/GHOST_Wintab.h

===

diff --git a/intern/ghost/CMakeLists.txt b/intern/ghost/CMakeLists.txt
index 1b5cdb3cda0..40d78a22e6f 100644
--- a/intern/ghost/CMakeLists.txt
+++ b/intern/ghost/CMakeLists.txt
@@ -370,6 +370,7 @@ elseif(WIN32)
 intern/GHOST_DropTargetWin32.cpp
 intern/GHOST_SystemWin32.cpp
 intern/GHOST_WindowWin32.cpp
+intern/GHOST_Wintab.cpp
 
 intern/GHOST_ContextD3D.h
 intern/GHOST_DisplayManagerWin32.h
@@ -377,6 +378,7 @@ elseif(WIN32)
 intern/GHOST_SystemWin32.h
 intern/GHOST_TaskbarWin32.h
 intern/GHOST_WindowWin32.h
+intern/GHOST_Wintab.h
   )
 
   if(NOT WITH_GL_EGL)
diff --git a/intern/ghost/intern/GHOST_System.h 
b/intern/ghost/intern/GHOST_System.h
index 2a7123b293e..9915520691f 100644
--- a/intern/ghost/intern/GHOST_System.h
+++ b/intern/ghost/intern/GHOST_System.h
@@ -239,7 +239,7 @@ class GHOST_System : public GHOST_ISystem {
* Set which tablet API to use. Only affects Windows, other platforms have a 
single API.
* \param api: Enum indicating which API to use.
*/
-  void setTabletAPI(GHOST_TTabletAPI api);
+  virtual void setTabletAPI(GHOST_TTabletAPI api) override;
   GHOST_TTabletAPI getTabletAPI(void);
 
 #ifdef WITH_INPUT_NDOF
diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp 
b/intern/ghost/intern/GHOST_SystemWin32.cpp
index c3a243cc22c..c06f46520b3 100644
--- a/intern/ghost/intern/GHOST_SystemWin32.cpp
+++ b/intern/ghost/intern/GHOST_SystemWin32.cpp
@@ -867,15 +867,135 @@ GHOST_EventButton 
*GHOST_SystemWin32::processButtonEvent(GHOST_TEventType type,
 {
   GHOST_SystemWin32 *system = (GHOST_SystemWin32 *)getSystem();
 
-  if (type == GHOST_kEventButtonDown) {
-window->updateMouseCapture(MousePressed);
+  GHOST_TabletData td = window->getTabletData();
+
+  /* Move mouse to button event position. */
+  if (window->getTabletData().Active != GHOST_kTabletModeNone) {
+/* Tablet should be handling inbetween mouse moves, only move to event 
position. */
+DWORD msgPos = ::GetMessagePos();
+int msgPosX = GET_X_LPARAM(msgPos);
+int msgPosY = GET_Y_LPARAM(msgPos);
+system->pushEvent(new GHOST_EventCursor(
+::GetMessageTime(), GHOST_kEventCursorMove, window, msgPosX, msgPosY, 
td));
   }
-  else if (type == GHOST_kEventButtonUp) {
-window->updateMouseCapture(MouseReleased);
+
+  window->updateMouseCapture(type == GHOST_kEventButtonDown ? MousePressed : 
MouseReleased);
+  return new GHOST_EventButton(system->getMilliSeconds(), type, window, mask, 
td);
+}
+
+void GHOST_SystemWin32::processWintabEvent(GHOST_WindowWin32 *window)
+{
+  GHOST_Wintab *wt = window->getWintab();
+  if (!wt) {
+return;
+  }
+
+  GHOST_SystemWin32 *system = (GHOST_SystemWin32 *)getSystem();
+
+  std::vector wintabInfo;
+  wt->getInput(wintabInfo);
+
+  bool mouseUpdated = wt->trustCoordinates();
+
+  for (auto info : wintabInfo) {
+switch (info.type) {
+  case GHOST_kEventCursorMove: {
+if (!wt->trustCoordinates()) {
+  continue;
+}
+wt->mapWintabToSysCoordinates(info.x, info.y, info.x, info.y);
+system->pushEvent(new GHOST_EventCursor(
+info.time, GHOST_kEventCursorMove, window, info.x, info.y, 
info.tabletData));
+
+break;
+  }
+  case GHOST_kEventButtonDown: {
+/* Wintab buttons are modal, but the API does not inform us what mode 
a pressed button is
+ * in. Only issue button events if we can steal an equivalent Win32 
button event from the
+ * event queue. */
+UINT message;
+switch (info.button) {
+  case GHOST_kButtonMaskLeft:
+message = WM_LBUTTONDOWN;
+break;
+  case GHOST_kButtonMaskRight:
+message = WM_RBUTTONDOWN;
+break;
+  case GHOST_kButtonMaskMiddle:
+message = WM_MBUTTONDOWN;
+break;
+  default:
+continue;
+}
+
+MSG msg;
+if (PeekMessage(&msg, window->getHWND(), message, message, PM_NOYIELD) 
&&
+WM_QUIT != msg.message) {
+  if (wt->testCoordinates(msg.pt.x, msg.pt.y, info.x, info.y)) {
+   

[Bf-blender-cvs] [4a540b9b48c] master: Geometry Nodes: Curve Reverse Node

2021-06-14 Thread Johnny Matthews
Commit: 4a540b9b48cfd8cbb058dfd2eb86d7bcbe5a3b65
Author: Johnny Matthews
Date:   Mon Jun 14 13:28:38 2021 -0500
Branches: master
https://developer.blender.org/rB4a540b9b48cfd8cbb058dfd2eb86d7bcbe5a3b65

Geometry Nodes: Curve Reverse Node

This is an implementation of T88722. It accepts a curve object and
for each spline, reverses the order of the points and all attributes.
This is more of a foundational node to support other nodes in the
future (like curve deform)

Selection takes spline domain attributes to determine which splines
are selected. If no selection is present all splines are reversed.

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

===

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

===

diff --git a/release/scripts/startup/nodeitems_builtins.py 
b/release/scripts/startup/nodeitems_builtins.py
index 562a676907b..42c0e66aa42 100644
--- a/release/scripts/startup/nodeitems_builtins.py
+++ b/release/scripts/startup/nodeitems_builtins.py
@@ -506,6 +506,7 @@ geometry_node_categories = [
 NodeItem("GeometryNodeMeshToCurve"),
 NodeItem("GeometryNodeCurveToPoints"),
 NodeItem("GeometryNodeCurveLength"),
+NodeItem("GeometryNodeCurveReverse"),
 ]),
 GeometryNodeCategory("GEO_GEOMETRY", "Geometry", items=[
 NodeItem("GeometryNodeBoundBox"),
diff --git a/source/blender/blenkernel/BKE_node.h 
b/source/blender/blenkernel/BKE_node.h
index 9401e6a9f02..dbb0786af9d 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -1435,6 +1435,7 @@ int ntreeTexExecTree(struct bNodeTree *ntree,
 #define GEO_NODE_SELECT_BY_MATERIAL 1055
 #define GEO_NODE_CONVEX_HULL 1056
 #define GEO_NODE_CURVE_TO_POINTS 1057
+#define GEO_NODE_CURVE_REVERSE 1058
 
 /** \} */
 
diff --git a/source/blender/blenkernel/intern/node.cc 
b/source/blender/blenkernel/intern/node.cc
index 06d70869386..c247b808a4a 100644
--- a/source/blender/blenkernel/intern/node.cc
+++ b/source/blender/blenkernel/intern/node.cc
@@ -5057,6 +5057,7 @@ static void registerGeometryNodes()
   register_node_type_geo_curve_to_mesh();
   register_node_type_geo_curve_to_points();
   register_node_type_geo_curve_resample();
+  register_node_type_geo_curve_reverse();
   register_node_type_geo_delete_geometry();
   register_node_type_geo_edge_split();
   register_node_type_geo_input_material();
diff --git a/source/blender/nodes/CMakeLists.txt 
b/source/blender/nodes/CMakeLists.txt
index fe705f18fca..9d7c50c99cd 100644
--- a/source/blender/nodes/CMakeLists.txt
+++ b/source/blender/nodes/CMakeLists.txt
@@ -167,6 +167,7 @@ set(SRC
   geometry/nodes/node_geo_curve_to_mesh.cc
   geometry/nodes/node_geo_curve_to_points.cc
   geometry/nodes/node_geo_curve_resample.cc
+  geometry/nodes/node_geo_curve_reverse.cc
   geometry/nodes/node_geo_delete_geometry.cc
   geometry/nodes/node_geo_edge_split.cc
   geometry/nodes/node_geo_input_material.cc
diff --git a/source/blender/nodes/NOD_geometry.h 
b/source/blender/nodes/NOD_geometry.h
index 1995a42731e..eb3867af155 100644
--- a/source/blender/nodes/NOD_geometry.h
+++ b/source/blender/nodes/NOD_geometry.h
@@ -55,6 +55,7 @@ void register_node_type_geo_curve_length(void);
 void register_node_type_geo_curve_to_mesh(void);
 void register_node_type_geo_curve_to_points(void);
 void register_node_type_geo_curve_resample(void);
+void register_node_type_geo_curve_reverse(void);
 void register_node_type_geo_delete_geometry(void);
 void register_node_type_geo_edge_split(void);
 void register_node_type_geo_input_material(void);
diff --git a/source/blender/nodes/NOD_static_types.h 
b/source/blender/nodes/NOD_static_types.h
index edf516b7388..8ae1fab87ff 100644
--- a/source/blender/nodes/NOD_static_types.h
+++ b/source/blender/nodes/NOD_static_types.h
@@ -293,6 +293,7 @@ DefNode(GeometryNode, GEO_NODE_CONVEX_HULL, 0, 
"CONVEX_HULL", ConvexHull, "Conve
 DefNode(GeometryNode, GEO_NODE_CURVE_LENGTH, 0, "CURVE_LENGTH", CurveLength, 
"Curve Length", "")
 DefNode(GeometryNode, GEO_NODE_CURVE_RESAMPLE, def_geo_curve_resample, 
"CURVE_RESAMPLE", CurveResample, "Resample Curve", "")
 DefNode(GeometryNode, GEO_NODE_CURVE_TO_MESH, 0, "CURVE_TO_MESH", CurveToMesh, 
"Curve to Mesh", "")
+DefNode(GeometryNode, GEO_NODE_CURVE_REVERSE, 0, "CURVE_REVERSE", 
CurveReverse, "Curve Reverse", "")
 DefNode(GeometryNode, GEO_NODE_CURVE_TO_POINTS, def_geo_curve_to_points, 
"CURVE_TO_POINTS", CurveToPoints, "Curve to Points", "")
 DefNode(GeometryNode, GEO_NODE_DELETE_GEOMETRY, 0, "DELETE_GEOMETRY", 
DeleteGeometry, "Delete Geometry", "")
 DefNode(Geometr

[Bf-blender-cvs] [897ed456751] asset-browser-poselib: Cleanup: Move temporary ID consumer class for assets into own file

2021-06-14 Thread Julian Eisel
Commit: 897ed45675106bb5c2742df8bdaf0574d0b70559
Author: Julian Eisel
Date:   Mon Jun 14 20:22:36 2021 +0200
Branches: asset-browser-poselib
https://developer.blender.org/rB897ed45675106bb5c2742df8bdaf0574d0b70559

Cleanup: Move temporary ID consumer class for assets into own file

Doesn't really make sense to keep this in `asset_edit.cc`.

===

M   source/blender/editors/asset/CMakeLists.txt
M   source/blender/editors/asset/asset_edit.cc
A   source/blender/editors/asset/asset_temp_id_consumer.cc

===

diff --git a/source/blender/editors/asset/CMakeLists.txt 
b/source/blender/editors/asset/CMakeLists.txt
index d87879bea2a..a27975bc37b 100644
--- a/source/blender/editors/asset/CMakeLists.txt
+++ b/source/blender/editors/asset/CMakeLists.txt
@@ -33,6 +33,7 @@ set(SRC
   asset_edit.cc
   asset_list.cc
   asset_ops.cc
+  asset_temp_id_consumer.cc
 )
 
 set(LIB
diff --git a/source/blender/editors/asset/asset_edit.cc 
b/source/blender/editors/asset/asset_edit.cc
index 57832aa1e20..0937af0dbf1 100644
--- a/source/blender/editors/asset/asset_edit.cc
+++ b/source/blender/editors/asset/asset_edit.cc
@@ -24,9 +24,6 @@
 #include "BKE_asset.h"
 #include "BKE_context.h"
 #include "BKE_lib_id.h"
-#include "BKE_report.h"
-
-#include "BLI_utility_mixins.hh"
 
 #include "BLO_readfile.h"
 
@@ -34,10 +31,6 @@
 #include "DNA_asset_types.h"
 #include "DNA_space_types.h"
 
-#include "ED_fileselect.h"
-
-#include "MEM_guardedalloc.h"
-
 #include "UI_interface_icons.h"
 
 #include "RNA_access.h"
@@ -160,79 +153,3 @@ void ED_asset_handle_get_full_library_path(const bContext 
*C,
 
   BLO_library_path_explode(asset_path.c_str(), r_full_lib_path, nullptr, 
nullptr);
 }
-
-class AssetTemporaryIDConsumer : NonCopyable, NonMovable {
-  const AssetHandle &handle_;
-  TempLibraryContext *temp_lib_context_ = nullptr;
-
- public:
-  AssetTemporaryIDConsumer(const AssetHandle &handle) : handle_(handle)
-  {
-  }
-  ~AssetTemporaryIDConsumer()
-  {
-if (temp_lib_context_) {
-  BLO_library_temp_free(temp_lib_context_);
-}
-  }
-
-  ID *get_local_id()
-  {
-return ED_assetlist_asset_local_id_get(&handle_);
-  }
-
-  ID *import_id(const bContext *C,
-const AssetLibraryReference &asset_library,
-ID_Type id_type,
-Main &bmain,
-ReportList &reports)
-  {
-const char *asset_name = ED_asset_handle_get_name(&handle_);
-char blend_file_path[FILE_MAX_LIBEXTRA];
-ED_asset_handle_get_full_library_path(C, &asset_library, &handle_, 
blend_file_path);
-
-temp_lib_context_ = BLO_library_temp_load_id(
-&bmain, blend_file_path, id_type, asset_name, &reports);
-
-if (temp_lib_context_ == nullptr || temp_lib_context_->temp_id == nullptr) 
{
-  BKE_reportf(&reports, RPT_ERROR, "Unable to load %s from %s", 
asset_name, blend_file_path);
-  return nullptr;
-}
-
-BLI_assert(GS(temp_lib_context_->temp_id->name) == id_type);
-return temp_lib_context_->temp_id;
-  }
-};
-
-AssetTempIDConsumer *ED_asset_temp_id_consumer_create(const AssetHandle 
*handle)
-{
-  if (!handle) {
-return nullptr;
-  }
-  BLI_assert(handle->file_data->asset_data != nullptr);
-  return reinterpret_cast(
-  OBJECT_GUARDED_NEW(AssetTemporaryIDConsumer, *handle));
-}
-
-void ED_asset_temp_id_consumer_free(AssetTempIDConsumer **consumer)
-{
-  OBJECT_GUARDED_SAFE_DELETE(*consumer, AssetTemporaryIDConsumer);
-}
-
-ID *ED_asset_temp_id_consumer_ensure_local_id(AssetTempIDConsumer *consumer_,
-  const bContext *C,
-  const AssetLibraryReference 
*asset_library,
-  ID_Type id_type,
-  Main *bmain,
-  ReportList *reports)
-{
-  if (!(consumer_ && asset_library && bmain && reports)) {
-return nullptr;
-  }
-  AssetTemporaryIDConsumer *consumer = 
reinterpret_cast(consumer_);
-
-  if (ID *local_id = consumer->get_local_id()) {
-return local_id;
-  }
-  return consumer->import_id(C, *asset_library, id_type, *bmain, *reports);
-}
diff --git a/source/blender/editors/asset/asset_temp_id_consumer.cc 
b/source/blender/editors/asset/asset_temp_id_consumer.cc
new file mode 100644
index 000..24e1fc86fef
--- /dev/null
+++ b/source/blender/editors/asset/asset_temp_id_consumer.cc
@@ -0,0 +1,113 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FIT

[Bf-blender-cvs] [f9d221db9cf] asset-browser-poselib: Cleanup: Minor code-style cleanup

2021-06-14 Thread Julian Eisel
Commit: f9d221db9cf207f04b3b6060b466cc2d9574bf8d
Author: Julian Eisel
Date:   Mon Jun 14 20:21:49 2021 +0200
Branches: asset-browser-poselib
https://developer.blender.org/rBf9d221db9cf207f04b3b6060b466cc2d9574bf8d

Cleanup: Minor code-style cleanup

===

M   source/blender/editors/armature/pose_lib_2.c
M   source/blender/editors/asset/asset_list.cc

===

diff --git a/source/blender/editors/armature/pose_lib_2.c 
b/source/blender/editors/armature/pose_lib_2.c
index bbb82424953..c35bb8d3cd5 100644
--- a/source/blender/editors/armature/pose_lib_2.c
+++ b/source/blender/editors/armature/pose_lib_2.c
@@ -57,8 +57,6 @@
 
 #include "armature_intern.h"
 
-struct ScrArea;
-
 typedef enum ePoseBlendState {
   POSE_BLEND_INIT,
   POSE_BLEND_BLENDING,
@@ -90,8 +88,8 @@ typedef struct PoseBlendData {
   bAction *act; /* Pose to blend into the current pose. */
   bool free_action;
 
-  Scene *scene; /* For auto-keying. */
-  struct ScrArea *area; /* For drawing status text. */
+  Scene *scene;  /* For auto-keying. */
+  ScrArea *area; /* For drawing status text. */
 
   /** Info-text to print in header. */
   char headerstr[UI_MAX_DRAW_STR];
@@ -125,14 +123,13 @@ static void poselib_keytag_pose(bContext *C, Scene 
*scene, PoseBlendData *pbd)
 
   bPose *pose = pbd->ob->pose;
   bAction *act = pbd->act;
-  bActionGroup *agrp;
 
   KeyingSet *ks = ANIM_get_keyingset_for_autokeying(scene, 
ANIM_KS_WHOLE_CHARACTER_ID);
   ListBase dsources = {NULL, NULL};
 
   /* start tagging/keying */
   const bArmature *armature = pbd->ob->data;
-  for (agrp = act->groups.first; agrp; agrp = agrp->next) {
+  LISTBASE_FOREACH (bActionGroup *, agrp, &act->groups) {
 /* only for selected bones unless there aren't any selected, in which case 
all are included  */
 bPoseChannel *pchan = BKE_pose_channel_find_name(pose, agrp->name);
 if (pchan == NULL) {
diff --git a/source/blender/editors/asset/asset_list.cc 
b/source/blender/editors/asset/asset_list.cc
index 8b57c0c5a60..1ea948d97d4 100644
--- a/source/blender/editors/asset/asset_list.cc
+++ b/source/blender/editors/asset/asset_list.cc
@@ -402,9 +402,7 @@ void AssetListStorage::fetch_library(const 
AssetLibraryReference &library_refere
 return;
   }
 
-  std::tuple list_create_info = ensure_list_storage(library_reference, 
*filesel_type);
-  AssetList &list = std::get<0>(list_create_info);
-  const bool is_new = std::get<1>(list_create_info);
+  auto [list, is_new] = ensure_list_storage(library_reference, *filesel_type);
   if (is_new || list.needsRefetch()) {
 list.setup(filter_settings);
 list.fetch(C);

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


[Bf-blender-cvs] [b4d691444de] asset-browser-poselib: Merge remote-tracking branch 'origin/master' into asset-browser-poselib

2021-06-14 Thread Julian Eisel
Commit: b4d691444de350881abaae05bbeac0aab93f3a9f
Author: Julian Eisel
Date:   Mon Jun 14 20:25:16 2021 +0200
Branches: asset-browser-poselib
https://developer.blender.org/rBb4d691444de350881abaae05bbeac0aab93f3a9f

Merge remote-tracking branch 'origin/master' into asset-browser-poselib

===



===



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


[Bf-blender-cvs] [fcbb20286a3] master: Geometry Nodes: Curve to Points Node for Evaluated Data

2021-06-14 Thread Hans Goudey
Commit: fcbb20286a3163d1d6669502375aa3f096e9547a
Author: Hans Goudey
Date:   Mon Jun 14 12:51:25 2021 -0500
Branches: master
https://developer.blender.org/rBfcbb20286a3163d1d6669502375aa3f096e9547a

Geometry Nodes: Curve to Points Node for Evaluated Data

This node implements the second option of T87429, creating points
along the input splines with the necessary evaluated information
for instancing: `tangent`, `normal`, and `rotation` attributes.
All generic curve point and spline attributes are copied to the
result points as well.

The "Count" and "Length" methods are just like the current options
in the resample node, but the output is points instead of a curve.
The "Evaluated" method uses the points you see on the curve directly,
and therefore should be the fastest.

The rotation data is retrieved from a transform matrix built with the
same method that the curve to mesh node uses. The radius attribute is
divided by 10 so the points don't look absurdly huge in the viewport.
In the future that could be an option.

For the implementation, one thing that could use an improvement
is the amount of temporary allocations while resampling to evaluated
points before the final points. I expect that reusing a buffer for
each thread would give a nice improvement.

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

===

M   release/scripts/startup/nodeitems_builtins.py
M   source/blender/blenkernel/BKE_node.h
M   source/blender/blenkernel/intern/node.cc
M   source/blender/makesdna/DNA_node_types.h
M   source/blender/makesrna/intern/rna_nodetree.c
M   source/blender/nodes/CMakeLists.txt
M   source/blender/nodes/NOD_geometry.h
M   source/blender/nodes/NOD_static_types.h
A   source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc

===

diff --git a/release/scripts/startup/nodeitems_builtins.py 
b/release/scripts/startup/nodeitems_builtins.py
index 5927123cdd8..562a676907b 100644
--- a/release/scripts/startup/nodeitems_builtins.py
+++ b/release/scripts/startup/nodeitems_builtins.py
@@ -504,6 +504,7 @@ geometry_node_categories = [
 NodeItem("GeometryNodeCurveToMesh"),
 NodeItem("GeometryNodeCurveResample"),
 NodeItem("GeometryNodeMeshToCurve"),
+NodeItem("GeometryNodeCurveToPoints"),
 NodeItem("GeometryNodeCurveLength"),
 ]),
 GeometryNodeCategory("GEO_GEOMETRY", "Geometry", items=[
diff --git a/source/blender/blenkernel/BKE_node.h 
b/source/blender/blenkernel/BKE_node.h
index a67d7116874..9401e6a9f02 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -1434,6 +1434,7 @@ int ntreeTexExecTree(struct bNodeTree *ntree,
 #define GEO_NODE_CURVE_LENGTH 1054
 #define GEO_NODE_SELECT_BY_MATERIAL 1055
 #define GEO_NODE_CONVEX_HULL 1056
+#define GEO_NODE_CURVE_TO_POINTS 1057
 
 /** \} */
 
diff --git a/source/blender/blenkernel/intern/node.cc 
b/source/blender/blenkernel/intern/node.cc
index 1c82218fc65..06d70869386 100644
--- a/source/blender/blenkernel/intern/node.cc
+++ b/source/blender/blenkernel/intern/node.cc
@@ -5055,6 +5055,7 @@ static void registerGeometryNodes()
   register_node_type_geo_convex_hull();
   register_node_type_geo_curve_length();
   register_node_type_geo_curve_to_mesh();
+  register_node_type_geo_curve_to_points();
   register_node_type_geo_curve_resample();
   register_node_type_geo_delete_geometry();
   register_node_type_geo_edge_split();
diff --git a/source/blender/makesdna/DNA_node_types.h 
b/source/blender/makesdna/DNA_node_types.h
index 2ae48bfe0ad..e6884f45258 100644
--- a/source/blender/makesdna/DNA_node_types.h
+++ b/source/blender/makesdna/DNA_node_types.h
@@ -1362,6 +1362,11 @@ typedef struct NodeGeometryCurveResample {
   uint8_t mode;
 } NodeGeometryCurveResample;
 
+typedef struct NodeGeometryCurveToPoints {
+  /* GeometryNodeCurveSampleMode. */
+  uint8_t mode;
+} NodeGeometryCurveToPoints;
+
 typedef struct NodeGeometryAttributeTransfer {
   /* AttributeDomain. */
   int8_t domain;
@@ -1873,6 +1878,7 @@ typedef enum GeometryNodeMeshLineCountMode {
 typedef enum GeometryNodeCurveSampleMode {
   GEO_NODE_CURVE_SAMPLE_COUNT = 0,
   GEO_NODE_CURVE_SAMPLE_LENGTH = 1,
+  GEO_NODE_CURVE_SAMPLE_EVALUATED = 2,
 } GeometryNodeCurveSampleMode;
 
 typedef enum GeometryNodeAttributeTransferMapMode {
diff --git a/source/blender/makesrna/intern/rna_nodetree.c 
b/source/blender/makesrna/intern/rna_nodetree.c
index 7271ecb49eb..87bfb554611 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -9849,6 +9849,38 @@ static void def_geo_curve_resample(StructRNA *srna)
   RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_socket_update");
 }
 
+static void def_geo_curve_to_points(StructRNA *srna)
+{
+  PropertyRNA *prop;
+
+  static EnumPropertyItem mode_items[] = {
+  {G

[Bf-blender-cvs] [d08e925ef1a] master: Fix Build Warning

2021-06-14 Thread Harley Acheson
Commit: d08e925ef1aaa892b0d5bb549d4ec2c8b47d7187
Author: Harley Acheson
Date:   Mon Jun 14 10:42:28 2021 -0700
Branches: master
https://developer.blender.org/rBd08e925ef1aaa892b0d5bb549d4ec2c8b47d7187

Fix Build Warning

Marking unused function argument.

Introduced in bcff0ef9cabc

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

===

M   source/blender/editors/space_file/file_ops.c

===

diff --git a/source/blender/editors/space_file/file_ops.c 
b/source/blender/editors/space_file/file_ops.c
index 4bbdbb0d97c..334e421c837 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -2636,7 +2636,7 @@ void FILE_OT_hidedot(struct wmOperatorType *ot)
 /** \name Associate File Type Operator (Windows only)
  * \{ */
 
-static int associate_blend_exec(bContext *C, wmOperator *op)
+static int associate_blend_exec(bContext *UNUSED(C), wmOperator *op)
 {
 #ifdef WIN32
   WM_cursor_wait(true);

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


[Bf-blender-cvs] [bbfa14980e8] asset-browser-poselib: Cleanup: Remove unnecessary includes

2021-06-14 Thread Julian Eisel
Commit: bbfa14980e842754fafe3ee965569361aaf8b49a
Author: Julian Eisel
Date:   Mon Jun 14 19:22:27 2021 +0200
Branches: asset-browser-poselib
https://developer.blender.org/rBbbfa14980e842754fafe3ee965569361aaf8b49a

Cleanup: Remove unnecessary includes

===

M   source/blender/editors/armature/pose_lib_2.c

===

diff --git a/source/blender/editors/armature/pose_lib_2.c 
b/source/blender/editors/armature/pose_lib_2.c
index 52db54791c7..bbb82424953 100644
--- a/source/blender/editors/armature/pose_lib_2.c
+++ b/source/blender/editors/armature/pose_lib_2.c
@@ -25,28 +25,17 @@
 
 #include "MEM_guardedalloc.h"
 
-#include "BLI_listbase.h"
-#include "BLI_path_util.h"
 #include "BLI_string.h"
-#include "BLI_utildefines.h"
-
-#include "BLO_readfile.h"
 
 #include "BLT_translation.h"
 
-#include "DNA_ID.h"
-#include "DNA_action_types.h"
-#include "DNA_anim_types.h"
 #include "DNA_armature_types.h"
-#include "DNA_object_types.h"
-#include "DNA_scene_types.h"
 
 #include "BKE_action.h"
 #include "BKE_anim_data.h"
 #include "BKE_animsys.h"
 #include "BKE_armature.h"
 #include "BKE_context.h"
-#include "BKE_idprop.h"
 #include "BKE_lib_id.h"
 #include "BKE_object.h"
 #include "BKE_report.h"
@@ -64,7 +53,6 @@
 #include "ED_armature.h"
 #include "ED_asset.h"
 #include "ED_keyframing.h"
-#include "ED_object.h"
 #include "ED_screen.h"
 
 #include "armature_intern.h"

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


[Bf-blender-cvs] [bcff0ef9cab] master: UI: Windows Blend File Association

2021-06-14 Thread Harley Acheson
Commit: bcff0ef9cabc37c4b89a1e2c7972a09ac80d4555
Author: Harley Acheson
Date:   Mon Jun 14 10:15:37 2021 -0700
Branches: master
https://developer.blender.org/rBbcff0ef9cabc37c4b89a1e2c7972a09ac80d4555

UI: Windows Blend File Association

This patch allows Windows users to specify that their current blender
installation should be used to create thumbnails and be associated
with ".blend" files. This is done from Preferences / System. The only
way to do this currently is from the command-line and this is sometimes
inconvenient.

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

Reviewed by Brecht Van Lommel

===

M   release/scripts/startup/bl_ui/space_userpref.py
M   source/blender/blenlib/BLI_winstuff.h
M   source/blender/blenlib/intern/winstuff.c
M   source/blender/editors/space_file/file_intern.h
M   source/blender/editors/space_file/file_ops.c
M   source/blender/editors/space_file/space_file.c
M   source/creator/creator_args.c

===

diff --git a/release/scripts/startup/bl_ui/space_userpref.py 
b/release/scripts/startup/bl_ui/space_userpref.py
index 26ad22d3ac2..b3a456ee2fe 100644
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@ -605,6 +605,25 @@ class USERPREF_PT_system_cycles_devices(SystemPanel, 
CenterAlignMixIn, Panel):
 # col.row().prop(system, "opensubdiv_compute_type", text="")
 
 
+class USERPREF_PT_system_os_settings(SystemPanel, CenterAlignMixIn, Panel):
+bl_label = "Operating System Settings"
+
+@classmethod
+def poll(cls, _context):
+# Only for Windows so far
+import sys
+return sys.platform[:3] == "win"
+
+def draw_centered(self, context, layout):
+prefs = context.preferences
+
+layout.label(text="Make this installation your default Blender")
+split = layout.split(factor=0.4)
+split.alignment = 'RIGHT'
+split.label(text="")
+split.operator("file.associate_blend", text="Make Default")
+
+
 class USERPREF_PT_system_memory(SystemPanel, CenterAlignMixIn, Panel):
 bl_label = "Memory & Limits"
 
@@ -2324,6 +2343,7 @@ classes = (
 USERPREF_PT_animation_fcurves,
 
 USERPREF_PT_system_cycles_devices,
+USERPREF_PT_system_os_settings,
 USERPREF_PT_system_memory,
 USERPREF_PT_system_video_sequencer,
 USERPREF_PT_system_sound,
diff --git a/source/blender/blenlib/BLI_winstuff.h 
b/source/blender/blenlib/BLI_winstuff.h
index f771d26baab..0953e3f1946 100644
--- a/source/blender/blenlib/BLI_winstuff.h
+++ b/source/blender/blenlib/BLI_winstuff.h
@@ -105,7 +105,7 @@ int closedir(DIR *dp);
 const char *dirname(char *path);
 
 /* Windows utility functions. */
-void BLI_windows_register_blend_extension(const bool background);
+bool BLI_windows_register_blend_extension(const bool background);
 void BLI_windows_get_default_root_dir(char *root_dir);
 int BLI_windows_get_executable_dir(char *str);
 
diff --git a/source/blender/blenlib/intern/winstuff.c 
b/source/blender/blenlib/intern/winstuff.c
index 3aa61d1fec5..d40f665ba0d 100644
--- a/source/blender/blenlib/intern/winstuff.c
+++ b/source/blender/blenlib/intern/winstuff.c
@@ -67,10 +67,9 @@ static void register_blend_extension_failed(HKEY root, const 
bool background)
   if (!background) {
 MessageBox(0, "Could not register file extension.", "Blender error", MB_OK 
| MB_ICONERROR);
   }
-  TerminateProcess(GetCurrentProcess(), 1);
 }
 
-void BLI_windows_register_blend_extension(const bool background)
+bool BLI_windows_register_blend_extension(const bool background)
 {
   LONG lresult;
   HKEY hkey = 0;
@@ -107,6 +106,7 @@ void BLI_windows_register_blend_extension(const bool 
background)
 lresult = RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\Classes", 0, 
KEY_ALL_ACCESS, &root);
 if (lresult != ERROR_SUCCESS) {
   register_blend_extension_failed(0, background);
+  return false;
 }
   }
 
@@ -119,6 +119,7 @@ void BLI_windows_register_blend_extension(const bool 
background)
   }
   if (lresult != ERROR_SUCCESS) {
 register_blend_extension_failed(root, background);
+return false;
   }
 
   lresult = RegCreateKeyEx(root,
@@ -137,6 +138,7 @@ void BLI_windows_register_blend_extension(const bool 
background)
   }
   if (lresult != ERROR_SUCCESS) {
 register_blend_extension_failed(root, background);
+return false;
   }
 
   lresult = RegCreateKeyEx(root,
@@ -155,6 +157,7 @@ void BLI_windows_register_blend_extension(const bool 
background)
   }
   if (lresult != ERROR_SUCCESS) {
 register_blend_extension_failed(root, background);
+return false;
   }
 
   lresult = RegCreateKeyEx(
@@ -166,6 +169,7 @@ void BLI_windows_register_blend_extension(const bool 
background)
   }
   if (lresult != ERROR_SUCCESS) {
 register_blend_extension_failed(root, background);
+return false;

[Bf-blender-cvs] [491168c02f4] asset-browser-poselib: Cleanup: Move version patch to correct file

2021-06-14 Thread Julian Eisel
Commit: 491168c02f43ba0cfa14d71500cb5406f91063f0
Author: Julian Eisel
Date:   Mon Jun 14 19:06:45 2021 +0200
Branches: asset-browser-poselib
https://developer.blender.org/rB491168c02f43ba0cfa14d71500cb5406f91063f0

Cleanup: Move version patch to correct file

Should be in `versioning_300.c` by now.

===

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

===

diff --git a/source/blender/blenloader/intern/versioning_290.c 
b/source/blender/blenloader/intern/versioning_290.c
index 2148f434a38..1a52f05dae3 100644
--- a/source/blender/blenloader/intern/versioning_290.c
+++ b/source/blender/blenloader/intern/versioning_290.c
@@ -2100,13 +2100,4 @@ void blo_do_versions_290(FileData *fd, Library 
*UNUSED(lib), Main *bmain)
   {
 /* Keep this block, even when empty. */
   }
-
-  {
-if (!DNA_struct_elem_find(
-fd->filesdna, "WorkSpace", "AssetLibraryReference", 
"active_asset_library")) {
-  LISTBASE_FOREACH (WorkSpace *, workspace, &bmain->workspaces) {
-
BKE_asset_library_reference_init_default(&workspace->active_asset_library);
-  }
-}
-  }
 }
diff --git a/source/blender/blenloader/intern/versioning_300.c 
b/source/blender/blenloader/intern/versioning_300.c
index 268598ccc51..60650edcea6 100644
--- a/source/blender/blenloader/intern/versioning_300.c
+++ b/source/blender/blenloader/intern/versioning_300.c
@@ -30,7 +30,9 @@
 #include "DNA_listBase.h"
 #include "DNA_modifier_types.h"
 #include "DNA_text_types.h"
+#include "DNA_workspace_types.h"
 
+#include "BKE_asset.h"
 #include "BKE_lib_id.h"
 #include "BKE_main.h"
 #include "BKE_node.h"
@@ -259,5 +261,14 @@ void blo_do_versions_300(FileData *fd, Library 
*UNUSED(lib), Main *bmain)
 }
   }
 }
+
+{
+  if (!DNA_struct_elem_find(
+  fd->filesdna, "WorkSpace", "AssetLibraryReference", 
"active_asset_library")) {
+LISTBASE_FOREACH (WorkSpace *, workspace, &bmain->workspaces) {
+  
BKE_asset_library_reference_init_default(&workspace->active_asset_library);
+}
+  }
+}
   }
 }

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


[Bf-blender-cvs] [2e5671a9591] master: Fix: VSE seeking with proxy strips would fail on certain frames

2021-06-14 Thread Sebastian Parborg
Commit: 2e5671a959182dadcdd55117732082ab7893f3d1
Author: Sebastian Parborg
Date:   Mon Jun 14 19:05:29 2021 +0200
Branches: master
https://developer.blender.org/rB2e5671a959182dadcdd55117732082ab7893f3d1

Fix: VSE seeking with proxy strips would fail on certain frames

If the last decoded frame had the same timestamp as the GOP current
packet, then we would skip over this frame when fast forwarding and we
would seek until the end of the file.

This would could only be triggered reliably in single threaded mode.

Reviewed By: Richard Antalik

Differential Revision: http://developer.blender.org/D11601

===

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

===

diff --git a/source/blender/imbuf/intern/anim_movie.c 
b/source/blender/imbuf/intern/anim_movie.c
index 796f7469fb3..450c76630a8 100644
--- a/source/blender/imbuf/intern/anim_movie.c
+++ b/source/blender/imbuf/intern/anim_movie.c
@@ -1290,11 +1290,16 @@ static int ffmpeg_seek_to_key_frame(struct anim *anim,
 
   if (same_gop && position > anim->cur_position) {
 /* Change back to our old frame position so we can simply continue 
decoding from there. */
+int64_t cur_pts = timestamp_from_pts_or_dts(anim->cur_packet->pts, 
anim->cur_packet->dts);
+
+if (cur_pts == gop_pts) {
+  /* We are already at the correct position. */
+  return 0;
+}
 AVPacket *temp = av_packet_alloc();
+
 while (av_read_frame(anim->pFormatCtx, temp) >= 0) {
   int64_t temp_pts = timestamp_from_pts_or_dts(temp->pts, temp->dts);
-  int64_t cur_pts = timestamp_from_pts_or_dts(anim->cur_packet->pts,
-  anim->cur_packet->dts);
   if (temp->stream_index == anim->videoStream && temp_pts == cur_pts) {
 break;
   }

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


[Bf-blender-cvs] [aadd3550289] master: Fix possible C-linkage warning on Clang

2021-06-14 Thread Julian Eisel
Commit: aadd3550289aa0258e9e99864bc6063d0dd03460
Author: Julian Eisel
Date:   Thu Apr 15 23:45:13 2021 +0200
Branches: master
https://developer.blender.org/rBaadd3550289aa0258e9e99864bc6063d0dd03460

Fix possible C-linkage warning on Clang

The warning would appear when using the `ENUM_OPERATORS()` macro inside
of an `extern "C"` block.
Didn't cause a warning in master currently, but in the
`asset-browser-poselib` branch.

After macro expansion, there would be C++ code in code with C linkage
(`extern "C"`). So make sure the expanded C++ code always uses C++
linkage.
The syntax used is totally C++ compliant: the C++ standard requires that
in such nested linkage specifications, the innermost one determines the
linking language (e.g. see
https://timsong-cpp.github.io/cppwp/n4659/dcl.link#4).

===

M   source/blender/blenlib/BLI_utildefines.h

===

diff --git a/source/blender/blenlib/BLI_utildefines.h 
b/source/blender/blenlib/BLI_utildefines.h
index 1c6e6ffe578..0bf117df43b 100644
--- a/source/blender/blenlib/BLI_utildefines.h
+++ b/source/blender/blenlib/BLI_utildefines.h
@@ -785,6 +785,7 @@ extern bool BLI_memory_is_zero(const void *arr, const 
size_t arr_size);
  * To use after the enum declaration. */
 /* If any enumerator `C` is set to say `A|B`, then `C` would be the max enum 
value. */
 #  define ENUM_OPERATORS(_enum_type, _max_enum_value) \
+extern "C++" { \
 inline constexpr _enum_type operator|(_enum_type a, _enum_type b) \
 { \
   return static_cast<_enum_type>(static_cast(a) | b); \
@@ -804,7 +805,8 @@ extern bool BLI_memory_is_zero(const void *arr, const 
size_t arr_size);
 inline _enum_type &operator&=(_enum_type &a, _enum_type b) \
 { \
   return a = static_cast<_enum_type>(static_cast(a) & b); \
-}
+} \
+} /* extern "C++" */
 
 #else
 /* Output nothing. */

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


[Bf-blender-cvs] [3de6fe0b3ee] master: Error Messages Creating Thumbnail Folders

2021-06-14 Thread Harley Acheson
Commit: 3de6fe0b3eebb2af66db8051fbb65a49e49a8578
Author: Harley Acheson
Date:   Mon Jun 14 09:16:35 2021 -0700
Branches: master
https://developer.blender.org/rB3de6fe0b3eebb2af66db8051fbb65a49e49a8578

Error Messages Creating Thumbnail Folders

On the Windows platform there will be some errors printed to the
console if the user's thumbnail cache folder doesn't already exist.
While creating those folders there is an attempt to do so multiple
times and so we get errors when trying to create when exists. This
is caused by paths that have hard-coded forward slashes, which causes
our path processing routines to not work correctly. This patch defines
those paths using platform-varying separator characters.

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

Reviewed by Brecht Van Lommel

===

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

===

diff --git a/source/blender/imbuf/intern/thumbs.c 
b/source/blender/imbuf/intern/thumbs.c
index 61bc185eb8d..7b4bf704096 100644
--- a/source/blender/imbuf/intern/thumbs.c
+++ b/source/blender/imbuf/intern/thumbs.c
@@ -112,13 +112,13 @@ static bool get_thumb_dir(char *dir, ThumbSize size)
 #endif
   switch (size) {
 case THB_NORMAL:
-  subdir = "/" THUMBNAILS "/normal/";
+  subdir = SEP_STR THUMBNAILS SEP_STR "normal" SEP_STR;
   break;
 case THB_LARGE:
-  subdir = "/" THUMBNAILS "/large/";
+  subdir = SEP_STR THUMBNAILS SEP_STR "large" SEP_STR;
   break;
 case THB_FAIL:
-  subdir = "/" THUMBNAILS "/fail/blender/";
+  subdir = SEP_STR THUMBNAILS SEP_STR "fail" SEP_STR "blender" SEP_STR;
   break;
 default:
   return 0; /* unknown size */

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


[Bf-blender-cvs] [e9b4de43d86] master: Cleanup: rename id to owner_id for python id properties

2021-06-14 Thread Jacques Lucke
Commit: e9b4de43d86332bf85d8119742a39135dc2156b3
Author: Jacques Lucke
Date:   Mon Jun 14 18:13:19 2021 +0200
Branches: master
https://developer.blender.org/rBe9b4de43d86332bf85d8119742a39135dc2156b3

Cleanup: rename id to owner_id for python id properties

This is consistent with the naming in `PointerRNA`.

===

M   source/blender/python/generic/idprop_py_api.c
M   source/blender/python/generic/idprop_py_api.h

===

diff --git a/source/blender/python/generic/idprop_py_api.c 
b/source/blender/python/generic/idprop_py_api.c
index 9b6ca7fcec5..cebc72d99d1 100644
--- a/source/blender/python/generic/idprop_py_api.c
+++ b/source/blender/python/generic/idprop_py_api.c
@@ -91,7 +91,7 @@ static PyObject *idprop_py_from_idp_double(const IDProperty 
*prop)
 static PyObject *idprop_py_from_idp_group(ID *id, IDProperty *prop, IDProperty 
*parent)
 {
   BPy_IDProperty *group = PyObject_New(BPy_IDProperty, &BPy_IDGroup_Type);
-  group->id = id;
+  group->owner_id = id;
   group->prop = prop;
   group->parent = parent; /* can be NULL */
   return (PyObject *)group;
@@ -105,7 +105,7 @@ static PyObject *idprop_py_from_idp_id(IDProperty *prop)
 static PyObject *idprop_py_from_idp_array(ID *id, IDProperty *prop)
 {
   BPy_IDProperty *array = PyObject_New(BPy_IDProperty, &BPy_IDArray_Type);
-  array->id = id;
+  array->owner_id = id;
   array->prop = prop;
   return (PyObject *)array;
 }
@@ -152,7 +152,7 @@ static Py_hash_t BPy_IDGroup_hash(BPy_IDProperty *self)
 static PyObject *BPy_IDGroup_repr(BPy_IDProperty *self)
 {
   return PyUnicode_FromFormat("",
-  self->id ? self->id->name : "",
+  self->owner_id ? self->owner_id->name : "",
   self->prop->name,
   self->prop);
 }
@@ -326,7 +326,7 @@ static PyObject *BPy_IDGroup_Map_GetItem(BPy_IDProperty 
*self, PyObject *item)
 return NULL;
   }
 
-  return BPy_IDGroup_WrapData(self->id, idprop, self->prop);
+  return BPy_IDGroup_WrapData(self->owner_id, idprop, self->prop);
 }
 
 /* returns NULL on success, error string on failure */
@@ -946,7 +946,7 @@ static PyObject *BPy_Group_IterValues_next(BPy_IDGroup_Iter 
*self)
 }
 IDProperty *cur = self->cur;
 self->cur = self->reversed ? self->cur->prev : self->cur->next;
-return BPy_IDGroup_WrapData(self->group->id, cur, self->group->prop);
+return BPy_IDGroup_WrapData(self->group->owner_id, cur, self->group->prop);
   }
   PyErr_SetNone(PyExc_StopIteration);
   return NULL;
@@ -964,7 +964,7 @@ static PyObject *BPy_Group_IterItems_next(BPy_IDGroup_Iter 
*self)
 PyObject *ret = PyTuple_New(2);
 PyTuple_SET_ITEMS(ret,
   PyUnicode_FromString(cur->name),
-  BPy_IDGroup_WrapData(self->group->id, cur, 
self->group->prop));
+  BPy_IDGroup_WrapData(self->group->owner_id, cur, 
self->group->prop));
 return ret;
   }
   PyErr_SetNone(PyExc_StopIteration);
@@ -1514,7 +1514,7 @@ static PyObject *BPy_IDGroup_get(BPy_IDProperty *self, 
PyObject *args)
 
   idprop = IDP_GetPropertyFromGroup(self->prop, key);
   if (idprop) {
-PyObject *pyobj = BPy_IDGroup_WrapData(self->id, idprop, self->prop);
+PyObject *pyobj = BPy_IDGroup_WrapData(self->owner_id, idprop, self->prop);
 if (pyobj) {
   return pyobj;
 }
diff --git a/source/blender/python/generic/idprop_py_api.h 
b/source/blender/python/generic/idprop_py_api.h
index 1e8e26a3b6d..f53c45b07c2 100644
--- a/source/blender/python/generic/idprop_py_api.h
+++ b/source/blender/python/generic/idprop_py_api.h
@@ -56,14 +56,14 @@ extern PyTypeObject BPy_IDGroup_IterItems_Type;
 
 typedef struct BPy_IDProperty {
   PyObject_VAR_HEAD
-  struct ID *id;   /* can be NULL */
+  struct ID *owner_id; /* can be NULL */
   struct IDProperty *prop; /* must be second member */
   struct IDProperty *parent;
 } BPy_IDProperty;
 
 typedef struct BPy_IDArray {
   PyObject_VAR_HEAD
-  struct ID *id;   /* can be NULL */
+  struct ID *owner_id; /* can be NULL */
   struct IDProperty *prop; /* must be second member */
 } BPy_IDArray;

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


[Bf-blender-cvs] [121fa8b997c] override-recursive-resync: Python API: option for render engines to disable image file saving

2021-06-14 Thread Thomas Lachmann
Commit: 121fa8b997c900edef9ffaf7307a64ffe0679177
Author: Thomas Lachmann
Date:   Mon Jun 14 13:44:18 2021 +0200
Branches: override-recursive-resync
https://developer.blender.org/rB121fa8b997c900edef9ffaf7307a64ffe0679177

Python API: option for render engines to disable image file saving

For some custom rendering engines it's advantageous not to write the image 
files to disk.
An example would be a network rendering engine which does it's own image 
writing.

This feature is only supported when bl_use_postprocess is also disabled, since 
render
engines can't influence the saving behavior of the sequencer or compositor.

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

===

M   source/blender/makesrna/intern/rna_render.c
M   source/blender/render/RE_engine.h
M   source/blender/render/intern/pipeline.c

===

diff --git a/source/blender/makesrna/intern/rna_render.c 
b/source/blender/makesrna/intern/rna_render.c
index dd91a5509f5..6715941ae2a 100644
--- a/source/blender/makesrna/intern/rna_render.c
+++ b/source/blender/makesrna/intern/rna_render.c
@@ -856,6 +856,15 @@ static void rna_def_render_engine(BlenderRNA *brna)
   "Use Custom Freestyle",
   "Handles freestyle rendering on its own, instead of delegating it to 
EEVEE");
 
+  prop = RNA_def_property(srna, "bl_use_image_save", PROP_BOOLEAN, PROP_NONE);
+  RNA_def_property_boolean_negative_sdna(prop, NULL, "type->flag", 
RE_USE_NO_IMAGE_SAVE);
+  RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
+  RNA_def_property_ui_text(
+  prop,
+  "Use Image Save",
+  "Save images/movie to disk while rendering an animation. "
+  "Disabling image saving is only supported when bl_use_postprocess is 
also disabled");
+
   prop = RNA_def_property(srna, "bl_use_gpu_context", PROP_BOOLEAN, PROP_NONE);
   RNA_def_property_boolean_sdna(prop, NULL, "type->flag", RE_USE_GPU_CONTEXT);
   RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
diff --git a/source/blender/render/RE_engine.h 
b/source/blender/render/RE_engine.h
index 7352ac7b12e..6b2861bbefd 100644
--- a/source/blender/render/RE_engine.h
+++ b/source/blender/render/RE_engine.h
@@ -65,6 +65,7 @@ extern "C" {
 #define RE_USE_STEREO_VIEWPORT 256
 #define RE_USE_GPU_CONTEXT 512
 #define RE_USE_CUSTOM_FREESTYLE 1024
+#define RE_USE_NO_IMAGE_SAVE 2048
 
 /* RenderEngine.flag */
 #define RE_ENGINE_ANIMATION 1
diff --git a/source/blender/render/intern/pipeline.c 
b/source/blender/render/intern/pipeline.c
index a39214b609d..20f868ca86f 100644
--- a/source/blender/render/intern/pipeline.c
+++ b/source/blender/render/intern/pipeline.c
@@ -2215,35 +2215,42 @@ static int do_write_image_or_movie(Render *re,
   RenderResult rres;
   double render_time;
   bool ok = true;
+  RenderEngineType *re_type = RE_engines_find(re->r.engine);
 
-  RE_AcquireResultImageViews(re, &rres);
+  /* Only disable file writing if postprocessing is also disabled. */
+  const bool do_write_file = !(re_type->flag & RE_USE_NO_IMAGE_SAVE) ||
+ (re_type->flag & RE_USE_POSTPROCESS);
 
-  /* write movie or image */
-  if (BKE_imtype_is_movie(scene->r.im_format.imtype)) {
-RE_WriteRenderViewsMovie(
-re->reports, &rres, scene, &re->r, mh, re->movie_ctx_arr, totvideos, 
false);
-  }
-  else {
-if (name_override) {
-  BLI_strncpy(name, name_override, sizeof(name));
+  if (do_write_file) {
+RE_AcquireResultImageViews(re, &rres);
+
+/* write movie or image */
+if (BKE_imtype_is_movie(scene->r.im_format.imtype)) {
+  RE_WriteRenderViewsMovie(
+  re->reports, &rres, scene, &re->r, mh, re->movie_ctx_arr, totvideos, 
false);
 }
 else {
-  BKE_image_path_from_imformat(name,
-   scene->r.pic,
-   BKE_main_blendfile_path(bmain),
-   scene->r.cfra,
-   &scene->r.im_format,
-   (scene->r.scemode & R_EXTENSION) != 0,
-   true,
-   NULL);
+  if (name_override) {
+BLI_strncpy(name, name_override, sizeof(name));
+  }
+  else {
+BKE_image_path_from_imformat(name,
+ scene->r.pic,
+ BKE_main_blendfile_path(bmain),
+ scene->r.cfra,
+ &scene->r.im_format,
+ (scene->r.scemode & R_EXTENSION) != 0,
+ true,
+ NULL);
+  }
+
+  /* write images as individual images or stereo */
+  ok = RE_WriteRenderViewsImage(re->reports, &rres, scene, true, name);
 }
 
-/* write images as individual images or stereo */
-ok = RE_Wr

[Bf-blender-cvs] [f76203764ce] override-recursive-resync: Fix T88947: invalid normals when converting point cloud to mesh

2021-06-14 Thread Jacques Lucke
Commit: f76203764ce6afd0af24ed7f8dbd1b8fd3be1835
Author: Jacques Lucke
Date:   Mon Jun 14 11:07:31 2021 +0200
Branches: override-recursive-resync
https://developer.blender.org/rBf76203764ce6afd0af24ed7f8dbd1b8fd3be1835

Fix T88947: invalid normals when converting point cloud to mesh

===

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

===

diff --git a/source/blender/blenkernel/intern/geometry_set_instances.cc 
b/source/blender/blenkernel/intern/geometry_set_instances.cc
index 69840ba1612..847df75c8cb 100644
--- a/source/blender/blenkernel/intern/geometry_set_instances.cc
+++ b/source/blender/blenkernel/intern/geometry_set_instances.cc
@@ -472,6 +472,11 @@ static Mesh 
*join_mesh_topology_and_builtin_attributes(Spanhttps://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [f566d7b0a36] override-recursive-resync: Nodes: remove redundant increment node tree current socket index

2021-06-14 Thread Campbell Barton
Commit: f566d7b0a366720cd28b5f09f1ab978748baa968
Author: Campbell Barton
Date:   Mon Jun 14 18:37:25 2021 +1000
Branches: override-recursive-resync
https://developer.blender.org/rBf566d7b0a366720cd28b5f09f1ab978748baa968

Nodes: remove redundant increment node tree current socket index

`ntree->cur_index` was being incremented twice in make_socket_interface.

Reviewed By: JacquesLucke

Ref D11590

===

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

===

diff --git a/source/blender/blenkernel/intern/node.cc 
b/source/blender/blenkernel/intern/node.cc
index f4e78859749..1c82218fc65 100644
--- a/source/blender/blenkernel/intern/node.cc
+++ b/source/blender/blenkernel/intern/node.cc
@@ -3342,8 +3342,6 @@ static bNodeSocket *make_socket_interface(bNodeTree 
*ntree,
   const char *name)
 {
   bNodeSocketType *stype = nodeSocketTypeFind(idname);
-  int own_index = ntree->cur_index++;
-
   if (stype == nullptr) {
 return nullptr;
   }
@@ -3355,7 +3353,7 @@ static bNodeSocket *make_socket_interface(bNodeTree 
*ntree,
   sock->type = SOCK_CUSTOM; /* int type undefined by default */
 
   /* assign new unique index */
-  own_index = ntree->cur_index++;
+  const int own_index = ntree->cur_index++;
   /* use the own_index as socket identifier */
   if (in_out == SOCK_IN) {
 BLI_snprintf(sock->identifier, MAX_NAME, "Input_%d", own_index);

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


[Bf-blender-cvs] [72bdb74a940] override-recursive-resync: Cleanup: use return arg prefix for ED_object_add_generic_get_opts

2021-06-14 Thread Campbell Barton
Commit: 72bdb74a9407305ab8f39b96846f38d6f83f599b
Author: Campbell Barton
Date:   Sun Jun 13 14:47:18 2021 +1000
Branches: override-recursive-resync
https://developer.blender.org/rB72bdb74a9407305ab8f39b96846f38d6f83f599b

Cleanup: use return arg prefix for ED_object_add_generic_get_opts

===

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

===

diff --git a/source/blender/editors/include/ED_object.h 
b/source/blender/editors/include/ED_object.h
index 6f88ab4253a..1738c383328 100644
--- a/source/blender/editors/include/ED_object.h
+++ b/source/blender/editors/include/ED_object.h
@@ -295,12 +295,12 @@ void ED_object_add_mesh_props(struct wmOperatorType *ot);
 bool ED_object_add_generic_get_opts(struct bContext *C,
 struct wmOperator *op,
 const char view_align_axis,
-float loc[3],
-float rot[3],
-float scale[3],
-bool *enter_editmode,
-unsigned short *local_view_bits,
-bool *is_view_aligned);
+float r_loc[3],
+float r_rot[3],
+float r_scale[3],
+bool *r_enter_editmode,
+unsigned short *r_local_view_bits,
+bool *r_is_view_aligned);
 
 struct Object *ED_object_add_type_with_obdata(struct bContext *C,
   const int type,
diff --git a/source/blender/editors/object/object_add.c 
b/source/blender/editors/object/object_add.c
index 2256dee20cb..aefcf68390e 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -456,53 +456,53 @@ void ED_object_add_mesh_props(wmOperatorType *ot)
 bool ED_object_add_generic_get_opts(bContext *C,
 wmOperator *op,
 const char view_align_axis,
-float loc[3],
-float rot[3],
-float scale[3],
-bool *enter_editmode,
-ushort *local_view_bits,
-bool *is_view_aligned)
+float r_loc[3],
+float r_rot[3],
+float r_scale[3],
+bool *r_enter_editmode,
+ushort *r_local_view_bits,
+bool *r_is_view_aligned)
 {
   /* Edit Mode! (optional) */
   {
 bool _enter_editmode;
-if (!enter_editmode) {
-  enter_editmode = &_enter_editmode;
+if (!r_enter_editmode) {
+  r_enter_editmode = &_enter_editmode;
 }
 /* Only to ensure the value is _always_ set.
  * Typically the property will exist when the argument is non-NULL. */
-*enter_editmode = false;
+*r_enter_editmode = false;
 
 PropertyRNA *prop = RNA_struct_find_property(op->ptr, "enter_editmode");
 if (prop != NULL) {
-  if (RNA_property_is_set(op->ptr, prop) && enter_editmode) {
-*enter_editmode = RNA_property_boolean_get(op->ptr, prop);
+  if (RNA_property_is_set(op->ptr, prop) && r_enter_editmode) {
+*r_enter_editmode = RNA_property_boolean_get(op->ptr, prop);
   }
   else {
-*enter_editmode = (U.flag & USER_ADD_EDITMODE) != 0;
-RNA_property_boolean_set(op->ptr, prop, *enter_editmode);
+*r_enter_editmode = (U.flag & USER_ADD_EDITMODE) != 0;
+RNA_property_boolean_set(op->ptr, prop, *r_enter_editmode);
   }
 }
   }
 
-  if (local_view_bits) {
+  if (r_local_view_bits) {
 View3D *v3d = CTX_wm_view3d(C);
-*local_view_bits = (v3d && v3d->localvd) ? v3d->local_view_uuid : 0;
+*r_local_view_bits = (v3d && v3d->localvd) ? v3d->local_view_uuid : 0;
   }
 
   /* Location! */
   {
 float _loc[3];
-if (!loc) {
-  loc = _loc;
+if (!r_loc) {
+  r_loc = _loc;
 }
 
 if (RNA_struct_property_is_set(op->ptr, "location")) {
-  RNA_float_get_array(op->ptr, "location", loc);
+  RNA_float_get_array(op->ptr, "location", r_loc);
 }
 else {
-  ED_object_location_from_view(C, loc);
-  RNA_float_set_array(op->ptr, "location", loc);
+  ED_object_location_from_view(C, r_loc);
+  RNA_float_set_array(op->ptr, "location", r_loc);
 }
   }
 
@@ -510,19 +510,19 @@ bool ED_object_add_generic_get_opts(bContext *C,
   {
 bool _is_view_alig

[Bf-blender-cvs] [ed00750e0a8] override-recursive-resync: tweak messages further.

2021-06-14 Thread Bastien Montagne
Commit: ed00750e0a8062edf7f0dd7dac464a646cf9de81
Author: Bastien Montagne
Date:   Mon Jun 14 16:34:12 2021 +0200
Branches: override-recursive-resync
https://developer.blender.org/rBed00750e0a8062edf7f0dd7dac464a646cf9de81

tweak messages further.

===

M   source/blender/blenloader/intern/readfile.c
M   source/blender/windowmanager/intern/wm_files.c

===

diff --git a/source/blender/blenloader/intern/readfile.c 
b/source/blender/blenloader/intern/readfile.c
index 493ec94dbc3..ae590724fe9 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -5615,16 +5615,6 @@ static void read_libraries(FileData *basefd, ListBase 
*mainlist)
 mainptr->curlib->filedata = NULL;
   }
   BKE_main_free(main_newid);
-
-  if (basefd->reports != NULL && (basefd->reports->num_missing_libraries != 0 
||
-  basefd->reports->num_missing_linked_id != 
0)) {
-BKE_reportf(basefd->reports->reports,
-RPT_WARNING,
-"LIB: %d libraries and %d linked data-blocks are missing, 
please check the "
-"Info and Outliner editors for details",
-basefd->reports->num_missing_libraries,
-basefd->reports->num_missing_linked_id);
-  }
 }
 
 void *BLO_read_get_new_data_address(BlendDataReader *reader, const void 
*old_address)
diff --git a/source/blender/windowmanager/intern/wm_files.c 
b/source/blender/windowmanager/intern/wm_files.c
index e015dceb804..29e3e0a1a7a 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -822,40 +822,56 @@ bool WM_file_read(bContext *C, const char *filepath, 
ReportList *reports)
   const int duration_lib_override_recursive_resync_minutes = (int)floor(
   bf_reports.duration_lib_overrides_recursive_resync / 60.0);
 
-  BKE_reportf(
-  reports,
-  RPT_INFO,
-  "Blender file read in %d min %.2f sec (loading libraries: %d min 
%.2f sec, applying "
-  "overrides: %d min %.2f sec, resyncing overrides: %d min %.2f sec 
(%d root "
-  "overrides), among which recursive resync of overrides: %d min %.2f 
sec)",
-  duration_whole_minutes,
-  bf_reports.duration_whole - (duration_whole_minutes * 60.0),
-  duration_libraries_minutes,
-  bf_reports.duration_libraries - (duration_libraries_minutes * 60.0),
-  duration_lib_override_minutes,
-  bf_reports.duration_lib_overrides - (duration_lib_override_minutes * 
60.0),
-  duration_lib_override_resync_minutes,
-  bf_reports.duration_lib_overrides_resync - 
(duration_lib_override_resync_minutes * 60.0),
-  bf_reports.num_resynced_lib_overrides,
-  duration_lib_override_recursive_resync_minutes,
-  bf_reports.duration_lib_overrides_recursive_resync -
-  (duration_lib_override_recursive_resync_minutes * 60.0));
+  BKE_reportf(reports,
+  RPT_INFO,
+  "Blender file read in %dm%.2fs",
+  duration_whole_minutes,
+  bf_reports.duration_whole - (duration_whole_minutes * 60.0));
+  BKE_reportf(reports,
+  RPT_INFO,
+  " * Loading libraries: %dm%.2fs",
+  duration_libraries_minutes,
+  bf_reports.duration_libraries - (duration_libraries_minutes 
* 60.0));
+  BKE_reportf(reports,
+  RPT_INFO,
+  " * Applying overrides: %dm%.2fs",
+  duration_lib_override_minutes,
+  bf_reports.duration_lib_overrides - 
(duration_lib_override_minutes * 60.0));
+  BKE_reportf(reports,
+  RPT_INFO,
+  " * Resyncing overrides: %dm%.2fs (%d root overrides), 
including recursive "
+  "resyncs: %dm%.2fs)",
+  duration_lib_override_resync_minutes,
+  bf_reports.duration_lib_overrides_resync -
+  (duration_lib_override_resync_minutes * 60.0),
+  bf_reports.num_resynced_lib_overrides,
+  duration_lib_override_recursive_resync_minutes,
+  bf_reports.duration_lib_overrides_recursive_resync -
+  (duration_lib_override_recursive_resync_minutes * 60.0));
   if (bf_reports.num_resynced_lib_overrides_libraries != 0) {
 for (LinkNode *node_lib = bf_reports.libraries_recursive_linked; 
node_lib != NULL;
  node_lib = node_lib->next) {
   Library *library = node_lib->link;
   BKE_reportf(reports, RPT_INFO, "Library %s needs overrides resync.", 
library->filepath);
 }
+  }
+  if (bf_reports.num_missing_libraries != 0 || 
bf_reports.num_missing_linked_id != 0) {
+BKE_reportf(reports,
+   

[Bf-blender-cvs] [a82b8269395] override-recursive-resync: Cleanup: misleading return argument for hair_create_input_mesh

2021-06-14 Thread Campbell Barton
Commit: a82b8269395dc6558be26b80704f922708872f96
Author: Campbell Barton
Date:   Sun Jun 13 14:47:04 2021 +1000
Branches: override-recursive-resync
https://developer.blender.org/rBa82b8269395dc6558be26b80704f922708872f96

Cleanup: misleading return argument for hair_create_input_mesh

- The argument with named with an `r_` prefix when it was in fact
  also read from.
- The argument passed in had to be 'psys->clmd->hairdata',
  if it was not - the function would not worked.

===

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

===

diff --git a/source/blender/blenkernel/intern/particle_system.c 
b/source/blender/blenkernel/intern/particle_system.c
index ce4be411c9a..149e345e501 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -3312,13 +3312,11 @@ static MDeformVert *hair_set_pinning(MDeformVert 
*dvert, float weight)
 static void hair_create_input_mesh(ParticleSimulationData *sim,
int totpoint,
int totedge,
-   Mesh **r_mesh,
-   ClothHairData **r_hairdata)
+   Mesh **r_mesh)
 {
   ParticleSystem *psys = sim->psys;
   ParticleSettings *part = psys->part;
   Mesh *mesh;
-  ClothHairData *hairdata;
   MVert *mvert;
   MEdge *medge;
   MDeformVert *dvert;
@@ -3339,9 +3337,8 @@ static void hair_create_input_mesh(ParticleSimulationData 
*sim,
   medge = mesh->medge;
   dvert = mesh->dvert;
 
-  hairdata = *r_hairdata;
-  if (!hairdata) {
-*r_hairdata = hairdata = MEM_mallocN(sizeof(ClothHairData) * totpoint, 
"hair data");
+  if (psys->clmd->hairdata == NULL) {
+psys->clmd->hairdata = MEM_mallocN(sizeof(ClothHairData) * totpoint, "hair 
data");
   }
 
   /* calculate maximum segment length */
@@ -3493,7 +3490,7 @@ static void do_hair_dynamics(ParticleSimulationData *sim)
 }
   }
 
-  hair_create_input_mesh(sim, totpoint, totedge, &psys->hair_in_mesh, 
&psys->clmd->hairdata);
+  hair_create_input_mesh(sim, totpoint, totedge, &psys->hair_in_mesh);
 
   if (psys->hair_out_mesh) {
 BKE_id_free(NULL, psys->hair_out_mesh);

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


[Bf-blender-cvs] [2bd3c108764] override-recursive-resync: Cleanup: Reduce indentation from redundant check

2021-06-14 Thread Hans Goudey
Commit: 2bd3c108764363680cc437713051a442f86fa01a
Author: Hans Goudey
Date:   Sun Jun 13 18:56:52 2021 -0500
Branches: override-recursive-resync
https://developer.blender.org/rB2bd3c108764363680cc437713051a442f86fa01a

Cleanup: Reduce indentation from redundant check

===

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

===

diff --git a/source/blender/blenkernel/intern/displist.cc 
b/source/blender/blenkernel/intern/displist.cc
index a22a30aa2ee..70355f3883d 100644
--- a/source/blender/blenkernel/intern/displist.cc
+++ b/source/blender/blenkernel/intern/displist.cc
@@ -1420,237 +1420,237 @@ static void do_makeDispListCurveTypes(Depsgraph 
*depsgraph,
 
   if (ob->type == OB_SURF) {
 displist_make_surf(depsgraph, scene, ob, dispbase, r_final, for_render, 
for_orco);
+return;
   }
-  else if (ELEM(ob->type, OB_CURVE, OB_FONT)) {
-ListBase nubase = {nullptr, nullptr};
-bool force_mesh_conversion = false;
 
-BKE_curve_bevelList_free(&ob->runtime.curve_cache->bev);
+  ListBase nubase = {nullptr, nullptr};
+  bool force_mesh_conversion = false;
 
-/* We only re-evaluate path if evaluation is not happening for orco.
- * If the calculation happens for orco, we should never free data which
- * was needed before and only not needed for orco calculation. */
-if (!for_orco) {
-  if (ob->runtime.curve_cache->anim_path_accum_length) {
-MEM_freeN((void *)ob->runtime.curve_cache->anim_path_accum_length);
-  }
-  ob->runtime.curve_cache->anim_path_accum_length = nullptr;
-}
+  BKE_curve_bevelList_free(&ob->runtime.curve_cache->bev);
 
-if (ob->type == OB_FONT) {
-  BKE_vfont_to_curve_nubase(ob, FO_EDIT, &nubase);
-}
-else {
-  BKE_nurbList_duplicate(&nubase, BKE_curve_nurbs_get(const_cast(cu)));
+  /* We only re-evaluate path if evaluation is not happening for orco.
+   * If the calculation happens for orco, we should never free data which
+   * was needed before and only not needed for orco calculation. */
+  if (!for_orco) {
+if (ob->runtime.curve_cache->anim_path_accum_length) {
+  MEM_freeN((void *)ob->runtime.curve_cache->anim_path_accum_length);
 }
+ob->runtime.curve_cache->anim_path_accum_length = nullptr;
+  }
 
-if (!for_orco) {
-  force_mesh_conversion = BKE_curve_calc_modifiers_pre(
-  depsgraph, scene, ob, &nubase, &nubase, for_render);
-}
+  if (ob->type == OB_FONT) {
+BKE_vfont_to_curve_nubase(ob, FO_EDIT, &nubase);
+  }
+  else {
+BKE_nurbList_duplicate(&nubase, BKE_curve_nurbs_get(const_cast(cu)));
+  }
 
-BKE_curve_bevelList_make(ob, &nubase, for_render);
+  if (!for_orco) {
+force_mesh_conversion = BKE_curve_calc_modifiers_pre(
+depsgraph, scene, ob, &nubase, &nubase, for_render);
+  }
 
-/* If curve has no bevel will return nothing */
-ListBase dlbev = BKE_curve_bevel_make(cu);
+  BKE_curve_bevelList_make(ob, &nubase, for_render);
 
-/* no bevel or extrude, and no width correction? */
-if (BLI_listbase_is_empty(&dlbev) && cu->width == 1.0f) {
-  curve_to_displist(cu, &nubase, for_render, dispbase);
-}
-else {
-  const float widfac = cu->width - 1.0f;
+  /* If curve has no bevel will return nothing */
+  ListBase dlbev = BKE_curve_bevel_make(cu);
 
-  BevList *bl = (BevList *)ob->runtime.curve_cache->bev.first;
-  Nurb *nu = (Nurb *)nubase.first;
-  for (; bl && nu; bl = bl->next, nu = nu->next) {
-float *data;
+  /* no bevel or extrude, and no width correction? */
+  if (BLI_listbase_is_empty(&dlbev) && cu->width == 1.0f) {
+curve_to_displist(cu, &nubase, for_render, dispbase);
+  }
+  else {
+const float widfac = cu->width - 1.0f;
 
-if (bl->nr == 0) { /* blank bevel lists can happen */
-  continue;
-}
+BevList *bl = (BevList *)ob->runtime.curve_cache->bev.first;
+Nurb *nu = (Nurb *)nubase.first;
+for (; bl && nu; bl = bl->next, nu = nu->next) {
+  float *data;
 
-/* exception handling; curve without bevel or extrude, with width 
correction */
-if (BLI_listbase_is_empty(&dlbev)) {
-  DispList *dl = (DispList *)MEM_callocN(sizeof(DispList), 
"makeDispListbev");
-  dl->verts = (float *)MEM_mallocN(sizeof(float[3]) * bl->nr, 
"dlverts");
-  BLI_addtail(dispbase, dl);
+  if (bl->nr == 0) { /* blank bevel lists can happen */
+continue;
+  }
 
-  if (bl->poly != -1) {
-dl->type = DL_POLY;
-  }
-  else {
-dl->type = DL_SEGM;
-dl->flag = (DL_FRONT_CURVE | DL_BACK_CURVE);
-  }
+  /* exception handling; curve without bevel or extrude, with width 
correction */
+  if (BLI_listbase_is_empty(&dlbev)) {
+DispList *dl = (DispList *)MEM_callocN(sizeof(DispList), 
"makeDispListbev");
+dl->verts = (float *)ME

[Bf-blender-cvs] [0c9b87e05ea] override-recursive-resync: Fix build error in release builds after recent changes

2021-06-14 Thread Brecht Van Lommel
Commit: 0c9b87e05ea550707755b6f6c83917ebd3c37ff2
Author: Brecht Van Lommel
Date:   Mon Jun 14 13:22:11 2021 +0200
Branches: override-recursive-resync
https://developer.blender.org/rB0c9b87e05ea550707755b6f6c83917ebd3c37ff2

Fix build error in release builds after recent changes

===

M   source/blender/blenlib/BLI_math_base.h

===

diff --git a/source/blender/blenlib/BLI_math_base.h 
b/source/blender/blenlib/BLI_math_base.h
index 5a3482db046..88dc20a64f2 100644
--- a/source/blender/blenlib/BLI_math_base.h
+++ b/source/blender/blenlib/BLI_math_base.h
@@ -296,6 +296,7 @@ float ceil_power_of_10(float f);
 #else
 #  define BLI_ASSERT_UNIT_V2(v) (void)(v)
 #  define BLI_ASSERT_UNIT_V3(v) (void)(v)
+#  define BLI_ASSERT_UNIT_V3_DB(v) (void)(v)
 #  define BLI_ASSERT_UNIT_QUAT(v) (void)(v)
 #  define BLI_ASSERT_ZERO_M3(m) (void)(m)
 #  define BLI_ASSERT_ZERO_M4(m) (void)(m)

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


[Bf-blender-cvs] [196630d5f6c] override-recursive-resync: Fix T88494: add missing depsgraph relation update tags

2021-06-14 Thread Jacques Lucke
Commit: 196630d5f6c7ca469cea3f14f7117f316d4081d2
Author: Jacques Lucke
Date:   Mon Jun 14 11:35:36 2021 +0200
Branches: override-recursive-resync
https://developer.blender.org/rB196630d5f6c7ca469cea3f14f7117f316d4081d2

Fix T88494: add missing depsgraph relation update tags

Adding e.g. a Collection Info node creates a new depsgraph relation.
Therefore the relations should be updated.

===

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

===

diff --git a/source/blender/editors/space_node/node_add.cc 
b/source/blender/editors/space_node/node_add.cc
index 7276688e986..6143af8ed70 100644
--- a/source/blender/editors/space_node/node_add.cc
+++ b/source/blender/editors/space_node/node_add.cc
@@ -591,6 +591,7 @@ static int node_add_texture_exec(bContext *C, wmOperator 
*op)
 
   snode_notify(C, snode);
   snode_dag_update(C, snode);
+  DEG_relations_tag_update(bmain);
 
   ED_node_tag_update_nodetree(bmain, ntree, texture_node);
 
@@ -696,6 +697,7 @@ static int node_add_collection_exec(bContext *C, wmOperator 
*op)
 
   snode_notify(C, snode);
   snode_dag_update(C, snode);
+  DEG_relations_tag_update(bmain);
 
   ED_node_tag_update_nodetree(bmain, ntree, collection_node);
 
@@ -807,6 +809,7 @@ static int node_add_file_exec(bContext *C, wmOperator *op)
 
   snode_notify(C, snode);
   snode_dag_update(C, snode);
+  DEG_relations_tag_update(bmain);
 
   return OPERATOR_FINISHED;
 }
@@ -902,6 +905,7 @@ static int node_add_mask_exec(bContext *C, wmOperator *op)
 
   snode_notify(C, snode);
   snode_dag_update(C, snode);
+  DEG_relations_tag_update(bmain);
 
   return OPERATOR_FINISHED;
 }

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


[Bf-blender-cvs] [cab23264f25] override-recursive-resync: Fix T87867: file open dialog triggers OneDrive file downloads on macOS

2021-06-14 Thread Leon Zandman
Commit: cab23264f25f96556ea0ee659214c6ca320f9a74
Author: Leon Zandman
Date:   Mon Jun 14 11:16:42 2021 +0200
Branches: override-recursive-resync
https://developer.blender.org/rBcab23264f25f96556ea0ee659214c6ca320f9a74

Fix T87867: file open dialog triggers OneDrive file downloads on macOS

Until OneDrive supports macOS's native placeholder file implementation, detect
the com.microsoft.OneDrive.RecallOnOpen extended file attribute.

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

===

M   source/blender/blenlib/intern/storage_apple.mm

===

diff --git a/source/blender/blenlib/intern/storage_apple.mm 
b/source/blender/blenlib/intern/storage_apple.mm
index 2a4bbffa60e..8af98d61ecb 100644
--- a/source/blender/blenlib/intern/storage_apple.mm
+++ b/source/blender/blenlib/intern/storage_apple.mm
@@ -24,10 +24,15 @@
  */
 
 #import 
+#include 
+#include 
 
 #include "BLI_fileops.h"
 #include "BLI_path_util.h"
 
+/* Extended file attribute used by OneDrive to mark placeholder files. */
+static const char *ONEDRIVE_RECALLONOPEN_ATTRIBUTE = 
"com.microsoft.OneDrive.RecallOnOpen";
+
 /**
  * \param r_targetpath: Buffer for the target path an alias points to.
  * \return Whether the file at the input path is an alias.
@@ -66,6 +71,67 @@ bool BLI_file_alias_target(const char *filepath, char 
r_targetpath[FILE_MAXDIR])
   return true;
 }
 
+/**
+ * Checks if the given string of listxattr() attributes contains a specific 
attribute.
+ *
+ * \param attributes: a string of null-terminated listxattr() attributes.
+ * \param search_attribute: the attribute to search for.
+ * \return 'true' when the attribute is found, otherwise 'false'.
+ */
+static bool find_attribute(const std::string &attributes, const char 
*search_attribute)
+{
+  /* Attributes is a list of consecutive null-terminated strings. */
+  const char *end = attributes.data() + attributes.size();
+  for (const char *item = attributes.data(); item < end; item += strlen(item) 
+ 1) {
+if (STREQ(item, search_attribute)) {
+  return true;
+}
+  }
+
+  return false;
+}
+
+/**
+ * Checks if the file is merely a placeholder for a OneDrive file that hasn't 
yet been downloaded.
+ *
+ * \param path: the path of the file.
+ * \return 'true' when the file is a OneDrive placeholder, otherwise 'false'.
+ */
+static bool test_onedrive_file_is_placeholder(const char *path)
+{
+  /* Note: Currently only checking for the 
"com.microsoft.OneDrive.RecallOnOpen" extended file
+   * attribute. In theory this attribute can also be set on files that aren't 
located inside a
+   * OneDrive folder. Maybe additional checks are required? */
+
+  /* Get extended file attributes */
+  ssize_t size = listxattr(path, nullptr, 0, XATTR_NOFOLLOW);
+  if (size < 1) {
+return false;
+  }
+
+  std::string attributes(size, '\0');
+  size = listxattr(path, attributes.data(), size, XATTR_NOFOLLOW);
+  /* In case listxattr() has failed the second time it's called. */
+  if (size < 1) {
+return false;
+  }
+
+  /* Check for presence of 'com.microsoft.OneDrive.RecallOnOpen' attribute. */
+  return find_attribute(attributes, ONEDRIVE_RECALLONOPEN_ATTRIBUTE);
+}
+
+/**
+ * Checks if the file is marked as offline and not immediately available.
+ *
+ * \param path: the path of the file.
+ * \return 'true' when the file is a placeholder, otherwise 'false'.
+ */
+static bool test_file_is_offline(const char *path)
+{
+  /* Logic for additional cloud storage providers could be added in the 
future. */
+  return test_onedrive_file_is_placeholder(path);
+}
+
 eFileAttributes BLI_file_attributes(const char *path)
 {
   int ret = 0;
@@ -76,15 +142,28 @@ eFileAttributes BLI_file_attributes(const char *path)
 const NSURL *fileURL = [[NSURL alloc] 
initFileURLWithFileSystemRepresentation:path
   
isDirectory:NO
 
relativeToURL:nil];
-NSArray *resourceKeys =
-@[ NSURLIsAliasFileKey, NSURLIsHiddenKey, NSURLIsReadableKey, 
NSURLIsWritableKey ];
+
+/* Querying NSURLIsReadableKey and NSURLIsWritableKey keys for OneDrive 
placeholder files
+ * triggers their unwanted download. */
+NSArray *resourceKeys = nullptr;
+const bool is_offline = test_file_is_offline(path);
+
+if (is_offline) {
+  resourceKeys = @[ NSURLIsAliasFileKey, NSURLIsHiddenKey ];
+}
+else {
+  resourceKeys =
+  @[ NSURLIsAliasFileKey, NSURLIsHiddenKey, NSURLIsReadableKey, 
NSURLIsWritableKey ];
+}
 
 const NSDictionary *resourceKeyValues = [fileURL 
resourceValuesForKeys:resourceKeys error:nil];
 
 const bool is_alias = [resourceKeyValues[(void)(@"@%"), 
NSURLIsAliasFileKey] boolValue];
 const bool is_hidden = [resourceKeyValues[(void)(@"@%"), NSURLIsHiddenKey] 
boolValue];
-const bo

[Bf-blender-cvs] [84674a46a26] override-recursive-resync: Cleanup: redundant initialization

2021-06-14 Thread Campbell Barton
Commit: 84674a46a2646961993e905bcca2fd716e8276c3
Author: Campbell Barton
Date:   Sun Jun 13 14:47:22 2021 +1000
Branches: override-recursive-resync
https://developer.blender.org/rB84674a46a2646961993e905bcca2fd716e8276c3

Cleanup: redundant initialization

These were limited to obvious cases. Some less obvious cases
were kept as refactoring might make them necessary in future.

===

M   source/blender/blenkernel/intern/mesh.c
M   source/blender/blenkernel/intern/mesh_evaluate.c
M   source/blender/blenkernel/intern/subsurf_ccg.c
M   source/blender/blenlib/intern/mesh_boolean.cc
M   source/blender/blenloader/intern/versioning_280.c
M   source/blender/bmesh/tools/bmesh_bevel.c
M   source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
M   source/blender/draw/engines/overlay/overlay_armature.c
M   source/blender/editors/curve/editcurve.c
M   source/blender/editors/curve/editcurve_paint.c
M   source/blender/editors/gpencil/gpencil_trace_utils.c
M   source/blender/editors/mesh/meshtools.c
M   source/blender/editors/sculpt_paint/sculpt_undo.c
M   source/blender/editors/space_clip/clip_ops.c
M   source/blender/editors/space_graph/graph_select.c
M   source/blender/editors/space_image/image_ops.c
M   source/blender/editors/space_info/info_draw.c
M   source/blender/editors/transform/transform_mode_maskshrinkfatten.c
M   source/blender/editors/transform/transform_snap.c
M   source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c
M   source/blender/gpu/intern/gpu_shader.cc
M   source/blender/makesdna/intern/dna_genfile.c
M   source/blender/makesrna/intern/rna_scene.c
M   source/blender/makesrna/intern/rna_userdef.c
M   source/blender/sequencer/intern/strip_add.c
M   source/blender/windowmanager/intern/wm_files.c

===

diff --git a/source/blender/blenkernel/intern/mesh.c 
b/source/blender/blenkernel/intern/mesh.c
index ddbc7e7d1ef..0b843c3a97a 100644
--- a/source/blender/blenkernel/intern/mesh.c
+++ b/source/blender/blenkernel/intern/mesh.c
@@ -1521,12 +1521,12 @@ void BKE_mesh_transform(Mesh *me, const float 
mat[4][4], bool do_keys)
 
 void BKE_mesh_translate(Mesh *me, const float offset[3], const bool do_keys)
 {
-  MVert *mvert = CustomData_duplicate_referenced_layer(&me->vdata, CD_MVERT, 
me->totvert);
+  CustomData_duplicate_referenced_layer(&me->vdata, CD_MVERT, me->totvert);
   /* If the referenced layer has been re-allocated need to update pointers 
stored in the mesh. */
   BKE_mesh_update_customdata_pointers(me, false);
 
   int i = me->totvert;
-  for (mvert = me->mvert; i--; mvert++) {
+  for (MVert *mvert = me->mvert; i--; mvert++) {
 add_v3_v3(mvert->co, offset);
   }
 
diff --git a/source/blender/blenkernel/intern/mesh_evaluate.c 
b/source/blender/blenkernel/intern/mesh_evaluate.c
index 345546bc9cf..826094420a7 100644
--- a/source/blender/blenkernel/intern/mesh_evaluate.c
+++ b/source/blender/blenkernel/intern/mesh_evaluate.c
@@ -2567,7 +2567,7 @@ bool BKE_mesh_center_median_from_polys(const Mesh *me, 
float r_cent[3])
   const MLoop *mloop = me->mloop;
   const MVert *mvert = me->mvert;
   zero_v3(r_cent);
-  for (mpoly = me->mpoly; i--; mpoly++) {
+  for (; i--; mpoly++) {
 int loopend = mpoly->loopstart + mpoly->totloop;
 for (int j = mpoly->loopstart; j < loopend; j++) {
   add_v3_v3(r_cent, mvert[mloop[j].v].co);
diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c 
b/source/blender/blenkernel/intern/subsurf_ccg.c
index a28136f8527..23eccbfba9b 100644
--- a/source/blender/blenkernel/intern/subsurf_ccg.c
+++ b/source/blender/blenkernel/intern/subsurf_ccg.c
@@ -1879,12 +1879,11 @@ static const MeshElemMap *ccgDM_getPolyMap(Object *ob, 
DerivedMesh *dm)
 /* WARNING! *MUST* be called in an 'loops_cache_rwlock' protected thread 
context! */
 static void ccgDM_recalcLoopTri(DerivedMesh *dm)
 {
-  MLoopTri *mlooptri = dm->looptris.array;
   const int tottri = dm->numPolyData * 2;
   int i, poly_index;
 
   DM_ensure_looptri_data(dm);
-  mlooptri = dm->looptris.array_wip;
+  MLoopTri *mlooptri = dm->looptris.array_wip;
 
   BLI_assert(tottri == 0 || mlooptri != NULL);
   BLI_assert(poly_to_tri_count(dm->numPolyData, dm->numLoopData) == 
dm->looptris.num);
diff --git a/source/blender/blenlib/intern/mesh_boolean.cc 
b/source/blender/blenlib/intern/mesh_boolean.cc
index 25aeae519c1..c5c830bb4dd 100644
--- a/source/blender/blenlib/intern/mesh_boolean.cc
+++ b/source/blender/blenlib/intern/mesh_boolean.cc
@@ -1406,9 +1406,9 @@ static int find_cell_for_point_near_edge(mpq3 p,
   int dummy_index = p_sorted_dummy - sorted_tris.begin();
   int prev_tri = (dummy_index == 0) ? sorted_tris[sorted_tris.size() - 1] :
   sorted_tris[dummy_index - 1];
-  int next_tri = (dummy_index == sorted_tris.size() - 1) ? sorted_tris

[Bf-blender-cvs] [cdef5db221b] override-recursive-resync: Cleanup: use ATTR_RETURNS_NONNULL function attribute

2021-06-14 Thread Campbell Barton
Commit: cdef5db221be3e69aa58d02c3d3b4a451f2f1193
Author: Campbell Barton
Date:   Sun Jun 13 14:47:19 2021 +1000
Branches: override-recursive-resync
https://developer.blender.org/rBcdef5db221be3e69aa58d02c3d3b4a451f2f1193

Cleanup: use ATTR_RETURNS_NONNULL function attribute

===

M   source/blender/blenlib/BLI_memarena.h
M   source/blender/blenlib/BLI_memiter.h
M   source/blender/blenlib/BLI_mempool.h

===

diff --git a/source/blender/blenlib/BLI_memarena.h 
b/source/blender/blenlib/BLI_memarena.h
index 87a320e336d..d7798f12fcc 100644
--- a/source/blender/blenlib/BLI_memarena.h
+++ b/source/blender/blenlib/BLI_memarena.h
@@ -38,7 +38,8 @@ extern "C" {
 struct MemArena;
 typedef struct MemArena MemArena;
 
-struct MemArena *BLI_memarena_new(const size_t bufsize, const char *name) 
ATTR_WARN_UNUSED_RESULT
+struct MemArena *BLI_memarena_new(const size_t bufsize,
+  const char *name) ATTR_WARN_UNUSED_RESULT 
ATTR_RETURNS_NONNULL
 ATTR_NONNULL(2) ATTR_MALLOC;
 void BLI_memarena_free(struct MemArena *ma) ATTR_NONNULL(1);
 void BLI_memarena_use_malloc(struct MemArena *ma) ATTR_NONNULL(1);
diff --git a/source/blender/blenlib/BLI_memiter.h 
b/source/blender/blenlib/BLI_memiter.h
index c7a715309e1..abb1bec809d 100644
--- a/source/blender/blenlib/BLI_memiter.h
+++ b/source/blender/blenlib/BLI_memiter.h
@@ -36,15 +36,14 @@ struct BLI_memiter;
 typedef struct BLI_memiter BLI_memiter;
 
 /* warning, ATTR_MALLOC flag on BLI_memiter_alloc causes crash, see: D2756 */
-BLI_memiter *BLI_memiter_create(unsigned int chunk_size) ATTR_MALLOC 
ATTR_WARN_UNUSED_RESULT;
-void *BLI_memiter_alloc(BLI_memiter *mi,
-unsigned int size) ATTR_RETURNS_NONNULL 
ATTR_WARN_UNUSED_RESULT
-ATTR_NONNULL(1);
+BLI_memiter *BLI_memiter_create(unsigned int chunk_size)
+ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL;
+void *BLI_memiter_alloc(BLI_memiter *mi, unsigned int size)
+ATTR_RETURNS_NONNULL ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL 
ATTR_NONNULL(1);
 void BLI_memiter_alloc_from(BLI_memiter *mi, uint elem_size, const void 
*data_from)
 ATTR_NONNULL(1, 3);
-void *BLI_memiter_calloc(BLI_memiter *mi,
- unsigned int size) ATTR_RETURNS_NONNULL 
ATTR_WARN_UNUSED_RESULT
-ATTR_NONNULL(1);
+void *BLI_memiter_calloc(BLI_memiter *mi, unsigned int size)
+ATTR_RETURNS_NONNULL ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL 
ATTR_NONNULL(1);
 void BLI_memiter_destroy(BLI_memiter *mi) ATTR_NONNULL(1);
 void BLI_memiter_clear(BLI_memiter *mi) ATTR_NONNULL(1);
 unsigned int BLI_memiter_count(const BLI_memiter *mi) ATTR_WARN_UNUSED_RESULT 
ATTR_NONNULL(1);
@@ -59,11 +58,11 @@ typedef struct BLI_memiter_handle {
   uint elem_left;
 } BLI_memiter_handle;
 
-void BLI_memiter_iter_init(BLI_memiter *mi, BLI_memiter_handle *iter) 
ATTR_NONNULL();
-bool BLI_memiter_iter_done(const BLI_memiter_handle *iter) ATTR_NONNULL();
-void *BLI_memiter_iter_step(BLI_memiter_handle *iter) ATTR_WARN_UNUSED_RESULT 
ATTR_NONNULL();
+void BLI_memiter_iter_init(BLI_memiter *mi, BLI_memiter_handle *iter) 
ATTR_NONNULL(1, 2);
+bool BLI_memiter_iter_done(const BLI_memiter_handle *iter) ATTR_NONNULL(1);
+void *BLI_memiter_iter_step(BLI_memiter_handle *iter) ATTR_WARN_UNUSED_RESULT 
ATTR_NONNULL(1);
 void *BLI_memiter_iter_step_size(BLI_memiter_handle *iter, uint *r_size) 
ATTR_WARN_UNUSED_RESULT
-ATTR_NONNULL();
+ATTR_NONNULL(1, 2);
 
 #ifdef __cplusplus
 }
diff --git a/source/blender/blenlib/BLI_mempool.h 
b/source/blender/blenlib/BLI_mempool.h
index c11802d6270..4d9381093c7 100644
--- a/source/blender/blenlib/BLI_mempool.h
+++ b/source/blender/blenlib/BLI_mempool.h
@@ -38,9 +38,12 @@ typedef struct BLI_mempool BLI_mempool;
 BLI_mempool *BLI_mempool_create(unsigned int esize,
 unsigned int totelem,
 unsigned int pchunk,
-unsigned int flag) ATTR_MALLOC 
ATTR_WARN_UNUSED_RESULT;
-void *BLI_mempool_alloc(BLI_mempool *pool) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT 
ATTR_NONNULL(1);
-void *BLI_mempool_calloc(BLI_mempool *pool) ATTR_MALLOC 
ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1);
+unsigned int flag)
+ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL;
+void *BLI_mempool_alloc(BLI_mempool *pool) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT 
ATTR_RETURNS_NONNULL
+ATTR_NONNULL(1);
+void *BLI_mempool_calloc(BLI_mempool *pool)
+ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL ATTR_NONNULL(1);
 void BLI_mempool_free(BLI_mempool *pool, void *addr) ATTR_NONNULL(1, 2);
 void BLI_mempool_clear_ex(BLI_mempool *pool, const int totelem_reserve) 
ATTR_NONNULL(1);
 void BLI_mempool_clear(BLI_mempool *pool) ATTR_NONNULL(1);

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

[Bf-blender-cvs] [7bd8a518a8d] override-recursive-resync: BLI_math: Cleanup: Use `mul_`/`madd_` functions.

2021-06-14 Thread Bastien Montagne
Commit: 7bd8a518a8d1b8929c3f89b7d8b0c855e81134d3
Author: Bastien Montagne
Date:   Mon Jun 14 12:30:11 2021 +0200
Branches: override-recursive-resync
https://developer.blender.org/rB7bd8a518a8d1b8929c3f89b7d8b0c855e81134d3

BLI_math: Cleanup: Use `mul_`/`madd_` functions.

Better to avoid explicit vectors components direct manipulation when a
generic operation for whole vector exists, if nothing else it avoids
potential mistakes in indices.

===

M   source/blender/blenlib/BLI_math_base.h
M   source/blender/blenlib/BLI_math_vector.h
M   source/blender/blenlib/intern/math_vector.c
M   source/blender/blenlib/intern/math_vector_inline.c

===

diff --git a/source/blender/blenlib/BLI_math_base.h 
b/source/blender/blenlib/BLI_math_base.h
index 46219ad5493..5a3482db046 100644
--- a/source/blender/blenlib/BLI_math_base.h
+++ b/source/blender/blenlib/BLI_math_base.h
@@ -237,6 +237,7 @@ float ceil_power_of_10(float f);
 #ifndef NDEBUG
 /** \note 0.0001 is too small because normals may be converted from short's: 
see T34322. */
 #  define BLI_ASSERT_UNIT_EPSILON 0.0002f
+#  define BLI_ASSERT_UNIT_EPSILON_DB 0.0002
 /**
  * \note Checks are flipped so NAN doesn't assert.
  * This is done because we're making sure the value was normalized and in the 
case we
@@ -253,8 +254,8 @@ float ceil_power_of_10(float f);
 #  define BLI_ASSERT_UNIT_V3_DB(v) \
 { \
   const double _test_unit = len_squared_v3_db(v); \
-  BLI_assert(!(fabs(_test_unit - 1.0) >= BLI_ASSERT_UNIT_EPSILON) || \
- !(fabs(_test_unit) >= BLI_ASSERT_UNIT_EPSILON)); \
+  BLI_assert(!(fabs(_test_unit - 1.0) >= BLI_ASSERT_UNIT_EPSILON_DB) || \
+ !(fabs(_test_unit) >= BLI_ASSERT_UNIT_EPSILON_DB)); \
 } \
 (void)0
 
diff --git a/source/blender/blenlib/BLI_math_vector.h 
b/source/blender/blenlib/BLI_math_vector.h
index caedf83666f..556a216bb89 100644
--- a/source/blender/blenlib/BLI_math_vector.h
+++ b/source/blender/blenlib/BLI_math_vector.h
@@ -163,6 +163,7 @@ MINLINE void madd_v3_v3fl(float r[3], const float a[3], 
float f);
 MINLINE void madd_v3_v3v3(float r[3], const float a[3], const float b[3]);
 MINLINE void madd_v2_v2v2fl(float r[2], const float a[2], const float b[2], 
float f);
 MINLINE void madd_v3_v3v3fl(float r[3], const float a[3], const float b[3], 
float f);
+MINLINE void madd_v3_v3v3db_db(double r[3], const double a[3], const double 
b[3], double f);
 MINLINE void madd_v3_v3v3v3(float r[3], const float a[3], const float b[3], 
const float c[3]);
 MINLINE void madd_v4_v4fl(float r[4], const float a[4], float f);
 MINLINE void madd_v4_v4v4(float r[4], const float a[4], const float b[4]);
diff --git a/source/blender/blenlib/intern/math_vector.c 
b/source/blender/blenlib/intern/math_vector.c
index 05c5f672baa..35dfe421cf0 100644
--- a/source/blender/blenlib/intern/math_vector.c
+++ b/source/blender/blenlib/intern/math_vector.c
@@ -663,9 +663,7 @@ void project_v2_v2v2(float out[2], const float p[2], const 
float v_proj[2])
   }
 
   const float mul = dot_v2v2(p, v_proj) / dot_v2v2(v_proj, v_proj);
-
-  out[0] = mul * v_proj[0];
-  out[1] = mul * v_proj[1];
+  mul_v2_v2fl(out, v_proj, mul);
 }
 
 /**
@@ -679,10 +677,7 @@ void project_v3_v3v3(float out[3], const float p[3], const 
float v_proj[3])
   }
 
   const float mul = dot_v3v3(p, v_proj) / dot_v3v3(v_proj, v_proj);
-
-  out[0] = mul * v_proj[0];
-  out[1] = mul * v_proj[1];
-  out[2] = mul * v_proj[2];
+  mul_v3_v3fl(out, v_proj, mul);
 }
 
 void project_v3_v3v3_db(double out[3], const double p[3], const double 
v_proj[3])
@@ -693,10 +688,7 @@ void project_v3_v3v3_db(double out[3], const double p[3], 
const double v_proj[3]
   }
 
   const double mul = dot_v3v3_db(p, v_proj) / dot_v3v3_db(v_proj, v_proj);
-
-  out[0] = mul * v_proj[0];
-  out[1] = mul * v_proj[1];
-  out[2] = mul * v_proj[2];
+  mul_v3_v3db_db(out, v_proj, mul);
 }
 
 /**
@@ -705,10 +697,9 @@ void project_v3_v3v3_db(double out[3], const double p[3], 
const double v_proj[3]
 void project_v2_v2v2_normalized(float out[2], const float p[2], const float 
v_proj[2])
 {
   BLI_ASSERT_UNIT_V2(v_proj);
-  const float mul = dot_v2v2(p, v_proj);
 
-  out[0] = mul * v_proj[0];
-  out[1] = mul * v_proj[1];
+  const float mul = dot_v2v2(p, v_proj);
+  mul_v2_v2fl(out, v_proj, mul);
 }
 
 /**
@@ -717,11 +708,9 @@ void project_v2_v2v2_normalized(float out[2], const float 
p[2], const float v_pr
 void project_v3_v3v3_normalized(float out[3], const float p[3], const float 
v_proj[3])
 {
   BLI_ASSERT_UNIT_V3(v_proj);
-  const float mul = dot_v3v3(p, v_proj);
 
-  out[0] = mul * v_proj[0];
-  out[1] = mul * v_proj[1];
-  out[2] = mul * v_proj[2];
+  const float mul = dot_v3v3(p, v_proj);
+  mul_v3_v3fl(out, v_proj, mul);
 }
 
 /**
@@ -740,37 +729,31 @@ void project_v3_v3v3_normalized(float out[3], const float 
p[3], const float v_pr
 void project_plane_v

[Bf-blender-cvs] [894cd25828e] override-recursive-resync: BLI_math: Fix several division-by-zero cases.

2021-06-14 Thread Bastien Montagne
Commit: 894cd25828e71fdba69fc1899d7bff7471297bc1
Author: Bastien Montagne
Date:   Mon Jun 14 11:06:35 2021 +0200
Branches: override-recursive-resync
https://developer.blender.org/rB894cd25828e71fdba69fc1899d7bff7471297bc1

BLI_math: Fix several division-by-zero cases.

Those were caused by various tools used on degenerate geometry, see
T79775.

Note that fixes are as low-level as possible, to ensure they cover as
much as possible of unreported issues too.

We still probably have many more of those hidden in BLI_math though.

===

M   source/blender/blenlib/BLI_math_vector.h
M   source/blender/blenlib/intern/math_geom.c
M   source/blender/blenlib/intern/math_vector.c
M   source/blender/blenlib/intern/math_vector_inline.c

===

diff --git a/source/blender/blenlib/BLI_math_vector.h 
b/source/blender/blenlib/BLI_math_vector.h
index b43f86af670..caedf83666f 100644
--- a/source/blender/blenlib/BLI_math_vector.h
+++ b/source/blender/blenlib/BLI_math_vector.h
@@ -327,6 +327,10 @@ MINLINE bool is_zero_v2(const float a[2]) 
ATTR_WARN_UNUSED_RESULT;
 MINLINE bool is_zero_v3(const float a[3]) ATTR_WARN_UNUSED_RESULT;
 MINLINE bool is_zero_v4(const float a[4]) ATTR_WARN_UNUSED_RESULT;
 
+MINLINE bool is_zero_v2_db(const double a[2]) ATTR_WARN_UNUSED_RESULT;
+MINLINE bool is_zero_v3_db(const double a[3]) ATTR_WARN_UNUSED_RESULT;
+MINLINE bool is_zero_v4_db(const double a[4]) ATTR_WARN_UNUSED_RESULT;
+
 bool is_finite_v2(const float a[2]) ATTR_WARN_UNUSED_RESULT;
 bool is_finite_v3(const float a[3]) ATTR_WARN_UNUSED_RESULT;
 bool is_finite_v4(const float a[4]) ATTR_WARN_UNUSED_RESULT;
diff --git a/source/blender/blenlib/intern/math_geom.c 
b/source/blender/blenlib/intern/math_geom.c
index 508de506ae8..6b1730f8ee8 100644
--- a/source/blender/blenlib/intern/math_geom.c
+++ b/source/blender/blenlib/intern/math_geom.c
@@ -3344,6 +3344,13 @@ float closest_to_ray_v3(float r_close[3],
 const float ray_dir[3])
 {
   float h[3], lambda;
+
+  if (UNLIKELY(is_zero_v3(ray_dir))) {
+lambda = 0.0f;
+copy_v3_v3(r_close, ray_orig);
+return lambda;
+  }
+
   sub_v3_v3v3(h, p, ray_orig);
   lambda = dot_v3v3(ray_dir, h) / dot_v3v3(ray_dir, ray_dir);
   madd_v3_v3v3fl(r_close, ray_orig, ray_dir, lambda);
@@ -4467,7 +4474,7 @@ void interp_weights_poly_v2(float *w, float v[][2], const 
int n, const float co[
 d_curr = d_next;
 DIR_V2_SET(&d_next, v_next, co);
 ht = mean_value_half_tan_v2_db(&d_curr, &d_next);
-w[i_curr] = (float)((ht_prev + ht) / d_curr.len);
+w[i_curr] = (d_curr.len == 0.0) ? 0.0f : (float)((ht_prev + ht) / 
d_curr.len);
 totweight += w[i_curr];
 
 /* step */
diff --git a/source/blender/blenlib/intern/math_vector.c 
b/source/blender/blenlib/intern/math_vector.c
index fb7b96fde78..05c5f672baa 100644
--- a/source/blender/blenlib/intern/math_vector.c
+++ b/source/blender/blenlib/intern/math_vector.c
@@ -657,6 +657,11 @@ void angle_poly_v3(float *angles, const float *verts[3], 
int len)
  */
 void project_v2_v2v2(float out[2], const float p[2], const float v_proj[2])
 {
+  if (UNLIKELY(is_zero_v2(v_proj))) {
+zero_v2(out);
+return;
+  }
+
   const float mul = dot_v2v2(p, v_proj) / dot_v2v2(v_proj, v_proj);
 
   out[0] = mul * v_proj[0];
@@ -668,6 +673,11 @@ void project_v2_v2v2(float out[2], const float p[2], const 
float v_proj[2])
  */
 void project_v3_v3v3(float out[3], const float p[3], const float v_proj[3])
 {
+  if (UNLIKELY(is_zero_v3(v_proj))) {
+zero_v3(out);
+return;
+  }
+
   const float mul = dot_v3v3(p, v_proj) / dot_v3v3(v_proj, v_proj);
 
   out[0] = mul * v_proj[0];
@@ -677,6 +687,11 @@ void project_v3_v3v3(float out[3], const float p[3], const 
float v_proj[3])
 
 void project_v3_v3v3_db(double out[3], const double p[3], const double 
v_proj[3])
 {
+  if (UNLIKELY(is_zero_v3_db(v_proj))) {
+zero_v3_db(out);
+return;
+  }
+
   const double mul = dot_v3v3_db(p, v_proj) / dot_v3v3_db(v_proj, v_proj);
 
   out[0] = mul * v_proj[0];
diff --git a/source/blender/blenlib/intern/math_vector_inline.c 
b/source/blender/blenlib/intern/math_vector_inline.c
index ead354c2d87..e0df9665a7e 100644
--- a/source/blender/blenlib/intern/math_vector_inline.c
+++ b/source/blender/blenlib/intern/math_vector_inline.c
@@ -1282,6 +1282,21 @@ MINLINE bool is_zero_v4(const float v[4])
   return (v[0] == 0.0f && v[1] == 0.0f && v[2] == 0.0f && v[3] == 0.0f);
 }
 
+MINLINE bool is_zero_v2_db(const double v[2])
+{
+  return (v[0] == 0.0 && v[1] == 0.0);
+}
+
+MINLINE bool is_zero_v3_db(const double v[3])
+{
+  return (v[0] == 0.0 && v[1] == 0.0 && v[2] == 0.0);
+}
+
+MINLINE bool is_zero_v4_db(const double v[4])
+{
+  return (v[0] == 0.0 && v[1] == 0.0 && v[2] == 0.0 && v[3] == 0.0);
+}
+
 MINLINE bool is_one_v3(const float v[3])
 {
   return (v[0] == 1.0f && v[1] == 1.0f && v[2] == 1.0f);

___

[Bf-blender-cvs] [e82109da8cb] override-recursive-resync: Sequencer: Do not redraw during playback.

2021-06-14 Thread Jeroen Bakker
Commit: e82109da8cb18dab0e7efc9e6b7d78fb86b022bf
Author: Jeroen Bakker
Date:   Fri Jun 11 15:47:19 2021 +0200
Branches: override-recursive-resync
https://developer.blender.org/rBe82109da8cb18dab0e7efc9e6b7d78fb86b022bf

Sequencer: Do not redraw during playback.

When using large sequences including audio the drawing of the audio on
top of the strip takes a lot of time. This effects the playback
performance heavily.

During the animation playback performance there was a solution for this
by only drawing the playhead overlay. This was reverted for the sequence
editor as it didn't update the color strips when they were animated.

This patch checks if there are animated color strips if so the full
screen is redrawn, otherwise only the playhead is redrawn.

Reviewed By: ISS

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

===

M   source/blender/editors/include/ED_sequencer.h
M   source/blender/editors/screen/screen_ops.c
M   source/blender/editors/space_sequencer/sequencer_draw.c
M   source/blender/editors/space_sequencer/sequencer_edit.c

===

diff --git a/source/blender/editors/include/ED_sequencer.h 
b/source/blender/editors/include/ED_sequencer.h
index 11eff2d583b..ae76f0b6eaf 100644
--- a/source/blender/editors/include/ED_sequencer.h
+++ b/source/blender/editors/include/ED_sequencer.h
@@ -42,6 +42,7 @@ bool ED_space_sequencer_maskedit_poll(struct bContext *C);
 
 bool ED_space_sequencer_check_show_imbuf(struct SpaceSeq *sseq);
 bool ED_space_sequencer_check_show_strip(struct SpaceSeq *sseq);
+bool ED_space_sequencer_has_visible_animation_on_strip(const struct Scene 
*scene);
 
 void ED_operatormacros_sequencer(void);
 
diff --git a/source/blender/editors/screen/screen_ops.c 
b/source/blender/editors/screen/screen_ops.c
index 6b8d4e73f12..b41b54fee1f 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -4446,9 +4446,16 @@ static void screen_animation_region_tag_redraw(ScrArea 
*area,
   /* No need to do a full redraw as the current frame indicator is only 
updated.
* We do need to redraw when this area is in full screen as no other areas
* will be tagged for redrawing. */
-  if ((region->regiontype == RGN_TYPE_WINDOW) &&
-  (ELEM(area->spacetype, SPACE_GRAPH, SPACE_NLA, SPACE_ACTION)) && 
!area->full) {
-return;
+  if (region->regiontype == RGN_TYPE_WINDOW && !area->full) {
+if (ELEM(area->spacetype, SPACE_GRAPH, SPACE_NLA, SPACE_ACTION)) {
+  return;
+}
+
+if (area->spacetype == SPACE_SEQ) {
+  if (!ED_space_sequencer_has_visible_animation_on_strip(scene)) {
+return;
+  }
+}
   }
   ED_region_tag_redraw(region);
 }
diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c 
b/source/blender/editors/space_sequencer/sequencer_draw.c
index 7f500597906..5f831cbf535 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -2365,6 +2365,31 @@ static void draw_cache_view(const bContext *C)
 }
 
 /* Draw sequencer timeline. */
+static void draw_overlap_frame_indicator(const struct Scene *scene, const 
View2D *v2d)
+{
+  int overlap_frame = (scene->ed->over_flag & SEQ_EDIT_OVERLAY_ABS) ?
+  scene->ed->over_cfra :
+  scene->r.cfra + scene->ed->over_ofs;
+
+  uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 
2, GPU_FETCH_FLOAT);
+  immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
+  float viewport_size[4];
+  GPU_viewport_size_get_f(viewport_size);
+  immUniform2f("viewport_size", viewport_size[2], viewport_size[3]);
+  /* Shader may have color set from past usage - reset it. */
+  immUniform1i("colors_len", 0);
+  immUniform1f("dash_width", 20.0f * U.pixelsize);
+  immUniform1f("dash_factor", 0.5f);
+  immUniformThemeColor(TH_CFRAME);
+
+  immBegin(GPU_PRIM_LINES, 2);
+  immVertex2f(pos, overlap_frame, v2d->cur.ymin);
+  immVertex2f(pos, overlap_frame, v2d->cur.ymax);
+  immEnd();
+
+  immUnbindProgram();
+}
+
 void draw_timeline_seq(const bContext *C, ARegion *region)
 {
   Scene *scene = CTX_data_scene(C);
@@ -2424,31 +2449,6 @@ void draw_timeline_seq(const bContext *C, ARegion 
*region)
 cfra_flag |= DRAWCFRA_UNIT_SECONDS;
   }
 
-  /* Draw overlap frame frame indicator. */
-  if (scene->ed && scene->ed->over_flag & SEQ_EDIT_OVERLAY_SHOW) {
-int overlap_frame = (scene->ed->over_flag & SEQ_EDIT_OVERLAY_ABS) ?
-scene->ed->over_cfra :
-scene->r.cfra + scene->ed->over_ofs;
-
-uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 
2, GPU_FETCH_FLOAT);
-immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
-float viewport_size[4];
-GPU_viewport_size_get_f(viewport_size);
-i

[Bf-blender-cvs] [f5583ef8d12] override-recursive-resync: Cleanup: Order return argument last

2021-06-14 Thread Hans Goudey
Commit: f5583ef8d12757c1e58a44c29378030dc1b9331a
Author: Hans Goudey
Date:   Sun Jun 13 18:22:31 2021 -0500
Branches: override-recursive-resync
https://developer.blender.org/rBf5583ef8d12757c1e58a44c29378030dc1b9331a

Cleanup: Order return argument last

===

M   source/blender/blenkernel/BKE_displist.h
M   source/blender/blenkernel/intern/displist.cc
M   source/blender/blenkernel/intern/mesh_convert.c

===

diff --git a/source/blender/blenkernel/BKE_displist.h 
b/source/blender/blenkernel/BKE_displist.h
index ffa0b4d0091..a2d9bbcd011 100644
--- a/source/blender/blenkernel/BKE_displist.h
+++ b/source/blender/blenkernel/BKE_displist.h
@@ -93,8 +93,8 @@ void BKE_displist_make_curveTypes_forRender(struct Depsgraph 
*depsgraph,
 const struct Scene *scene,
 struct Object *ob,
 struct ListBase *dispbase,
-struct Mesh **r_final,
-const bool for_orco);
+const bool for_orco,
+struct Mesh **r_final);
 void BKE_displist_make_mball(struct Depsgraph *depsgraph, struct Scene *scene, 
struct Object *ob);
 void BKE_displist_make_mball_forRender(struct Depsgraph *depsgraph,
struct Scene *scene,
diff --git a/source/blender/blenkernel/intern/displist.cc 
b/source/blender/blenkernel/intern/displist.cc
index 8661941bd4c..a22a30aa2ee 100644
--- a/source/blender/blenkernel/intern/displist.cc
+++ b/source/blender/blenkernel/intern/displist.cc
@@ -1689,8 +1689,8 @@ void BKE_displist_make_curveTypes_forRender(Depsgraph 
*depsgraph,
 const Scene *scene,
 Object *ob,
 ListBase *dispbase,
-Mesh **r_final,
-const bool for_orco)
+const bool for_orco,
+Mesh **r_final)
 {
   if (ob->runtime.curve_cache == nullptr) {
 ob->runtime.curve_cache = (CurveCache *)MEM_callocN(sizeof(CurveCache),
diff --git a/source/blender/blenkernel/intern/mesh_convert.c 
b/source/blender/blenkernel/intern/mesh_convert.c
index e893a3983bd..c698d95ed8d 100644
--- a/source/blender/blenkernel/intern/mesh_convert.c
+++ b/source/blender/blenkernel/intern/mesh_convert.c
@@ -1113,7 +1113,7 @@ static void curve_to_mesh_eval_ensure(Object *object)
* Brecht says hold off with that. */
   Mesh *mesh_eval = NULL;
   BKE_displist_make_curveTypes_forRender(
-  NULL, NULL, &remapped_object, 
&remapped_object.runtime.curve_cache->disp, &mesh_eval, false);
+  NULL, NULL, &remapped_object, 
&remapped_object.runtime.curve_cache->disp, false, &mesh_eval);
 
   /* Note: this is to be consistent with `BKE_displist_make_curveTypes()`, 
however that is not a
* real issue currently, code here is broken in more than one way, fix(es) 
will be done

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


[Bf-blender-cvs] [bb1d5849d22] override-recursive-resync: Cleanup: rename 'unsigned int' -> 'uint'

2021-06-14 Thread Campbell Barton
Commit: bb1d5849d22430941ecea6bd5474e7aee833e06e
Author: Campbell Barton
Date:   Sun Jun 13 14:47:25 2021 +1000
Branches: override-recursive-resync
https://developer.blender.org/rBbb1d5849d22430941ecea6bd5474e7aee833e06e

Cleanup: rename 'unsigned int' -> 'uint'

===

M   source/blender/datatoc/datatoc_icon.c

===

diff --git a/source/blender/datatoc/datatoc_icon.c 
b/source/blender/datatoc/datatoc_icon.c
index f4f510891e0..0f5b155e343 100644
--- a/source/blender/datatoc/datatoc_icon.c
+++ b/source/blender/datatoc/datatoc_icon.c
@@ -66,9 +66,9 @@ static bool path_test_extension(const char *str, const char 
*ext)
   return !(a == 0 || b == 0 || b >= a) && (strcmp(ext, str + a - b) == 0);
 }
 
-static void endian_switch_uint32(unsigned int *val)
+static void endian_switch_uint32(uint *val)
 {
-  unsigned int tval = *val;
+  uint tval = *val;
   *val = ((tval >> 24)) | ((tval << 8) & 0x00ff) | ((tval >> 8) & 
0xff00) | ((tval << 24));
 }
 
@@ -96,10 +96,7 @@ static const char *path_basename(const char *path)
 /*  */
 /* Write a PNG from RGBA pixels */
 
-static bool write_png(const char *name,
-  const unsigned int *pixels,
-  const int width,
-  const int height)
+static bool write_png(const char *name, const uint *pixels, const int width, 
const int height)
 {
   png_structp png_ptr;
   png_infop info_ptr;
@@ -199,9 +196,9 @@ static bool write_png(const char *name,
 /* Merge icon-data from files */
 
 struct IconHead {
-  unsigned int icon_w, icon_h;
-  unsigned int orig_x, orig_y;
-  unsigned int canvas_w, canvas_h;
+  uint icon_w, icon_h;
+  uint orig_x, orig_y;
+  uint canvas_w, canvas_h;
 };
 
 struct IconInfo {
@@ -289,10 +286,10 @@ static bool icon_decode_head(FILE *f_src, struct IconHead 
*r_head)
   return false;
 }
 
-static bool icon_decode(FILE *f_src, struct IconHead *r_head, unsigned int 
**r_pixels)
+static bool icon_decode(FILE *f_src, struct IconHead *r_head, uint **r_pixels)
 {
-  unsigned int *pixels;
-  unsigned int pixels_size;
+  uint *pixels;
+  uint pixels_size;
 
   if (!icon_decode_head(f_src, r_head)) {
 printf("%s: failed to read header\n", __func__);
@@ -316,7 +313,7 @@ static bool icon_decode(FILE *f_src, struct IconHead 
*r_head, unsigned int **r_p
   return true;
 }
 
-static bool icon_read(const char *file_src, struct IconHead *r_head, unsigned 
int **r_pixels)
+static bool icon_read(const char *file_src, struct IconHead *r_head, uint 
**r_pixels)
 {
   FILE *f_src;
   bool success;
@@ -335,18 +332,18 @@ static bool icon_read(const char *file_src, struct 
IconHead *r_head, unsigned in
 
 static bool icon_merge(struct IconMergeContext *context,
const char *file_src,
-   unsigned int **r_pixels_canvas,
-   unsigned int *r_canvas_w,
-   unsigned int *r_canvas_h)
+   uint **r_pixels_canvas,
+   uint *r_canvas_w,
+   uint *r_canvas_h)
 {
   struct IconHead head;
-  unsigned int *pixels;
+  uint *pixels;
 
-  unsigned int x, y;
+  uint x, y;
 
   /* canvas */
-  unsigned int *pixels_canvas;
-  unsigned int canvas_w, canvas_h;
+  uint *pixels_canvas;
+  uint canvas_w, canvas_h;
 
   if (!icon_read(file_src, &head, &pixels)) {
 return false;
@@ -377,9 +374,9 @@ static bool icon_merge(struct IconMergeContext *context,
 
   for (x = 0; x < head.icon_w; x++) {
 for (y = 0; y < head.icon_h; y++) {
-  unsigned int pixel;
-  unsigned int dst_x, dst_y;
-  unsigned int pixel_xy_dst;
+  uint pixel;
+  uint dst_x, dst_y;
+  uint pixel_xy_dst;
 
   /* get pixel */
   pixel = pixels[(y * head.icon_w) + x];
@@ -413,8 +410,8 @@ static bool icondir_to_png(const char *path_src, const char 
*file_dst)
 
   struct IconMergeContext context;
 
-  unsigned int *pixels_canvas = NULL;
-  unsigned int canvas_w = 0, canvas_h = 0;
+  uint *pixels_canvas = NULL;
+  uint canvas_w = 0, canvas_h = 0;
 
   icon_merge_context_init(&context);

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


[Bf-blender-cvs] [af1f328db53] override-recursive-resync: Cleanup: allocation size mismatch warning

2021-06-14 Thread Campbell Barton
Commit: af1f328db537cc00aa51cf386527ad891ea352d7
Author: Campbell Barton
Date:   Sun Jun 13 14:47:28 2021 +1000
Branches: override-recursive-resync
https://developer.blender.org/rBaf1f328db537cc00aa51cf386527ad891ea352d7

Cleanup: allocation size mismatch warning

While harmless, use fixed size int type for pixel data.

===

M   source/blender/datatoc/datatoc_icon.c

===

diff --git a/source/blender/datatoc/datatoc_icon.c 
b/source/blender/datatoc/datatoc_icon.c
index 0f5b155e343..7f1d90f20ea 100644
--- a/source/blender/datatoc/datatoc_icon.c
+++ b/source/blender/datatoc/datatoc_icon.c
@@ -332,7 +332,7 @@ static bool icon_read(const char *file_src, struct IconHead 
*r_head, uint **r_pi
 
 static bool icon_merge(struct IconMergeContext *context,
const char *file_src,
-   uint **r_pixels_canvas,
+   uint32_t **r_pixels_canvas,
uint *r_canvas_w,
uint *r_canvas_h)
 {
@@ -342,7 +342,7 @@ static bool icon_merge(struct IconMergeContext *context,
   uint x, y;
 
   /* canvas */
-  uint *pixels_canvas;
+  uint32_t *pixels_canvas;
   uint canvas_w, canvas_h;
 
   if (!icon_read(file_src, &head, &pixels)) {
@@ -362,7 +362,7 @@ static bool icon_merge(struct IconMergeContext *context,
 /* init once */
 *r_canvas_w = head.canvas_w;
 *r_canvas_h = head.canvas_h;
-*r_pixels_canvas = calloc(1, (head.canvas_w * head.canvas_h) * 
sizeof(const unsigned char[4]));
+*r_pixels_canvas = calloc(1, (head.canvas_w * head.canvas_h) * 
sizeof(uint32_t));
   }
 
   canvas_w = *r_canvas_w;
@@ -410,7 +410,7 @@ static bool icondir_to_png(const char *path_src, const char 
*file_dst)
 
   struct IconMergeContext context;
 
-  uint *pixels_canvas = NULL;
+  uint32_t *pixels_canvas = NULL;
   uint canvas_w = 0, canvas_h = 0;
 
   icon_merge_context_init(&context);

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


[Bf-blender-cvs] [be4679918e4] override-recursive-resync: Fix T88807: crash when there are multiple links between the same sockets

2021-06-14 Thread Jacques Lucke
Commit: be4679918e421b735912e2561125ea58bca2d052
Author: Jacques Lucke
Date:   Mon Jun 14 10:04:32 2021 +0200
Branches: override-recursive-resync
https://developer.blender.org/rBbe4679918e421b735912e2561125ea58bca2d052

Fix T88807: crash when there are multiple links between the same sockets

This commit does two things:

* Disallows creating more than one link from one socket to a multi socket input.
* Properly count links if there happen to be more than one link between the 
same sockets.

The new link counting should also be more efficient asymptotically.

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

===

M   source/blender/editors/space_node/node_draw.cc
M   source/blender/makesrna/intern/rna_nodetree.c

===

diff --git a/source/blender/editors/space_node/node_draw.cc 
b/source/blender/editors/space_node/node_draw.cc
index fd9c0f42f2d..1dc8e1412af 100644
--- a/source/blender/editors/space_node/node_draw.cc
+++ b/source/blender/editors/space_node/node_draw.cc
@@ -82,6 +82,7 @@
 #  include "COM_compositor.h"
 #endif
 
+using blender::Map;
 using blender::Set;
 using blender::Span;
 using blender::Vector;
@@ -1767,26 +1768,27 @@ static void node_update(const bContext *C, bNodeTree 
*ntree, bNode *node)
 
 static void count_mutli_input_socket_links(bNodeTree *ntree, SpaceNode *snode)
 {
+  Map counts;
+  LISTBASE_FOREACH (bNodeLink *, link, &ntree->links) {
+if (link->tosock->flag & SOCK_MULTI_INPUT) {
+  int &count = counts.lookup_or_add(link->tosock, 0);
+  count++;
+}
+  }
+  /* Count temporary links going into this socket. */
+  LISTBASE_FOREACH (bNodeLinkDrag *, nldrag, &snode->runtime->linkdrag) {
+LISTBASE_FOREACH (LinkData *, linkdata, &nldrag->links) {
+  bNodeLink *link = (bNodeLink *)linkdata->data;
+  if (link->tosock && (link->tosock->flag & SOCK_MULTI_INPUT)) {
+int &count = counts.lookup_or_add(link->tosock, 0);
+count++;
+  }
+}
+  }
   LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
-LISTBASE_FOREACH (struct bNodeSocket *, socket, &node->inputs) {
+LISTBASE_FOREACH (bNodeSocket *, socket, &node->inputs) {
   if (socket->flag & SOCK_MULTI_INPUT) {
-Set visited_from_sockets;
-socket->total_inputs = 0;
-LISTBASE_FOREACH (bNodeLink *, link, &ntree->links) {
-  if (link->tosock == socket) {
-visited_from_sockets.add(link->fromsock);
-  }
-}
-/* Count temporary links going into this socket. */
-LISTBASE_FOREACH (bNodeLinkDrag *, nldrag, &snode->runtime->linkdrag) {
-  LISTBASE_FOREACH (LinkData *, linkdata, &nldrag->links) {
-bNodeLink *link = (bNodeLink *)linkdata->data;
-if (link->tosock == socket) {
-  visited_from_sockets.add(link->fromsock);
-}
-  }
-}
-socket->total_inputs = visited_from_sockets.size();
+socket->total_inputs = counts.lookup_default(socket, 0);
   }
 }
   }
diff --git a/source/blender/makesrna/intern/rna_nodetree.c 
b/source/blender/makesrna/intern/rna_nodetree.c
index b625f0fc204..2a1ea3d6716 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -1283,6 +1283,13 @@ static bNodeLink *rna_NodeTree_link_new(bNodeTree *ntree,
 if (nodeCountSocketLinks(ntree, tosock) + 1 > nodeSocketLinkLimit(tosock)) 
{
   nodeRemSocketLinks(ntree, tosock);
 }
+if (tosock->flag & SOCK_MULTI_INPUT) {
+  LISTBASE_FOREACH_MUTABLE (bNodeLink *, link, &ntree->links) {
+if (link->fromsock == fromsock && link->tosock == tosock) {
+  nodeRemLink(ntree, link);
+}
+  }
+}
   }
 
   ret = nodeAddLink(ntree, fromnode, fromsock, tonode, tosock);

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


[Bf-blender-cvs] [ab29311ee04] override-recursive-resync: Cleanup: remove redundant NULL check, reduce scope

2021-06-14 Thread Campbell Barton
Commit: ab29311ee0470672b33a832fb03d8c4c77f0c260
Author: Campbell Barton
Date:   Sun Jun 13 14:47:03 2021 +1000
Branches: override-recursive-resync
https://developer.blender.org/rBab29311ee0470672b33a832fb03d8c4c77f0c260

Cleanup: remove redundant NULL check, reduce scope

===

M   source/blender/editors/armature/pose_slide.c

===

diff --git a/source/blender/editors/armature/pose_slide.c 
b/source/blender/editors/armature/pose_slide.c
index 2f5d2f6c12d..d32faf9a9ea 100644
--- a/source/blender/editors/armature/pose_slide.c
+++ b/source/blender/editors/armature/pose_slide.c
@@ -270,9 +270,9 @@ static void draw_ticks(const float start_factor,
 
   /* Round initial_tick_factor up to the next tick_increment. */
   int tick_percentage = ceil((start_factor * 100) / tick_increment) * 
tick_increment;
-  float tick_height = base_tick_height;
 
   while (tick_percentage <= (int)(end_factor * 100)) {
+float tick_height;
 /* Different ticks have different heights. Multiples of 100% are the 
tallest, 50% is a bit
  * smaller and the rest is the minimum size. */
 if (tick_percentage % 100 == 0) {
@@ -578,22 +578,19 @@ static void pose_slide_exit(wmOperator *op)
   /* Remove UI drawing callback. */
   ED_region_draw_cb_exit(pso->region_header->type, pso->draw_handle);
 
-  /* If data exists, clear its data and exit. */
-  if (pso) {
-/* Free the temp pchan links and their data. */
-poseAnim_mapping_free(&pso->pfLinks);
+  /* Free the temp pchan links and their data. */
+  poseAnim_mapping_free(&pso->pfLinks);
 
-/* Free RB-BST for keyframes (if it contained data). */
-BLI_dlrbTree_free(&pso->keys);
+  /* Free RB-BST for keyframes (if it contained data). */
+  BLI_dlrbTree_free(&pso->keys);
 
-if (pso->ob_data_array != NULL) {
-  MEM_freeN(pso->ob_data_array);
-}
-
-/* Free data itself. */
-MEM_freeN(pso);
+  if (pso->ob_data_array != NULL) {
+MEM_freeN(pso->ob_data_array);
   }
 
+  /* Free data itself. */
+  MEM_freeN(pso);
+
   /* Cleanup. */
   op->customdata = NULL;
 }
@@ -2258,7 +2255,7 @@ static void pose_propagate_fcurve(
   BezTriple *bezt;
   float refVal = 0.0f;
   bool keyExists;
-  int i, match;
+  int i;
   bool first = true;
 
   /* Skip if no keyframes to edit. */
@@ -2281,7 +2278,8 @@ static void pose_propagate_fcurve(
* - if only doing selected keyframes, start from the first one
*/
   if (mode != POSE_PROPAGATE_SELECTED_KEYS) {
-match = BKE_fcurve_bezt_binarysearch_index(fcu->bezt, startFrame, 
fcu->totvert, &keyExists);
+const int match = BKE_fcurve_bezt_binarysearch_index(
+fcu->bezt, startFrame, fcu->totvert, &keyExists);
 
 if (fcu->bezt[match].vec[1][0] < startFrame) {
   i = match + 1;

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


[Bf-blender-cvs] [309849621d5] override-recursive-resync: Fix libmv new[]/delete[] mismatch

2021-06-14 Thread Campbell Barton
Commit: 309849621d552b1bc73f0e7033e4f5568e849f57
Author: Campbell Barton
Date:   Sun Jun 13 15:11:40 2021 +1000
Branches: override-recursive-resync
https://developer.blender.org/rB309849621d552b1bc73f0e7033e4f5568e849f57

Fix libmv new[]/delete[] mismatch

===

M   intern/libmv/libmv/base/scoped_ptr.h

===

diff --git a/intern/libmv/libmv/base/scoped_ptr.h 
b/intern/libmv/libmv/base/scoped_ptr.h
index 9bfcfe1d615..45b5722034c 100644
--- a/intern/libmv/libmv/base/scoped_ptr.h
+++ b/intern/libmv/libmv/base/scoped_ptr.h
@@ -77,7 +77,7 @@ class scoped_array {
 
   void reset(T* new_array) {
 if (sizeof(T)) {
-  delete array_;
+  delete[] array_;
 }
 array_ = new_array;
   }

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


[Bf-blender-cvs] [ef7e116fec4] override-recursive-resync: Add option to link assets on drag & drop

2021-06-14 Thread Julian Eisel
Commit: ef7e116fec4b72a2eea9a8103cb80152d7448488
Author: Julian Eisel
Date:   Fri Jun 11 16:35:39 2021 +0200
Branches: override-recursive-resync
https://developer.blender.org/rBef7e116fec4b72a2eea9a8103cb80152d7448488

Add option to link assets on drag & drop

Note: Linking in this case as in link vs. append. Easily confused with linking
a data-block to multiple usages (e.g. single material used by multiple
objects).

Adds a drop-down to the Asset Browser header to choose between Link and Append.
This is probably gonna be a temporary place, T54642 shows where this could be
placed eventually.

Linking support is crucial for usage of the asset browser in production
environments. It just wasn't enabled yet because a) the asset project currently
focuses on single user, not production assets, and b) because there were many
unkowns still for the workflow that have big impact on production use as well.
With the recently held asset workshop I'm more confident with enabling linking,
as design ideas relevant to production use were confirmed.

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

Reviewed by: Bastien Montagne

===

M   release/scripts/startup/bl_ui/space_filebrowser.py
M   source/blender/blenloader/intern/versioning_300.c
M   source/blender/editors/include/UI_interface.h
M   source/blender/editors/interface/interface.c
M   source/blender/editors/space_file/file_draw.c
M   source/blender/editors/space_file/filesel.c
M   source/blender/makesdna/DNA_space_types.h
M   source/blender/makesrna/intern/rna_space.c
M   source/blender/windowmanager/WM_api.h
M   source/blender/windowmanager/WM_types.h
M   source/blender/windowmanager/intern/wm_dragdrop.c
M   source/blender/windowmanager/intern/wm_files_link.c

===

diff --git a/release/scripts/startup/bl_ui/space_filebrowser.py 
b/release/scripts/startup/bl_ui/space_filebrowser.py
index b236b2ee7cf..1ad88744b16 100644
--- a/release/scripts/startup/bl_ui/space_filebrowser.py
+++ b/release/scripts/startup/bl_ui/space_filebrowser.py
@@ -44,6 +44,10 @@ class FILEBROWSER_HT_header(Header):
 
 layout.separator_spacer()
 
+layout.prop(params, "import_type", text="")
+
+layout.separator_spacer()
+
 # Uses prop_with_popover() as popover() only adds the triangle icon in 
headers.
 layout.prop_with_popover(
 params,
diff --git a/source/blender/blenloader/intern/versioning_300.c 
b/source/blender/blenloader/intern/versioning_300.c
index 93e2af1b68e..268598ccc51 100644
--- a/source/blender/blenloader/intern/versioning_300.c
+++ b/source/blender/blenloader/intern/versioning_300.c
@@ -244,5 +244,20 @@ void blo_do_versions_300(FileData *fd, Library 
*UNUSED(lib), Main *bmain)
   }
 }
 FOREACH_NODETREE_END;
+
+if (!DNA_struct_elem_find(fd->filesdna, "FileAssetSelectParams", "int", 
"import_type")) {
+  LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) {
+LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
+  LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
+if (sl->spacetype == SPACE_FILE) {
+  SpaceFile *sfile = (SpaceFile *)sl;
+  if (sfile->asset_params) {
+sfile->asset_params->import_type = FILE_ASSET_IMPORT_APPEND;
+  }
+}
+  }
+}
+  }
+}
   }
 }
diff --git a/source/blender/editors/include/UI_interface.h 
b/source/blender/editors/include/UI_interface.h
index 338b12f7985..1d335c500ca 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -723,6 +723,7 @@ void UI_but_drag_set_asset(uiBut *but,
const char *name,
const char *path,
int id_type,
+   int import_type, /* eFileAssetImportType */
int icon,
struct ImBuf *imb,
float scale);
diff --git a/source/blender/editors/interface/interface.c 
b/source/blender/editors/interface/interface.c
index f6b2a6a1bc6..26ea5f8e24a 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -6144,6 +6144,7 @@ void UI_but_drag_set_asset(uiBut *but,
const char *name,
const char *path,
int id_type,
+   int import_type,
int icon,
struct ImBuf *imb,
float scale)
@@ -6153,6 +6154,7 @@ void UI_but_drag_set_asset(uiBut *but,
   BLI_strncpy(asset_drag->name, name, sizeof(asset_drag->name));
   asset_drag->path = path;
   asset_drag->id_type = id_type;
+  asset_drag->import_type = import_

[Bf-blender-cvs] [209d2bcfa9c] asset-browser-poselib: Merge remote-tracking branch 'origin/master' into asset-browser-poselib

2021-06-14 Thread Sybren A. Stüvel
Commit: 209d2bcfa9ce1429879c24f657ace39feb04fb3c
Author: Sybren A. Stüvel
Date:   Mon Jun 14 16:31:30 2021 +0200
Branches: asset-browser-poselib
https://developer.blender.org/rB209d2bcfa9ce1429879c24f657ace39feb04fb3c

Merge remote-tracking branch 'origin/master' into asset-browser-poselib

===



===



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


[Bf-blender-cvs] [ca856bbe21b] override-recursive-resync: Cleanup: avoid the possibility of 'enter_editmode' being left unset

2021-06-14 Thread Campbell Barton
Commit: ca856bbe21bac256611a56de507c25a4686e09cb
Author: Campbell Barton
Date:   Sun Jun 13 14:47:07 2021 +1000
Branches: override-recursive-resync
https://developer.blender.org/rBca856bbe21bac256611a56de507c25a4686e09cb

Cleanup: avoid the possibility of 'enter_editmode' being left unset

While in practice this isn't an issue currently, always set
'enter_editmode' in ED_object_add_generic_get_opts
to avoid problems in the future.

===

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

===

diff --git a/source/blender/editors/object/object_add.c 
b/source/blender/editors/object/object_add.c
index 166d168471f..2256dee20cb 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -463,21 +463,25 @@ bool ED_object_add_generic_get_opts(bContext *C,
 ushort *local_view_bits,
 bool *is_view_aligned)
 {
-  PropertyRNA *prop;
-
-  /* Switch to Edit mode? optional prop */
-  if ((prop = RNA_struct_find_property(op->ptr, "enter_editmode"))) {
+  /* Edit Mode! (optional) */
+  {
 bool _enter_editmode;
 if (!enter_editmode) {
   enter_editmode = &_enter_editmode;
 }
+/* Only to ensure the value is _always_ set.
+ * Typically the property will exist when the argument is non-NULL. */
+*enter_editmode = false;
 
-if (RNA_property_is_set(op->ptr, prop) && enter_editmode) {
-  *enter_editmode = RNA_property_boolean_get(op->ptr, prop);
-}
-else {
-  *enter_editmode = (U.flag & USER_ADD_EDITMODE) != 0;
-  RNA_property_boolean_set(op->ptr, prop, *enter_editmode);
+PropertyRNA *prop = RNA_struct_find_property(op->ptr, "enter_editmode");
+if (prop != NULL) {
+  if (RNA_property_is_set(op->ptr, prop) && enter_editmode) {
+*enter_editmode = RNA_property_boolean_get(op->ptr, prop);
+  }
+  else {
+*enter_editmode = (U.flag & USER_ADD_EDITMODE) != 0;
+RNA_property_boolean_set(op->ptr, prop, *enter_editmode);
+  }
 }
   }
 
@@ -522,7 +526,7 @@ bool ED_object_add_generic_get_opts(bContext *C,
 }
 else {
   int alignment = ALIGN_WORLD;
-  prop = RNA_struct_find_property(op->ptr, "align");
+  PropertyRNA *prop = RNA_struct_find_property(op->ptr, "align");
 
   if (RNA_property_is_set(op->ptr, prop)) {
 /* If alignment is set, always use it. */
@@ -574,7 +578,9 @@ bool ED_object_add_generic_get_opts(bContext *C,
 
 /* For now this is optional, we can make it always use. */
 copy_v3_fl(scale, 1.0f);
-if ((prop = RNA_struct_find_property(op->ptr, "scale"))) {
+
+PropertyRNA *prop = RNA_struct_find_property(op->ptr, "scale");
+if (prop != NULL) {
   if (RNA_property_is_set(op->ptr, prop)) {
 RNA_property_float_get_array(op->ptr, prop, scale);
   }

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


[Bf-blender-cvs] [85e1c6b4436] override-recursive-resync: Cleanup: missing include

2021-06-14 Thread Campbell Barton
Commit: 85e1c6b4436a633beb7d13507caa4bb74212a3af
Author: Campbell Barton
Date:   Sun Jun 13 14:47:01 2021 +1000
Branches: override-recursive-resync
https://developer.blender.org/rB85e1c6b4436a633beb7d13507caa4bb74212a3af

Cleanup: missing include

===

M   source/blender/python/intern/bpy_rna_operator.c

===

diff --git a/source/blender/python/intern/bpy_rna_operator.c 
b/source/blender/python/intern/bpy_rna_operator.c
index 6e0db3eca49..490d9aa5212 100644
--- a/source/blender/python/intern/bpy_rna_operator.c
+++ b/source/blender/python/intern/bpy_rna_operator.c
@@ -31,6 +31,8 @@
 #include "BPY_extern.h"
 #include "bpy_capi_utils.h"
 
+#include "bpy_rna_operator.h" /* Own include. */
+
 /*  */
 /** \name Operator `poll_message_set` Method
  * \{ */

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


[Bf-blender-cvs] [d02d868f263] override-recursive-resync: Nodes: cache socket identifier to index mapping

2021-06-14 Thread Jacques Lucke
Commit: d02d868f263368f76697890b6c67e8841d61640d
Author: Jacques Lucke
Date:   Fri Jun 11 16:21:08 2021 +0200
Branches: override-recursive-resync
https://developer.blender.org/rBd02d868f263368f76697890b6c67e8841d61640d

Nodes: cache socket identifier to index mapping

While this preprocessing does take some time upfront,
it avoids longer lookup later on, especially as nodes get
more sockets.

It's probably possible to make this more efficient in some cases
but this is good enough for now.

===

M   source/blender/modifiers/intern/MOD_nodes_evaluator.cc
M   source/blender/nodes/NOD_derived_node_tree.hh
M   source/blender/nodes/NOD_node_tree_ref.hh
M   source/blender/nodes/intern/node_tree_ref.cc

===

diff --git a/source/blender/modifiers/intern/MOD_nodes_evaluator.cc 
b/source/blender/modifiers/intern/MOD_nodes_evaluator.cc
index 5f82cd9ba27..170ad0f2c48 100644
--- a/source/blender/modifiers/intern/MOD_nodes_evaluator.cc
+++ b/source/blender/modifiers/intern/MOD_nodes_evaluator.cc
@@ -1381,27 +1381,6 @@ LockedNode::~LockedNode()
   }
 }
 
-/* TODO: Use a map data structure or so to make this faster. */
-static DInputSocket get_input_by_identifier(const DNode node, const StringRef 
identifier)
-{
-  for (const InputSocketRef *socket : node->inputs()) {
-if (socket->identifier() == identifier) {
-  return {node.context(), socket};
-}
-  }
-  return {};
-}
-
-static DOutputSocket get_output_by_identifier(const DNode node, const 
StringRef identifier)
-{
-  for (const OutputSocketRef *socket : node->outputs()) {
-if (socket->identifier() == identifier) {
-  return {node.context(), socket};
-}
-  }
-  return {};
-}
-
 NodeParamsProvider::NodeParamsProvider(GeometryNodesEvaluator &evaluator,
DNode dnode,
NodeState &node_state)
@@ -1415,7 +1394,7 @@ 
NodeParamsProvider::NodeParamsProvider(GeometryNodesEvaluator &evaluator,
 
 bool NodeParamsProvider::can_get_input(StringRef identifier) const
 {
-  const DInputSocket socket = get_input_by_identifier(this->dnode, identifier);
+  const DInputSocket socket = this->dnode.input_by_identifier(identifier);
   BLI_assert(socket);
 
   InputState &input_state = node_state_.inputs[socket->index()];
@@ -1433,7 +1412,7 @@ bool NodeParamsProvider::can_get_input(StringRef 
identifier) const
 
 bool NodeParamsProvider::can_set_output(StringRef identifier) const
 {
-  const DOutputSocket socket = get_output_by_identifier(this->dnode, 
identifier);
+  const DOutputSocket socket = this->dnode.output_by_identifier(identifier);
   BLI_assert(socket);
 
   OutputState &output_state = node_state_.outputs[socket->index()];
@@ -1442,7 +1421,7 @@ bool NodeParamsProvider::can_set_output(StringRef 
identifier) const
 
 GMutablePointer NodeParamsProvider::extract_input(StringRef identifier)
 {
-  const DInputSocket socket = get_input_by_identifier(this->dnode, identifier);
+  const DInputSocket socket = this->dnode.input_by_identifier(identifier);
   BLI_assert(socket);
   BLI_assert(!socket->is_multi_input_socket());
   BLI_assert(this->can_get_input(identifier));
@@ -1456,7 +1435,7 @@ GMutablePointer 
NodeParamsProvider::extract_input(StringRef identifier)
 
 Vector NodeParamsProvider::extract_multi_input(StringRef 
identifier)
 {
-  const DInputSocket socket = get_input_by_identifier(this->dnode, identifier);
+  const DInputSocket socket = this->dnode.input_by_identifier(identifier);
   BLI_assert(socket);
   BLI_assert(socket->is_multi_input_socket());
   BLI_assert(this->can_get_input(identifier));
@@ -1487,7 +1466,7 @@ Vector 
NodeParamsProvider::extract_multi_input(StringRef identi
 
 GPointer NodeParamsProvider::get_input(StringRef identifier) const
 {
-  const DInputSocket socket = get_input_by_identifier(this->dnode, identifier);
+  const DInputSocket socket = this->dnode.input_by_identifier(identifier);
   BLI_assert(socket);
   BLI_assert(!socket->is_multi_input_socket());
   BLI_assert(this->can_get_input(identifier));
@@ -1505,7 +1484,7 @@ GMutablePointer 
NodeParamsProvider::alloc_output_value(const CPPType &type)
 
 void NodeParamsProvider::set_output(StringRef identifier, GMutablePointer 
value)
 {
-  const DOutputSocket socket = get_output_by_identifier(this->dnode, 
identifier);
+  const DOutputSocket socket = this->dnode.output_by_identifier(identifier);
   BLI_assert(socket);
 
   evaluator_.log_socket_value(socket, value);
@@ -1519,7 +1498,7 @@ void NodeParamsProvider::set_output(StringRef identifier, 
GMutablePointer value)
 bool NodeParamsProvider::lazy_require_input(StringRef identifier)
 {
   BLI_assert(node_supports_laziness(this->dnode));
-  const DInputSocket socket = get_input_by_identifier(this->dnode, identifier);
+  const DInputSocket socket = this->dnode.input_by_identifier(identifier);
   BLI_assert(socket);
 
   

[Bf-blender-cvs] [2dd6ec1c087] override-recursive-resync: Fix missing directory in CMakeLists.txt

2021-06-14 Thread Germano Cavalcante
Commit: 2dd6ec1c087cb106d7a0d53b863cf4953fba4d50
Author: Germano Cavalcante
Date:   Fri Jun 11 23:45:04 2021 -0300
Branches: override-recursive-resync
https://developer.blender.org/rB2dd6ec1c087cb106d7a0d53b863cf4953fba4d50

Fix missing directory in CMakeLists.txt

===

M   source/blender/draw/CMakeLists.txt

===

diff --git a/source/blender/draw/CMakeLists.txt 
b/source/blender/draw/CMakeLists.txt
index 3938242eb6e..e99bf1f5b0c 100644
--- a/source/blender/draw/CMakeLists.txt
+++ b/source/blender/draw/CMakeLists.txt
@@ -172,6 +172,7 @@ set(SRC
   intern/DRW_render.h
   intern/draw_cache.h
   intern/draw_cache_extract.h
+  intern/draw_cache_extract_mesh_private.h
   intern/draw_cache_impl.h
   intern/draw_cache_inline.h
   intern/draw_color_management.h

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


[Bf-blender-cvs] [80811aa5813] override-recursive-resync: Fix T88515: Cycles does not update light transform from linked collections

2021-06-14 Thread Kévin Dietrich
Commit: 80811aa581361b3a03df9c1b84af70218847f188
Author: Kévin Dietrich
Date:   Tue Jun 8 10:17:07 2021 +0200
Branches: override-recursive-resync
https://developer.blender.org/rB80811aa581361b3a03df9c1b84af70218847f188

Fix T88515: Cycles does not update light transform from linked collections

When moving a linked collection, we seem to only receive a depsgraph update
for an empty object so the Blender synchronization cannot discriminate it
and tag the object(s) (light or geometry) for an update through
id_map.set_recalc.

This missing transform update only affects lights since we do not check
manually if the transformations were modified like we do for objects.

To fix this, add a check to see if the transformation is different provided
that a light was already created.

Reviewed By: brecht

Maniphest Tasks: T88515

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

===

M   intern/cycles/blender/blender_light.cpp

===

diff --git a/intern/cycles/blender/blender_light.cpp 
b/intern/cycles/blender/blender_light.cpp
index 283ed7d0adc..ae353b32633 100644
--- a/intern/cycles/blender/blender_light.cpp
+++ b/intern/cycles/blender/blender_light.cpp
@@ -34,12 +34,17 @@ void BlenderSync::sync_light(BL::Object &b_parent,
  bool *use_portal)
 {
   /* test if we need to sync */
-  Light *light;
   ObjectKey key(b_parent, persistent_id, b_ob_instance, false);
   BL::Light b_light(b_ob.data());
 
+  Light *light = light_map.find(key);
+
+  /* Check if the transform was modified, in case a linked collection is moved 
we do not get a
+   * specific depsgraph update (T88515). This also mimics the behavior for 
Objects. */
+  const bool tfm_updated = (light && light->get_tfm() != tfm);
+
   /* Update if either object or light data changed. */
-  if (!light_map.add_or_update(&light, b_ob, b_parent, key)) {
+  if (!tfm_updated && !light_map.add_or_update(&light, b_ob, b_parent, key)) {
 Shader *shader;
 if (!shader_map.add_or_update(&shader, b_light)) {
   if (light->get_is_portal())

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


[Bf-blender-cvs] [13a36f3b75a] override-recursive-resync: Performance: Use parallel range for ImBuf scanline processor.

2021-06-14 Thread Jeroen Bakker
Commit: 13a36f3b75a9494364173caeb2c62a120b7418a2
Author: Jeroen Bakker
Date:   Fri Jun 11 15:55:09 2021 +0200
Branches: override-recursive-resync
https://developer.blender.org/rB13a36f3b75a9494364173caeb2c62a120b7418a2

Performance: Use parallel range for ImBuf scanline processor.

Scanline processor did its own heurestic what didn't scale well when
having a multiple cores. In stead of using our own code this patch will
leave it to TBB to determine how to split the scanlines over the
available threads.

Performance of the IMB_transform before this change was 0.002123s, with
this change 0.001601s. This change increases performance in other areas
as well including color management conversions.

Reviewed By: zeddb

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

===

M   source/blender/blenkernel/intern/image_gen.c
M   source/blender/imbuf/IMB_imbuf.h
M   source/blender/imbuf/intern/colormanagement.c
M   source/blender/imbuf/intern/divers.c
M   source/blender/imbuf/intern/imageprocess.c
M   source/blender/imbuf/intern/rectop.c

===

diff --git a/source/blender/blenkernel/intern/image_gen.c 
b/source/blender/blenkernel/intern/image_gen.c
index ceb13c4955e..1a0cc8c2924 100644
--- a/source/blender/blenkernel/intern/image_gen.c
+++ b/source/blender/blenkernel/intern/image_gen.c
@@ -69,10 +69,11 @@ static void image_buf_fill_color_slice(
   }
 }
 
-static void image_buf_fill_color_thread_do(void *data_v, int start_scanline, 
int num_scanlines)
+static void image_buf_fill_color_thread_do(void *data_v, int scanline)
 {
   FillColorThreadData *data = (FillColorThreadData *)data_v;
-  size_t offset = ((size_t)start_scanline) * data->width * 4;
+  const int num_scanlines = 1;
+  size_t offset = ((size_t)scanline) * data->width * 4;
   unsigned char *rect = (data->rect != NULL) ? (data->rect + offset) : NULL;
   float *rect_float = (data->rect_float != NULL) ? (data->rect_float + offset) 
: NULL;
   image_buf_fill_color_slice(rect, rect_float, data->width, num_scanlines, 
data->color);
@@ -197,13 +198,14 @@ typedef struct FillCheckerThreadData {
   int width;
 } FillCheckerThreadData;
 
-static void image_buf_fill_checker_thread_do(void *data_v, int start_scanline, 
int num_scanlines)
+static void image_buf_fill_checker_thread_do(void *data_v, int scanline)
 {
   FillCheckerThreadData *data = (FillCheckerThreadData *)data_v;
-  size_t offset = ((size_t)start_scanline) * data->width * 4;
+  size_t offset = ((size_t)scanline) * data->width * 4;
+  const int num_scanlines = 1;
   unsigned char *rect = (data->rect != NULL) ? (data->rect + offset) : NULL;
   float *rect_float = (data->rect_float != NULL) ? (data->rect_float + offset) 
: NULL;
-  image_buf_fill_checker_slice(rect, rect_float, data->width, num_scanlines, 
start_scanline);
+  image_buf_fill_checker_slice(rect, rect_float, data->width, num_scanlines, 
scanline);
 }
 
 void BKE_image_buf_fill_checker(unsigned char *rect, float *rect_float, int 
width, int height)
@@ -444,16 +446,15 @@ typedef struct FillCheckerColorThreadData {
   int width, height;
 } FillCheckerColorThreadData;
 
-static void checker_board_color_prepare_thread_do(void *data_v,
-  int start_scanline,
-  int num_scanlines)
+static void checker_board_color_prepare_thread_do(void *data_v, int scanline)
 {
   FillCheckerColorThreadData *data = (FillCheckerColorThreadData *)data_v;
-  size_t offset = ((size_t)data->width) * start_scanline * 4;
+  const int num_scanlines = 1;
+  size_t offset = ((size_t)data->width) * scanline * 4;
   unsigned char *rect = (data->rect != NULL) ? (data->rect + offset) : NULL;
   float *rect_float = (data->rect_float != NULL) ? (data->rect_float + offset) 
: NULL;
   checker_board_color_prepare_slice(
-  rect, rect_float, data->width, num_scanlines, start_scanline, 
data->height);
+  rect, rect_float, data->width, num_scanlines, scanline, data->height);
 }
 
 void BKE_image_buf_fill_checker_color(unsigned char *rect,
diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h
index 651c69726ff..69a80d6e0d3 100644
--- a/source/blender/imbuf/IMB_imbuf.h
+++ b/source/blender/imbuf/IMB_imbuf.h
@@ -733,7 +733,7 @@ void IMB_processor_apply_threaded(
 void(init_handle)(void *handle, int start_line, int tot_line, void 
*customdata),
 void *(do_thread)(void *));
 
-typedef void (*ScanlineThreadFunc)(void *custom_data, int start_scanline, int 
num_scanlines);
+typedef void (*ScanlineThreadFunc)(void *custom_data, int scanline);
 void IMB_processor_apply_threaded_scanlines(int total_scanlines,
 ScanlineThreadFunc do_thread,
 void *custom_data);
diff --git a/source/blender/imbuf/intern/colormanagement.c

[Bf-blender-cvs] [c6d1e7e6dca] override-recursive-resync: Fix modifier deform by armature check ignoring virtual modifiers

2021-06-14 Thread Campbell Barton
Commit: c6d1e7e6dca891efb3110acff6c790ea7b649ed9
Author: Campbell Barton
Date:   Sun Jun 13 14:46:59 2021 +1000
Branches: override-recursive-resync
https://developer.blender.org/rBc6d1e7e6dca891efb3110acff6c790ea7b649ed9

Fix modifier deform by armature check ignoring virtual modifiers

Regression in f00cb93dbec7bf5dc05302c868f20fcd5aed7db7 (fix for T63125)

===

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

===

diff --git a/source/blender/blenkernel/intern/modifier.c 
b/source/blender/blenkernel/intern/modifier.c
index 3b67237f5eb..e60f0102b9a 100644
--- a/source/blender/blenkernel/intern/modifier.c
+++ b/source/blender/blenkernel/intern/modifier.c
@@ -729,7 +729,6 @@ Object *BKE_modifiers_is_deformed_by_armature(Object *ob)
 ArmatureGpencilModifierData *agmd = NULL;
 GpencilModifierData *gmd = BKE_gpencil_modifiers_get_virtual_modifierlist(
 ob, &gpencilvirtualModifierData);
-gmd = ob->greasepencil_modifiers.first;
 
 /* return the first selected armature, this lets us use multiple armatures 
*/
 for (; gmd; gmd = gmd->next) {
@@ -749,7 +748,6 @@ Object *BKE_modifiers_is_deformed_by_armature(Object *ob)
 VirtualModifierData virtualModifierData;
 ArmatureModifierData *amd = NULL;
 ModifierData *md = BKE_modifiers_get_virtual_modifierlist(ob, 
&virtualModifierData);
-md = ob->modifiers.first;
 
 /* return the first selected armature, this lets us use multiple armatures 
*/
 for (; md; md = md->next) {

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


[Bf-blender-cvs] [b3875858c2e] override-recursive-resync: Overlays: Make flash on mode transfer an operator property

2021-06-14 Thread Pablo Dobarro
Commit: b3875858c2ead16fff653d7d4a5392d75971b760
Author: Pablo Dobarro
Date:   Fri Jun 11 21:42:36 2021 +0200
Branches: override-recursive-resync
https://developer.blender.org/rBb3875858c2ead16fff653d7d4a5392d75971b760

Overlays: Make flash on mode transfer an operator property

This moves the flash on mode transfer effect option from the overlays to
an operator property of the mode transfer operator.

- This effect is intended to show the target object when no overlays or
a minimal set of overlays is enabled. Making it part of the whole set of
overlays invalidates this use case.

- The effect is not intended to be configurable per viewport, it should
be a global option.

The effect is still implemented using the overlay engine (instead of a
draw modal callback) due to performance and drawing artifacts. Having it
implemented as an overlay with runtime timer data in the objects makes
also possible to run multiple animations at the same time without any
visual glitches.

Reviewed By: campbellbarton, JulienKaspar

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

===

M   release/scripts/startup/bl_ui/space_view3d.py
M   source/blender/draw/engines/overlay/overlay_engine.c
M   source/blender/editors/object/object_modes.c
M   source/blender/makesdna/DNA_view3d_types.h
M   source/blender/makesrna/intern/rna_space.c

===

diff --git a/release/scripts/startup/bl_ui/space_view3d.py 
b/release/scripts/startup/bl_ui/space_view3d.py
index 5f47aa90026..fd56e86ea39 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -6186,9 +6186,6 @@ class VIEW3D_PT_overlay_geometry(Panel):
 sub.active = overlay.show_fade_inactive
 sub.prop(overlay, "fade_inactive_alpha", text="Fade Inactive 
Geometry")
 
-row = col.row(align=True)
-row.prop(overlay, "show_mode_transfer", text="Flash on Mode Transfer")
-
 col = layout.column(align=True)
 col.active = display_all
 
diff --git a/source/blender/draw/engines/overlay/overlay_engine.c 
b/source/blender/draw/engines/overlay/overlay_engine.c
index 19f822e3f68..81b07b49784 100644
--- a/source/blender/draw/engines/overlay/overlay_engine.c
+++ b/source/blender/draw/engines/overlay/overlay_engine.c
@@ -324,7 +324,7 @@ static void OVERLAY_cache_populate(void *vedata, Object *ob)
!is_select;
   const bool draw_fade = draw_surface && (pd->overlay.flag & 
V3D_OVERLAY_FADE_INACTIVE) &&
  overlay_should_fade_object(ob, draw_ctx->obact);
-  const bool draw_mode_transfer = draw_surface && (pd->overlay.flag & 
V3D_OVERLAY_MODE_TRANSFER);
+  const bool draw_mode_transfer = draw_surface;
   const bool draw_bones = (pd->overlay.flag & V3D_OVERLAY_HIDE_BONES) == 0;
   const bool draw_wires = draw_surface && has_surface &&
   (pd->wireframe_mode || !pd->hide_overlays);
diff --git a/source/blender/editors/object/object_modes.c 
b/source/blender/editors/object/object_modes.c
index 3d1a5ac2d62..ed06cd2a217 100644
--- a/source/blender/editors/object/object_modes.c
+++ b/source/blender/editors/object/object_modes.c
@@ -484,7 +484,9 @@ static bool object_transfer_mode_to_base(bContext *C, 
wmOperator *op, Base *base
 ob_dst_orig = DEG_get_original_object(ob_dst);
 ED_object_mode_set_ex(C, last_mode, true, op->reports);
 
-object_overlay_mode_transfer_animation_start(C, ob_dst);
+if (RNA_boolean_get(op->ptr, "use_flash_on_transfer")) {
+  object_overlay_mode_transfer_animation_start(C, ob_dst);
+}
 
 WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
 WM_toolsystem_update_from_context_view3d(C);
@@ -578,6 +580,12 @@ void OBJECT_OT_transfer_mode(wmOperatorType *ot)
   false,
   "Use Eyedropper",
   "Pick the object to switch to using an eyedropper");
+
+  RNA_def_boolean(ot->srna,
+  "use_flash_on_transfer",
+  true,
+  "Flash On Transfer",
+  "Flash the target object when transfering the mode");
 }
 
 /** \} */
diff --git a/source/blender/makesdna/DNA_view3d_types.h 
b/source/blender/makesdna/DNA_view3d_types.h
index 9e7e30d913e..2f4e4e57b9f 100644
--- a/source/blender/makesdna/DNA_view3d_types.h
+++ b/source/blender/makesdna/DNA_view3d_types.h
@@ -515,7 +515,6 @@ enum {
   V3D_OVERLAY_HIDE_OBJECT_ORIGINS = (1 << 10),
   V3D_OVERLAY_STATS = (1 << 11),
   V3D_OVERLAY_FADE_INACTIVE = (1 << 12),
-  V3D_OVERLAY_MODE_TRANSFER = (1 << 13),
 };
 
 /** #View3DOverlay.edit_flag */
diff --git a/source/blender/makesrna/intern/rna_space.c 
b/source/blender/makesrna/intern/rna_space.c
index 3cd576a9641..39edc6c3b9a 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -4129,14 +4129

[Bf-blender-cvs] [a6172fc6b09] override-recursive-resync: Render Window as Non-Child on Win32 platform

2021-06-14 Thread Harley Acheson
Commit: a6172fc6b09e16b62591d778edbf59641ea96abd
Author: Harley Acheson
Date:   Fri Jun 11 13:05:34 2021 -0700
Branches: override-recursive-resync
https://developer.blender.org/rBa6172fc6b09e16b62591d778edbf59641ea96abd

Render Window as Non-Child on Win32 platform

This patch makes the "Render" window a top-level window, not a child of
the main window, which was the case in blender versions prior to 2.93.
This means it is no longer "on top", nor is the icon grouped on the
taskbar in the same way, but you can Alt-Tab between it and the main
window. This change only affects the Windows platform as the other
platforms behave this way.

See D11576 for links to negative feedback that prompts this change.

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

Reviewed by Brecht Van Lommel

===

M   source/blender/editors/render/render_view.c
M   source/blender/editors/screen/screen_edit.c
M   source/blender/editors/screen/screen_ops.c
M   source/blender/windowmanager/WM_api.h
M   source/blender/windowmanager/intern/wm_window.c

===

diff --git a/source/blender/editors/render/render_view.c 
b/source/blender/editors/render/render_view.c
index 465438f814a..eb4a040e891 100644
--- a/source/blender/editors/render/render_view.c
+++ b/source/blender/editors/render/render_view.c
@@ -164,6 +164,7 @@ ScrArea *render_view_open(bContext *C, int mx, int my, 
ReportList *reports)
sizex,
sizey,
SPACE_IMAGE,
+   true,
false,
true,
WIN_ALIGN_LOCATION_CENTER) == NULL) {
diff --git a/source/blender/editors/screen/screen_edit.c 
b/source/blender/editors/screen/screen_edit.c
index 6fb5f33d836..6cb184a3394 100644
--- a/source/blender/editors/screen/screen_edit.c
+++ b/source/blender/editors/screen/screen_edit.c
@@ -1585,6 +1585,7 @@ ScrArea *ED_screen_temp_space_open(bContext *C,
  sizex,
  sizey,
  (int)space_type,
+ false,
  dialog,
  true,
  WIN_ALIGN_LOCATION_CENTER)) {
diff --git a/source/blender/editors/screen/screen_ops.c 
b/source/blender/editors/screen/screen_ops.c
index b41b54fee1f..373bde99e24 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -1362,6 +1362,7 @@ static int area_dupli_invoke(bContext *C, wmOperator *op, 
const wmEvent *event)
 area->winx,
 area->winy,
 SPACE_EMPTY,
+false,
 true,
 false,
 WIN_ALIGN_ABSOLUTE);
@@ -4955,6 +4956,7 @@ static int userpref_show_exec(bContext *C, wmOperator *op)
  sizey,
  SPACE_USERPREF,
  false,
+ false,
  true,
  WIN_ALIGN_LOCATION_CENTER) != NULL) {
 /* The header only contains the editor switcher and looks empty.
@@ -5021,6 +5023,7 @@ static int drivers_editor_show_exec(bContext *C, 
wmOperator *op)
  sizey,
  SPACE_GRAPH,
  false,
+ false,
  true,
  WIN_ALIGN_LOCATION_CENTER) != NULL) {
 ED_drivers_editor_init(C, CTX_wm_area(C));
@@ -5089,6 +5092,7 @@ static int info_log_show_exec(bContext *C, wmOperator *op)
  sizey,
  SPACE_INFO,
  false,
+ false,
  true,
  WIN_ALIGN_LOCATION_CENTER) != NULL) {
 return OPERATOR_FINISHED;
diff --git a/source/blender/windowmanager/WM_api.h 
b/source/blender/windowmanager/WM_api.h
index eebd6e16dd7..3525502a6dc 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -190,6 +190,7 @@ struct wmWindow *WM_window_open(struct bContext *C,
 int sizex,
 int sizey,
 int space_type,
+bool toplevel,
 bool dialog,
 bool temp,
 WindowAlignment alignment);
diff --git a/source/blender/windowmanager/intern/wm_window.c 
b/source/blender/windowmanager/intern/wm_window.c
index cdd5ea12df8..f55dc886950 100644
--- a/source/blender/windowmanager/intern/wm_window.c
+++ b/source/blender/windowmanager/intern/wm_window.c
@@ -756,6 +756,7 @@ static bool wm_windo

[Bf-blender-cvs] [7a87b469db4] override-recursive-resync: Fix T88812: Child Windows on Vertical Monitors

2021-06-14 Thread Harley Acheson
Commit: 7a87b469db43f1e61c2c56e1e5a3cd1d05a1e7de
Author: Harley Acheson
Date:   Fri Jun 11 14:39:19 2021 -0700
Branches: override-recursive-resync
https://developer.blender.org/rB7a87b469db43f1e61c2c56e1e5a3cd1d05a1e7de

Fix T88812: Child Windows on Vertical Monitors

This patch improves the positioning of child windows when on monitors
that are arranged vertically (any above any other). When calculating a
window position in Ghost coordinates from GL coordinates we were using
monitor height, which can give incorrect values when desktop is taller
than any single monitor. So use desktop height instead.

See D10637 for more details and examples.

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

Reviewed by Brecht Van Lommel

===

M   source/blender/windowmanager/intern/wm_window.c

===

diff --git a/source/blender/windowmanager/intern/wm_window.c 
b/source/blender/windowmanager/intern/wm_window.c
index f55dc886950..6aedfb10dde 100644
--- a/source/blender/windowmanager/intern/wm_window.c
+++ b/source/blender/windowmanager/intern/wm_window.c
@@ -550,7 +550,7 @@ static void wm_window_ghostwindow_add(wmWindowManager *wm,
   }
 
   int scr_w, scr_h;
-  wm_get_screensize(&scr_w, &scr_h);
+  wm_get_desktopsize(&scr_w, &scr_h);
   int posy = (scr_h - win->posy - win->sizey);
 
   /* Clear drawable so we can set the new window. */

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


[Bf-blender-cvs] [dab763441df] override-recursive-resync: Fix T89001: node search not working anymore

2021-06-14 Thread Jacques Lucke
Commit: dab763441dfc464166fb24316dd438f1abfaf54b
Author: Jacques Lucke
Date:   Fri Jun 11 16:27:26 2021 +0200
Branches: override-recursive-resync
https://developer.blender.org/rBdab763441dfc464166fb24316dd438f1abfaf54b

Fix T89001: node search not working anymore

===

M   release/scripts/startup/nodeitems_builtins.py

===

diff --git a/release/scripts/startup/nodeitems_builtins.py 
b/release/scripts/startup/nodeitems_builtins.py
index 5ff0e13f242..5927123cdd8 100644
--- a/release/scripts/startup/nodeitems_builtins.py
+++ b/release/scripts/startup/nodeitems_builtins.py
@@ -119,8 +119,8 @@ def node_group_items(context):
 if group.name.startswith('.'):
 continue
 yield NodeItem(node_tree_group_type[group.bl_idname],
-   group.name,
-   {"node_tree": "bpy.data.node_groups[%r]" % group.name})
+   label=group.name,
+   settings={"node_tree": "bpy.data.node_groups[%r]" % 
group.name})
 
 
 # only show input/output nodes inside node groups

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


[Bf-blender-cvs] [eac8958aa75] override-recursive-resync: Fix object assets getting duplicated after dropping

2021-06-14 Thread Julian Eisel
Commit: eac8958aa7524c386ba914a589871fb194e6eeb5
Author: Julian Eisel
Date:   Fri Jun 11 16:31:57 2021 +0200
Branches: override-recursive-resync
https://developer.blender.org/rBeac8958aa7524c386ba914a589871fb194e6eeb5

Fix object assets getting duplicated after dropping

The operator run when dropping objects would duplicate the dropped object and
place that in the scene, even though that was just appended. Addressed by
making the duplication optional for the operator. If the duplication is not
requested, the object is just added to the scene (if needed), repositioned
based on the drop location and selected (deselecting other objects).
This makes the operator work as expected when using it to drop assets.

Reviewed as part of https://developer.blender.org/D11536.

Reviewed by: Bastien Montagne

===

M   source/blender/editors/object/object_add.c
M   source/blender/editors/space_view3d/space_view3d.c

===

diff --git a/source/blender/editors/object/object_add.c 
b/source/blender/editors/object/object_add.c
index 12aaa9c2d9f..166d168471f 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -3462,6 +3462,19 @@ void OBJECT_OT_duplicate(wmOperatorType *ot)
  * Use for drag & drop.
  * \{ */
 
+static Base *object_add_ensure_in_view_layer(Main *bmain, ViewLayer 
*view_layer, Object *ob)
+{
+  Base *base = BKE_view_layer_base_find(view_layer, ob);
+
+  if (!base) {
+LayerCollection *layer_collection = 
BKE_layer_collection_get_active(view_layer);
+BKE_collection_object_add(bmain, layer_collection->collection, ob);
+base = BKE_view_layer_base_find(view_layer, ob);
+  }
+
+  return base;
+}
+
 static int object_add_named_exec(bContext *C, wmOperator *op)
 {
   Main *bmain = CTX_data_main(C);
@@ -3469,7 +3482,8 @@ static int object_add_named_exec(bContext *C, wmOperator 
*op)
   ViewLayer *view_layer = CTX_data_view_layer(C);
   Base *basen;
   Object *ob;
-  const bool linked = RNA_boolean_get(op->ptr, "linked");
+  const bool duplicate = RNA_boolean_get(op->ptr, "duplicate");
+  const bool linked = duplicate && RNA_boolean_get(op->ptr, "linked");
   const eDupli_ID_Flags dupflag = (linked) ? 0 : (eDupli_ID_Flags)U.dupflag;
   char name[MAX_ID_NAME - 2];
 
@@ -3483,20 +3497,30 @@ static int object_add_named_exec(bContext *C, 
wmOperator *op)
   }
 
   /* prepare dupli */
-  basen = object_add_duplicate_internal(
-  bmain,
-  scene,
-  view_layer,
-  ob,
-  dupflag,
-  /* Sub-process flag because the new-ID remapping 
(#BKE_libblock_relink_to_newid()) in this
-   * function will only work if the object is already linked in the view 
layer, which is not
-   * the case here. So we have to do the new-ID relinking ourselves 
(#copy_object_set_idnew()).
-   */
-  LIB_ID_DUPLICATE_IS_SUBPROCESS);
+  if (duplicate) {
+basen = object_add_duplicate_internal(
+bmain,
+scene,
+view_layer,
+ob,
+dupflag,
+/* Sub-process flag because the new-ID remapping 
(#BKE_libblock_relink_to_newid()) in this
+ * function will only work if the object is already linked in the view 
layer, which is not
+ * the case here. So we have to do the new-ID relinking ourselves
+ * (#copy_object_set_idnew()).
+ */
+LIB_ID_DUPLICATE_IS_SUBPROCESS);
+  }
+  else {
+/* basen is actually not a new base in this case. */
+basen = object_add_ensure_in_view_layer(bmain, view_layer, ob);
+  }
 
   if (basen == NULL) {
-BKE_report(op->reports, RPT_ERROR, "Object could not be duplicated");
+BKE_report(op->reports,
+   RPT_ERROR,
+   duplicate ? "Object could not be duplicated" :
+   "Object could not be linked to the view layer");
 return OPERATOR_CANCELLED;
   }
 
@@ -3543,11 +3567,24 @@ void OBJECT_OT_add_named(wmOperatorType *ot)
   /* flags */
   ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 
+  PropertyRNA *prop;
+
+  prop = RNA_def_boolean(
+  ot->srna,
+  "duplicate",
+  true,
+  "Duplicate",
+  "Create a duplicate of the object. If not set, only ensures the object 
is linked into the "
+  "active view layer, positions and selects/activates it (deselecting 
others)");
+  RNA_def_property_flag(prop, PROP_HIDDEN);
+
   RNA_def_boolean(ot->srna,
   "linked",
-  0,
+  false,
   "Linked",
-  "Duplicate object but not object data, linking to the 
original data");
+  "Duplicate object but not object data, linking to the 
original data (ignored if "
+  "'duplicate' is false)");
+
   RNA_def_string(ot->srna, "name", NULL, MAX_ID_NAME - 2, "Name", "Object name 
to add");
 
   object_add_drop_xy_props(ot);
diff --git a/source/blender/editors/

[Bf-blender-cvs] [0cf1e57461d] override-recursive-resync: Fix T89033: segfault reordering animation channels

2021-06-14 Thread Maxime Casas
Commit: 0cf1e57461dac0d659fbac5d4682173c6ab8b1b1
Author: Maxime Casas
Date:   Fri Jun 11 16:26:01 2021 +0200
Branches: override-recursive-resync
https://developer.blender.org/rB0cf1e57461dac0d659fbac5d4682173c6ab8b1b1

Fix T89033: segfault reordering animation channels

Fix segmentation fault that can occur when reordering animation
channels.

Under some specific conditions, the list "act->curves" is empty in the
"join_groups_action_temp" function. In particular, this happens when a
scene contains an action that has not been pushed down, and with no
keyframe in it.

Reviewed By: sybren

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

===

M   source/blender/editors/animation/anim_channels_edit.c

===

diff --git a/source/blender/editors/animation/anim_channels_edit.c 
b/source/blender/editors/animation/anim_channels_edit.c
index 64082b08da9..6c6fab13b7a 100644
--- a/source/blender/editors/animation/anim_channels_edit.c
+++ b/source/blender/editors/animation/anim_channels_edit.c
@@ -1349,10 +1349,12 @@ static void join_groups_action_temp(bAction *act)
 
   /* BLI_movelisttolist() doesn't touch first->prev and last->next pointers in 
its "dst" list.
* Ensure that after the reshuffling the list is properly terminated. */
-  FCurve *act_fcurves_first = act->curves.first;
-  act_fcurves_first->prev = NULL;
-  FCurve *act_fcurves_last = act->curves.last;
-  act_fcurves_last->next = NULL;
+  if (!BLI_listbase_is_empty(&act->curves)) {
+FCurve *act_fcurves_first = act->curves.first;
+act_fcurves_first->prev = NULL;
+FCurve *act_fcurves_last = act->curves.last;
+act_fcurves_last->next = NULL;
+  }
 }
 
 /* Change the order of anim-channels within action

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


[Bf-blender-cvs] [f5d0d3134ab] override-recursive-resync: Refactor: use 'BLI_task_parallel_range' in Draw Cache

2021-06-14 Thread Germano Cavalcante
Commit: f5d0d3134abd6191b0355ba8a1b721cd47dd96ad
Author: Germano Cavalcante
Date:   Thu Jun 10 11:13:01 2021 -0300
Branches: override-recursive-resync
https://developer.blender.org/rBf5d0d3134abd6191b0355ba8a1b721cd47dd96ad

Refactor: use 'BLI_task_parallel_range' in Draw Cache

One drawback to trying to predict the number of threads that will be
used in the `task_graph` is that we are only sure of the number when the
threads are running.

Using `BLI_task_parallel_range` allows the driver to
choose the best thread distribution through `parallel_reduce`.

The benefit is most evident on hardware with fewer cores.

This is the result on an 4-core laptop:
||before:|after:
|---|---|---|
|large_mesh_editing:|Average: 5.203638 FPS|Average: 5.398925 FPS
||rdata 15ms iter 43ms (frame 193ms)|rdata 14ms iter 36ms (frame 187ms)

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

===

M   source/blender/draw/intern/draw_cache_extract_mesh.cc
M   source/blender/draw/intern/draw_cache_extract_mesh_private.h
M   source/blender/draw/intern/draw_manager_profiling.c
M   source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_lines.cc
M   source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_points.cc
M   source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_tris.cc
M   source/blender/gpu/GPU_index_buffer.h
M   source/blender/gpu/intern/gpu_index_buffer.cc
M   source/blender/gpu/tests/gpu_index_buffer_test.cc

===

diff --git a/source/blender/draw/intern/draw_cache_extract_mesh.cc 
b/source/blender/draw/intern/draw_cache_extract_mesh.cc
index c6303d541b3..c6b749fe11a 100644
--- a/source/blender/draw/intern/draw_cache_extract_mesh.cc
+++ b/source/blender/draw/intern/draw_cache_extract_mesh.cc
@@ -50,7 +50,7 @@
 #  include "PIL_time_utildefines.h"
 #endif
 
-#define CHUNK_SIZE 1024
+#define MIM_RANGE_LEN 1024
 
 namespace blender::draw {
 
@@ -439,18 +439,18 @@ static void extract_task_range_run(void *__restrict 
taskdata)
   const eMRIterType iter_type = data->iter_type;
   const bool is_mesh = data->mr->extract_type != MR_EXTRACT_BMESH;
 
+  size_t userdata_chunk_size = data->extractors->data_size_total();
+  char *userdata_chunk = new char[userdata_chunk_size];
+
   TaskParallelSettings settings;
   BLI_parallel_range_settings_defaults(&settings);
-  settings.func_reduce = extract_task_reduce;
-  settings.min_iter_per_thread = CHUNK_SIZE;
   settings.use_threading = data->use_threading;
+  settings.userdata_chunk = userdata_chunk;
+  settings.userdata_chunk_size = userdata_chunk_size;
+  settings.func_reduce = extract_task_reduce;
+  settings.min_iter_per_thread = MIM_RANGE_LEN;
 
-  size_t chunk_size = data->extractors->data_size_total();
-  char *chunk = new char[chunk_size];
-  extract_init(data->mr, data->cache, *data->extractors, data->mbc, (void 
*)chunk);
-
-  settings.userdata_chunk = chunk;
-  settings.userdata_chunk_size = chunk_size;
+  extract_init(data->mr, data->cache, *data->extractors, data->mbc, (void 
*)userdata_chunk);
 
   if (iter_type & MR_ITER_LOOPTRI) {
 extract_task_range_run_iter(data->mr, data->extractors, MR_ITER_LOOPTRI, 
is_mesh, &settings);
@@ -465,14 +465,14 @@ static void extract_task_range_run(void *__restrict 
taskdata)
 extract_task_range_run_iter(data->mr, data->extractors, MR_ITER_LVERT, 
is_mesh, &settings);
   }
 
-  extract_finish(data->mr, data->cache, *data->extractors, (void *)chunk);
-  delete[] chunk;
+  extract_finish(data->mr, data->cache, *data->extractors, (void 
*)userdata_chunk);
+  delete[] userdata_chunk;
 }
 
 /** \} */
 
 /* -- */
-/** \name Extract Single Thread
+/** \name Extract In Parallel Ranges
  * \{ */
 
 static struct TaskNode *extract_task_node_create(struct TaskGraph *task_graph,
@@ -705,7 +705,7 @@ static void mesh_buffer_cache_create_requested(struct 
TaskGraph *task_graph,
   task_graph, mr, iter_type, data_flag);
 
   /* Simple heuristic. */
-  const bool use_thread = (mr->loop_len + mr->loop_loose_len) > CHUNK_SIZE;
+  const bool use_thread = (mr->loop_len + mr->loop_loose_len) > MIM_RANGE_LEN;
 
   if (use_thread) {
 /* First run the requested extractors that do not support asynchronous 
ranges. */
diff --git a/source/blender/draw/intern/draw_cache_extract_mesh_private.h 
b/source/blender/draw/intern/draw_cache_extract_mesh_private.h
index 26849eca08c..2ece0b4f1db 100644
--- a/source/blender/draw/intern/draw_cache_extract_mesh_private.h
+++ b/source/blender/draw/intern/draw_cache_extract_mesh_private.h
@@ -194,8 +194,7 @@ typedef void(ExtractFinishFn)(const MeshRenderData *mr,
   struct MeshBatchCache *cache,
   void *buffer,
   void *data);
-typedef void(ExtractTaskInitFn)(void *userdata, void *r_task

[Bf-blender-cvs] [dfc695ed74d] override-recursive-resync: Refactor: Draw Cache: use 'BLI_task_parallel_range'

2021-06-14 Thread Germano Cavalcante
Commit: dfc695ed74d55457b46916309ca322526713a613
Author: Germano Cavalcante
Date:   Thu Jun 10 11:01:36 2021 -0300
Branches: override-recursive-resync
https://developer.blender.org/rBdfc695ed74d55457b46916309ca322526713a613

Refactor: Draw Cache: use 'BLI_task_parallel_range'

This is an adaptation of {D11488}.

A disadvantage of manually setting the iter ranges per thread is that
we don't know how many threads are running in the background and so we
don't know how to best distribute the ranges.

To solve this limitation we can use `parallel_reduce` and thus let the
driver choose the best distribution of ranges among the threads.

This proved to be especially beneficial for computers with few cores.

**Benchmarking:**
Here's the result on an 4-core laptop:
||master:|PATCH:
|---|---|---|
|large_mesh_editing:|Average: 5.203638 FPS|Average: 5.398925 FPS
||rdata 15ms iter 43ms (frame 193ms)|rdata 14ms iter 36ms (frame 187ms)

Here's the result on an 8-core PC:
||master:|PATCH:
|---|---|---|
|large_mesh_editing:|Average: 15.267482 FPS|Average: 15.906881 FPS
||rdata 9ms iter 28ms (frame 65ms)|rdata 9ms iter 25ms (frame 63ms)
|large_mesh_editing_ledge: |Average: 15.145966 FPS|Average: 15.520474 FPS
||rdata 9ms iter 29ms (frame 65ms)|rdata 9ms iter 25ms (frame 64ms)
|looptris_test:|Average: 4.001917 FPS|Average: 4.061105 FPS
||rdata 12ms iter 90ms (frame 236ms)|rdata 12ms iter 87ms (frame 230ms)
|subdiv_mesh_cage_and_final:|Average: 1.917769 FPS|Average: 1.971790 FPS
||rdata 7ms iter 37ms (frame 261ms)|rdata 7ms iter 31ms (frame 258ms)
||rdata 7ms iter 38ms (frame 252ms)|rdata 7ms iter 33ms (frame 249ms)
|subdiv_mesh_final_only:|Average: 6.387240 FPS|Average: 6.591251 FPS
||rdata 3ms iter 25ms (frame 151ms)|rdata 3ms iter 16ms (frame 145ms)
|subdiv_mesh_final_only_ledge:|Average: 6.247393 FPS|Average: 6.596024 FPS
||rdata 3ms iter 26ms (frame 158ms)|rdata 3ms iter 16ms (frame 148ms)

**Notes:**
- The improvement can only be noticed if all extracts are multithreaded.
- This patch touches different areas of the code, so it can be split into 
another patch if the idea is accepted.

These screenshots show how threads behave in a quadcore:
Master:
{F10164664}
Patch:
{F10164666}

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

===

M   source/blender/draw/intern/draw_cache_extract_mesh.cc
M   source/blender/draw/intern/draw_cache_extract_mesh_extractors.c
M   source/blender/draw/intern/draw_cache_extract_mesh_private.h
M   source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_edituv.cc
M   source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_fdots.cc
M   source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_lines.cc
M   
source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_lines_adjacency.cc
M   
source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_lines_paint_mask.cc
M   source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_points.cc
M   source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_tris.cc
M   source/blender/gpu/GPU_index_buffer.h
M   source/blender/gpu/intern/gpu_index_buffer.cc
M   source/tools

===

diff --git a/source/blender/draw/intern/draw_cache_extract_mesh.cc 
b/source/blender/draw/intern/draw_cache_extract_mesh.cc
index 6b5877e6759..c6303d541b3 100644
--- a/source/blender/draw/intern/draw_cache_extract_mesh.cc
+++ b/source/blender/draw/intern/draw_cache_extract_mesh.cc
@@ -50,7 +50,7 @@
 #  include "PIL_time_utildefines.h"
 #endif
 
-#define CHUNK_SIZE 8192
+#define CHUNK_SIZE 1024
 
 namespace blender::draw {
 
@@ -65,26 +65,12 @@ struct ExtractorRunData {
   const MeshExtract *extractor;
   /* During iteration the VBO/IBO that is being build. */
   void *buffer = nullptr;
-  /* User data during iteration. Created in MeshExtract.init and passed along 
to other MeshExtract
-   * functions. */
-  void *user_data = nullptr;
-  std::optional> task_user_datas;
+  uint32_t data_offset = 0;
 
   ExtractorRunData(const MeshExtract *extractor) : extractor(extractor)
   {
   }
 
-  void init_task_user_datas(const TaskLen task_len)
-  {
-task_user_datas = Array(task_len);
-  }
-
-  void *&operator[](const TaskId task_id)
-  {
-BLI_assert(task_user_datas);
-return (*task_user_datas)[task_id];
-  }
-
 #ifdef WITH_CXX_GUARDEDALLOC
   MEM_CXX_CLASS_ALLOC_FUNCS("DRAW:ExtractorRunData")
 #endif
@@ -157,6 +143,16 @@ class ExtractorRunDatas : public Vector {
 return data_type;
   }
 
+  size_t data_size_total()
+  {
+size_t data_size = 0;
+for (const ExtractorRunData &data : *this) {
+  const MeshExtract *extractor = data.extractor;
+  data_size += extractor->data_size;
+}
+return data_size;
+  }
+
 #ifdef WITH_CXX_GUARDEDALLOC
   MEM_CXX_CLASS_ALLOC_FUNCS("DRAW:ExtractorRunDatas")
 #endif
@@ -165,446 +161,334 @@ class ExtractorRunDatas : public

[Bf-blender-cvs] [90b0fb135fd] master: PyAPI: remove deprecated bpy.app.binary_path_python

2021-06-14 Thread Campbell Barton
Commit: 90b0fb135fdd06055d42f22396120e812440122d
Author: Campbell Barton
Date:   Mon Jun 14 23:50:24 2021 +1000
Branches: master
https://developer.blender.org/rB90b0fb135fdd06055d42f22396120e812440122d

PyAPI: remove deprecated bpy.app.binary_path_python

===

M   source/blender/python/intern/bpy_app.c
M   tests/python/bl_test.py

===

diff --git a/source/blender/python/intern/bpy_app.c 
b/source/blender/python/intern/bpy_app.c
index 4de6063098b..a89d97bb40c 100644
--- a/source/blender/python/intern/bpy_app.c
+++ b/source/blender/python/intern/bpy_app.c
@@ -298,15 +298,6 @@ static int bpy_app_global_flag_set__only_disable(PyObject 
*UNUSED(self),
   return bpy_app_global_flag_set(NULL, value, closure);
 }
 
-PyDoc_STRVAR(bpy_app_binary_path_python_doc,
- "String, the path to the python executable (read-only). "
- "Deprecated! Use ``sys.executable`` instead.");
-static PyObject *bpy_app_binary_path_python_get(PyObject *UNUSED(self), void 
*UNUSED(closure))
-{
-  PyErr_Warn(PyExc_RuntimeWarning, "Use 'sys.executable' instead of 
'binary_path_python'!");
-  return Py_INCREF_RET(PySys_GetObject("executable"));
-}
-
 PyDoc_STRVAR(bpy_app_debug_value_doc,
  "Short, number which can be set to non-zero values for testing 
purposes");
 static PyObject *bpy_app_debug_value_get(PyObject *UNUSED(self), void 
*UNUSED(closure))
@@ -441,12 +432,6 @@ static PyGetSetDef bpy_app_getsets[] = {
  bpy_app_global_flag_doc,
  (void *)G_FLAG_USERPREF_NO_SAVE_ON_EXIT},
 
-{"binary_path_python",
- bpy_app_binary_path_python_get,
- NULL,
- bpy_app_binary_path_python_doc,
- NULL},
-
 {"debug_value",
  bpy_app_debug_value_get,
  bpy_app_debug_value_set,
diff --git a/tests/python/bl_test.py b/tests/python/bl_test.py
index 110b4238f6c..6315ffbfa9d 100644
--- a/tests/python/bl_test.py
+++ b/tests/python/bl_test.py
@@ -32,18 +32,9 @@ def replace_bpy_app_version():
 app = bpy.app
 app_fake = type(bpy)("bpy.app")
 
-app_attr_exclude = {
-# This causes a noisy warning every time.
-"binary_path_python",
-}
-
 for attr in dir(app):
-if attr.startswith("_"):
-continue
-if attr in app_attr_exclude:
-continue
-
-setattr(app_fake, attr, getattr(app, attr))
+if not attr.startswith("_"):
+setattr(app_fake, attr, getattr(app, attr))
 
 app_fake.version = 0, 0, 0
 app_fake.version_string = "0.00 (sub 0)"

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


[Bf-blender-cvs] [6bef2559047] master: BMesh: remove unit-length edge-vector cache from normal calculation

2021-06-14 Thread Campbell Barton
Commit: 6bef2559047461794eb3ff27de15f4caf5ddcf1e
Author: Campbell Barton
Date:   Mon Jun 14 22:56:02 2021 +1000
Branches: master
https://developer.blender.org/rB6bef2559047461794eb3ff27de15f4caf5ddcf1e

BMesh: remove unit-length edge-vector cache from normal calculation

Bypass stored edge-vectors for ~16% performance gains.

While this increases unit-length edge-vector calculations by around ~4x
the overhead of a parallel loop over all edges makes it worthwhile.

Note that caching edge-vectors per-vertex performs better and may be
worth investigating further, although in my tests this increases code
complexity with barley measurable benefits over not using cache at all.

Details about performance and possible optimizations are noted in
bm_vert_calc_normals_impl.

===

M   source/blender/bmesh/intern/bmesh_mesh_normals.c
M   source/blender/bmesh/intern/bmesh_mesh_partial_update.c
M   source/blender/bmesh/intern/bmesh_mesh_partial_update.h

===

diff --git a/source/blender/bmesh/intern/bmesh_mesh_normals.c 
b/source/blender/bmesh/intern/bmesh_mesh_normals.c
index a3eae6dabe8..bf30f3a52e1 100644
--- a/source/blender/bmesh/intern/bmesh_mesh_normals.c
+++ b/source/blender/bmesh/intern/bmesh_mesh_normals.c
@@ -49,67 +49,9 @@
  * assuming no other tool using it would run concurrently to clnors editing. */
 #define BM_LNORSPACE_UPDATE _FLAG_MF
 
-typedef struct BMEdgesCalcVectorsData {
-  /* Read-only data. */
-  const float (*vcos)[3];
-
-  /* Read-write data, but no need to protect it, no concurrency to fear here. 
*/
-  float (*edgevec)[3];
-} BMEdgesCalcVectorsData;
-
-static void bm_edge_calc_vectors_cb(void *userdata,
-MempoolIterData *mp_e,
-const TaskParallelTLS *__restrict 
UNUSED(tls))
-{
-  BMEdge *e = (BMEdge *)mp_e;
-  /* The edge vector will not be needed when the edge has no radial. */
-  if (e->l != NULL) {
-float(*edgevec)[3] = userdata;
-float *e_diff = edgevec[BM_elem_index_get(e)];
-sub_v3_v3v3(e_diff, e->v2->co, e->v1->co);
-normalize_v3(e_diff);
-  }
-}
-
-static void bm_edge_calc_vectors_with_coords_cb(void *userdata,
-MempoolIterData *mp_e,
-const TaskParallelTLS 
*__restrict UNUSED(tls))
-{
-  BMEdge *e = (BMEdge *)mp_e;
-  /* The edge vector will not be needed when the edge has no radial. */
-  if (e->l != NULL) {
-BMEdgesCalcVectorsData *data = userdata;
-float *e_diff = data->edgevec[BM_elem_index_get(e)];
-sub_v3_v3v3(
-e_diff, data->vcos[BM_elem_index_get(e->v2)], 
data->vcos[BM_elem_index_get(e->v1)]);
-normalize_v3(e_diff);
-  }
-}
-
-static void bm_mesh_edges_calc_vectors(BMesh *bm, float (*edgevec)[3], const 
float (*vcos)[3])
-{
-  BM_mesh_elem_index_ensure(bm, BM_EDGE | (vcos ? BM_VERT : 0));
-
-  TaskParallelSettings settings;
-  BLI_parallel_mempool_settings_defaults(&settings);
-  settings.use_threading = bm->totedge >= BM_OMP_LIMIT;
-
-  if (vcos == NULL) {
-BM_iter_parallel(bm, BM_EDGES_OF_MESH, bm_edge_calc_vectors_cb, edgevec, 
&settings);
-  }
-  else {
-BMEdgesCalcVectorsData data = {
-.edgevec = edgevec,
-.vcos = vcos,
-};
-BM_iter_parallel(bm, BM_EDGES_OF_MESH, 
bm_edge_calc_vectors_with_coords_cb, &data, &settings);
-  }
-}
-
 typedef struct BMVertsCalcNormalsWithCoordsData {
   /* Read-only data. */
   const float (*fnos)[3];
-  const float (*edgevec)[3];
   const float (*vcos)[3];
 
   /* Write data. */
@@ -117,13 +59,12 @@ typedef struct BMVertsCalcNormalsWithCoordsData {
 } BMVertsCalcNormalsWithCoordsData;
 
 BLI_INLINE void bm_vert_calc_normals_accum_loop(const BMLoop *l_iter,
-const float (*edgevec)[3],
+const float e1diff[3],
+const float e2diff[3],
 const float f_no[3],
 float v_no[3])
 {
   /* Calculate the dot product of the two edges that meet at the loop's 
vertex. */
-  const float *e1diff = edgevec[BM_elem_index_get(l_iter->prev->e)];
-  const float *e2diff = edgevec[BM_elem_index_get(l_iter->e)];
   /* Edge vectors are calculated from e->v1 to e->v2, so adjust the dot 
product if one but not
* both loops actually runs from from e->v2 to e->v1. */
   float dotprod = dot_v3v3(e1diff, e2diff);
@@ -132,25 +73,61 @@ BLI_INLINE void bm_vert_calc_normals_accum_loop(const 
BMLoop *l_iter,
   }
   const float fac = saacos(-dotprod);
   /* NAN detection, otherwise this is a degenerated case, ignore that vertex 
in this case. */
-  if (fac == fac) { /* NAN detection. */
+  if (fac == fac) {
 madd_v3_v3fl(v_no, f_no, fac);
   }
 }
 
-static void 

[Bf-blender-cvs] [8a1860bd9ae] master: BMesh: support face-normal calculation in normal & looptri functions

2021-06-14 Thread Campbell Barton
Commit: 8a1860bd9aecddf611b64e3e842bdc8c76f15cc6
Author: Campbell Barton
Date:   Mon Jun 14 22:56:03 2021 +1000
Branches: master
https://developer.blender.org/rB8a1860bd9aecddf611b64e3e842bdc8c76f15cc6

BMesh: support face-normal calculation in normal & looptri functions

Support calculating face normals when tessellating. When this is done
before updating vertex normals it gives ~20% performance improvement.

Now vertex normal calculation only needs to perform a single pass on the
mesh vertices when called after tessellation.

Extended versions of normal & looptri update functions have been added:

- BM_mesh_calc_tessellation_ex
- BM_mesh_normals_update_ex

Most callers don't need to be aware of this detail by using:

- BKE_editmesh_looptri_and_normals_calc
- BKE_editmesh_looptri_and_normals_calc_with_partial

- EDBM_update also takes advantage of this,
  where calling EDBM_update with calc_looptri & calc_normals
  enabled uses the faster normal updating logic.

===

M   source/blender/blenkernel/BKE_editmesh.h
M   source/blender/blenkernel/intern/editmesh.c
M   source/blender/bmesh/intern/bmesh_mesh_normals.c
M   source/blender/bmesh/intern/bmesh_mesh_normals.h
M   source/blender/bmesh/intern/bmesh_mesh_tessellate.c
M   source/blender/bmesh/intern/bmesh_mesh_tessellate.h
M   source/blender/editors/include/ED_mesh.h
M   source/blender/editors/mesh/editmesh_utils.c
M   source/blender/editors/object/object_edit.c
M   source/blender/editors/object/object_hook.c
M   source/blender/editors/object/object_relations.c
M   source/blender/editors/transform/transform_convert_mesh.c
M   source/blender/editors/transform/transform_convert_mesh_skin.c
M   source/blender/makesrna/intern/rna_object.c

===

diff --git a/source/blender/blenkernel/BKE_editmesh.h 
b/source/blender/blenkernel/BKE_editmesh.h
index 3a1eedfd807..075a9bc0eac 100644
--- a/source/blender/blenkernel/BKE_editmesh.h
+++ b/source/blender/blenkernel/BKE_editmesh.h
@@ -34,6 +34,7 @@ extern "C" {
 struct BMLoop;
 struct BMesh;
 struct BMPartialUpdate;
+struct BMeshCalcTessellation_Params;
 struct BoundBox;
 struct Depsgraph;
 struct Mesh;
@@ -85,8 +86,17 @@ typedef struct BMEditMesh {
 } BMEditMesh;
 
 /* editmesh.c */
+void BKE_editmesh_looptri_calc_ex(BMEditMesh *em,
+  const struct BMeshCalcTessellation_Params 
*params);
 void BKE_editmesh_looptri_calc(BMEditMesh *em);
+void BKE_editmesh_looptri_calc_with_partial_ex(BMEditMesh *em,
+   struct BMPartialUpdate *bmpinfo,
+   const struct 
BMeshCalcTessellation_Params *params);
 void BKE_editmesh_looptri_calc_with_partial(BMEditMesh *em, struct 
BMPartialUpdate *bmpinfo);
+void BKE_editmesh_looptri_and_normals_calc_with_partial(BMEditMesh *em,
+struct BMPartialUpdate 
*bmpinfo);
+
+void BKE_editmesh_looptri_and_normals_calc(BMEditMesh *em);
 
 BMEditMesh *BKE_editmesh_create(BMesh *bm, const bool do_tessellate);
 BMEditMesh *BKE_editmesh_copy(BMEditMesh *em);
diff --git a/source/blender/blenkernel/intern/editmesh.c 
b/source/blender/blenkernel/intern/editmesh.c
index 472de1f3c77..b908df267c4 100644
--- a/source/blender/blenkernel/intern/editmesh.c
+++ b/source/blender/blenkernel/intern/editmesh.c
@@ -96,7 +96,8 @@ BMEditMesh *BKE_editmesh_from_object(Object *ob)
   return ((Mesh *)ob->data)->edit_mesh;
 }
 
-static void editmesh_tessface_calc_intern(BMEditMesh *em)
+static void editmesh_tessface_calc_intern(BMEditMesh *em,
+  const struct 
BMeshCalcTessellation_Params *params)
 {
   /* allocating space before calculating the tessellation */
 
@@ -130,12 +131,13 @@ static void editmesh_tessface_calc_intern(BMEditMesh *em)
   em->tottri = looptris_tot;
 
   /* after allocating the em->looptris, we're ready to tessellate */
-  BM_mesh_calc_tessellation(em->bm, em->looptris);
+  BM_mesh_calc_tessellation_ex(em->bm, em->looptris, params);
 }
 
-void BKE_editmesh_looptri_calc(BMEditMesh *em)
+void BKE_editmesh_looptri_calc_ex(BMEditMesh *em,
+  const struct BMeshCalcTessellation_Params 
*params)
 {
-  editmesh_tessface_calc_intern(em);
+  editmesh_tessface_calc_intern(em, params);
 
   /* commented because editbmesh_build_data() ensures we get tessfaces */
 #if 0
@@ -149,12 +151,58 @@ void BKE_editmesh_looptri_calc(BMEditMesh *em)
 #endif
 }
 
-void BKE_editmesh_looptri_calc_with_partial(BMEditMesh *em, struct 
BMPartialUpdate *bmpinfo)
+void BKE_editmesh_looptri_calc(BMEditMesh *em)
+{
+  BKE_editmesh_looptri_calc_ex(em,
+   &(const struct BMeshCalcTessellation_Params){
+   .face_normals = false,
+   }

[Bf-blender-cvs] [8083527f90d] master: Edit Mesh: use params arg for update function, add calc_normals arg

2021-06-14 Thread Campbell Barton
Commit: 8083527f90d1556f576cf102d4143749677c45e0
Author: Campbell Barton
Date:   Mon Jun 14 22:56:01 2021 +1000
Branches: master
https://developer.blender.org/rB8083527f90d1556f576cf102d4143749677c45e0

Edit Mesh: use params arg for update function, add calc_normals arg

Rename function EDBM_update_generic to EDBM_update, use a parameters
argument for better readability.

Also add calc_normals argument, which will have benefits when
calculating normals and tessellation together is optimized.

===

M   source/blender/editors/include/ED_mesh.h
M   source/blender/editors/mesh/editmesh_add.c
M   source/blender/editors/mesh/editmesh_add_gizmo.c
M   source/blender/editors/mesh/editmesh_automerge.c
M   source/blender/editors/mesh/editmesh_bevel.c
M   source/blender/editors/mesh/editmesh_bisect.c
M   source/blender/editors/mesh/editmesh_extrude.c
M   source/blender/editors/mesh/editmesh_extrude_screw.c
M   source/blender/editors/mesh/editmesh_extrude_spin.c
M   source/blender/editors/mesh/editmesh_inset.c
M   source/blender/editors/mesh/editmesh_intersect.c
M   source/blender/editors/mesh/editmesh_knife.c
M   source/blender/editors/mesh/editmesh_loopcut.c
M   source/blender/editors/mesh/editmesh_path.c
M   source/blender/editors/mesh/editmesh_polybuild.c
M   source/blender/editors/mesh/editmesh_rip.c
M   source/blender/editors/mesh/editmesh_rip_edge.c
M   source/blender/editors/mesh/editmesh_select.c
M   source/blender/editors/mesh/editmesh_select_similar.c
M   source/blender/editors/mesh/editmesh_tools.c
M   source/blender/editors/mesh/editmesh_utils.c
M   source/blender/editors/object/object_data_transform.c
M   source/blender/editors/uvedit/uvedit_ops.c
M   source/blender/python/bmesh/bmesh_py_api.c

===

diff --git a/source/blender/editors/include/ED_mesh.h 
b/source/blender/editors/include/ED_mesh.h
index b8e9f6e8871..b76c35c7d7a 100644
--- a/source/blender/editors/include/ED_mesh.h
+++ b/source/blender/editors/include/ED_mesh.h
@@ -103,7 +103,14 @@ bool EDBM_vert_color_check(struct BMEditMesh *em);
 bool EDBM_mesh_hide(struct BMEditMesh *em, bool swap);
 bool EDBM_mesh_reveal(struct BMEditMesh *em, bool select);
 
-void EDBM_update_generic(struct Mesh *me, const bool do_tessellation, const 
bool is_destructive);
+struct EDBMUpdate_Params {
+  uint calc_looptri : 1;
+  uint calc_normals : 1;
+  uint is_destructive : 1;
+};
+
+void EDBM_update(struct Mesh *me, const struct EDBMUpdate_Params *params);
+void EDBM_update_extern(struct Mesh *me, const bool do_tessellation, const 
bool is_destructive);
 
 struct UvElementMap *BM_uv_element_map_create(struct BMesh *bm,
   const struct Scene *scene,
diff --git a/source/blender/editors/mesh/editmesh_add.c 
b/source/blender/editors/mesh/editmesh_add.c
index 18e231893d4..a64b90e15a3 100644
--- a/source/blender/editors/mesh/editmesh_add.c
+++ b/source/blender/editors/mesh/editmesh_add.c
@@ -95,7 +95,12 @@ static void make_prim_finish(bContext *C,
   EDBM_selectmode_flush_ex(em, SCE_SELECT_VERTEX);
 
   /* only recalc editmode tessface if we are staying in editmode */
-  EDBM_update_generic(obedit->data, !exit_editmode, true);
+  EDBM_update(obedit->data,
+  &(const struct EDBMUpdate_Params){
+  .calc_looptri = !exit_editmode,
+  .calc_normals = false,
+  .is_destructive = true,
+  });
 
   /* userdef */
   if (exit_editmode) {
diff --git a/source/blender/editors/mesh/editmesh_add_gizmo.c 
b/source/blender/editors/mesh/editmesh_add_gizmo.c
index e7a99ca9e08..9efcf0963b4 100644
--- a/source/blender/editors/mesh/editmesh_add_gizmo.c
+++ b/source/blender/editors/mesh/editmesh_add_gizmo.c
@@ -357,7 +357,12 @@ static int add_primitive_cube_gizmo_exec(bContext *C, 
wmOperator *op)
   }
 
   EDBM_selectmode_flush_ex(em, SCE_SELECT_VERTEX);
-  EDBM_update_generic(obedit->data, true, true);
+  EDBM_update(obedit->data,
+  &(const struct EDBMUpdate_Params){
+  .calc_looptri = true,
+  .calc_normals = false,
+  .is_destructive = true,
+  });
 
   return OPERATOR_FINISHED;
 }
diff --git a/source/blender/editors/mesh/editmesh_automerge.c 
b/source/blender/editors/mesh/editmesh_automerge.c
index 2bd5b9b26ca..35fff1f8f3a 100644
--- a/source/blender/editors/mesh/editmesh_automerge.c
+++ b/source/blender/editors/mesh/editmesh_automerge.c
@@ -76,7 +76,12 @@ void EDBM_automerge(Object *obedit, bool update, const char 
hflag, const float d
   BMO_op_finish(bm, &weldop);
 
   if ((totvert_prev != bm->totvert) && update) {
-EDBM_update_generic(obedit->data, true, true);
+EDBM_update(obedit->data,
+&(const struct EDBMUpdate_Params){
+.calc_looptri

[Bf-blender-cvs] [1d2eb461b52] master: Cleanup: clang-format

2021-06-14 Thread Campbell Barton
Commit: 1d2eb461b528cc309ad6d2fa94ce1e910e93d8be
Author: Campbell Barton
Date:   Mon Jun 14 22:56:00 2021 +1000
Branches: master
https://developer.blender.org/rB1d2eb461b528cc309ad6d2fa94ce1e910e93d8be

Cleanup: clang-format

===

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

===

diff --git a/source/blender/makesrna/intern/rna_nodetree.c 
b/source/blender/makesrna/intern/rna_nodetree.c
index 2a1ea3d6716..7271ecb49eb 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -10840,8 +10840,10 @@ static void 
rna_def_node_socket_standard_types(BlenderRNA *brna)
   brna, "NodeSocketFloatAngle", "NodeSocketInterfaceFloatAngle", 
PROP_ANGLE);
   rna_def_node_socket_float(
   brna, "NodeSocketFloatTime", "NodeSocketInterfaceFloatTime", PROP_TIME);
-  rna_def_node_socket_float(
-  brna, "NodeSocketFloatTimeAbsolute", 
"NodeSocketInterfaceFloatTimeAbsolute", PROP_TIME_ABSOLUTE);
+  rna_def_node_socket_float(brna,
+"NodeSocketFloatTimeAbsolute",
+"NodeSocketInterfaceFloatTimeAbsolute",
+PROP_TIME_ABSOLUTE);
   rna_def_node_socket_float(
   brna, "NodeSocketFloatDistance", "NodeSocketInterfaceFloatDistance", 
PROP_DISTANCE);
 
diff --git a/source/blender/sequencer/intern/render.c 
b/source/blender/sequencer/intern/render.c
index b0a8605e922..76623599864 100644
--- a/source/blender/sequencer/intern/render.c
+++ b/source/blender/sequencer/intern/render.c
@@ -514,9 +514,9 @@ static void sequencer_image_crop_transform_matrix(const 
Sequence *seq,
 }
 
 static void sequencer_image_crop_init(const Sequence *seq,
- const ImBuf *in,
- float crop_scale_factor,
- rctf *r_crop)
+  const ImBuf *in,
+  float crop_scale_factor,
+  rctf *r_crop)
 {
   const StripCrop *c = seq->strip->crop;
   const int left = c->left * crop_scale_factor;

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


[Bf-blender-cvs] [07b52c9fb68] soc-2021-adaptive-cloth: adaptive_cloth: run BKE_cloth_remesh() when remesh flag is on

2021-06-14 Thread ishbosamiya
Commit: 07b52c9fb6862d224b8ab661d7aa4c05c24e574a
Author: ishbosamiya
Date:   Fri Jun 11 21:19:39 2021 +0530
Branches: soc-2021-adaptive-cloth
https://developer.blender.org/rB07b52c9fb6862d224b8ab661d7aa4c05c24e574a

adaptive_cloth: run BKE_cloth_remesh() when remesh flag is on

===

A   source/blender/blenkernel/BKE_cloth_remesh.hh
M   source/blender/blenkernel/CMakeLists.txt
M   source/blender/blenkernel/intern/cloth.c
A   source/blender/blenkernel/intern/cloth_remesh.cc

===

diff --git a/source/blender/blenkernel/BKE_cloth_remesh.hh 
b/source/blender/blenkernel/BKE_cloth_remesh.hh
new file mode 100644
index 000..5927ae2537a
--- /dev/null
+++ b/source/blender/blenkernel/BKE_cloth_remesh.hh
@@ -0,0 +1,44 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) Blender Foundation.
+ * All rights reserved.
+ */
+
+#pragma once
+
+/** \file
+ * \ingroup bke
+ */
+
+/**
+ * reference http://graphics.berkeley.edu/papers/Narain-AAR-2012-11/index.html
+ 
**/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct ClothModifierData;
+struct Mesh;
+struct Object;
+
+void BKE_cloth_remesh(const struct Object *ob,
+  struct ClothModifierData *clmd,
+  struct Mesh *r_mesh);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/source/blender/blenkernel/CMakeLists.txt 
b/source/blender/blenkernel/CMakeLists.txt
index 021d7e15814..112c1ccd164 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -99,6 +99,7 @@ set(SRC
   intern/camera.c
   intern/cdderivedmesh.c
   intern/cloth.c
+  intern/cloth_remesh.cc
   intern/collection.c
   intern/collision.c
   intern/colorband.c
@@ -313,6 +314,7 @@ set(SRC
   BKE_ccg.h
   BKE_cdderivedmesh.h
   BKE_cloth.h
+  BKE_cloth_remesh.hh
   BKE_collection.h
   BKE_collision.h
   BKE_colorband.h
diff --git a/source/blender/blenkernel/intern/cloth.c 
b/source/blender/blenkernel/intern/cloth.c
index 99dcdd21d83..3a9631aef1a 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -40,6 +40,7 @@
 
 #include "BKE_bvhutils.h"
 #include "BKE_cloth.h"
+#include "BKE_cloth_remesh.hh"
 #include "BKE_effect.h"
 #include "BKE_global.h"
 #include "BKE_mesh.h"
@@ -316,7 +317,14 @@ static int do_step_cloth(
 
   // printf ( "%f\n", ( float ) tval() );
 
-  cloth_to_object(ob, clmd, r_mesh);
+  if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_REMESH) {
+/* In case remeshing is enabled, the remeshing function would update 
`r_mesh` */
+BKE_cloth_remesh(ob, clmd, r_mesh);
+  }
+  else {
+/* if remeshing is off, need to update `r_mesh` from clmd->clothObject */
+cloth_to_object(ob, clmd, r_mesh);
+  }
 
   return ret;
 }
diff --git a/source/blender/blenkernel/intern/cloth_remesh.cc 
b/source/blender/blenkernel/intern/cloth_remesh.cc
new file mode 100644
index 000..abb42ed2978
--- /dev/null
+++ b/source/blender/blenkernel/intern/cloth_remesh.cc
@@ -0,0 +1,38 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) Blender Foundation
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup bke
+ */
+
+#include "DNA_cloth_types.h"
+#include "DNA_mesh_types.h"
+#include "DNA_object_types.h"
+
+#include "BLI_utildefines.h"
+
+#include "BKE_c

[Bf-blender-cvs] [d4be1bfb818] soc-2021-adaptive-cloth: adaptive_cloth: `clothModifier_do()` returns a new `Mesh` if simulation was successful

2021-06-14 Thread ishbosamiya
Commit: d4be1bfb8187b2ca270982f6e59157ac0ff72647
Author: ishbosamiya
Date:   Fri Jun 11 12:19:52 2021 +0530
Branches: soc-2021-adaptive-cloth
https://developer.blender.org/rBd4be1bfb8187b2ca270982f6e59157ac0ff72647

adaptive_cloth: `clothModifier_do()` returns a new `Mesh` if simulation was 
successful

This is an important change that allows for remeshing operations in
the cloth simulator. `clothModifier_do()` returns the resulting mesh
if it was successful otherwise NULL.

===

M   source/blender/blenkernel/BKE_cloth.h
M   source/blender/blenkernel/intern/cloth.c
M   source/blender/blenkernel/intern/particle_system.c
M   source/blender/modifiers/intern/MOD_cloth.c

===

diff --git a/source/blender/blenkernel/BKE_cloth.h 
b/source/blender/blenkernel/BKE_cloth.h
index 04fcdd6ed6f..7bf47e37c69 100644
--- a/source/blender/blenkernel/BKE_cloth.h
+++ b/source/blender/blenkernel/BKE_cloth.h
@@ -241,12 +241,11 @@ int cloth_bvh_collision(struct Depsgraph *depsgraph,
 // needed for modifier.c
 void cloth_free_modifier_extern(struct ClothModifierData *clmd);
 void cloth_free_modifier(struct ClothModifierData *clmd);
-void clothModifier_do(struct ClothModifierData *clmd,
-  struct Depsgraph *depsgraph,
-  struct Scene *scene,
-  struct Object *ob,
-  struct Mesh *me,
-  float (*vertexCos)[3]);
+struct Mesh *clothModifier_do(struct ClothModifierData *clmd,
+  struct Depsgraph *depsgraph,
+  struct Scene *scene,
+  struct Object *ob,
+  struct Mesh *mesh);
 
 int cloth_uses_vgroup(struct ClothModifierData *clmd);
 
diff --git a/source/blender/blenkernel/intern/cloth.c 
b/source/blender/blenkernel/intern/cloth.c
index 09bd397cc78..a63dbf5f467 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -54,7 +54,7 @@
 /* ** cloth engine *** */
 /* Prototypes for internal functions.
  */
-static void cloth_to_object(Object *ob, ClothModifierData *clmd, float 
(*vertexCos)[3]);
+static void cloth_to_object(Object *ob, ClothModifierData *clmd, Mesh *r_mesh);
 static void cloth_from_mesh(ClothModifierData *clmd, const Object *ob, Mesh 
*mesh);
 static bool cloth_from_object(
 Object *ob, ClothModifierData *clmd, Mesh *mesh, float framenr, int first);
@@ -318,12 +318,8 @@ static int do_step_cloth(
 /
  * clothModifier_do - main simulation function
  /
-void clothModifier_do(ClothModifierData *clmd,
-  Depsgraph *depsgraph,
-  Scene *scene,
-  Object *ob,
-  Mesh *mesh,
-  float (*vertexCos)[3])
+Mesh *clothModifier_do(
+ClothModifierData *clmd, Depsgraph *depsgraph, Scene *scene, Object *ob, 
Mesh *mesh)
 {
   PointCache *cache;
   PTCacheID pid;
@@ -351,7 +347,7 @@ void clothModifier_do(ClothModifierData *clmd,
   /* simulation is only active during a specific period */
   if (framenr < startframe) {
 BKE_ptcache_invalidate(cache);
-return;
+return NULL;
   }
   if (framenr > endframe) {
 framenr = endframe;
@@ -359,7 +355,7 @@ void clothModifier_do(ClothModifierData *clmd,
 
   /* initialize simulation data if it didn't exist already */
   if (!do_init_cloth(ob, clmd, mesh, framenr)) {
-return;
+return NULL;
   }
 
   if (framenr == startframe) {
@@ -368,7 +364,7 @@ void clothModifier_do(ClothModifierData *clmd,
 BKE_ptcache_validate(cache, framenr);
 cache->flag &= ~PTCACHE_REDO_NEEDED;
 clmd->clothObject->last_frame = framenr;
-return;
+return NULL;
   }
 
   /* try to read from cache */
@@ -380,7 +376,10 @@ void clothModifier_do(ClothModifierData *clmd,
   if (cache_result == PTCACHE_READ_EXACT || cache_result == 
PTCACHE_READ_INTERPOLATED ||
   (!can_simulate && cache_result == PTCACHE_READ_OLD)) {
 SIM_cloth_solver_set_positions(clmd);
-cloth_to_object(ob, clmd, vertexCos);
+
+Mesh *mesh_result = BKE_mesh_copy_for_eval(mesh, false);
+
+cloth_to_object(ob, clmd, mesh_result);
 
 BKE_ptcache_validate(cache, framenr);
 
@@ -390,7 +389,7 @@ void clothModifier_do(ClothModifierData *clmd,
 
 clmd->clothObject->last_frame = framenr;
 
-return;
+return mesh_result;
   }
   if (cache_result == PTCACHE_READ_OLD) {
 SIM_cloth_solver_set_positions(clmd);
@@ -400,7 +399,8 @@ void clothModifier_do(ClothModifierData *clmd,
   /*ob->id.lib ||*/ (cache->flag & PTCACHE_BAKED)) {
 /* if baked and nothing in cache, do nothing */
 BKE_ptcache_invalidate(cache);
-return;
+return NULL; /* TODO(ish): figure out if this is an early esca

[Bf-blender-cvs] [ad5d6448f2c] soc-2021-adaptive-cloth: adaptive_cloth: ui: add remesh option within shape

2021-06-14 Thread ishbosamiya
Commit: ad5d6448f2cbec3753fcac577024f8b6fc4eced2
Author: ishbosamiya
Date:   Fri Jun 11 19:42:55 2021 +0530
Branches: soc-2021-adaptive-cloth
https://developer.blender.org/rBad5d6448f2cbec3753fcac577024f8b6fc4eced2

adaptive_cloth: ui: add remesh option within shape

===

M   release/scripts/startup/bl_ui/properties_physics_cloth.py
M   source/blender/makesdna/DNA_cloth_types.h
M   source/blender/makesrna/intern/rna_cloth.c

===

diff --git a/release/scripts/startup/bl_ui/properties_physics_cloth.py 
b/release/scripts/startup/bl_ui/properties_physics_cloth.py
index 3a5ca1e04f5..d985f62ba56 100644
--- a/release/scripts/startup/bl_ui/properties_physics_cloth.py
+++ b/release/scripts/startup/bl_ui/properties_physics_cloth.py
@@ -307,6 +307,30 @@ class PHYSICS_PT_cloth_shape(PhysicButtonsPanel, Panel):
 col.prop_search(cloth, "rest_shape_key", key, "key_blocks", 
text="Rest Shape Key")
 
 
+class PHYSICS_PT_cloth_remesh(PhysicButtonsPanel, Panel):
+bl_label = "Remesh"
+bl_parent_id = 'PHYSICS_PT_cloth_shape'
+COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
+
+def draw_header(self, context):
+cloth = context.cloth.settings
+
+self.layout.active = cloth_panel_enabled(context.cloth)
+self.layout.prop(cloth, "use_remesh", text="")
+
+def draw(self, context):
+layout = self.layout
+layout.use_property_split = True
+
+cloth = context.cloth.settings
+md = context.cloth
+ob = context.object
+
+layout.active = cloth.use_remesh and cloth_panel_enabled(md)
+
+flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, 
even_rows=False, align=True)
+
+
 class PHYSICS_PT_cloth_collision(PhysicButtonsPanel, Panel):
 bl_label = "Collisions"
 bl_parent_id = 'PHYSICS_PT_cloth'
@@ -475,6 +499,7 @@ classes = (
 PHYSICS_PT_cloth_pressure,
 PHYSICS_PT_cloth_cache,
 PHYSICS_PT_cloth_shape,
+PHYSICS_PT_cloth_remesh,
 PHYSICS_PT_cloth_collision,
 PHYSICS_PT_cloth_object_collision,
 PHYSICS_PT_cloth_self_collision,
diff --git a/source/blender/makesdna/DNA_cloth_types.h 
b/source/blender/makesdna/DNA_cloth_types.h
index aae29e5fddc..2d446f3d224 100644
--- a/source/blender/makesdna/DNA_cloth_types.h
+++ b/source/blender/makesdna/DNA_cloth_types.h
@@ -211,6 +211,8 @@ typedef enum {
   CLOTH_SIMSETTINGS_FLAG_SEW = (1 << 14),
   /** Make simulation respect deformations in the base object. */
   CLOTH_SIMSETTINGS_FLAG_DYNAMIC_BASEMESH = (1 << 15),
+  /** True if remeshing is enabled */
+  CLOTH_SIMSETTINGS_FLAG_REMESH = (1 << 16),
 } CLOTH_SIMSETTINGS_FLAGS;
 
 /* ClothSimSettings.bending_model. */
diff --git a/source/blender/makesrna/intern/rna_cloth.c 
b/source/blender/makesrna/intern/rna_cloth.c
index 9e57368f8f9..becbae6bd13 100644
--- a/source/blender/makesrna/intern/rna_cloth.c
+++ b/source/blender/makesrna/intern/rna_cloth.c
@@ -1053,6 +1053,13 @@ static void rna_def_cloth_sim_settings(BlenderRNA *brna)
   "that has zero weight will be excluded from the volume calculation");
   RNA_def_property_update(prop, 0, "rna_cloth_update");
 
+  prop = RNA_def_property(srna, "use_remesh", PROP_BOOLEAN, PROP_NONE);
+  RNA_def_property_boolean_sdna(prop, NULL, "flags", 
CLOTH_SIMSETTINGS_FLAG_REMESH);
+  RNA_def_property_ui_text(
+  prop, "Remesh", "Remesh the cloth's mesh based on user defined 
parameters");
+  RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+  RNA_def_property_update(prop, 0, "rna_cloth_update");
+
   /* unused */
 
   /* unused still */

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


[Bf-blender-cvs] [57c1f52d2ea] soc-2021-adaptive-cloth: adaptive_cloth: initial conversion of cloth modifier to `modifyMesh` from `deformVerts`

2021-06-14 Thread ishbosamiya
Commit: 57c1f52d2ea477c526bb5f5628c831dbc4181641
Author: ishbosamiya
Date:   Thu Jun 10 12:02:20 2021 +0530
Branches: soc-2021-adaptive-cloth
https://developer.blender.org/rB57c1f52d2ea477c526bb5f5628c831dbc4181641

adaptive_cloth: initial conversion of cloth modifier to `modifyMesh`
from `deformVerts`

Adaptive remeshing requires the mesh connectivity to change, so the
modifier should be of `eModifierTypeType_Nonconstructive` type and use
the `modifyMesh()` function instead of the `deformVerts()` function.

The next step is to make the `clothModifier_do()` function to take
advantage of the mesh given to it since now that mesh can be edited by
it and returned directly.

===

M   source/blender/modifiers/intern/MOD_cloth.c

===

diff --git a/source/blender/modifiers/intern/MOD_cloth.c 
b/source/blender/modifiers/intern/MOD_cloth.c
index 40d027f3044..3ad4bd209c7 100644
--- a/source/blender/modifiers/intern/MOD_cloth.c
+++ b/source/blender/modifiers/intern/MOD_cloth.c
@@ -89,13 +89,10 @@ static void initData(ModifierData *md)
   }
 }
 
-static void deformVerts(ModifierData *md,
-const ModifierEvalContext *ctx,
-Mesh *mesh,
-float (*vertexCos)[3],
-int numVerts)
+static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh 
*mesh)
 {
-  Mesh *mesh_src;
+  BLI_assert(mesh != NULL);
+
   ClothModifierData *clmd = (ClothModifierData *)md;
   Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph);
 
@@ -104,44 +101,43 @@ static void deformVerts(ModifierData *md,
 initData(md);
 
 if (!clmd->sim_parms || !clmd->coll_parms) {
-  return;
-}
-  }
-
-  if (mesh == NULL) {
-mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, NULL, NULL, 
numVerts, false, false);
-  }
-  else {
-/* Not possible to use get_mesh() in this case as we'll modify its vertices
- * and get_mesh() would return 'mesh' directly. */
-mesh_src = (Mesh *)BKE_id_copy_ex(NULL, (ID *)mesh, NULL, 
LIB_ID_COPY_LOCALIZE);
-  }
-
-  /* TODO(sergey): For now it actually duplicates logic from DerivedMesh.cc
-   * and needs some more generic solution. But starting experimenting with
-   * this so close to the release is not that nice..
-   *
-   * Also hopefully new cloth system will arrive soon..
-   */
-  if (mesh == NULL && clmd->sim_parms->shapekey_rest) {
-KeyBlock *kb = BKE_keyblock_from_key(BKE_key_from_object(ctx->object),
- clmd->sim_parms->shapekey_rest);
-if (kb && kb->data != NULL) {
-  float(*layerorco)[3];
-  if (!(layerorco = CustomData_get_layer(&mesh_src->vdata, 
CD_CLOTH_ORCO))) {
-layerorco = CustomData_add_layer(
-&mesh_src->vdata, CD_CLOTH_ORCO, CD_CALLOC, NULL, 
mesh_src->totvert);
-  }
-
-  memcpy(layerorco, kb->data, sizeof(float[3]) * numVerts);
+  return mesh;
 }
   }
 
-  BKE_mesh_vert_coords_apply(mesh_src, vertexCos);
-
-  clothModifier_do(clmd, ctx->depsgraph, scene, ctx->object, mesh_src, 
vertexCos);
-
-  BKE_id_free(NULL, mesh_src);
+  /* TODO(ish): Add back support for "Dynamic Mesh", there is
+   * something weird going on here, even with "Dynamic Mesh" on and the
+   * next part commented out, it just works. */
+  /* /\* TODO(sergey): For now it actually duplicates logic from 
DerivedMesh.cc */
+  /*  * and needs some more generic solution. But starting experimenting with 
*/
+  /*  * this so close to the release is not that nice.. */
+  /*  * */
+  /*  * Also hopefully new cloth system will arrive soon.. */
+  /*  *\/ */
+  /* if (mesh == NULL && clmd->sim_parms->shapekey_rest) { */
+  /*   KeyBlock *kb = BKE_keyblock_from_key(BKE_key_from_object(ctx->object), 
*/
+  /*clmd->sim_parms->shapekey_rest); */
+  /*   if (kb && kb->data != NULL) { */
+  /* float(*layerorco)[3]; */
+  /* if (!(layerorco = CustomData_get_layer(&mesh_src->vdata, 
CD_CLOTH_ORCO))) { */
+  /*   layerorco = CustomData_add_layer( */
+  /*   &mesh_src->vdata, CD_CLOTH_ORCO, CD_CALLOC, NULL, 
mesh_src->totvert); */
+  /* } */
+
+  /* memcpy(layerorco, kb->data, sizeof(float[3]) * numVerts); */
+  /*   } */
+  /* } */
+
+  Mesh *mesh_result = BKE_mesh_copy_for_eval(mesh, false);
+
+  float(*vert_coords)[3] = BKE_mesh_vert_coords_alloc(mesh_result, NULL);
+  BKE_mesh_vert_coords_get(mesh_result, vert_coords);
+
+  clothModifier_do(clmd, ctx->depsgraph, scene, ctx->object, mesh_result, 
vert_coords);
+
+  BKE_mesh_vert_coords_apply(mesh_result, vert_coords);
+
+  return mesh_result;
 }
 
 static void updateDepsgraph(ModifierData *md, const 
ModifierUpdateDepsgraphContext *ctx)
@@ -297,18 +293,18 @@ ModifierTypeInfo modifierType_Cloth = {
 /* structName */ "ClothModifierData",
 /* structSize */ sizeof(ClothModifierData)

[Bf-blender-cvs] [87ade2a279e] soc-2021-adaptive-cloth: adaptive_cloth: `do_step_cloth()` should update the input mesh

2021-06-14 Thread ishbosamiya
Commit: 87ade2a279e604850c423e39639427e759b7935b
Author: ishbosamiya
Date:   Fri Jun 11 13:22:52 2021 +0530
Branches: soc-2021-adaptive-cloth
https://developer.blender.org/rB87ade2a279e604850c423e39639427e759b7935b

adaptive_cloth: `do_step_cloth()` should update the input mesh

===

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

===

diff --git a/source/blender/blenkernel/intern/cloth.c 
b/source/blender/blenkernel/intern/cloth.c
index a63dbf5f467..99dcdd21d83 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -259,8 +259,12 @@ static bool do_init_cloth(Object *ob, ClothModifierData 
*clmd, Mesh *result, int
   return true;
 }
 
+/**
+ * Performs the next step in the cloth simulation
+ * @param r_mesh The `Mesh` that has the input mesh information and
+ * will be modified with the updated `Mesh` information */
 static int do_step_cloth(
-Depsgraph *depsgraph, Object *ob, ClothModifierData *clmd, Mesh *result, 
int framenr)
+Depsgraph *depsgraph, Object *ob, ClothModifierData *clmd, int framenr, 
Mesh *r_mesh)
 {
   ClothVertex *verts = NULL;
   Cloth *cloth;
@@ -272,7 +276,7 @@ static int do_step_cloth(
   /* simulate 1 frame forward */
   cloth = clmd->clothObject;
   verts = cloth->verts;
-  mvert = result->mvert;
+  mvert = r_mesh->mvert;
 
   /* force any pinned verts to their constrained location. */
   for (i = 0; i < clmd->clothObject->mvert_num; i++, verts++) {
@@ -288,15 +292,15 @@ static int do_step_cloth(
   effectors = BKE_effectors_create(depsgraph, ob, NULL, 
clmd->sim_parms->effector_weights, false);
 
   if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_DYNAMIC_BASEMESH) {
-cloth_update_verts(ob, clmd, result);
+cloth_update_verts(ob, clmd, r_mesh);
   }
 
   /* Support for dynamic vertex groups, changing from frame to frame */
-  cloth_apply_vgroup(clmd, result);
+  cloth_apply_vgroup(clmd, r_mesh);
 
   if ((clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_DYNAMIC_BASEMESH) ||
   (clmd->sim_parms->vgroup_shrink > 0) || (clmd->sim_parms->shrink_min != 
0.0f)) {
-cloth_update_spring_lengths(clmd, result);
+cloth_update_spring_lengths(clmd, r_mesh);
   }
 
   cloth_update_springs(clmd);
@@ -312,6 +316,8 @@ static int do_step_cloth(
 
   // printf ( "%f\n", ( float ) tval() );
 
+  cloth_to_object(ob, clmd, r_mesh);
+
   return ret;
 }
 
@@ -414,16 +420,15 @@ Mesh *clothModifier_do(
   /* do simulation */
   BKE_ptcache_validate(cache, framenr);
 
-  if (!do_step_cloth(depsgraph, ob, clmd, mesh, framenr)) {
+  Mesh *mesh_result = BKE_mesh_copy_for_eval(mesh, false);
+
+  if (!do_step_cloth(depsgraph, ob, clmd, framenr, mesh_result)) {
 BKE_ptcache_invalidate(cache);
   }
   else {
 BKE_ptcache_write(&pid, framenr);
   }
 
-  Mesh *mesh_result = BKE_mesh_copy_for_eval(mesh, false);
-
-  cloth_to_object(ob, clmd, mesh_result);
   clmd->clothObject->last_frame = framenr;
 
   return mesh_result;

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


[Bf-blender-cvs] [b84707df175] master: Python API: option for render engines to disable image file saving

2021-06-14 Thread Thomas Lachmann
Commit: b84707df17547e45e91f242b810bd2c66c6b1771
Author: Thomas Lachmann
Date:   Mon Jun 14 13:44:18 2021 +0200
Branches: master
https://developer.blender.org/rBb84707df17547e45e91f242b810bd2c66c6b1771

Python API: option for render engines to disable image file saving

For some custom rendering engines it's advantageous not to write the image 
files to disk.
An example would be a network rendering engine which does it's own image 
writing.

This feature is only supported when bl_use_postprocess is also disabled, since 
render
engines can't influence the saving behavior of the sequencer or compositor.

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

===

M   source/blender/makesrna/intern/rna_render.c
M   source/blender/render/RE_engine.h
M   source/blender/render/intern/pipeline.c

===

diff --git a/source/blender/makesrna/intern/rna_render.c 
b/source/blender/makesrna/intern/rna_render.c
index dd91a5509f5..6715941ae2a 100644
--- a/source/blender/makesrna/intern/rna_render.c
+++ b/source/blender/makesrna/intern/rna_render.c
@@ -856,6 +856,15 @@ static void rna_def_render_engine(BlenderRNA *brna)
   "Use Custom Freestyle",
   "Handles freestyle rendering on its own, instead of delegating it to 
EEVEE");
 
+  prop = RNA_def_property(srna, "bl_use_image_save", PROP_BOOLEAN, PROP_NONE);
+  RNA_def_property_boolean_negative_sdna(prop, NULL, "type->flag", 
RE_USE_NO_IMAGE_SAVE);
+  RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
+  RNA_def_property_ui_text(
+  prop,
+  "Use Image Save",
+  "Save images/movie to disk while rendering an animation. "
+  "Disabling image saving is only supported when bl_use_postprocess is 
also disabled");
+
   prop = RNA_def_property(srna, "bl_use_gpu_context", PROP_BOOLEAN, PROP_NONE);
   RNA_def_property_boolean_sdna(prop, NULL, "type->flag", RE_USE_GPU_CONTEXT);
   RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
diff --git a/source/blender/render/RE_engine.h 
b/source/blender/render/RE_engine.h
index 7352ac7b12e..6b2861bbefd 100644
--- a/source/blender/render/RE_engine.h
+++ b/source/blender/render/RE_engine.h
@@ -65,6 +65,7 @@ extern "C" {
 #define RE_USE_STEREO_VIEWPORT 256
 #define RE_USE_GPU_CONTEXT 512
 #define RE_USE_CUSTOM_FREESTYLE 1024
+#define RE_USE_NO_IMAGE_SAVE 2048
 
 /* RenderEngine.flag */
 #define RE_ENGINE_ANIMATION 1
diff --git a/source/blender/render/intern/pipeline.c 
b/source/blender/render/intern/pipeline.c
index a39214b609d..20f868ca86f 100644
--- a/source/blender/render/intern/pipeline.c
+++ b/source/blender/render/intern/pipeline.c
@@ -2215,35 +2215,42 @@ static int do_write_image_or_movie(Render *re,
   RenderResult rres;
   double render_time;
   bool ok = true;
+  RenderEngineType *re_type = RE_engines_find(re->r.engine);
 
-  RE_AcquireResultImageViews(re, &rres);
+  /* Only disable file writing if postprocessing is also disabled. */
+  const bool do_write_file = !(re_type->flag & RE_USE_NO_IMAGE_SAVE) ||
+ (re_type->flag & RE_USE_POSTPROCESS);
 
-  /* write movie or image */
-  if (BKE_imtype_is_movie(scene->r.im_format.imtype)) {
-RE_WriteRenderViewsMovie(
-re->reports, &rres, scene, &re->r, mh, re->movie_ctx_arr, totvideos, 
false);
-  }
-  else {
-if (name_override) {
-  BLI_strncpy(name, name_override, sizeof(name));
+  if (do_write_file) {
+RE_AcquireResultImageViews(re, &rres);
+
+/* write movie or image */
+if (BKE_imtype_is_movie(scene->r.im_format.imtype)) {
+  RE_WriteRenderViewsMovie(
+  re->reports, &rres, scene, &re->r, mh, re->movie_ctx_arr, totvideos, 
false);
 }
 else {
-  BKE_image_path_from_imformat(name,
-   scene->r.pic,
-   BKE_main_blendfile_path(bmain),
-   scene->r.cfra,
-   &scene->r.im_format,
-   (scene->r.scemode & R_EXTENSION) != 0,
-   true,
-   NULL);
+  if (name_override) {
+BLI_strncpy(name, name_override, sizeof(name));
+  }
+  else {
+BKE_image_path_from_imformat(name,
+ scene->r.pic,
+ BKE_main_blendfile_path(bmain),
+ scene->r.cfra,
+ &scene->r.im_format,
+ (scene->r.scemode & R_EXTENSION) != 0,
+ true,
+ NULL);
+  }
+
+  /* write images as individual images or stereo */
+  ok = RE_WriteRenderViewsImage(re->reports, &rres, scene, true, name);
 }
 
-/* write images as individual images or stereo */
-ok = RE_WriteRenderViewsImage

[Bf-blender-cvs] [ada47c47728] master: Fix build error in release builds after recent changes

2021-06-14 Thread Brecht Van Lommel
Commit: ada47c47728316fb0e25830c642626aeda0693f4
Author: Brecht Van Lommel
Date:   Mon Jun 14 13:22:11 2021 +0200
Branches: master
https://developer.blender.org/rBada47c47728316fb0e25830c642626aeda0693f4

Fix build error in release builds after recent changes

===

M   source/blender/blenlib/BLI_math_base.h

===

diff --git a/source/blender/blenlib/BLI_math_base.h 
b/source/blender/blenlib/BLI_math_base.h
index 5a3482db046..88dc20a64f2 100644
--- a/source/blender/blenlib/BLI_math_base.h
+++ b/source/blender/blenlib/BLI_math_base.h
@@ -296,6 +296,7 @@ float ceil_power_of_10(float f);
 #else
 #  define BLI_ASSERT_UNIT_V2(v) (void)(v)
 #  define BLI_ASSERT_UNIT_V3(v) (void)(v)
+#  define BLI_ASSERT_UNIT_V3_DB(v) (void)(v)
 #  define BLI_ASSERT_UNIT_QUAT(v) (void)(v)
 #  define BLI_ASSERT_ZERO_M3(m) (void)(m)
 #  define BLI_ASSERT_ZERO_M4(m) (void)(m)

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


[Bf-blender-cvs] [244fab58760] soc-2021-simulation-display: Physics: Added visualisation for rigid bodies' velocities.

2021-06-14 Thread soumya pochiraju
Commit: 244fab587605c73284de084c7b0c4ec345bbe4a5
Author: soumya pochiraju
Date:   Mon Jun 14 15:55:59 2021 +0530
Branches: soc-2021-simulation-display
https://developer.blender.org/rB244fab587605c73284de084c7b0c4ec345bbe4a5

Physics: Added visualisation for rigid bodies' velocities.

===

M   source/blender/blenkernel/intern/effect.c
M   source/blender/blenkernel/intern/pointcache.c
M   source/blender/blenkernel/intern/rigidbody.c
M   source/blender/draw/CMakeLists.txt
M   source/blender/draw/engines/overlay/overlay_extra.c
M   source/blender/makesdna/DNA_rigidbody_types.h

===

diff --git a/source/blender/blenkernel/intern/effect.c 
b/source/blender/blenkernel/intern/effect.c
index 23b978c3b92..c8bca48ec68 100644
--- a/source/blender/blenkernel/intern/effect.c
+++ b/source/blender/blenkernel/intern/effect.c
@@ -1215,7 +1215,12 @@ void BKE_effectors_apply(ListBase *effectors,
 }
 
 if(eff_forces!=NULL){
-copy_v3_v3(eff_forces[num_eff_forces],force);
+if(eff->flag & PE_VELOCITY_TO_IMPULSE && impulse){
+  copy_v3_v3(eff_forces[num_eff_forces],impulse);
+}
+else{
+  copy_v3_v3(eff_forces[num_eff_forces],force);
+}
 }
   }
 }
diff --git a/source/blender/blenkernel/intern/pointcache.c 
b/source/blender/blenkernel/intern/pointcache.c
index 8ba6958f08f..6093bebddf3 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -781,9 +781,11 @@ static int ptcache_rigidbody_write(int index, void *rb_v, 
void **data, int UNUSE
 #ifdef WITH_BULLET
   RB_body_get_position(rbo->shared->physics_object, rbo->pos);
   RB_body_get_orientation(rbo->shared->physics_object, rbo->orn);
+  RB_body_get_linear_velocity(rbo->shared->physics_object, rbo->vel);
 #endif
   PTCACHE_DATA_FROM(data, BPHYS_DATA_LOCATION, rbo->pos);
   PTCACHE_DATA_FROM(data, BPHYS_DATA_ROTATION, rbo->orn);
+  PTCACHE_DATA_FROM(data, BPHYS_DATA_VELOCITY, rbo->vel);
   PTCACHE_DATA_FROM(data, BPHYS_DATA_EFF_FORCES, rbo->eff_forces);
   PTCACHE_DATA_FROM(data, BPHYS_DATA_NORM_FORCES, rbo->norm_forces);
   PTCACHE_DATA_FROM(data, BPHYS_DATA_FRIC_FORCES, rbo->fric_forces);
@@ -815,6 +817,7 @@ static void ptcache_rigidbody_read(
   else {
 PTCACHE_DATA_TO(data, BPHYS_DATA_LOCATION, 0, rbo->pos);
 PTCACHE_DATA_TO(data, BPHYS_DATA_ROTATION, 0, rbo->orn);
+PTCACHE_DATA_TO(data, BPHYS_DATA_VELOCITY, 0, rbo->vel);
 PTCACHE_DATA_TO(data, BPHYS_DATA_EFF_FORCES, 0 ,rbo->eff_forces);
 PTCACHE_DATA_TO(data, BPHYS_DATA_NORM_FORCES, 0 ,rbo->norm_forces);
 PTCACHE_DATA_TO(data, BPHYS_DATA_FRIC_FORCES, 0 ,rbo->fric_forces);
@@ -1106,7 +1109,7 @@ void BKE_ptcache_id_from_rigidbody(PTCacheID *pid, Object 
*ob, RigidBodyWorld *r
   pid->write_header = ptcache_basic_header_write;
   pid->read_header = ptcache_basic_header_read;
 
-  pid->data_types = (1 << BPHYS_DATA_LOCATION) | (1 << BPHYS_DATA_ROTATION) | 
(1 << BPHYS_DATA_EFF_FORCES) |  (1 << BPHYS_DATA_NORM_FORCES) | (1 << 
BPHYS_DATA_FRIC_FORCES) | (1 << BPHYS_DATA_VEC_LOCATIONS);
+  pid->data_types = (1 << BPHYS_DATA_LOCATION) | (1 << BPHYS_DATA_ROTATION) | 
(1 << BPHYS_DATA_VELOCITY) | (1 << BPHYS_DATA_EFF_FORCES) |  (1 << 
BPHYS_DATA_NORM_FORCES) | (1 << BPHYS_DATA_FRIC_FORCES) | (1 << 
BPHYS_DATA_VEC_LOCATIONS);
   pid->info_types = 0;
 
   pid->stack_index = pid->cache->index;
diff --git a/source/blender/blenkernel/intern/rigidbody.c 
b/source/blender/blenkernel/intern/rigidbody.c
index 634df6aee35..2b02127265d 100644
--- a/source/blender/blenkernel/intern/rigidbody.c
+++ b/source/blender/blenkernel/intern/rigidbody.c
@@ -1299,6 +1299,8 @@ RigidBodyOb *BKE_rigidbody_create_object(Scene *scene, 
Object *ob, short type)
   zero_v3(rbo->vec_locations[1].vector);
   zero_v3(rbo->vec_locations[2].vector);
 
+  zero_v3(rbo->vel);
+
   /* use triangle meshes for passive objects
* use convex hulls for active objects since dynamic triangle meshes are 
very unstable
*/
@@ -1755,7 +1757,7 @@ static void rigidbody_update_sim_ob(
*   which we don't have... */
   float eff_forces[3][3] = {{0.0}};
   BKE_effectors_apply(effectors, NULL, effector_weights, &epoint, 
eff_force, NULL, NULL,eff_forces);
-  if(rbo->display_force_types & RB_SIM_EFFECTORS) {
+  if(rbo->sim_display_options & RB_SIM_FORCES) {
 for(int i=0; i<3; i++){
 copy_v3_v3(rbo->eff_forces[i].vector, eff_forces[i]);
 }
diff --git a/source/blender/draw/CMakeLists.txt 
b/source/blender/draw/CMakeLists.txt
index 06f650eb8f0..388613dfb80 100644
--- a/source/blender/draw/CMakeLists.txt
+++ b/source/blender/draw/CMakeLists.txt
@@ -483,6 +483,13 @@ if(WITH_GTESTS)
   endif()
 endif()
 
+if(WITH_BULLET)
+  list(APPEND I

[Bf-blender-cvs] [63c8bf807d9] soc-2021-simulation-display: Pysics: Added visualisation for forces due to effectors, normal forces and gravity.

2021-06-14 Thread soumya pochiraju
Commit: 63c8bf807d92f4d5f805f418a5b2999a618245d8
Author: soumya pochiraju
Date:   Thu Jun 10 21:43:09 2021 +0530
Branches: soc-2021-simulation-display
https://developer.blender.org/rB63c8bf807d92f4d5f805f418a5b2999a618245d8

Pysics: Added visualisation for forces due to effectors, normal forces and 
gravity.

===

M   intern/rigidbody/RBI_api.h
M   intern/rigidbody/rb_bullet_api.cpp
M   release/scripts/startup/bl_ui/properties_physics_rigidbody.py
M   source/blender/blenkernel/BKE_effect.h
M   source/blender/blenkernel/BKE_pointcache.h
M   source/blender/blenkernel/intern/boids.c
M   source/blender/blenkernel/intern/dynamicpaint.c
M   source/blender/blenkernel/intern/effect.c
M   source/blender/blenkernel/intern/fluid.c
M   source/blender/blenkernel/intern/particle.c
M   source/blender/blenkernel/intern/particle_system.c
M   source/blender/blenkernel/intern/pointcache.c
M   source/blender/blenkernel/intern/rigidbody.c
M   source/blender/blenkernel/intern/softbody.c
M   source/blender/draw/engines/overlay/overlay_extra.c
M   source/blender/draw/engines/overlay/shaders/vector_vert.glsl
M   source/blender/makesdna/DNA_pointcache_types.h
M   source/blender/makesdna/DNA_rigidbody_types.h
M   source/blender/makesrna/intern/rna_rigidbody.c
M   source/blender/simulation/intern/SIM_mass_spring.cpp

===

diff --git a/intern/rigidbody/RBI_api.h b/intern/rigidbody/RBI_api.h
index 2e09f8952cb..81c7c442706 100644
--- a/intern/rigidbody/RBI_api.h
+++ b/intern/rigidbody/RBI_api.h
@@ -22,6 +22,7 @@
  * \brief Rigid Body API for interfacing with external Physics Engines
  */
 
+
 #ifndef __RB_API_H__
 #define __RB_API_H__
 
@@ -81,6 +82,13 @@ void RB_dworld_set_solver_iterations(rbDynamicsWorld *world, 
int num_solver_iter
 /* Split Impulse */
 void RB_dworld_set_split_impulse(rbDynamicsWorld *world, int split_impulse);
 
+/* Get latest applied impulse */
+void RB_dworld_get_impulse(rbDynamicsWorld *world,
+   rbRigidBody *rbo,
+   float timeSubStep,
+   float norm_forces[3][3],
+   float vec_locations[3][3]);
+
 /* Simulation --- */
 
 /* Step the simulation by the desired amount (in seconds) with extra controls 
on substep sizes and
diff --git a/intern/rigidbody/rb_bullet_api.cpp 
b/intern/rigidbody/rb_bullet_api.cpp
index d932a9ca951..639c4a13c79 100644
--- a/intern/rigidbody/rb_bullet_api.cpp
+++ b/intern/rigidbody/rb_bullet_api.cpp
@@ -204,6 +204,65 @@ void RB_dworld_set_split_impulse(rbDynamicsWorld *world, 
int split_impulse)
   info.m_splitImpulse = split_impulse;
 }
 
+/* Get last applied impulse at contact points */
+/* TODO: this may not be the most efficient way to do it. get all forces at 
once and store in a lookup table. */
+void RB_dworld_get_impulse(rbDynamicsWorld *world,
+   rbRigidBody *rbo,
+   float timeSubStep,
+   float norm_forces[3][3],
+   float vec_locations[3][3])
+{
+int numManifolds = world->dispatcher->getNumManifolds();
+int num_forces = 0;
+for (int i = 0; i < numManifolds; i++)
+{
+btPersistentManifold* contactManifold =  
world->dispatcher->getManifoldByIndexInternal(i);
+const void *obA = contactManifold->getBody0();
+const void *obB = contactManifold->getBody1();
+if(num_forces>2)
+  break;
+if(obA != rbo->body && obB != rbo->body)
+{
+  printf("%p,%p,\n",rbo,obA);
+  continue;
+}
+else
+{
+  btVector3 tot_impulse = btVector3(0.0,0.0,0.0);
+  btVector3 final_loc =  btVector3(0.0,0.0,0.0);
+  int numContacts = contactManifold->getNumContacts();
+  int num_impulse_points = 0;
+  for (int j = 0; j < numContacts; j++)
+  {
+  /* Find points where impulse was appplied. */
+  btManifoldPoint& pt = contactManifold->getContactPoint(j);
+  if (pt.getAppliedImpulse() > 0.f)
+num_impulse_points++;
+  }
+
+  for (int j = 0; j < numContacts; j++)
+  {
+btManifoldPoint& pt = contactManifold->getContactPoint(j);
+if (pt.getAppliedImpulse() > 0.f)
+{
+   const btVector3& loc = pt.getPositionWorldOnB();
+   const btVector3 lat_imp1 = pt.m_appliedImpulseLateral1 * 
pt.m_lateralFrictionDir1;
+   const btVector3 lat_imp2 = pt.m_appliedImpulseLateral2 * 
pt.m_lateralFrictionDir2;
+   printf("%f,%f,%f 
%f,%f,%f\n",lat_imp1.getX(),lat_imp1.getY(),lat_imp1.getZ(),lat_imp2.getX(), 
lat_imp2.getY(),lat_imp2.getZ());
+   const btVector3 imp = (rbo->body == obB)? -pt.m_nor

[Bf-blender-cvs] [337eb4306cb] soc-2021-simulation-display: Physics: Added visualisation for frictional forces, plus some clean-ups to previous commit

2021-06-14 Thread soumya pochiraju
Commit: 337eb4306cb24b066e86dd70f0d6e25672dbaada
Author: soumya pochiraju
Date:   Sat Jun 12 17:24:17 2021 +0530
Branches: soc-2021-simulation-display
https://developer.blender.org/rB337eb4306cb24b066e86dd70f0d6e25672dbaada

Physics: Added visualisation for frictional forces, plus some clean-ups to 
previous commit

===

M   intern/rigidbody/RBI_api.h
M   intern/rigidbody/rb_bullet_api.cpp
M   source/blender/blenkernel/BKE_pointcache.h
M   source/blender/blenkernel/intern/pointcache.c
M   source/blender/blenkernel/intern/rigidbody.c
M   source/blender/draw/engines/overlay/overlay_extra.c
M   source/blender/makesdna/DNA_pointcache_types.h
M   source/blender/makesdna/DNA_rigidbody_types.h

===

diff --git a/intern/rigidbody/RBI_api.h b/intern/rigidbody/RBI_api.h
index 81c7c442706..cde25ec8991 100644
--- a/intern/rigidbody/RBI_api.h
+++ b/intern/rigidbody/RBI_api.h
@@ -87,7 +87,10 @@ void RB_dworld_get_impulse(rbDynamicsWorld *world,
rbRigidBody *rbo,
float timeSubStep,
float norm_forces[3][3],
-   float vec_locations[3][3]);
+   float fric_forces[3][3],
+   float vec_locations[3][3],
+   int norm_flag,
+   int fric_flag);
 
 /* Simulation --- */
 
diff --git a/intern/rigidbody/rb_bullet_api.cpp 
b/intern/rigidbody/rb_bullet_api.cpp
index 639c4a13c79..20e104b4b49 100644
--- a/intern/rigidbody/rb_bullet_api.cpp
+++ b/intern/rigidbody/rb_bullet_api.cpp
@@ -210,26 +210,31 @@ void RB_dworld_get_impulse(rbDynamicsWorld *world,
rbRigidBody *rbo,
float timeSubStep,
float norm_forces[3][3],
-   float vec_locations[3][3])
+   float fric_forces[3][3],
+   float vec_locations[3][3],
+   int norm_flag,
+   int fric_flag)
 {
 int numManifolds = world->dispatcher->getNumManifolds();
-int num_forces = 0;
+int num_norm_forces = 0;
+int num_fric_forces = 0;
 for (int i = 0; i < numManifolds; i++)
 {
 btPersistentManifold* contactManifold =  
world->dispatcher->getManifoldByIndexInternal(i);
 const void *obA = contactManifold->getBody0();
 const void *obB = contactManifold->getBody1();
-if(num_forces>2)
+if(num_norm_forces>2)
   break;
 if(obA != rbo->body && obB != rbo->body)
 {
-  printf("%p,%p,\n",rbo,obA);
   continue;
 }
 else
 {
   btVector3 tot_impulse = btVector3(0.0,0.0,0.0);
   btVector3 final_loc =  btVector3(0.0,0.0,0.0);
+  btScalar tot_impulse_magnitude=0.f;
+  btVector3 tot_lat_impulse = btVector3(0.0,0.0,0.0);
   int numContacts = contactManifold->getNumContacts();
   int num_impulse_points = 0;
   for (int j = 0; j < numContacts; j++)
@@ -245,19 +250,33 @@ void RB_dworld_get_impulse(rbDynamicsWorld *world,
 btManifoldPoint& pt = contactManifold->getContactPoint(j);
 if (pt.getAppliedImpulse() > 0.f)
 {
-   const btVector3& loc = pt.getPositionWorldOnB();
-   const btVector3 lat_imp1 = pt.m_appliedImpulseLateral1 * 
pt.m_lateralFrictionDir1;
-   const btVector3 lat_imp2 = pt.m_appliedImpulseLateral2 * 
pt.m_lateralFrictionDir2;
-   printf("%f,%f,%f 
%f,%f,%f\n",lat_imp1.getX(),lat_imp1.getY(),lat_imp1.getZ(),lat_imp2.getX(), 
lat_imp2.getY(),lat_imp2.getZ());
-   const btVector3 imp = (rbo->body == obB)? -pt.m_normalWorldOnB 
* pt.getAppliedImpulse()/timeSubStep:pt.m_normalWorldOnB * 
pt.getAppliedImpulse()/timeSubStep;
-
-   tot_impulse += imp;
-   final_loc += num_impulse_points>1 ? loc * 
pt.getAppliedImpulse() / numContacts : loc;
+ const btVector3& loc = pt.getPositionWorldOnB();
+ const btVector3 imp = (rbo->body == obB)? 
-pt.m_normalWorldOnB * pt.getAppliedImpulse()/timeSubStep:pt.m_normalWorldOnB * 
pt.getAppliedImpulse()/timeSubStep;
+ tot_impulse_magnitude += pt.getAppliedImpulse();
+ tot_impulse += imp;
+ final_loc += num_impulse_points>1 ? loc * 
pt.getAppliedImpulse() : loc;
+   if (fric_flag)
+   {
+   const btVector3 lat_imp1 = (rbo->body == obB)? 
-pt.m_appliedImpulseLateral1 * pt.m_lateralFrictionDir1/timeSubStep : 
pt.m_appliedImpulseLateral1 * pt.m_lateralFrictionDir1/timeSubStep;
+   const btVector3 lat_imp2 = (rbo->body == obB)? 
-pt.m_appliedImpulseLateral2 * pt.m_lateralFrict

[Bf-blender-cvs] [5f5b1e51a4b] soc-2021-simulation-display: learnt basic arrow, ui panels

2021-06-14 Thread soumya pochiraju
Commit: 5f5b1e51a4bb6811ffd0c2df2fd94612877872d2
Author: soumya pochiraju
Date:   Sat Jun 5 18:54:10 2021 +0530
Branches: soc-2021-simulation-display
https://developer.blender.org/rB5f5b1e51a4bb6811ffd0c2df2fd94612877872d2

learnt basic arrow, ui panels

===

M   intern/rigidbody/rb_bullet_api.cpp
M   release/scripts/startup/bl_ui/properties_physics_rigidbody.py
M   source/blender/blenkernel/intern/rigidbody.c
M   source/blender/draw/CMakeLists.txt
M   source/blender/draw/engines/overlay/overlay_extra.c
M   source/blender/draw/engines/overlay/overlay_private.h
M   source/blender/draw/engines/overlay/overlay_shader.c
A   source/blender/draw/engines/overlay/shaders/vector_vert.glsl
M   source/blender/makesdna/DNA_rigidbody_types.h
M   source/blender/makesrna/intern/rna_rigidbody.c

===

diff --git a/intern/rigidbody/rb_bullet_api.cpp 
b/intern/rigidbody/rb_bullet_api.cpp
index daa377a7b55..d932a9ca951 100644
--- a/intern/rigidbody/rb_bullet_api.cpp
+++ b/intern/rigidbody/rb_bullet_api.cpp
@@ -212,6 +212,31 @@ void RB_dworld_step_simulation(rbDynamicsWorld *world,
float timeSubStep)
 {
   world->dynamicsWorld->stepSimulation(timeStep, maxSubSteps, timeSubStep);
+
+  int numManifolds = world->dispatcher->getNumManifolds();
+  for (int i = 0; i < numManifolds; i++)
+  {
+  printf("manifold:%d\n",i);
+  btPersistentManifold* contactManifold =  
world->dispatcher->getManifoldByIndexInternal(i);
+  const btCollisionObject* obA = contactManifold->getBody0();
+  const btCollisionObject* obB = contactManifold->getBody1();
+
+  int numContacts = contactManifold->getNumContacts();
+  for (int j = 0; j < numContacts; j++)
+  {
+  btManifoldPoint& pt = contactManifold->getContactPoint(j);
+  if (pt.getAppliedImpulse() > 0.f)
+  {
+  const btVector3& ptA = pt.getPositionWorldOnA();
+  const btVector3& ptB = pt.getPositionWorldOnB();
+  const btScalar imp = pt.getAppliedImpulse() ;
+  if((imp/timeStep)>=9.82) printf("impulse on 
point%d:%f\n",j,imp);
+  printf("impulse on point%d:%f \nloc: %f %f 
%f\ndist:%f\n",j,imp,ptA.getX(),ptA.getY(),ptA.getZ(),pt.getDistance());
+  printf("force on point%d:%f\n",j,imp/timeSubStep);
+
+  }
+  }
+  }
 }
 
 /* Export -- */
diff --git a/release/scripts/startup/bl_ui/properties_physics_rigidbody.py 
b/release/scripts/startup/bl_ui/properties_physics_rigidbody.py
index a55bd89ca18..75b584617c3 100644
--- a/release/scripts/startup/bl_ui/properties_physics_rigidbody.py
+++ b/release/scripts/startup/bl_ui/properties_physics_rigidbody.py
@@ -295,6 +295,36 @@ class 
PHYSICS_PT_rigid_body_dynamics_deactivation(PHYSICS_PT_rigidbody_panel, Pa
 # TODO: other params such as time?
 
 
+class PHYSICS_PT_rigid_body_display_options(PHYSICS_PT_rigidbody_panel, Panel):
+bl_label = "Display Options"
+bl_parent_id = 'PHYSICS_PT_rigid_body'
+bl_options = {'DEFAULT_CLOSED'}
+COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
+
+@classmethod
+def poll(cls, context):
+obj = context.object
+if obj.parent is not None and obj.parent.rigid_body is not None:
+return False
+return (obj and obj.rigid_body and (context.engine in 
cls.COMPAT_ENGINES))
+
+def draw(self, context):
+layout = self.layout
+layout.use_property_split = True
+
+ob = context.object
+rbo = ob.rigid_body
+
+if rbo is None:
+rigid_body_warning(layout, "Object does not have a Rigid Body")
+return
+
+col = layout.column()
+col.prop(rbo, "display_forces")
+col.prop(rbo, "display_acceleration")
+col.prop(rbo, "display_velocity")
+
+
 classes = (
 PHYSICS_PT_rigid_body,
 PHYSICS_PT_rigid_body_settings,
@@ -304,10 +334,12 @@ classes = (
 PHYSICS_PT_rigid_body_collisions_collections,
 PHYSICS_PT_rigid_body_dynamics,
 PHYSICS_PT_rigid_body_dynamics_deactivation,
+PHYSICS_PT_rigid_body_display_options,
 )
 
 
 if __name__ == "__main__":  # only for live edit.
-from bpy.utils import register_class
+from bpy.utils import register_class, unregister_class
 for cls in classes:
 register_class(cls)
+
diff --git a/source/blender/blenkernel/intern/rigidbody.c 
b/source/blender/blenkernel/intern/rigidbody.c
index 21b86aa8148..eb0ec2a9d58 100644
--- a/source/blender/blenkernel/intern/rigidbody.c
+++ b/source/blender/blenkernel/intern/rigidbody.c
@@ -1746,6 +1746,11 @@ static void rigidbody_update_sim_ob(
eff_force[2],
ob->id.name + 2);
   }
+  printf("\tapplying force (%f,%f,%f) to '%s'\n",
+ eff_force[0],
+ eff_

[Bf-blender-cvs] [93f6db102d8] soc-2021-simulation-display: Merge branch 'master' of https://git.blender.org/blender

2021-06-14 Thread soumya pochiraju
Commit: 93f6db102d8d0d5b75691a33e28da9623974f257
Author: soumya pochiraju
Date:   Mon Jun 14 15:59:15 2021 +0530
Branches: soc-2021-simulation-display
https://developer.blender.org/rB93f6db102d8d0d5b75691a33e28da9623974f257

Merge branch 'master' of https://git.blender.org/blender

===



===



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


[Bf-blender-cvs] [fbd14c1c750] soc-2021-simulation-display: Merge branch 'master' of https://git.blender.org/blender

2021-06-14 Thread soumya pochiraju
Commit: fbd14c1c750e6bd2ce762efe79b7c7c55e5acf8e
Author: soumya pochiraju
Date:   Fri May 21 12:12:28 2021 +0530
Branches: soc-2021-simulation-display
https://developer.blender.org/rBfbd14c1c750e6bd2ce762efe79b7c7c55e5acf8e

Merge branch 'master' of https://git.blender.org/blender

===



===



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


[Bf-blender-cvs] [b826df8aa14] soc-2021-simulation-display: make format

2021-06-14 Thread soumya pochiraju
Commit: b826df8aa14d4019f7a85c1eb9b2631e4aef3541
Author: soumya pochiraju
Date:   Tue Apr 27 12:44:53 2021 +0530
Branches: soc-2021-simulation-display
https://developer.blender.org/rBb826df8aa14d4019f7a85c1eb9b2631e4aef3541

make format

===

M   intern/libmv/third_party/msinttypes/inttypes.h
M   intern/libmv/third_party/msinttypes/stdint.h

===

diff --git a/intern/libmv/third_party/msinttypes/inttypes.h 
b/intern/libmv/third_party/msinttypes/inttypes.h
index 0e8af69cb07..bfb6a76bd73 100644
--- a/intern/libmv/third_party/msinttypes/inttypes.h
+++ b/intern/libmv/third_party/msinttypes/inttypes.h
@@ -1,305 +1,304 @@
 // ISO C9x  compliant inttypes.h for Microsoft Visual Studio
-// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 
-// 
+// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
+//
 //  Copyright (c) 2006 Alexander Chemeris
-// 
+//
 // Redistribution and use in source and binary forms, with or without
 // modification, are permitted provided that the following conditions are met:
-// 
+//
 //   1. Redistributions of source code must retain the above copyright notice,
 //  this list of conditions and the following disclaimer.
-// 
+//
 //   2. Redistributions in binary form must reproduce the above copyright
 //  notice, this list of conditions and the following disclaimer in the
 //  documentation and/or other materials provided with the distribution.
-// 
+//
 //   3. The name of the author may be used to endorse or promote products
 //  derived from this software without specific prior written permission.
-// 
+//
 // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
 // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
 // EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-// 
+//
 ///
 
-#ifndef _MSC_VER // [
-#error "Use this header only with Microsoft Visual C++ compilers!"
-#endif // _MSC_VER ]
+#ifndef _MSC_VER  // [
+#  error "Use this header only with Microsoft Visual C++ compilers!"
+#endif  // _MSC_VER ]
 
-#ifndef _MSC_INTTYPES_H_ // [
-#define _MSC_INTTYPES_H_
+#ifndef _MSC_INTTYPES_H_  // [
+#  define _MSC_INTTYPES_H_
 
-#if _MSC_VER > 1000
-#pragma once
-#endif
+#  if _MSC_VER > 1000
+#pragma once
+#  endif
 
-#include 
+#  include 
 
 // 7.8 Format conversion of integer types
 
 typedef struct {
-   intmax_t quot;
-   intmax_t rem;
+  intmax_t quot;
+  intmax_t rem;
 } imaxdiv_t;
 
 // 7.8.1 Macros for format specifiers
 
-#if !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS) // [   See footnote 
185 at page 198
+#  if !defined(__cplusplus) || 
\
+  defined(__STDC_FORMAT_MACROS)  // [   See footnote 185 at page 198
 
 // The fprintf macros for signed integers are:
-#define PRId8   "d"
-#define PRIi8   "i"
-#define PRIdLEAST8  "d"
-#define PRIiLEAST8  "i"
-#define PRIdFAST8   "d"
-#define PRIiFAST8   "i"
-
-#define PRId16   "hd"
-#define PRIi16   "hi"
-#define PRIdLEAST16  "hd"
-#define PRIiLEAST16  "hi"
-#define PRIdFAST16   "hd"
-#define PRIiFAST16   "hi"
-
-#define PRId32   "I32d"
-#define PRIi32   "I32i"
-#define PRIdLEAST32  "I32d"
-#define PRIiLEAST32  "I32i"
-#define PRIdFAST32   "I32d"
-#define PRIiFAST32   "I32i"
-
-#define PRId64   "I64d"
-#define PRIi64   "I64i"
-#define PRIdLEAST64  "I64d"
-#define PRIiLEAST64  "I64i"
-#define PRIdFAST64   "I64d"
-#define PRIiFAST64   "I64i"
-
-#define PRIdMAX "I64d"
-#define PRIiMAX "I64i"
-
-#define PRIdPTR "Id"
-#define PRIiPTR "Ii"
+#define PRId8 "d"
+#define PRIi8 "i"
+#define PRIdLEAST8 "d"
+#define PRIiLEAST8 "i"
+#define PRIdFAST8 "d"
+#define PRIiFAST8 "i"
+
+#define PRId16 "hd"
+#define PRIi16 "hi"
+#define PRIdLEAST16 "hd"
+#define PRIiLEAST16 "hi"
+#define PRIdFAST16 "hd"
+#define PRIiFAST16 "hi"
+
+#define PRId32 "I32d"
+#define PRIi32 "I32i"
+#define PRIdLEAST32 "I32d"
+#define PRIiLEAST32 "I32i"
+#define PRIdFAST32 "I32d"
+#define PRIiFAST32 "I32i"
+
+#define PRId64 "I64d"
+#define PRIi64 "I64i"
+#define PRIdLEAST64 "I64d"
+# 

[Bf-blender-cvs] [cfe1f39b5f3] soc-2021-simulation-display: Merge branch 'master' of https://git.blender.org/blender

2021-06-14 Thread soumya pochiraju
Commit: cfe1f39b5f3f591b40fba51c9b5880307fd4c045
Author: soumya pochiraju
Date:   Wed Apr 28 16:20:52 2021 +0530
Branches: soc-2021-simulation-display
https://developer.blender.org/rBcfe1f39b5f3f591b40fba51c9b5880307fd4c045

Merge branch 'master' of https://git.blender.org/blender

===



===



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


[Bf-blender-cvs] [9545f3ec674] soc-2021-simulation-display: Merge branch 'master' of https://git.blender.org/blender

2021-06-14 Thread soumya pochiraju
Commit: 9545f3ec6740dbf918910be8b666891a59727a3f
Author: soumya pochiraju
Date:   Wed Apr 28 18:26:14 2021 +0530
Branches: soc-2021-simulation-display
https://developer.blender.org/rB9545f3ec6740dbf918910be8b666891a59727a3f

Merge branch 'master' of https://git.blender.org/blender

===



===



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


[Bf-blender-cvs] [4bc0ec4dda2] soc-2021-simulation-display: Merge branch 'master' of https://git.blender.org/blender

2021-06-14 Thread soumya pochiraju
Commit: 4bc0ec4dda2a74edcc57e6ba29c2240bb40659c3
Author: soumya pochiraju
Date:   Tue Apr 27 13:09:13 2021 +0530
Branches: soc-2021-simulation-display
https://developer.blender.org/rB4bc0ec4dda2a74edcc57e6ba29c2240bb40659c3

Merge branch 'master' of https://git.blender.org/blender

===



===



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


[Bf-blender-cvs] [87e6e4d3ad9] soc-2021-simulation-display: Merge branch 'master' of https://git.blender.org/blender

2021-06-14 Thread soumya pochiraju
Commit: 87e6e4d3ad90f9b04fc5c3bf3dfaffacc1b422fd
Author: soumya pochiraju
Date:   Wed Apr 28 10:07:11 2021 +0530
Branches: soc-2021-simulation-display
https://developer.blender.org/rB87e6e4d3ad90f9b04fc5c3bf3dfaffacc1b422fd

Merge branch 'master' of https://git.blender.org/blender

===



===



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


[Bf-blender-cvs] [dddcf1e9bbf] temp-compact-node-prototype: Merge branch 'master' into temp-compact-node-prototype

2021-06-14 Thread Jacques Lucke
Commit: dddcf1e9bbf4a6d1f4ff03eaf0cb7e9228b18ec5
Author: Jacques Lucke
Date:   Mon Jun 14 12:44:13 2021 +0200
Branches: temp-compact-node-prototype
https://developer.blender.org/rBdddcf1e9bbf4a6d1f4ff03eaf0cb7e9228b18ec5

Merge branch 'master' into temp-compact-node-prototype

===



===

diff --cc release/scripts/startup/bl_operators/node.py
index 52484f8ffc8,6150789ea10..17e17273432
--- a/release/scripts/startup/bl_operators/node.py
+++ b/release/scripts/startup/bl_operators/node.py
@@@ -302,28 -305,65 +305,86 @@@ class NODE_OT_tree_path_parent(Operator
  
  return {'FINISHED'}
  
- 
 +class NODE_OT_expose_input_socket(Operator):
 +'''Expose socket'''
 +bl_idname = "node.expose_input_socket"
 +bl_label = "Expose Input Socket"
 +
 +tree_name: StringProperty()
 +node_name: StringProperty()
 +# Might reference multiple sockets intentionally.
 +socket_name: StringProperty()
 +
 +expose: BoolProperty(default=True)
 +
 +def execute(self, context):
 +tree = bpy.data.node_groups[self.tree_name]
 +node = tree.nodes[self.node_name]
 +for socket in node.inputs:
 +if socket.name == self.socket_name:
 +socket.hide = not self.expose
 +return {'FINISHED'}
 +
  
+ class NODE_OT_active_preview_toggle(Operator):
+ '''Toggle active preview state of node'''
+ bl_idname = "node.active_preview_toggle"
+ bl_label = "Toggle Active Preview"
+ bl_options = {'REGISTER', 'UNDO'}
+ 
+ @classmethod
+ def poll(cls, context):
+ space = context.space_data
+ if space is None:
+ return False
+ if space.type != 'NODE_EDITOR':
+ return False
+ if space.edit_tree is None:
+ return False
+ if space.edit_tree.nodes.active is None:
+ return False
+ return True
+ 
+ def execute(self, context):
+ node_editor = context.space_data
+ ntree = node_editor.edit_tree
+ active_node = ntree.nodes.active
+ 
+ if active_node.active_preview:
+ self.disable_preview(context, ntree, active_node)
+ else:
+ self.enable_preview(context, node_editor, ntree, active_node)
+ 
+ return {'FINISHED'}
+ 
+ def enable_preview(self, context, node_editor, ntree, active_node):
+ spreadsheets = self.find_unpinned_spreadsheets(context)
+ 
+ for spreadsheet in spreadsheets:
+ spreadsheet.set_geometry_node_context(node_editor, active_node)
+ 
+ for node in ntree.nodes:
+ node.active_preview = False
+ active_node.active_preview = True
+ 
+ def disable_preview(self, context, ntree, active_node):
+ spreadsheets = self.find_unpinned_spreadsheets(context)
+ for spreadsheet in spreadsheets:
+ spreadsheet.context_path.clear()
+ 
+ active_node.active_preview = False
+ 
+ def find_unpinned_spreadsheets(self, context):
+ spreadsheets = []
+ for window in context.window_manager.windows:
+ for area in window.screen.areas:
+ space = area.spaces.active
+ if space.type == 'SPREADSHEET' and not space.is_pinned:
+ spreadsheets.append(space)
+ return spreadsheets
+ 
+ 
++
  classes = (
  NodeSetting,
  
@@@ -332,5 -372,5 +393,6 @@@
  NODE_OT_add_search,
  NODE_OT_collapse_hide_unused_toggle,
  NODE_OT_tree_path_parent,
 +NODE_OT_expose_input_socket,
+ NODE_OT_active_preview_toggle,
  )
diff --cc source/blender/nodes/geometry/nodes/node_geo_attribute_fill.cc
index cbe44c54fb4,389abe3b2aa..51fd65f65fd
--- a/source/blender/nodes/geometry/nodes/node_geo_attribute_fill.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_fill.cc
@@@ -14,19 -14,11 +14,24 @@@
   * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
   */
  
 +#include "node_geometry_util.hh"
 +
 +#include "BLI_heap_value.hh"
 +#include "BLI_rand.hh"
 +
 +#include "DNA_mesh_types.h"
 +#include "DNA_pointcloud_types.h"
 +
 +#include "UI_interface.h"
 +#include "UI_resources.h"
 +
 +#include "WM_types.h"
 +
+ #include "UI_interface.h"
+ #include "UI_resources.h"
+ 
+ #include "node_geometry_util.hh"
+ 
  static bNodeSocketTemplate geo_node_attribute_fill_in[] = {
  {SOCK_GEOMETRY, N_("Geometry")},
  {SOCK_STRING, N_("Attribute")},
@@@ -74,127 -68,12 +79,126 @@@ static void geo_node_attribute_fill_upd
  
  namespace blender::nodes {
  
 +struct SocketMenuInfo {
 +  bNodeTree *ntree;
 +  bNode *node;
 +  bNodeSocket *socket;
 +  std::string enum_name;
 +
 +  uint64_t hash() const
 +  {
 +return get_default_hash_3(ntree, node, socket);
 +  }
 +
 +  friend bool operator==(const SocketMenuInfo &a, const SocketMenuInfo &b)
 +  {
 +return a.ntree == b.ntree && a.node == b.no

[Bf-blender-cvs] [748475b9431] master: BLI_math: Cleanup: Use `mul_`/`madd_` functions.

2021-06-14 Thread Bastien Montagne
Commit: 748475b9431c5b09514b69b042f0daaea1231dc1
Author: Bastien Montagne
Date:   Mon Jun 14 12:30:11 2021 +0200
Branches: master
https://developer.blender.org/rB748475b9431c5b09514b69b042f0daaea1231dc1

BLI_math: Cleanup: Use `mul_`/`madd_` functions.

Better to avoid explicit vectors components direct manipulation when a
generic operation for whole vector exists, if nothing else it avoids
potential mistakes in indices.

===

M   source/blender/blenlib/BLI_math_base.h
M   source/blender/blenlib/BLI_math_vector.h
M   source/blender/blenlib/intern/math_vector.c
M   source/blender/blenlib/intern/math_vector_inline.c

===

diff --git a/source/blender/blenlib/BLI_math_base.h 
b/source/blender/blenlib/BLI_math_base.h
index 46219ad5493..5a3482db046 100644
--- a/source/blender/blenlib/BLI_math_base.h
+++ b/source/blender/blenlib/BLI_math_base.h
@@ -237,6 +237,7 @@ float ceil_power_of_10(float f);
 #ifndef NDEBUG
 /** \note 0.0001 is too small because normals may be converted from short's: 
see T34322. */
 #  define BLI_ASSERT_UNIT_EPSILON 0.0002f
+#  define BLI_ASSERT_UNIT_EPSILON_DB 0.0002
 /**
  * \note Checks are flipped so NAN doesn't assert.
  * This is done because we're making sure the value was normalized and in the 
case we
@@ -253,8 +254,8 @@ float ceil_power_of_10(float f);
 #  define BLI_ASSERT_UNIT_V3_DB(v) \
 { \
   const double _test_unit = len_squared_v3_db(v); \
-  BLI_assert(!(fabs(_test_unit - 1.0) >= BLI_ASSERT_UNIT_EPSILON) || \
- !(fabs(_test_unit) >= BLI_ASSERT_UNIT_EPSILON)); \
+  BLI_assert(!(fabs(_test_unit - 1.0) >= BLI_ASSERT_UNIT_EPSILON_DB) || \
+ !(fabs(_test_unit) >= BLI_ASSERT_UNIT_EPSILON_DB)); \
 } \
 (void)0
 
diff --git a/source/blender/blenlib/BLI_math_vector.h 
b/source/blender/blenlib/BLI_math_vector.h
index caedf83666f..556a216bb89 100644
--- a/source/blender/blenlib/BLI_math_vector.h
+++ b/source/blender/blenlib/BLI_math_vector.h
@@ -163,6 +163,7 @@ MINLINE void madd_v3_v3fl(float r[3], const float a[3], 
float f);
 MINLINE void madd_v3_v3v3(float r[3], const float a[3], const float b[3]);
 MINLINE void madd_v2_v2v2fl(float r[2], const float a[2], const float b[2], 
float f);
 MINLINE void madd_v3_v3v3fl(float r[3], const float a[3], const float b[3], 
float f);
+MINLINE void madd_v3_v3v3db_db(double r[3], const double a[3], const double 
b[3], double f);
 MINLINE void madd_v3_v3v3v3(float r[3], const float a[3], const float b[3], 
const float c[3]);
 MINLINE void madd_v4_v4fl(float r[4], const float a[4], float f);
 MINLINE void madd_v4_v4v4(float r[4], const float a[4], const float b[4]);
diff --git a/source/blender/blenlib/intern/math_vector.c 
b/source/blender/blenlib/intern/math_vector.c
index 05c5f672baa..35dfe421cf0 100644
--- a/source/blender/blenlib/intern/math_vector.c
+++ b/source/blender/blenlib/intern/math_vector.c
@@ -663,9 +663,7 @@ void project_v2_v2v2(float out[2], const float p[2], const 
float v_proj[2])
   }
 
   const float mul = dot_v2v2(p, v_proj) / dot_v2v2(v_proj, v_proj);
-
-  out[0] = mul * v_proj[0];
-  out[1] = mul * v_proj[1];
+  mul_v2_v2fl(out, v_proj, mul);
 }
 
 /**
@@ -679,10 +677,7 @@ void project_v3_v3v3(float out[3], const float p[3], const 
float v_proj[3])
   }
 
   const float mul = dot_v3v3(p, v_proj) / dot_v3v3(v_proj, v_proj);
-
-  out[0] = mul * v_proj[0];
-  out[1] = mul * v_proj[1];
-  out[2] = mul * v_proj[2];
+  mul_v3_v3fl(out, v_proj, mul);
 }
 
 void project_v3_v3v3_db(double out[3], const double p[3], const double 
v_proj[3])
@@ -693,10 +688,7 @@ void project_v3_v3v3_db(double out[3], const double p[3], 
const double v_proj[3]
   }
 
   const double mul = dot_v3v3_db(p, v_proj) / dot_v3v3_db(v_proj, v_proj);
-
-  out[0] = mul * v_proj[0];
-  out[1] = mul * v_proj[1];
-  out[2] = mul * v_proj[2];
+  mul_v3_v3db_db(out, v_proj, mul);
 }
 
 /**
@@ -705,10 +697,9 @@ void project_v3_v3v3_db(double out[3], const double p[3], 
const double v_proj[3]
 void project_v2_v2v2_normalized(float out[2], const float p[2], const float 
v_proj[2])
 {
   BLI_ASSERT_UNIT_V2(v_proj);
-  const float mul = dot_v2v2(p, v_proj);
 
-  out[0] = mul * v_proj[0];
-  out[1] = mul * v_proj[1];
+  const float mul = dot_v2v2(p, v_proj);
+  mul_v2_v2fl(out, v_proj, mul);
 }
 
 /**
@@ -717,11 +708,9 @@ void project_v2_v2v2_normalized(float out[2], const float 
p[2], const float v_pr
 void project_v3_v3v3_normalized(float out[3], const float p[3], const float 
v_proj[3])
 {
   BLI_ASSERT_UNIT_V3(v_proj);
-  const float mul = dot_v3v3(p, v_proj);
 
-  out[0] = mul * v_proj[0];
-  out[1] = mul * v_proj[1];
-  out[2] = mul * v_proj[2];
+  const float mul = dot_v3v3(p, v_proj);
+  mul_v3_v3fl(out, v_proj, mul);
 }
 
 /**
@@ -740,37 +729,31 @@ void project_v3_v3v3_normalized(float out[3], const float 
p[3], const float v_pr
 void project_plane_v3_v3v3(float out[3]

[Bf-blender-cvs] [b21db5e6988] master: BLI_math: Fix several division-by-zero cases.

2021-06-14 Thread Bastien Montagne
Commit: b21db5e6988566dc3344b3293eb7e33234ec2597
Author: Bastien Montagne
Date:   Mon Jun 14 11:06:35 2021 +0200
Branches: master
https://developer.blender.org/rBb21db5e6988566dc3344b3293eb7e33234ec2597

BLI_math: Fix several division-by-zero cases.

Those were caused by various tools used on degenerate geometry, see
T79775.

Note that fixes are as low-level as possible, to ensure they cover as
much as possible of unreported issues too.

We still probably have many more of those hidden in BLI_math though.

===

M   source/blender/blenlib/BLI_math_vector.h
M   source/blender/blenlib/intern/math_geom.c
M   source/blender/blenlib/intern/math_vector.c
M   source/blender/blenlib/intern/math_vector_inline.c

===

diff --git a/source/blender/blenlib/BLI_math_vector.h 
b/source/blender/blenlib/BLI_math_vector.h
index b43f86af670..caedf83666f 100644
--- a/source/blender/blenlib/BLI_math_vector.h
+++ b/source/blender/blenlib/BLI_math_vector.h
@@ -327,6 +327,10 @@ MINLINE bool is_zero_v2(const float a[2]) 
ATTR_WARN_UNUSED_RESULT;
 MINLINE bool is_zero_v3(const float a[3]) ATTR_WARN_UNUSED_RESULT;
 MINLINE bool is_zero_v4(const float a[4]) ATTR_WARN_UNUSED_RESULT;
 
+MINLINE bool is_zero_v2_db(const double a[2]) ATTR_WARN_UNUSED_RESULT;
+MINLINE bool is_zero_v3_db(const double a[3]) ATTR_WARN_UNUSED_RESULT;
+MINLINE bool is_zero_v4_db(const double a[4]) ATTR_WARN_UNUSED_RESULT;
+
 bool is_finite_v2(const float a[2]) ATTR_WARN_UNUSED_RESULT;
 bool is_finite_v3(const float a[3]) ATTR_WARN_UNUSED_RESULT;
 bool is_finite_v4(const float a[4]) ATTR_WARN_UNUSED_RESULT;
diff --git a/source/blender/blenlib/intern/math_geom.c 
b/source/blender/blenlib/intern/math_geom.c
index 508de506ae8..6b1730f8ee8 100644
--- a/source/blender/blenlib/intern/math_geom.c
+++ b/source/blender/blenlib/intern/math_geom.c
@@ -3344,6 +3344,13 @@ float closest_to_ray_v3(float r_close[3],
 const float ray_dir[3])
 {
   float h[3], lambda;
+
+  if (UNLIKELY(is_zero_v3(ray_dir))) {
+lambda = 0.0f;
+copy_v3_v3(r_close, ray_orig);
+return lambda;
+  }
+
   sub_v3_v3v3(h, p, ray_orig);
   lambda = dot_v3v3(ray_dir, h) / dot_v3v3(ray_dir, ray_dir);
   madd_v3_v3v3fl(r_close, ray_orig, ray_dir, lambda);
@@ -4467,7 +4474,7 @@ void interp_weights_poly_v2(float *w, float v[][2], const 
int n, const float co[
 d_curr = d_next;
 DIR_V2_SET(&d_next, v_next, co);
 ht = mean_value_half_tan_v2_db(&d_curr, &d_next);
-w[i_curr] = (float)((ht_prev + ht) / d_curr.len);
+w[i_curr] = (d_curr.len == 0.0) ? 0.0f : (float)((ht_prev + ht) / 
d_curr.len);
 totweight += w[i_curr];
 
 /* step */
diff --git a/source/blender/blenlib/intern/math_vector.c 
b/source/blender/blenlib/intern/math_vector.c
index fb7b96fde78..05c5f672baa 100644
--- a/source/blender/blenlib/intern/math_vector.c
+++ b/source/blender/blenlib/intern/math_vector.c
@@ -657,6 +657,11 @@ void angle_poly_v3(float *angles, const float *verts[3], 
int len)
  */
 void project_v2_v2v2(float out[2], const float p[2], const float v_proj[2])
 {
+  if (UNLIKELY(is_zero_v2(v_proj))) {
+zero_v2(out);
+return;
+  }
+
   const float mul = dot_v2v2(p, v_proj) / dot_v2v2(v_proj, v_proj);
 
   out[0] = mul * v_proj[0];
@@ -668,6 +673,11 @@ void project_v2_v2v2(float out[2], const float p[2], const 
float v_proj[2])
  */
 void project_v3_v3v3(float out[3], const float p[3], const float v_proj[3])
 {
+  if (UNLIKELY(is_zero_v3(v_proj))) {
+zero_v3(out);
+return;
+  }
+
   const float mul = dot_v3v3(p, v_proj) / dot_v3v3(v_proj, v_proj);
 
   out[0] = mul * v_proj[0];
@@ -677,6 +687,11 @@ void project_v3_v3v3(float out[3], const float p[3], const 
float v_proj[3])
 
 void project_v3_v3v3_db(double out[3], const double p[3], const double 
v_proj[3])
 {
+  if (UNLIKELY(is_zero_v3_db(v_proj))) {
+zero_v3_db(out);
+return;
+  }
+
   const double mul = dot_v3v3_db(p, v_proj) / dot_v3v3_db(v_proj, v_proj);
 
   out[0] = mul * v_proj[0];
diff --git a/source/blender/blenlib/intern/math_vector_inline.c 
b/source/blender/blenlib/intern/math_vector_inline.c
index ead354c2d87..e0df9665a7e 100644
--- a/source/blender/blenlib/intern/math_vector_inline.c
+++ b/source/blender/blenlib/intern/math_vector_inline.c
@@ -1282,6 +1282,21 @@ MINLINE bool is_zero_v4(const float v[4])
   return (v[0] == 0.0f && v[1] == 0.0f && v[2] == 0.0f && v[3] == 0.0f);
 }
 
+MINLINE bool is_zero_v2_db(const double v[2])
+{
+  return (v[0] == 0.0 && v[1] == 0.0);
+}
+
+MINLINE bool is_zero_v3_db(const double v[3])
+{
+  return (v[0] == 0.0 && v[1] == 0.0 && v[2] == 0.0);
+}
+
+MINLINE bool is_zero_v4_db(const double v[4])
+{
+  return (v[0] == 0.0 && v[1] == 0.0 && v[2] == 0.0 && v[3] == 0.0);
+}
+
 MINLINE bool is_one_v3(const float v[3])
 {
   return (v[0] == 1.0f && v[1] == 1.0f && v[2] == 1.0f);

__

[Bf-blender-cvs] [5add6f2ed93] master: Fix T87867: file open dialog triggers OneDrive file downloads on macOS

2021-06-14 Thread Leon Zandman
Commit: 5add6f2ed93773e1231e3d52dc9fd963b3bfb9e7
Author: Leon Zandman
Date:   Mon Jun 14 11:16:42 2021 +0200
Branches: master
https://developer.blender.org/rB5add6f2ed93773e1231e3d52dc9fd963b3bfb9e7

Fix T87867: file open dialog triggers OneDrive file downloads on macOS

Until OneDrive supports macOS's native placeholder file implementation, detect
the com.microsoft.OneDrive.RecallOnOpen extended file attribute.

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

===

M   source/blender/blenlib/intern/storage_apple.mm

===

diff --git a/source/blender/blenlib/intern/storage_apple.mm 
b/source/blender/blenlib/intern/storage_apple.mm
index 2a4bbffa60e..8af98d61ecb 100644
--- a/source/blender/blenlib/intern/storage_apple.mm
+++ b/source/blender/blenlib/intern/storage_apple.mm
@@ -24,10 +24,15 @@
  */
 
 #import 
+#include 
+#include 
 
 #include "BLI_fileops.h"
 #include "BLI_path_util.h"
 
+/* Extended file attribute used by OneDrive to mark placeholder files. */
+static const char *ONEDRIVE_RECALLONOPEN_ATTRIBUTE = 
"com.microsoft.OneDrive.RecallOnOpen";
+
 /**
  * \param r_targetpath: Buffer for the target path an alias points to.
  * \return Whether the file at the input path is an alias.
@@ -66,6 +71,67 @@ bool BLI_file_alias_target(const char *filepath, char 
r_targetpath[FILE_MAXDIR])
   return true;
 }
 
+/**
+ * Checks if the given string of listxattr() attributes contains a specific 
attribute.
+ *
+ * \param attributes: a string of null-terminated listxattr() attributes.
+ * \param search_attribute: the attribute to search for.
+ * \return 'true' when the attribute is found, otherwise 'false'.
+ */
+static bool find_attribute(const std::string &attributes, const char 
*search_attribute)
+{
+  /* Attributes is a list of consecutive null-terminated strings. */
+  const char *end = attributes.data() + attributes.size();
+  for (const char *item = attributes.data(); item < end; item += strlen(item) 
+ 1) {
+if (STREQ(item, search_attribute)) {
+  return true;
+}
+  }
+
+  return false;
+}
+
+/**
+ * Checks if the file is merely a placeholder for a OneDrive file that hasn't 
yet been downloaded.
+ *
+ * \param path: the path of the file.
+ * \return 'true' when the file is a OneDrive placeholder, otherwise 'false'.
+ */
+static bool test_onedrive_file_is_placeholder(const char *path)
+{
+  /* Note: Currently only checking for the 
"com.microsoft.OneDrive.RecallOnOpen" extended file
+   * attribute. In theory this attribute can also be set on files that aren't 
located inside a
+   * OneDrive folder. Maybe additional checks are required? */
+
+  /* Get extended file attributes */
+  ssize_t size = listxattr(path, nullptr, 0, XATTR_NOFOLLOW);
+  if (size < 1) {
+return false;
+  }
+
+  std::string attributes(size, '\0');
+  size = listxattr(path, attributes.data(), size, XATTR_NOFOLLOW);
+  /* In case listxattr() has failed the second time it's called. */
+  if (size < 1) {
+return false;
+  }
+
+  /* Check for presence of 'com.microsoft.OneDrive.RecallOnOpen' attribute. */
+  return find_attribute(attributes, ONEDRIVE_RECALLONOPEN_ATTRIBUTE);
+}
+
+/**
+ * Checks if the file is marked as offline and not immediately available.
+ *
+ * \param path: the path of the file.
+ * \return 'true' when the file is a placeholder, otherwise 'false'.
+ */
+static bool test_file_is_offline(const char *path)
+{
+  /* Logic for additional cloud storage providers could be added in the 
future. */
+  return test_onedrive_file_is_placeholder(path);
+}
+
 eFileAttributes BLI_file_attributes(const char *path)
 {
   int ret = 0;
@@ -76,15 +142,28 @@ eFileAttributes BLI_file_attributes(const char *path)
 const NSURL *fileURL = [[NSURL alloc] 
initFileURLWithFileSystemRepresentation:path
   
isDirectory:NO
 
relativeToURL:nil];
-NSArray *resourceKeys =
-@[ NSURLIsAliasFileKey, NSURLIsHiddenKey, NSURLIsReadableKey, 
NSURLIsWritableKey ];
+
+/* Querying NSURLIsReadableKey and NSURLIsWritableKey keys for OneDrive 
placeholder files
+ * triggers their unwanted download. */
+NSArray *resourceKeys = nullptr;
+const bool is_offline = test_file_is_offline(path);
+
+if (is_offline) {
+  resourceKeys = @[ NSURLIsAliasFileKey, NSURLIsHiddenKey ];
+}
+else {
+  resourceKeys =
+  @[ NSURLIsAliasFileKey, NSURLIsHiddenKey, NSURLIsReadableKey, 
NSURLIsWritableKey ];
+}
 
 const NSDictionary *resourceKeyValues = [fileURL 
resourceValuesForKeys:resourceKeys error:nil];
 
 const bool is_alias = [resourceKeyValues[(void)(@"@%"), 
NSURLIsAliasFileKey] boolValue];
 const bool is_hidden = [resourceKeyValues[(void)(@"@%"), NSURLIsHiddenKey] 
boolValue];
-const bool is_readable = [r

[Bf-blender-cvs] [c9dc55301cd] master: Fix T88494: add missing depsgraph relation update tags

2021-06-14 Thread Jacques Lucke
Commit: c9dc55301cd7903b7ef7c045d337ada29aa809a1
Author: Jacques Lucke
Date:   Mon Jun 14 11:35:36 2021 +0200
Branches: master
https://developer.blender.org/rBc9dc55301cd7903b7ef7c045d337ada29aa809a1

Fix T88494: add missing depsgraph relation update tags

Adding e.g. a Collection Info node creates a new depsgraph relation.
Therefore the relations should be updated.

===

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

===

diff --git a/source/blender/editors/space_node/node_add.cc 
b/source/blender/editors/space_node/node_add.cc
index 7276688e986..6143af8ed70 100644
--- a/source/blender/editors/space_node/node_add.cc
+++ b/source/blender/editors/space_node/node_add.cc
@@ -591,6 +591,7 @@ static int node_add_texture_exec(bContext *C, wmOperator 
*op)
 
   snode_notify(C, snode);
   snode_dag_update(C, snode);
+  DEG_relations_tag_update(bmain);
 
   ED_node_tag_update_nodetree(bmain, ntree, texture_node);
 
@@ -696,6 +697,7 @@ static int node_add_collection_exec(bContext *C, wmOperator 
*op)
 
   snode_notify(C, snode);
   snode_dag_update(C, snode);
+  DEG_relations_tag_update(bmain);
 
   ED_node_tag_update_nodetree(bmain, ntree, collection_node);
 
@@ -807,6 +809,7 @@ static int node_add_file_exec(bContext *C, wmOperator *op)
 
   snode_notify(C, snode);
   snode_dag_update(C, snode);
+  DEG_relations_tag_update(bmain);
 
   return OPERATOR_FINISHED;
 }
@@ -902,6 +905,7 @@ static int node_add_mask_exec(bContext *C, wmOperator *op)
 
   snode_notify(C, snode);
   snode_dag_update(C, snode);
+  DEG_relations_tag_update(bmain);
 
   return OPERATOR_FINISHED;
 }

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


[Bf-blender-cvs] [a19c9e9351c] master: Fix T88947: invalid normals when converting point cloud to mesh

2021-06-14 Thread Jacques Lucke
Commit: a19c9e9351cacdc9a7ab4e4177c2e3ae83166cd8
Author: Jacques Lucke
Date:   Mon Jun 14 11:07:31 2021 +0200
Branches: master
https://developer.blender.org/rBa19c9e9351cacdc9a7ab4e4177c2e3ae83166cd8

Fix T88947: invalid normals when converting point cloud to mesh

===

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

===

diff --git a/source/blender/blenkernel/intern/geometry_set_instances.cc 
b/source/blender/blenkernel/intern/geometry_set_instances.cc
index 69840ba1612..847df75c8cb 100644
--- a/source/blender/blenkernel/intern/geometry_set_instances.cc
+++ b/source/blender/blenkernel/intern/geometry_set_instances.cc
@@ -472,6 +472,11 @@ static Mesh 
*join_mesh_topology_and_builtin_attributes(Spanhttps://lists.blender.org/mailman/listinfo/bf-blender-cvs


  1   2   >