[Bf-blender-cvs] [6d297c35c86] master: Fix T104371: GPencil merge down layer duplicates wrong frame

2023-02-06 Thread Amelie Fondevilla
Commit: 6d297c35c8658b3e0579767d4a9fd3b761e81a61
Author: Amelie Fondevilla
Date:   Mon Feb 6 10:22:57 2023 +0100
Branches: master
https://developer.blender.org/rB6d297c35c8658b3e0579767d4a9fd3b761e81a61

Fix T104371: GPencil merge down layer duplicates wrong frame

The merge down operator was sometimes copying the wrong frame, which altered 
the animation.
While merging the layers, it is sometimes needed to duplicate a keyframe,
when the lowest layer does not have a keyframe but the highest layer does.
Instead of duplicating the previous keyframe of the lowest layer, the code
was actually duplicating the active frame of the layer which was the current 
frame in the timeline.

This patch fixes the issue by setting the previous keyframe of the layer as its 
active frame before duplication.

Related issue: T104371.

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

===

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

===

diff --git a/source/blender/blenkernel/intern/gpencil.c 
b/source/blender/blenkernel/intern/gpencil.c
index b77f43276e7..6405ce06a5b 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -1273,6 +1273,10 @@ bGPDframe *BKE_gpencil_layer_frame_get(bGPDlayer *gpl, 
int cframe, eGP_GetFrame_
   gpl->actframe = gpf;
 }
 else if (addnew == GP_GETFRAME_ADD_COPY) {
+  /* The frame_addcopy function copies the active frame of gpl,
+ so we need to set the active frame before copying.
+  */
+  gpl->actframe = gpf;
   gpl->actframe = BKE_gpencil_frame_addcopy(gpl, cframe);
 }
 else {
@@ -1300,6 +1304,10 @@ bGPDframe *BKE_gpencil_layer_frame_get(bGPDlayer *gpl, 
int cframe, eGP_GetFrame_
   gpl->actframe = gpf;
 }
 else if (addnew == GP_GETFRAME_ADD_COPY) {
+  /* The frame_addcopy function copies the active frame of gpl;
+ so we need to set the active frame before copying.
+  */
+  gpl->actframe = gpf;
   gpl->actframe = BKE_gpencil_frame_addcopy(gpl, cframe);
 }
 else {

___
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] [ef39d85d7c9] master: Fix T104121: Grease pencil clear function in python not updated in viewport

2023-01-26 Thread Amelie Fondevilla
Commit: ef39d85d7c94c28e952683c0ddd0f3b7435b8460
Author: Amelie Fondevilla
Date:   Wed Jan 25 17:00:10 2023 +0100
Branches: master
https://developer.blender.org/rBef39d85d7c94c28e952683c0ddd0f3b7435b8460

Fix T104121: Grease pencil clear function in python not updated in viewport

The clear functions for grease pencil data/frame/layer
was not followed by immediate update in the viewport.
Some notifiers were missing in the rna definition of these functions,
which are added in by this patch.

Reviewed By: Antonio Vazquez

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

===

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

===

diff --git a/source/blender/makesrna/intern/rna_gpencil.c 
b/source/blender/makesrna/intern/rna_gpencil.c
index 544a7f73cab..dd608ce9acb 100644
--- a/source/blender/makesrna/intern/rna_gpencil.c
+++ b/source/blender/makesrna/intern/rna_gpencil.c
@@ -1101,17 +1101,23 @@ static void rna_GPencil_layer_mask_remove(bGPDlayer 
*gpl,
   WM_main_add_notifier(NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
 }
 
-static void rna_GPencil_frame_clear(bGPDframe *frame)
+static void rna_GPencil_frame_clear(ID *id, bGPDframe *frame)
 {
   BKE_gpencil_free_strokes(frame);
 
+  bGPdata *gpd = (bGPdata *)id;
+  DEG_id_tag_update(>id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
+
   WM_main_add_notifier(NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
 }
 
-static void rna_GPencil_layer_clear(bGPDlayer *layer)
+static void rna_GPencil_layer_clear(ID *id, bGPDlayer *layer)
 {
   BKE_gpencil_free_frames(layer);
 
+  bGPdata *gpd = (bGPdata *)id;
+  DEG_id_tag_update(>id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
+
   WM_main_add_notifier(NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
 }
 
@@ -1119,6 +1125,8 @@ static void rna_GPencil_clear(bGPdata *gpd)
 {
   BKE_gpencil_free_layers(>layers);
 
+  DEG_id_tag_update(>id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
+
   WM_main_add_notifier(NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
 }
 
@@ -1841,6 +1849,7 @@ static void rna_def_gpencil_frame(BlenderRNA *brna)
   /* API */
   func = RNA_def_function(srna, "clear", "rna_GPencil_frame_clear");
   RNA_def_function_ui_description(func, "Remove all the grease pencil frame 
data");
+  RNA_def_function_flag(func, FUNC_USE_SELF_ID);
 }
 
 static void rna_def_gpencil_frames_api(BlenderRNA *brna, PropertyRNA *cprop)
@@ -2304,6 +2313,7 @@ static void rna_def_gpencil_layer(BlenderRNA *brna)
   /* Layers API */
   func = RNA_def_function(srna, "clear", "rna_GPencil_layer_clear");
   RNA_def_function_ui_description(func, "Remove all the grease pencil layer 
data");
+  RNA_def_function_flag(func, FUNC_USE_SELF_ID);
 }
 
 static void rna_def_gpencil_layers_api(BlenderRNA *brna, PropertyRNA *cprop)

___
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] [a36e2a9b649] master: Gpencil: Expose stroke and point time properties to API

2023-01-24 Thread Amelie Fondevilla
Commit: a36e2a9b649eef7b21541bb397555b7d6eb6bd6d
Author: Amelie Fondevilla
Date:   Tue Jan 24 11:57:49 2023 +0100
Branches: master
https://developer.blender.org/rBa36e2a9b649eef7b21541bb397555b7d6eb6bd6d

Gpencil: Expose stroke and point time properties to API

Two properties are now exposed in python API :
time of each point, and inittime of each stroke.

Reviewed by: Antonio Vazquez

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

===

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

===

diff --git a/source/blender/makesrna/intern/rna_gpencil.c 
b/source/blender/makesrna/intern/rna_gpencil.c
index a9dc4f4dc12..544a7f73cab 100644
--- a/source/blender/makesrna/intern/rna_gpencil.c
+++ b/source/blender/makesrna/intern/rna_gpencil.c
@@ -1275,6 +1275,11 @@ static void rna_def_gpencil_stroke_point(BlenderRNA 
*brna)
   RNA_def_property_ui_text(prop, "Select", "Point is selected for viewport 
editing");
   RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
 
+  prop = RNA_def_property(srna, "time", PROP_FLOAT, PROP_TIME);
+  RNA_def_property_float_sdna(prop, NULL, "time");
+  RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+  RNA_def_property_ui_text(prop, "Time", "Time relative to stroke start");
+
   /* Vertex color. */
   prop = RNA_def_property(srna, "vertex_color", PROP_FLOAT, PROP_COLOR);
   RNA_def_property_float_sdna(prop, NULL, "vert_color");
@@ -1748,6 +1753,12 @@ static void rna_def_gpencil_stroke(BlenderRNA *brna)
   prop = RNA_def_property(srna, "select_index", PROP_INT, PROP_NONE);
   RNA_def_property_int_sdna(prop, NULL, "select_index");
   RNA_def_property_ui_text(prop, "Select Index", "Index of selection used for 
interpolation");
+
+  /* Init time */
+  prop = RNA_def_property(srna, "init_time", PROP_FLOAT, PROP_TIME);
+  RNA_def_property_float_sdna(prop, NULL, "inittime");
+  RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+  RNA_def_property_ui_text(prop, "Init Time", "Initial time of the stroke");
 }
 
 static void rna_def_gpencil_strokes_api(BlenderRNA *brna, PropertyRNA *cprop)

___
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] [9137a4f03ce] blender-v3.3-release: Fix: new Grease Pencil layer not selected when added from the viewport

2023-01-12 Thread Amelie Fondevilla
Commit: 9137a4f03ce6571ae5ab8497ba35ffa7d8cc43e5
Author: Amelie Fondevilla
Date:   Tue Jan 10 14:18:09 2023 +0100
Branches: blender-v3.3-release
https://developer.blender.org/rB9137a4f03ce6571ae5ab8497ba35ffa7d8cc43e5

Fix: new Grease Pencil layer not selected when added from the viewport

When adding a new layer from the viewport, the newly created layer
is set as active, which is visible in the properties panel,
but the selection in the dopesheet was not updated accordingly,
due to a missing notifier which is added in this patch.

===

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

===

diff --git a/source/blender/editors/gpencil/gpencil_data.c 
b/source/blender/editors/gpencil/gpencil_data.c
index 340288b2d74..7897763ab58 100644
--- a/source/blender/editors/gpencil/gpencil_data.c
+++ b/source/blender/editors/gpencil/gpencil_data.c
@@ -237,6 +237,7 @@ static int gpencil_layer_add_exec(bContext *C, wmOperator 
*op)
   ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | 
ID_RECALC_COPY_ON_WRITE);
   }
   WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
+  WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_SELECTED, NULL);
 
   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] [fddb76e9af8] master: Fix: new Grease Pencil layer not selected when added from the viewport

2023-01-10 Thread Amelie Fondevilla
Commit: fddb76e9af8de34852cb9906abd1de43ad9f24d3
Author: Amelie Fondevilla
Date:   Tue Jan 10 14:18:09 2023 +0100
Branches: master
https://developer.blender.org/rBfddb76e9af8de34852cb9906abd1de43ad9f24d3

Fix: new Grease Pencil layer not selected when added from the viewport

When adding a new layer from the viewport, the newly created layer
is set as active, which is visible in the properties panel,
but the selection in the dopesheet was not updated accordingly,
due to a missing notifier which is added in this patch.

===

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

===

diff --git a/source/blender/editors/gpencil/gpencil_data.c 
b/source/blender/editors/gpencil/gpencil_data.c
index 4f61016215a..c876832bc0c 100644
--- a/source/blender/editors/gpencil/gpencil_data.c
+++ b/source/blender/editors/gpencil/gpencil_data.c
@@ -247,6 +247,7 @@ static int gpencil_layer_add_exec(bContext *C, wmOperator 
*op)
   ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | 
ID_RECALC_COPY_ON_WRITE);
   }
   WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
+  WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_SELECTED, NULL);
 
   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] [0bcfe2788df] master: Fix T103376: Grease pencil frames selected from python are not updated in the dopesheet

2022-12-22 Thread Amelie Fondevilla
Commit: 0bcfe2788df225ae948c31815535532a8b02b894
Author: Amelie Fondevilla
Date:   Wed Dec 21 11:54:44 2022 +0100
Branches: master
https://developer.blender.org/rB0bcfe2788df225ae948c31815535532a8b02b894

Fix T103376: Grease pencil frames selected from python are not updated in the 
dopesheet

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

===

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

===

diff --git a/source/blender/makesrna/intern/rna_gpencil.c 
b/source/blender/makesrna/intern/rna_gpencil.c
index cf02b8fe61c..a9dc4f4dc12 100644
--- a/source/blender/makesrna/intern/rna_gpencil.c
+++ b/source/blender/makesrna/intern/rna_gpencil.c
@@ -1825,6 +1825,7 @@ static void rna_def_gpencil_frame(BlenderRNA *brna)
   prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
   RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_FRAME_SELECT);
   RNA_def_property_ui_text(prop, "Select", "Frame is selected for editing in 
the Dope Sheet");
+  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
 
   /* API */
   func = RNA_def_function(srna, "clear", "rna_GPencil_frame_clear");

___
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] [7c77bc9a54c] gpencil-new-data-proposal: Rename CurveGeometry getter in new gpencil structure

2022-12-20 Thread Amelie Fondevilla
Commit: 7c77bc9a54c1eeb27646adffb6847497f37ef396
Author: Amelie Fondevilla
Date:   Tue Dec 20 15:53:05 2022 +0100
Branches: gpencil-new-data-proposal
https://developer.blender.org/rB7c77bc9a54c1eeb27646adffb6847497f37ef396

Rename CurveGeometry getter in new gpencil structure

===

M   release/datafiles/locale
M   release/scripts/addons
M   release/scripts/addons_contrib
M   source/blender/blenkernel/intern/gpencil_new_proposal.cc
M   source/blender/blenkernel/intern/gpencil_new_proposal.hh
M   source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc
M   source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
M   source/tools

===

diff --git a/release/datafiles/locale b/release/datafiles/locale
index 4a581c54af9..6514c6647d4 16
--- a/release/datafiles/locale
+++ b/release/datafiles/locale
@@ -1 +1 @@
-Subproject commit 4a581c54af9b92cb670d750951b9382160f10f3e
+Subproject commit 6514c6647d4019971c54c436cd2288a9f84c7b28
diff --git a/release/scripts/addons b/release/scripts/addons
index 0b0052bd53a..5ba2c7517e8 16
--- a/release/scripts/addons
+++ b/release/scripts/addons
@@ -1 +1 @@
-Subproject commit 0b0052bd53ad8249ed07dfb87705c338af698bde
+Subproject commit 5ba2c7517e8577e3cfe1dcb2e29a4627842e2aea
diff --git a/release/scripts/addons_contrib b/release/scripts/addons_contrib
index 96143b1a8b0..bdcfdd47ec3 16
--- a/release/scripts/addons_contrib
+++ b/release/scripts/addons_contrib
@@ -1 +1 @@
-Subproject commit 96143b1a8b037ea3c81f065f557025db9fe1ace3
+Subproject commit bdcfdd47ec3451822b21d1cff2ea2db751093c9a
diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal.cc 
b/source/blender/blenkernel/intern/gpencil_new_proposal.cc
index c3d6ada6071..3a9767f253d 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal.cc
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal.cc
@@ -164,7 +164,7 @@ bool GPFrame::operator==(const GPFrame ) const
   return this->layer_index == other.layer_index && this->start_time == 
other.start_time;
 }
 
-CurvesGeometry ::strokes_as_curves()
+CurvesGeometry ::curves()
 {
   if (!this->strokes) {
 this->strokes = MEM_new(__func__);
@@ -172,7 +172,7 @@ CurvesGeometry ::strokes_as_curves()
   return CurvesGeometry::wrap(*this->strokes);
 }
 
-const CurvesGeometry ::strokes_as_curves() const
+const CurvesGeometry ::curves() const
 {
   BLI_assert(this->strokes != nullptr);
   return CurvesGeometry::wrap(*this->strokes);
@@ -201,7 +201,7 @@ int GPFrame::points_num() const
 
 IndexRange GPFrame::add_new_stroke(int new_points_num)
 {
-  CurvesGeometry  = this->strokes_as_curves();
+  CurvesGeometry  = this->curves();
   int orig_last_offset = strokes.offsets().last();
 
   strokes.resize(strokes.points_num() + new_points_num, strokes.curves_num() + 
1);
diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal.hh 
b/source/blender/blenkernel/intern/gpencil_new_proposal.hh
index 461de5c8041..c61948c5175 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal.hh
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal.hh
@@ -258,8 +258,8 @@ class GPFrame : public ::GPFrame {
 
   bool operator==(const GPFrame ) const;
 
-  CurvesGeometry _as_curves();
-  const CurvesGeometry _as_curves() const;
+  CurvesGeometry ();
+  const CurvesGeometry () const;
 
   bool is_empty() const;
   int strokes_num() const;
diff --git 
a/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc 
b/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc
index 7e155b57f72..a076c49b1ce 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc
@@ -27,7 +27,7 @@ GPData convert_old_to_new_gpencil_data(bGPdata *old_gpd)
 offsets.append(old_gps->totpoints + offsets.last());
   }
 
-  CurvesGeometry _gps{new_gpf.strokes_as_curves()};
+  CurvesGeometry _gps{new_gpf.curves()};
   MutableAttributeAccessor attributes = new_gps.attributes_for_write();
   new_gps.resize(offsets.last(), offsets.size() - 1);
   new_gps.offsets_for_write().copy_from(offsets);
@@ -81,11 +81,12 @@ bGPdata *convert_new_to_old_gpencil_data(const GPData 
_gpd)
   old_gpf->framenum = new_gpf.start_time;
 
   BLI_listbase_clear(_gpf->strokes);
-  const CurvesGeometry _gps{new_gpf.strokes_as_curves()};
+  const CurvesGeometry _gps{new_gpf.curves()};
   AttributeAccessor attributes = new_gps.attributes();
 
   Span new_gps_positions = new_gps.positions();
-  VArray new_gps_radii = 
attributes.lookup_or_default(ATTR_RADIUS, ATTR_DOMAIN_POINT, 0);
+  VArray new_gps_radii = attributes.lookup_or_default(
+  ATTR_RADIUS, ATTR_DOMAIN_POINT, 0);
 
   for (int stroke_index = 0; stroke_

[Bf-blender-cvs] [adc92cc23e7] master: Fix T103357: Grease pencil layer color not displayed in main dopesheet backdrop

2022-12-20 Thread Amelie Fondevilla
Commit: adc92cc23e74ce10cff95f58fd517ed7c23d3779
Author: Amelie Fondevilla
Date:   Tue Dec 20 13:14:21 2022 +0100
Branches: master
https://developer.blender.org/rBadc92cc23e74ce10cff95f58fd517ed7c23d3779

Fix T103357: Grease pencil layer color not displayed in main dopesheet backdrop

Reviewed By: Sybren A. Stüvel

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

===

M   source/blender/editors/space_action/action_draw.c

===

diff --git a/source/blender/editors/space_action/action_draw.c 
b/source/blender/editors/space_action/action_draw.c
index 343975919e2..de3d306a0be 100644
--- a/source/blender/editors/space_action/action_draw.c
+++ b/source/blender/editors/space_action/action_draw.c
@@ -272,6 +272,20 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction 
*saction, ARegion *region
   }
   break;
 }
+case ANIMTYPE_GPLAYER: {
+  if (show_group_colors) {
+uchar gpl_col[4];
+bGPDlayer *gpl = (bGPDlayer *)ale->data;
+rgb_float_to_uchar(gpl_col, gpl->color);
+gpl_col[3] = col1[3];
+
+immUniformColor4ubv(sel ? col1 : gpl_col);
+  }
+  else {
+immUniformColor4ubv(sel ? col1 : col2);
+  }
+  break;
+}
 default: {
   immUniformColor4ubv(sel ? col1 : col2);
 }

___
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] [a560f39ee89] gpencil-new-data-proposal: add conversion of point positions

2022-12-12 Thread Amelie Fondevilla
Commit: a560f39ee89882a97ba46841c345affd9f25f768
Author: Amelie Fondevilla
Date:   Mon Dec 12 18:18:20 2022 +0100
Branches: gpencil-new-data-proposal
https://developer.blender.org/rBa560f39ee89882a97ba46841c345affd9f25f768

add conversion of point positions

===

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

===

diff --git 
a/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc 
b/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc
index 9541e88106b..c81e200c25c 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc
@@ -22,8 +22,24 @@ GPData convert_old_to_new_gpencil_data(bGPdata *old_gpd)
   int new_gpf_index{new_gpd.add_frame_on_layer(layer_index, 
old_gpf->framenum)};
   GPFrame _gpf{new_gpd.frames_for_write(new_gpf_index)};
 
+  int stroke_index{0};
   LISTBASE_FOREACH (const bGPDstroke *, old_gps, _gpf->strokes) {
 new_gpf.add_new_stroke(old_gps->totpoints);
+++stroke_index;
+  }
+
+  CurvesGeometry _gps{new_gpf.strokes_as_curves()};
+  MutableSpan new_gps_positions{new_gps.positions_for_write()};
+  stroke_index = 0;
+  LISTBASE_FOREACH (const bGPDstroke *, old_gps, _gpf->strokes) {
+IndexRange 
point_index_in_curve{new_gps.points_for_curve(stroke_index)};
+
+for (int point_index = 0; point_index < old_gps->totpoints; 
point_index++) {
+  bGPDspoint *old_pt{old_gps->points + point_index};
+  new_gps_positions[point_index_in_curve[point_index]] = {old_pt->x, 
old_pt->y, old_pt->z};
+}
+
+++stroke_index;
   }
 }
 
@@ -73,6 +89,15 @@ bGPdata *convert_new_to_old_gpencil_data(const GPData 
_gpd)
 old_gps->editcurve = nullptr;
 old_gps->dvert = nullptr;
 
+Span new_gps_positions = new_gps.positions();
+
+int point_index{0};
+for (int new_gps_point_index : new_gps.points_for_curve(stroke_index)) 
{
+  bGPDspoint *pt = _gps->points[point_index];
+  copy_v3_v3(>x, new_gps_positions[new_gps_point_index]);
+  ++point_index;
+}
+
 BLI_addtail(_gpf->strokes, old_gps);
   }

___
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] [53885b6eaab] gpencil-new-data-proposal: adding stroke comparison test from new to old data structure

2022-12-12 Thread Amelie Fondevilla
Commit: 53885b6eaabfc8cfea509107719a8f0b2f92f337
Author: Amelie Fondevilla
Date:   Mon Dec 12 17:16:21 2022 +0100
Branches: gpencil-new-data-proposal
https://developer.blender.org/rB53885b6eaabfc8cfea509107719a8f0b2f92f337

adding stroke comparison test from new to old data structure

===

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

===

diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc 
b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
index 4a73ba82b80..23a4e20a224 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
@@ -145,6 +145,22 @@ static void insert_new_stroke_old_gpencil_data(bGPDframe 
*gpf,
   BLI_addtail(>strokes, gps);
 }
 
+static void insert_new_stroke_new_gpencil_data(GPFrame ,
+   int point_num,
+   float *position,
+   float *pressure)
+{
+  gpf.add_new_stroke(point_num);
+  CurvesGeometry  = gpf.strokes_as_curves();
+  int point_index{0};
+  for (float3  : curves.positions_for_write()) {
+pos.x = position[3 * point_index];
+pos.y = position[3 * point_index + 1];
+pos.z = position[3 * point_index + 2];
+++point_index;
+  }
+}
+
 static void compare_gpencil_stroke_data(const CurvesGeometry ,
 int curve_index,
 const bGPDstroke *stk)
@@ -570,4 +586,22 @@ TEST(gpencil_proposal, OldToNewStrokeConversion)
 
   free_old_gpencil_data(old_data);
 }
+
+TEST(gpencil_proposal, NewToOldStrokeConversion)
+{
+  int layers_num = 1, frames_num = 1, strokes_num = 0, points_num = 0;
+
+  GPData data = build_gpencil_data(layers_num, frames_num, strokes_num, 
points_num);
+
+  const int point_num{5};
+  float pos[point_num * 3] = {0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 
6, 6.5, 7};
+  float prs[point_num] = {0.5, 0.75, 1, 1.5, 1.75};
+  insert_new_stroke_new_gpencil_data(data.frames_for_write(0), point_num, pos, 
prs);
+
+  bGPdata *old_data = convert_new_to_old_gpencil_data(data);
+
+  compare_gpencil_data_structures(data, old_data);
+
+  free_old_gpencil_data(old_data);
+}
 }  // namespace blender::bke::gpencil::tests

___
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] [274eda29933] gpencil-new-data-proposal: conversion functions adds strokes and points

2022-12-12 Thread Amelie Fondevilla
Commit: 274eda2993316f4a5b33dedf8a4e1be7906151ab
Author: Amelie Fondevilla
Date:   Mon Dec 12 16:48:54 2022 +0100
Branches: gpencil-new-data-proposal
https://developer.blender.org/rB274eda2993316f4a5b33dedf8a4e1be7906151ab

conversion functions adds strokes and points

===

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

===

diff --git 
a/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc 
b/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc
index 267d6cf067a..9541e88106b 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc
@@ -21,6 +21,10 @@ GPData convert_old_to_new_gpencil_data(bGPdata *old_gpd)
 LISTBASE_FOREACH (bGPDframe *, old_gpf, _gpl->frames) {
   int new_gpf_index{new_gpd.add_frame_on_layer(layer_index, 
old_gpf->framenum)};
   GPFrame _gpf{new_gpd.frames_for_write(new_gpf_index)};
+
+  LISTBASE_FOREACH (const bGPDstroke *, old_gps, _gpf->strokes) {
+new_gpf.add_new_stroke(old_gps->totpoints);
+  }
 }
 
 ++layer_index;
@@ -36,10 +40,10 @@ bGPdata *convert_new_to_old_gpencil_data(const GPData 
_gpd)
   BLI_listbase_clear(_gpd->layers);
   old_gpd->totlayer = old_gpd->totframe = old_gpd->totstroke = 0;
 
-  int frm_offset{0};
-  for (int lay_i = 0; lay_i < new_gpd.layers_size; lay_i++) {
+  int frame_index{0};
+  for (int layer_index = 0; layer_index < new_gpd.layers_size; layer_index++) {
 bGPDlayer *old_gpl = reinterpret_cast(MEM_mallocN(sizeof(bGPDlayer), __func__));
-const ::GPLayer *new_gpl{new_gpd.layers_array + lay_i};
+const ::GPLayer *new_gpl{new_gpd.layers_array + layer_index};
 
 sprintf(old_gpl->info, "%s", new_gpl->name);
 
@@ -49,17 +53,32 @@ bGPdata *convert_new_to_old_gpencil_data(const GPData 
_gpd)
 /* Add frames of correct layer index.
Assumes that frames in new data structure are sorted by layer index.
 */
-while ((frm_offset < new_gpd.frames_size) &&
-   (new_gpd.frames_array[frm_offset].layer_index == lay_i)) {
-  bGPDframe *gpf = reinterpret_cast(MEM_mallocN(sizeof(bGPDframe), __func__));
-  const ::GPFrame *new_gpf{new_gpd.frames_array + frm_offset};
-  gpf->framenum = new_gpf->start_time;
-
-  BLI_listbase_clear(>strokes);
+while ((frame_index < new_gpd.frames_size) &&
+   (new_gpd.frames_array[frame_index].layer_index == layer_index)) {
+  bGPDframe *old_gpf = reinterpret_cast(MEM_mallocN(sizeof(bGPDframe), __func__));
+  const GPFrame _gpf{new_gpd.frames(frame_index)};
+  old_gpf->framenum = new_gpf.start_time;
+
+  BLI_listbase_clear(_gpf->strokes);
+  const CurvesGeometry _gps{new_gpf.strokes_as_curves()};
+  for (int stroke_index = 0; stroke_index < new_gpf.strokes_num(); 
stroke_index++) {
+bGPDstroke *old_gps = reinterpret_cast(
+MEM_mallocN(sizeof(bGPDstroke), __func__));
+
+int point_num{new_gps.points_num_for_curve(stroke_index)};
+old_gps->points = reinterpret_cast(
+MEM_calloc_arrayN(point_num, sizeof(bGPDspoint), __func__));
+old_gps->totpoints = point_num;
+old_gps->triangles = nullptr;
+old_gps->editcurve = nullptr;
+old_gps->dvert = nullptr;
+
+BLI_addtail(_gpf->strokes, old_gps);
+  }
 
   ++(old_gpd->totframe);
-  BLI_addtail(_gpl->frames, gpf);
-  ++frm_offset;
+  BLI_addtail(_gpl->frames, old_gpf);
+  ++frame_index;
 }
 
 ++(old_gpd->totlayer);

___
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] [509445955c2] gpencil-new-data-proposal: fix stroke insertion in new data structure

2022-12-12 Thread Amelie Fondevilla
Commit: 509445955c24d905e9cf63e7f039bc36985dac1a
Author: Amelie Fondevilla
Date:   Mon Dec 12 18:03:11 2022 +0100
Branches: gpencil-new-data-proposal
https://developer.blender.org/rB509445955c24d905e9cf63e7f039bc36985dac1a

fix stroke insertion in new data structure

===

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

===

diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc 
b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
index 23a4e20a224..a40da2a6719 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
@@ -150,13 +150,16 @@ static void insert_new_stroke_new_gpencil_data(GPFrame 
,
float *position,
float *pressure)
 {
+  int stroke_index{gpf.strokes_num()};
   gpf.add_new_stroke(point_num);
   CurvesGeometry  = gpf.strokes_as_curves();
+
   int point_index{0};
-  for (float3  : curves.positions_for_write()) {
-pos.x = position[3 * point_index];
-pos.y = position[3 * point_index + 1];
-pos.z = position[3 * point_index + 2];
+  MutableSpan pos = curves.positions_for_write();
+  for (int point_index_in_curve : curves.points_for_curve(stroke_index)) {
+pos[point_index_in_curve].x = position[3 * point_index];
+pos[point_index_in_curve].y = position[3 * point_index + 1];
+pos[point_index_in_curve].z = position[3 * point_index + 2];
 ++point_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] [9929b367df6] gpencil-new-data-proposal: refactor

2022-12-12 Thread Amelie Fondevilla
Commit: 9929b367df68cc8028d1a342d6b822fd269d6baf
Author: Amelie Fondevilla
Date:   Mon Dec 12 16:29:13 2022 +0100
Branches: gpencil-new-data-proposal
https://developer.blender.org/rB9929b367df68cc8028d1a342d6b822fd269d6baf

refactor

===

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

===

diff --git 
a/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc 
b/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc
index 853d43f..267d6cf067a 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc
@@ -15,11 +15,12 @@ GPData convert_old_to_new_gpencil_data(bGPdata *old_gpd)
   GPData new_gpd;
 
   int layer_index{0};
-  LISTBASE_FOREACH (bGPDlayer *, lay, _gpd->layers) {
-new_gpd.add_layer(std::string(lay->info));
+  LISTBASE_FOREACH (bGPDlayer *, old_gpl, _gpd->layers) {
+new_gpd.add_layer(std::string(old_gpl->info));
 
-LISTBASE_FOREACH (bGPDframe *, frm, >frames) {
-  new_gpd.add_frame_on_layer(layer_index, frm->framenum);
+LISTBASE_FOREACH (bGPDframe *, old_gpf, _gpl->frames) {
+  int new_gpf_index{new_gpd.add_frame_on_layer(layer_index, 
old_gpf->framenum)};
+  GPFrame _gpf{new_gpd.frames_for_write(new_gpf_index)};
 }
 
 ++layer_index;
@@ -30,19 +31,20 @@ GPData convert_old_to_new_gpencil_data(bGPdata *old_gpd)
 
 bGPdata *convert_new_to_old_gpencil_data(const GPData _gpd)
 {
-  bGPdata *gpd = reinterpret_cast(MEM_mallocN(sizeof(bGPdata), 
__func__));
+  bGPdata *old_gpd = reinterpret_cast(MEM_mallocN(sizeof(bGPdata), 
__func__));
 
-  BLI_listbase_clear(>layers);
-  gpd->totlayer = gpd->totframe = gpd->totstroke = 0;
+  BLI_listbase_clear(_gpd->layers);
+  old_gpd->totlayer = old_gpd->totframe = old_gpd->totstroke = 0;
 
   int frm_offset{0};
   for (int lay_i = 0; lay_i < new_gpd.layers_size; lay_i++) {
-bGPDlayer *gpl = reinterpret_cast(MEM_mallocN(sizeof(bGPDlayer), __func__));
-const ::GPLayer *lay{new_gpd.layers_array + lay_i};
-sprintf(gpl->info, "%s", lay->name);
+bGPDlayer *old_gpl = reinterpret_cast(MEM_mallocN(sizeof(bGPDlayer), __func__));
+const ::GPLayer *new_gpl{new_gpd.layers_array + lay_i};
 
-BLI_listbase_clear(>mask_layers);
-BLI_listbase_clear(>frames);
+sprintf(old_gpl->info, "%s", new_gpl->name);
+
+BLI_listbase_clear(_gpl->mask_layers);
+BLI_listbase_clear(_gpl->frames);
 
 /* Add frames of correct layer index.
Assumes that frames in new data structure are sorted by layer index.
@@ -50,21 +52,21 @@ bGPdata *convert_new_to_old_gpencil_data(const GPData 
_gpd)
 while ((frm_offset < new_gpd.frames_size) &&
(new_gpd.frames_array[frm_offset].layer_index == lay_i)) {
   bGPDframe *gpf = reinterpret_cast(MEM_mallocN(sizeof(bGPDframe), __func__));
-  const ::GPFrame *frm{new_gpd.frames_array + frm_offset};
-  gpf->framenum = frm->start_time;
+  const ::GPFrame *new_gpf{new_gpd.frames_array + frm_offset};
+  gpf->framenum = new_gpf->start_time;
 
   BLI_listbase_clear(>strokes);
 
-  ++(gpd->totframe);
-  BLI_addtail(>frames, gpf);
+  ++(old_gpd->totframe);
+  BLI_addtail(_gpl->frames, gpf);
   ++frm_offset;
 }
 
-++(gpd->totlayer);
-BLI_addtail(>layers, gpl);
+++(old_gpd->totlayer);
+BLI_addtail(_gpd->layers, old_gpl);
   }
 
-  return gpd;
+  return old_gpd;
 }
 
 }  // namespace blender::bke
\ No newline at end of file

___
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] [7c123f2da59] gpencil-new-data-proposal: refactor

2022-12-12 Thread Amelie Fondevilla
Commit: 7c123f2da590f6fc4bc8a079f0f2822e05b647dd
Author: Amelie Fondevilla
Date:   Mon Dec 12 15:47:09 2022 +0100
Branches: gpencil-new-data-proposal
https://developer.blender.org/rB7c123f2da590f6fc4bc8a079f0f2822e05b647dd

refactor

===

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

===

diff --git 
a/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc 
b/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc
index ccd71823821..853d43f 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc
@@ -14,21 +14,15 @@ GPData convert_old_to_new_gpencil_data(bGPdata *old_gpd)
 {
   GPData new_gpd;
 
-  /* Add all layers */
-  Vector layer_names;
+  int layer_index{0};
   LISTBASE_FOREACH (bGPDlayer *, lay, _gpd->layers) {
-layer_names.append(std::string(lay->info));
-  }
-  new_gpd.add_layers(layer_names.as_span());
+new_gpd.add_layer(std::string(lay->info));
 
-  /* Add all frames */
-  int layer_index{-1};
-  LISTBASE_FOREACH (bGPDlayer *, lay, _gpd->layers) {
-Vector frame_indices;
 LISTBASE_FOREACH (bGPDframe *, frm, >frames) {
-  frame_indices.append(frm->framenum);
+  new_gpd.add_frame_on_layer(layer_index, frm->framenum);
 }
-new_gpd.add_frames_on_layer(++layer_index, frame_indices.as_span());
+
+++layer_index;
   }
 
   return new_gpd;

___
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] [dabc06f4893] gpencil-new-data-proposal: minor fix

2022-12-12 Thread Amelie Fondevilla
Commit: dabc06f48932e9a457c3a5b251da43265ff57d6c
Author: Amelie Fondevilla
Date:   Mon Dec 12 16:19:28 2022 +0100
Branches: gpencil-new-data-proposal
https://developer.blender.org/rBdabc06f48932e9a457c3a5b251da43265ff57d6c

minor fix

===

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

===

diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc 
b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
index 7665e6ea987..4a73ba82b80 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
@@ -215,6 +215,7 @@ static void compare_gpencil_data_structures(const GPData 
_gpd, const bGPdata
 
   ++frame_id;
 }
+++layer_id;
   }
 }

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


[Bf-blender-cvs] [4fdeccf829b] gpencil-new-data-proposal: test compare stroke point positions

2022-12-12 Thread Amelie Fondevilla
Commit: 4fdeccf829b57142f8a973ae80c5e29fa56517ac
Author: Amelie Fondevilla
Date:   Mon Dec 12 14:59:34 2022 +0100
Branches: gpencil-new-data-proposal
https://developer.blender.org/rB4fdeccf829b57142f8a973ae80c5e29fa56517ac

test compare stroke point positions

===

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

===

diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc 
b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
index c000f818edd..061b1e027fd 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
@@ -9,6 +9,7 @@
 #include "BLI_index_mask_ops.hh"
 #include "BLI_math_vec_types.hh"
 
+#include "BKE_curves.hh"
 #include "BKE_gpencil.h"
 
 #include "DNA_gpencil_types.h"
@@ -121,6 +122,58 @@ static void free_old_gpencil_data(bGPdata *gpd)
   MEM_SAFE_FREE(gpd);
 }
 
+static void insert_new_stroke_old_gpencil_data(bGPDframe *gpf,
+   int point_num,
+   float *position,
+   float *pressure)
+{
+
+  bGPDstroke *gps = reinterpret_cast(MEM_mallocN(sizeof(bGPDstroke), __func__));
+  gps->totpoints = point_num;
+  gps->points = reinterpret_cast(
+  MEM_calloc_arrayN(point_num, sizeof(bGPDspoint), __func__));
+  gps->triangles = nullptr;
+  gps->editcurve = nullptr;
+  gps->dvert = nullptr;
+
+  for (int pt_i = 0; pt_i < point_num; pt_i++) {
+bGPDspoint *pt = >points[pt_i];
+copy_v3_v3(>x, position + 3 * pt_i);
+pt->pressure = pressure[pt_i];
+  }
+
+  BLI_addtail(>strokes, gps);
+}
+
+static void compare_gpencil_stroke_data(const CurvesGeometry ,
+int curve_index,
+const bGPDstroke *stk)
+{
+  /* Stroke/Curve length */
+  int curve_point_num{curves.points_num_for_curve(curve_index)};
+  EXPECT_EQ(curve_point_num, stk->totpoints);
+  if (curve_point_num != stk->totpoints) {
+return;
+  }
+
+  /* Get curve attributes */
+  Span curve_positions{curves.positions()};
+
+  IndexRange curve_id{curves.points_for_curve(curve_index)};
+  int stk_point_id{0};
+  for (int curve_point_id : curve_id) {
+const bGPDspoint *stk_point{stk->points + stk_point_id};
+const float3 _pos{curve_positions[curve_point_id]};
+
+/* Point positions */
+EXPECT_EQ(curve_pos.x, stk_point->x);
+EXPECT_EQ(curve_pos.y, stk_point->y);
+EXPECT_EQ(curve_pos.z, stk_point->z);
+
+++stk_point_id;
+  }
+}
+
 static void compare_gpencil_data_structures(const GPData _gpd, const 
bGPdata *old_gpd)
 {
   /* Compare Layers */
@@ -128,6 +181,9 @@ static void compare_gpencil_data_structures(const GPData 
_gpd, const bGPdata
 
   int index{-1};
   LISTBASE_FOREACH (bGPDlayer *, old_gpl, _gpd->layers) {
+if (index >= new_gpd.layers_size) {
+  break;
+}
 const ::GPLayer *new_gpl = &(new_gpd.layers_array[++index]);
 EXPECT_EQ(std::strcmp(new_gpl->name, old_gpl->info), 0);
   }
@@ -136,22 +192,34 @@ static void compare_gpencil_data_structures(const GPData 
_gpd, const bGPdata
   EXPECT_EQ(new_gpd.frames_size, old_gpd->totframe);
 
   /* Get vector of frames. */
-  Vector> old_gpd_frames;
+  Vector> old_gpd_frames;
   int layer_id{0};
   LISTBASE_FOREACH (bGPDlayer *, old_gpl, _gpd->layers) {
 LISTBASE_FOREACH (bGPDframe *, old_gpf, _gpl->frames) {
-  old_gpd_frames.append_as(layer_id, old_gpf->framenum);
+  old_gpd_frames.append_as(layer_id, old_gpf);
 }
 ++layer_id;
   }
 
   for (int i = 0; i < new_gpd.frames_size; i++) {
-const ::GPFrame *new_gpf = new_gpd.frames_array + i;
+const GPFrame _gpf{new_gpd.frames(i)};
 int old_gpf_layer_index{old_gpd_frames[i].first};
-int old_gpf_frame_number{old_gpd_frames[i].second};
+const bGPDframe *old_gpf{old_gpd_frames[i].second};
+
+EXPECT_EQ(new_gpf.layer_index, old_gpf_layer_index);
+EXPECT_EQ(new_gpf.start_time, old_gpf->framenum);
 
-EXPECT_EQ(new_gpf->layer_index, old_gpf_layer_index);
-EXPECT_EQ(new_gpf->start_time, old_gpf_frame_number);
+EXPECT_EQ(new_gpf.strokes_num(), BLI_listbase_count(_gpf->strokes));
+
+int curve_index{0};
+LISTBASE_FOREACH (const bGPDstroke *, stk, _gpf->strokes) {
+  if (curve_index >= new_gpf.strokes_num()) {
+break;
+  }
+  compare_gpencil_stroke_data(new_gpf.strokes_as_curves(), curve_index, 
stk);
+
+  ++curve_index;
+}
   }
 }
 
@@ -484,4 +552,26 @@ TEST(gpencil_proposal, NewToOldConversion)
   free_old_gpencil_data(old_data);
 }
 
+TEST(gpencil_proposal, OldToNewStrokeConversion)
+{
+  int layers_n

[Bf-blender-cvs] [382e189e375] gpencil-new-data-proposal: refactor

2022-12-12 Thread Amelie Fondevilla
Commit: 382e189e375a97cc0c1a2be4e10ef09ef4685cd7
Author: Amelie Fondevilla
Date:   Mon Dec 12 15:33:37 2022 +0100
Branches: gpencil-new-data-proposal
https://developer.blender.org/rB382e189e375a97cc0c1a2be4e10ef09ef4685cd7

refactor

===

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

===

diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc 
b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
index 061b1e027fd..7665e6ea987 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
@@ -149,14 +149,14 @@ static void compare_gpencil_stroke_data(const 
CurvesGeometry ,
 int curve_index,
 const bGPDstroke *stk)
 {
-  /* Stroke/Curve length */
+  // Stroke/Curve length
   int curve_point_num{curves.points_num_for_curve(curve_index)};
   EXPECT_EQ(curve_point_num, stk->totpoints);
   if (curve_point_num != stk->totpoints) {
 return;
   }
 
-  /* Get curve attributes */
+  // Get curve attributes
   Span curve_positions{curves.positions()};
 
   IndexRange curve_id{curves.points_for_curve(curve_index)};
@@ -165,7 +165,7 @@ static void compare_gpencil_stroke_data(const 
CurvesGeometry ,
 const bGPDspoint *stk_point{stk->points + stk_point_id};
 const float3 _pos{curve_positions[curve_point_id]};
 
-/* Point positions */
+// Point positions
 EXPECT_EQ(curve_pos.x, stk_point->x);
 EXPECT_EQ(curve_pos.y, stk_point->y);
 EXPECT_EQ(curve_pos.z, stk_point->z);
@@ -176,49 +176,44 @@ static void compare_gpencil_stroke_data(const 
CurvesGeometry ,
 
 static void compare_gpencil_data_structures(const GPData _gpd, const 
bGPdata *old_gpd)
 {
-  /* Compare Layers */
   EXPECT_EQ(new_gpd.layers_size, old_gpd->totlayer);
+  EXPECT_EQ(new_gpd.frames_size, old_gpd->totframe);
 
-  int index{-1};
+  int layer_id{0};
+  int frame_id{0};
   LISTBASE_FOREACH (bGPDlayer *, old_gpl, _gpd->layers) {
-if (index >= new_gpd.layers_size) {
+if (layer_id >= new_gpd.layers_size) {
   break;
 }
-const ::GPLayer *new_gpl = &(new_gpd.layers_array[++index]);
-EXPECT_EQ(std::strcmp(new_gpl->name, old_gpl->info), 0);
-  }
 
-  /* Compare Frames */
-  EXPECT_EQ(new_gpd.frames_size, old_gpd->totframe);
+// Compare layer data
+const ::GPLayer *new_gpl = &(new_gpd.layers_array[layer_id]);
+EXPECT_EQ(std::strcmp(new_gpl->name, old_gpl->info), 0);
 
-  /* Get vector of frames. */
-  Vector> old_gpd_frames;
-  int layer_id{0};
-  LISTBASE_FOREACH (bGPDlayer *, old_gpl, _gpd->layers) {
 LISTBASE_FOREACH (bGPDframe *, old_gpf, _gpl->frames) {
-  old_gpd_frames.append_as(layer_id, old_gpf);
-}
-++layer_id;
-  }
+  if (frame_id >= new_gpd.frames_size) {
+break;
+  }
+  const GPFrame _gpf{new_gpd.frames(frame_id)};
 
-  for (int i = 0; i < new_gpd.frames_size; i++) {
-const GPFrame _gpf{new_gpd.frames(i)};
-int old_gpf_layer_index{old_gpd_frames[i].first};
-const bGPDframe *old_gpf{old_gpd_frames[i].second};
+  // Compare frame data
+  EXPECT_EQ(new_gpf.layer_index, layer_id);
+  EXPECT_EQ(new_gpf.start_time, old_gpf->framenum);
+  EXPECT_EQ(new_gpf.strokes_num(), BLI_listbase_count(_gpf->strokes));
 
-EXPECT_EQ(new_gpf.layer_index, old_gpf_layer_index);
-EXPECT_EQ(new_gpf.start_time, old_gpf->framenum);
+  int curve_index{0};
+  LISTBASE_FOREACH (const bGPDstroke *, stk, _gpf->strokes) {
+if (curve_index >= new_gpf.strokes_num()) {
+  break;
+}
 
-EXPECT_EQ(new_gpf.strokes_num(), BLI_listbase_count(_gpf->strokes));
+// Compare stroke data
+compare_gpencil_stroke_data(new_gpf.strokes_as_curves(), curve_index, 
stk);
 
-int curve_index{0};
-LISTBASE_FOREACH (const bGPDstroke *, stk, _gpf->strokes) {
-  if (curve_index >= new_gpf.strokes_num()) {
-break;
+++curve_index;
   }
-  compare_gpencil_stroke_data(new_gpf.strokes_as_curves(), curve_index, 
stk);
 
-  ++curve_index;
+  ++frame_id;
 }
   }
 }

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


[Bf-blender-cvs] [6e2b594d98d] gpencil-new-data-proposal: adding is empty method for gpencil frame in the API

2022-12-12 Thread Amelie Fondevilla
Commit: 6e2b594d98d00d3259b914f1ca35efa954fcf52c
Author: Amelie Fondevilla
Date:   Mon Dec 12 12:17:39 2022 +0100
Branches: gpencil-new-data-proposal
https://developer.blender.org/rB6e2b594d98d00d3259b914f1ca35efa954fcf52c

adding is empty method for gpencil frame in the API

===

M   source/blender/blenkernel/intern/gpencil_new_proposal.cc
M   source/blender/blenkernel/intern/gpencil_new_proposal.hh

===

diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal.cc 
b/source/blender/blenkernel/intern/gpencil_new_proposal.cc
index f176c451040..551e0bd58fe 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal.cc
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal.cc
@@ -172,9 +172,14 @@ const CurvesGeometry ::strokes_as_curves() const
   return CurvesGeometry::wrap(*this->strokes);
 }
 
+bool GPFrame::is_empty() const
+{
+  return (this->strokes == nullptr) || (this->strokes->curve_num == 0);
+}
+
 int GPFrame::strokes_num() const
 {
-  if (this->strokes == nullptr) {
+  if (this->is_empty()) {
 return 0;
   }
   return this->strokes->curve_num;
diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal.hh 
b/source/blender/blenkernel/intern/gpencil_new_proposal.hh
index 0a15315172c..6c485b897e1 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal.hh
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal.hh
@@ -257,6 +257,7 @@ class GPFrame : public ::GPFrame {
   CurvesGeometry _as_curves();
   const CurvesGeometry _as_curves() const;
 
+  bool is_empty() const;
   int strokes_num() const;
   int points_num() const;

___
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] [702c4eaaeb4] gpencil-new-data-proposal: overload strokes getter for const

2022-12-12 Thread Amelie Fondevilla
Commit: 702c4eaaeb46a9e07cb8ff3b2a3e1e9b26488bc0
Author: Amelie Fondevilla
Date:   Mon Dec 12 12:07:16 2022 +0100
Branches: gpencil-new-data-proposal
https://developer.blender.org/rB702c4eaaeb46a9e07cb8ff3b2a3e1e9b26488bc0

overload strokes getter for const

===

M   source/blender/blenkernel/intern/gpencil_new_proposal.cc
M   source/blender/blenkernel/intern/gpencil_new_proposal.hh

===

diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal.cc 
b/source/blender/blenkernel/intern/gpencil_new_proposal.cc
index 61200bff594..f176c451040 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal.cc
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal.cc
@@ -167,6 +167,11 @@ CurvesGeometry ::strokes_as_curves()
   return CurvesGeometry::wrap(*this->strokes);
 }
 
+const CurvesGeometry ::strokes_as_curves() const
+{
+  return CurvesGeometry::wrap(*this->strokes);
+}
+
 int GPFrame::strokes_num() const
 {
   if (this->strokes == nullptr) {
diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal.hh 
b/source/blender/blenkernel/intern/gpencil_new_proposal.hh
index a4a68345578..0a15315172c 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal.hh
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal.hh
@@ -255,6 +255,7 @@ class GPFrame : public ::GPFrame {
   bool operator==(const GPFrame ) const;
 
   CurvesGeometry _as_curves();
+  const CurvesGeometry _as_curves() const;
 
   int strokes_num() const;
   int points_num() const;

___
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] [e7aa313ffea] gpencil-new-data-proposal: minor fix, no functional change

2022-12-05 Thread Amelie Fondevilla
Commit: e7aa313ffea0998d3231cabc2c3d3a2d4fd06cc1
Author: Amelie Fondevilla
Date:   Mon Dec 5 15:29:44 2022 +0100
Branches: gpencil-new-data-proposal
https://developer.blender.org/rBe7aa313ffea0998d3231cabc2c3d3a2d4fd06cc1

minor fix, no functional change

===

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

===

diff --git 
a/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc 
b/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc
index 02513b45171..ccd71823821 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc
@@ -42,7 +42,6 @@ bGPdata *convert_new_to_old_gpencil_data(const GPData 
_gpd)
   gpd->totlayer = gpd->totframe = gpd->totstroke = 0;
 
   int frm_offset{0};
-  gpd->totlayer = new_gpd.layers_size;
   for (int lay_i = 0; lay_i < new_gpd.layers_size; lay_i++) {
 bGPDlayer *gpl = reinterpret_cast(MEM_mallocN(sizeof(bGPDlayer), __func__));
 const ::GPLayer *lay{new_gpd.layers_array + lay_i};
@@ -50,7 +49,6 @@ bGPdata *convert_new_to_old_gpencil_data(const GPData 
_gpd)
 
 BLI_listbase_clear(>mask_layers);
 BLI_listbase_clear(>frames);
-BLI_addtail(>layers, gpl);
 
 /* Add frames of correct layer index.
Assumes that frames in new data structure are sorted by layer index.
@@ -63,10 +61,13 @@ bGPdata *convert_new_to_old_gpencil_data(const GPData 
_gpd)
 
   BLI_listbase_clear(>strokes);
 
-  BLI_addtail(>frames, gpf);
   ++(gpd->totframe);
+  BLI_addtail(>frames, gpf);
   ++frm_offset;
 }
+
+++(gpd->totlayer);
+BLI_addtail(>layers, gpl);
   }
 
   return gpd;

___
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] [12c5ed6aca3] gpencil-new-data-proposal: new to old data structure : conversion of layers and frames, no strokes yet

2022-12-05 Thread Amelie Fondevilla
Commit: 12c5ed6aca3af178403b508ebe88e655c1285528
Author: Amelie Fondevilla
Date:   Mon Dec 5 15:01:14 2022 +0100
Branches: gpencil-new-data-proposal
https://developer.blender.org/rB12c5ed6aca3af178403b508ebe88e655c1285528

new to old data structure : conversion of layers and frames, no strokes yet

===

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

===

diff --git 
a/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc 
b/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc
index 17295b3c469..02513b45171 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc
@@ -38,6 +38,37 @@ bGPdata *convert_new_to_old_gpencil_data(const GPData 
_gpd)
 {
   bGPdata *gpd = reinterpret_cast(MEM_mallocN(sizeof(bGPdata), 
__func__));
 
+  BLI_listbase_clear(>layers);
+  gpd->totlayer = gpd->totframe = gpd->totstroke = 0;
+
+  int frm_offset{0};
+  gpd->totlayer = new_gpd.layers_size;
+  for (int lay_i = 0; lay_i < new_gpd.layers_size; lay_i++) {
+bGPDlayer *gpl = reinterpret_cast(MEM_mallocN(sizeof(bGPDlayer), __func__));
+const ::GPLayer *lay{new_gpd.layers_array + lay_i};
+sprintf(gpl->info, "%s", lay->name);
+
+BLI_listbase_clear(>mask_layers);
+BLI_listbase_clear(>frames);
+BLI_addtail(>layers, gpl);
+
+/* Add frames of correct layer index.
+   Assumes that frames in new data structure are sorted by layer index.
+*/
+while ((frm_offset < new_gpd.frames_size) &&
+   (new_gpd.frames_array[frm_offset].layer_index == lay_i)) {
+  bGPDframe *gpf = reinterpret_cast(MEM_mallocN(sizeof(bGPDframe), __func__));
+  const ::GPFrame *frm{new_gpd.frames_array + frm_offset};
+  gpf->framenum = frm->start_time;
+
+  BLI_listbase_clear(>strokes);
+
+  BLI_addtail(>frames, gpf);
+  ++(gpd->totframe);
+  ++frm_offset;
+}
+  }
+
   return gpd;
 }

___
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] [5ce987f254f] gpencil-new-data-proposal: new to old conversion initialisation : test and empty function

2022-12-05 Thread Amelie Fondevilla
Commit: 5ce987f254f447e9d84763ed04cef33701a8a8dc
Author: Amelie Fondevilla
Date:   Mon Dec 5 14:23:04 2022 +0100
Branches: gpencil-new-data-proposal
https://developer.blender.org/rB5ce987f254f447e9d84763ed04cef33701a8a8dc

new to old conversion initialisation : test and empty function

===

M   source/blender/blenkernel/intern/gpencil_new_proposal.hh
M   source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc
M   source/blender/blenkernel/intern/gpencil_new_proposal_test.cc

===

diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal.hh 
b/source/blender/blenkernel/intern/gpencil_new_proposal.hh
index 27d1f671327..e3a847e882a 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal.hh
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal.hh
@@ -350,7 +350,7 @@ class GPData : public ::GPData {
 };
 
 GPData convert_old_to_new_gpencil_data(bGPdata *old_gpd);
-bGPdata *convert_new_to_old_gpencil_data(/*const GreasePencil _gpd*/);
+bGPdata *convert_new_to_old_gpencil_data(const GPData _gpd);
 
 }  // namespace blender::bke
 
diff --git 
a/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc 
b/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc
index 2712d587fd7..17295b3c469 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc
@@ -34,11 +34,11 @@ GPData convert_old_to_new_gpencil_data(bGPdata *old_gpd)
   return new_gpd;
 }
 
-bGPdata *convert_new_to_old_gpencil_data(/*const GreasePencil _gpd*/)
+bGPdata *convert_new_to_old_gpencil_data(const GPData _gpd)
 {
-  bGPdata *old_gpd = reinterpret_cast(MEM_mallocN(sizeof(bGPdata), 
__func__));
+  bGPdata *gpd = reinterpret_cast(MEM_mallocN(sizeof(bGPdata), 
__func__));
 
-  return old_gpd;
+  return gpd;
 }
 
 }  // namespace blender::bke
\ No newline at end of file
diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc 
b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
index aad705e089b..7c910565ba1 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
@@ -477,4 +477,17 @@ TEST(gpencil_proposal, Old2NewConversion)
   free_old_gpencil_data(old_data);
 }
 
+TEST(gpencil_proposal, New2OldConversion)
+{
+  int layers_num = 2, frames_num = 3, strokes_num = 2, points_num = 2;
+
+  GPData data = build_gpencil_data(layers_num, frames_num, strokes_num, 
points_num);
+
+  bGPdata *old_data = convert_new_to_old_gpencil_data(data);
+
+  compare_data_structures(data, old_data);
+
+  free_old_gpencil_data(old_data);
+}
+
 }  // namespace blender::bke::gpencil::tests

___
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] [218793464d4] gpencil-new-data-proposal: fix comparison function to prevent seg fault if structures are not similar

2022-12-05 Thread Amelie Fondevilla
Commit: 218793464d452a561d160c34d5113a2b3afa9bd2
Author: Amelie Fondevilla
Date:   Mon Dec 5 14:22:04 2022 +0100
Branches: gpencil-new-data-proposal
https://developer.blender.org/rB218793464d452a561d160c34d5113a2b3afa9bd2

fix comparison function to prevent seg fault if structures are not similar

===

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

===

diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc 
b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
index 073155500ec..aad705e089b 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
@@ -126,34 +126,38 @@ static void compare_data_structures(const GPData , 
const bGPdata *ogpd)
   /* Compare Layers */
   EXPECT_EQ(ngpd.layers_size, ogpd->totlayer);
 
-  int offset{-1};
-  LISTBASE_FOREACH (bGPDlayer *, lay, >layers) {
-const ::GPLayer *nlay = &(ngpd.layers_array[++offset]);
+  if (ngpd.layers_size == ogpd->totlayer) {
+int offset{-1};
+LISTBASE_FOREACH (bGPDlayer *, lay, >layers) {
+  const ::GPLayer *nlay = &(ngpd.layers_array[++offset]);
 
-// Same name
-EXPECT_EQ(std::strcmp(nlay->name, lay->info), 0);
+  // Same name
+  EXPECT_EQ(std::strcmp(nlay->name, lay->info), 0);
+}
   }
 
   /* Compare Frames */
   EXPECT_EQ(ngpd.frames_size, ogpd->totframe);
 
-  // get plain list of frames
-  std::vector> ogpd_frames;
-  int layer_id{0};
-  LISTBASE_FOREACH (bGPDlayer *, lay, >layers) {
-LISTBASE_FOREACH (bGPDframe *, frm, >frames) {
-  ogpd_frames.emplace_back(layer_id, frm->framenum);
+  if (ngpd.frames_size == ogpd->totframe) {
+// get plain list of frames
+std::vector> ogpd_frames;
+int layer_id{0};
+LISTBASE_FOREACH (bGPDlayer *, lay, >layers) {
+  LISTBASE_FOREACH (bGPDframe *, frm, >frames) {
+ogpd_frames.emplace_back(layer_id, frm->framenum);
+  }
+  ++layer_id;
 }
-++layer_id;
-  }
 
-  for (int i = 0; i < ngpd.frames_size; i++) {
-const ::GPFrame *nfrm = ngpd.frames_array + i;
-int ofrm_layer_index{ogpd_frames[i].first};
-int ofrm_frame_number{ogpd_frames[i].second};
+for (int i = 0; i < ngpd.frames_size; i++) {
+  const ::GPFrame *nfrm = ngpd.frames_array + i;
+  int ofrm_layer_index{ogpd_frames[i].first};
+  int ofrm_frame_number{ogpd_frames[i].second};
 
-EXPECT_EQ(nfrm->layer_index, ofrm_layer_index);
-EXPECT_EQ(nfrm->start_time, ofrm_frame_number);
+  EXPECT_EQ(nfrm->layer_index, ofrm_layer_index);
+  EXPECT_EQ(nfrm->start_time, ofrm_frame_number);
+}
   }
 }

___
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] [f801624d545] gpencil-new-data-proposal: Merge branch 'master' into gpencil-new-data-proposal

2022-12-05 Thread Amelie Fondevilla
Commit: f801624d545583e5b035fd66436f1ca581b7ecf9
Author: Amelie Fondevilla
Date:   Mon Dec 5 10:24:37 2022 +0100
Branches: gpencil-new-data-proposal
https://developer.blender.org/rBf801624d545583e5b035fd66436f1ca581b7ecf9

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

===



===

diff --cc build_files/utils/make_bpy_wheel.py
index a0ac1306dda,9a33c9c1b68..9a33c9c1b68
mode 100644,100755..100644
--- a/build_files/utils/make_bpy_wheel.py
+++ b/build_files/utils/make_bpy_wheel.py

___
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] [c2c12a16e23] gpencil-new-data-proposal: old to new conversion + testing

2022-11-29 Thread Amelie Fondevilla
Commit: c2c12a16e23a56ab4d610d52a274bd796c63c265
Author: Amelie Fondevilla
Date:   Tue Nov 29 09:30:47 2022 +0100
Branches: gpencil-new-data-proposal
https://developer.blender.org/rBc2c12a16e23a56ab4d610d52a274bd796c63c265

old to new conversion + testing

===

M   source/blender/blenkernel/intern/gpencil_new_proposal.hh
M   source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc
M   source/blender/blenkernel/intern/gpencil_new_proposal_test.cc

===

diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal.hh 
b/source/blender/blenkernel/intern/gpencil_new_proposal.hh
index 64f6360e9aa..5b2818d5106 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal.hh
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal.hh
@@ -349,7 +349,7 @@ class GPData : public ::GPData {
   void update_frames_array();
 };
 
-GreasePencil convert_old_to_new_gpencil_data(const bGPdata *old_gpd);
+GPData convert_old_to_new_gpencil_data(bGPdata *old_gpd);
 bGPdata *convert_new_to_old_gpencil_data(const GreasePencil _gpd);
 
 }  // namespace blender::bke
diff --git 
a/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc 
b/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc
index ae9fa96a19a..c9e3e3b552a 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc
@@ -4,14 +4,32 @@
  * \ingroup bke
  */
 
+#include "BKE_gpencil.h"
 #include "DNA_gpencil_types.h"
 #include "gpencil_new_proposal.hh"
 
 namespace blender::bke {
 
-GreasePencil convert_old_to_new_gpencil_data(const bGPdata *old_gpd)
+GPData convert_old_to_new_gpencil_data(bGPdata *old_gpd)
 {
-  GreasePencil new_gpd;
+  GPData new_gpd;
+
+  /* Add all layers */
+  Vector layer_names;
+  LISTBASE_FOREACH (bGPDlayer *, lay, _gpd->layers) {
+layer_names.append(std::string(lay->info));
+  }
+  new_gpd.add_layers(layer_names.as_span());
+
+  /* Add all frames */
+  int layer_index{-1};
+  LISTBASE_FOREACH (bGPDlayer *, lay, _gpd->layers) {
+Vector frame_indices;
+LISTBASE_FOREACH (bGPDframe *, frm, >frames) {
+  frame_indices.append(frm->framenum);
+}
+new_gpd.add_frames_on_layer(++layer_index, frame_indices.as_span());
+  }
 
   return new_gpd;
 }
diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc 
b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
index f15eb03e8b8..f9ddd7727f1 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
@@ -121,6 +121,44 @@ static void free_old_gpencil_data(bGPdata *gpd)
   MEM_SAFE_FREE(gpd);
 }
 
+static void compare_data_structures(const GPData , const bGPdata *ogpd)
+{
+  /* Compare Layers */
+  EXPECT_EQ(ngpd.layers_size, ogpd->totlayer);
+
+  int offset{-1};
+  LISTBASE_FOREACH (bGPDlayer *, lay, >layers) {
+const ::GPLayer *nlay = &(ngpd.layers_array[++offset]);
+
+// Same name
+EXPECT_EQ(std::strcmp(nlay->name, lay->info), 0);
+  }
+
+  /* Compare Frames */
+  EXPECT_EQ(ngpd.frames_size, ogpd->totframe);
+
+  // get plain list of frames
+  std::vector> ogpd_frames;
+  offset = 0;
+  LISTBASE_FOREACH (bGPDlayer *, lay, >layers) {
+LISTBASE_FOREACH (bGPDframe *, frm, >frames) {
+  ogpd_frames.push_back({offset, frm->framenum});
+}
+++offset;
+  }
+
+  // FIXME: this fails because in new data structure
+  // frames are sorted by frame_nb and then layer_index
+  for (int i = 0; i < ngpd.frames_size; i++) {
+const ::GPFrame *nfrm = ngpd.frames_array + i;
+int ofrm_layer_index{ogpd_frames[i].first};
+int ofrm_frame_number{ogpd_frames[i].second};
+
+EXPECT_EQ(nfrm->layer_index, ofrm_layer_index);
+EXPECT_EQ(nfrm->start_time, ofrm_frame_number);
+  }
+}
+
 TEST(gpencil_proposal, EmptyGPData)
 {
   GPData data;
@@ -426,11 +464,13 @@ TEST(gpencil_proposal, TimeMultiFrameTransformStrokes)
 
 TEST(gpencil_proposal, Old2NewConversion)
 {
-  int layers_num = 10, frames_num = 20, strokes_num = 10, points_num = 100;
+  int layers_num = 2, frames_num = 2, strokes_num = 2, points_num = 2;
 
   bGPdata *old_data = build_old_gpencil_data(layers_num, frames_num, 
strokes_num, points_num);
 
-  GreasePencil data = convert_old_to_new_gpencil_data(old_data);
+  GPData data = convert_old_to_new_gpencil_data(old_data);
+
+  compare_data_structures(data, old_data);
 
   free_old_gpencil_data(old_data);
 }

___
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] [26aa59e3f20] gpencil-new-data-proposal: minor changes

2022-11-29 Thread Amelie Fondevilla
Commit: 26aa59e3f20f4fac72865815bc7d62734a4c1533
Author: Amelie Fondevilla
Date:   Tue Nov 29 10:27:06 2022 +0100
Branches: gpencil-new-data-proposal
https://developer.blender.org/rB26aa59e3f20f4fac72865815bc7d62734a4c1533

minor changes

===

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

===

diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc 
b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
index 1ccfd6aaa91..073155500ec 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
@@ -139,12 +139,12 @@ static void compare_data_structures(const GPData , 
const bGPdata *ogpd)
 
   // get plain list of frames
   std::vector> ogpd_frames;
-  offset = 0;
+  int layer_id{0};
   LISTBASE_FOREACH (bGPDlayer *, lay, >layers) {
 LISTBASE_FOREACH (bGPDframe *, frm, >frames) {
-  ogpd_frames.push_back({offset, frm->framenum});
+  ogpd_frames.emplace_back(layer_id, frm->framenum);
 }
-++offset;
+++layer_id;
   }
 
   for (int i = 0; i < ngpd.frames_size; i++) {
@@ -462,7 +462,7 @@ TEST(gpencil_proposal, TimeMultiFrameTransformStrokes)
 
 TEST(gpencil_proposal, Old2NewConversion)
 {
-  int layers_num = 2, frames_num = 2, strokes_num = 2, points_num = 2;
+  int layers_num = 2, frames_num = 3, strokes_num = 2, points_num = 2;
 
   bGPdata *old_data = build_old_gpencil_data(layers_num, frames_num, 
strokes_num, points_num);

___
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] [bb637f68d81] gpencil-new-data-proposal: commented unused param to remove warning + removed an obsolete comment

2022-11-29 Thread Amelie Fondevilla
Commit: bb637f68d81822e88d67edd57de2ffd342fc55c8
Author: Amelie Fondevilla
Date:   Tue Nov 29 10:14:25 2022 +0100
Branches: gpencil-new-data-proposal
https://developer.blender.org/rBbb637f68d81822e88d67edd57de2ffd342fc55c8

commented unused param to remove warning + removed an obsolete comment

===

M   source/blender/blenkernel/intern/gpencil_new_proposal.hh
M   source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc
M   source/blender/blenkernel/intern/gpencil_new_proposal_test.cc

===

diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal.hh 
b/source/blender/blenkernel/intern/gpencil_new_proposal.hh
index 5b2818d5106..27d1f671327 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal.hh
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal.hh
@@ -350,7 +350,7 @@ class GPData : public ::GPData {
 };
 
 GPData convert_old_to_new_gpencil_data(bGPdata *old_gpd);
-bGPdata *convert_new_to_old_gpencil_data(const GreasePencil _gpd);
+bGPdata *convert_new_to_old_gpencil_data(/*const GreasePencil _gpd*/);
 
 }  // namespace blender::bke
 
diff --git 
a/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc 
b/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc
index c9e3e3b552a..2712d587fd7 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc
@@ -34,7 +34,7 @@ GPData convert_old_to_new_gpencil_data(bGPdata *old_gpd)
   return new_gpd;
 }
 
-bGPdata *convert_new_to_old_gpencil_data(const GreasePencil _gpd)
+bGPdata *convert_new_to_old_gpencil_data(/*const GreasePencil _gpd*/)
 {
   bGPdata *old_gpd = reinterpret_cast(MEM_mallocN(sizeof(bGPdata), 
__func__));
 
diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc 
b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
index f9ddd7727f1..1ccfd6aaa91 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
@@ -147,8 +147,6 @@ static void compare_data_structures(const GPData , 
const bGPdata *ogpd)
 ++offset;
   }
 
-  // FIXME: this fails because in new data structure
-  // frames are sorted by frame_nb and then layer_index
   for (int i = 0; i < ngpd.frames_size; i++) {
 const ::GPFrame *nfrm = ngpd.frames_array + i;
 int ofrm_layer_index{ogpd_frames[i].first};

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


[Bf-blender-cvs] [4c87f4f58d5] gpencil-new-data-proposal: setting up conversion functions and test, doing nothing for now

2022-11-29 Thread Amelie Fondevilla
Commit: 4c87f4f58d5803df94f05b41a52a0db7c61f8e2b
Author: Amelie Fondevilla
Date:   Thu Nov 24 10:22:10 2022 +0100
Branches: gpencil-new-data-proposal
https://developer.blender.org/rB4c87f4f58d5803df94f05b41a52a0db7c61f8e2b

setting up conversion functions and test, doing nothing for now

===

M   source/blender/blenkernel/intern/gpencil_new_proposal.hh
M   source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc
M   source/blender/blenkernel/intern/gpencil_new_proposal_test.cc

===

diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal.hh 
b/source/blender/blenkernel/intern/gpencil_new_proposal.hh
index 94935c8afef..64f6360e9aa 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal.hh
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal.hh
@@ -349,6 +349,9 @@ class GPData : public ::GPData {
   void update_frames_array();
 };
 
+GreasePencil convert_old_to_new_gpencil_data(const bGPdata *old_gpd);
+bGPdata *convert_new_to_old_gpencil_data(const GreasePencil _gpd);
+
 }  // namespace blender::bke
 
 #ifdef __cplusplus
diff --git 
a/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc 
b/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc
index 234b5170e38..ae9fa96a19a 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal_conversion.cc
@@ -4,8 +4,23 @@
  * \ingroup bke
  */
 
+#include "DNA_gpencil_types.h"
 #include "gpencil_new_proposal.hh"
 
 namespace blender::bke {
 
-} // namespace blender::bke
\ No newline at end of file
+GreasePencil convert_old_to_new_gpencil_data(const bGPdata *old_gpd)
+{
+  GreasePencil new_gpd;
+
+  return new_gpd;
+}
+
+bGPdata *convert_new_to_old_gpencil_data(const GreasePencil _gpd)
+{
+  bGPdata *old_gpd = reinterpret_cast(MEM_mallocN(sizeof(bGPdata), 
__func__));
+
+  return old_gpd;
+}
+
+}  // namespace blender::bke
\ No newline at end of file
diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc 
b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
index 026f3cf1f9e..630a297469a 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
@@ -420,4 +420,15 @@ TEST(gpencil_proposal, TimeMultiFrameTransformStrokes)
   free_old_gpencil_data(old_data);
 }
 
+TEST(gpencil_proposal, Old2NewConversion)
+{
+  int layers_num = 10, frames_num = 20, strokes_num = 10, points_num = 100;
+
+  bGPdata *old_data = build_old_gpencil_data(layers_num, frames_num, 
strokes_num, points_num);
+
+  GreasePencil data = convert_old_to_new_gpencil_data(old_data);
+
+  free_old_gpencil_data(old_data);
+}
+
 }  // namespace blender::bke::gpencil::tests

___
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] [4695e1c6627] gpencil-new-data-proposal: add grease pencil data statistics in build function

2022-11-29 Thread Amelie Fondevilla
Commit: 4695e1c662771c754bc7ba1b7fedb514bcc3328b
Author: Amelie Fondevilla
Date:   Thu Nov 24 14:42:33 2022 +0100
Branches: gpencil-new-data-proposal
https://developer.blender.org/rB4695e1c662771c754bc7ba1b7fedb514bcc3328b

add grease pencil data statistics in build function

===

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

===

diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc 
b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
index 630a297469a..f15eb03e8b8 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal_test.cc
@@ -55,6 +55,7 @@ static bGPdata *build_old_gpencil_data(int num_layers,
 {
   bGPdata *gpd = reinterpret_cast(MEM_mallocN(sizeof(bGPdata), 
__func__));
   BLI_listbase_clear(>layers);
+  gpd->totlayer = gpd->totframe = gpd->totstroke = 0;
   for (int i = 0; i < num_layers; i++) {
 bGPDlayer *gpl = reinterpret_cast(MEM_mallocN(sizeof(bGPDlayer), __func__));
 sprintf(gpl->info, "%s%d", "GPLayer", i);
@@ -85,10 +86,13 @@ static bGPdata *build_old_gpencil_data(int num_layers,
 
 BLI_addtail(>strokes, gps);
   }
+  gpd->totstroke += strokes_per_frame;
   BLI_addtail(>frames, gpf);
 }
+gpd->totframe += frames_per_layer;
 BLI_addtail(>layers, gpl);
   }
+  gpd->totlayer += num_layers;
 
   return gpd;
 }

___
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] [4911529f1b4] gpencil-new-data-proposal: Move GPDataRuntime function implementations to .cc file

2022-11-23 Thread Amelie Fondevilla
Commit: 4911529f1b48313f5e23d1a7acd9e1cda658357d
Author: Amelie Fondevilla
Date:   Wed Nov 23 15:11:05 2022 +0100
Branches: gpencil-new-data-proposal
https://developer.blender.org/rB4911529f1b48313f5e23d1a7acd9e1cda658357d

Move GPDataRuntime function implementations to .cc file

===

M   source/blender/blenkernel/intern/gpencil_new_proposal.cc
M   source/blender/blenkernel/intern/gpencil_new_proposal.hh

===

diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal.cc 
b/source/blender/blenkernel/intern/gpencil_new_proposal.cc
index 52a0a253c51..e826a07d4a1 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal.cc
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal.cc
@@ -48,6 +48,11 @@ IndexMask GPLayerGroup::layers_index_mask()
   return {reinterpret_cast(this->layer_indices), 
this->layer_indices_size};
 }
 
+IndexMask GPDataRuntime::frame_index_masks_cache_for_layer(int layer_index)
+{
+  return frame_index_masks_cache.lookup(layer_index).as_span();
+}
+
 Span GPStroke::points_positions() const
 {
   return {geometry_->positions().begin() + offset_, points_num_};
diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal.hh 
b/source/blender/blenkernel/intern/gpencil_new_proposal.hh
index 27850f0e5df..0f6afefa692 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal.hh
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal.hh
@@ -170,10 +170,7 @@ class GPDataRuntime {
   mutable Map> frame_index_masks_cache;
   mutable std::mutex frame_index_masks_cache_mutex;
 
-  IndexMask frame_index_masks_cache_for_layer(int layer_index)
-  {
-return frame_index_masks_cache.lookup(layer_index).as_span();
-  }
+  IndexMask frame_index_masks_cache_for_layer(int layer_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] [b338b7c2b6e] gpencil-new-data-proposal: Move GPLayer function implementations to .cc file

2022-11-23 Thread Amelie Fondevilla
Commit: b338b7c2b6e052cd6be113c5069b1e30311ffc2d
Author: Amelie Fondevilla
Date:   Wed Nov 23 15:32:57 2022 +0100
Branches: gpencil-new-data-proposal
https://developer.blender.org/rBb338b7c2b6e052cd6be113c5069b1e30311ffc2d

Move GPLayer function implementations to .cc file

===

M   source/blender/blenkernel/intern/gpencil_new_proposal.cc
M   source/blender/blenkernel/intern/gpencil_new_proposal.hh

===

diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal.cc 
b/source/blender/blenkernel/intern/gpencil_new_proposal.cc
index 2cc5cdf8275..e424cd32d37 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal.cc
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal.cc
@@ -209,6 +209,17 @@ GPStroke GPFrame::add_new_stroke(int new_points_num)
   return {reinterpret_cast(this->strokes), new_points_num, 
orig_last_offset};
 }
 
+/* GPLayer */
+GPLayer::GPLayer(const StringRefNull name)
+{
+  strcpy(this->name, name.c_str());
+}
+
+bool GPLayer::operator==(const GPLayer ) const
+{
+  return STREQ(this->name, other.name);
+}
+
 /* GPData */
 GPData::GPData(const int layers_size, const int frame_size)
 {
diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal.hh 
b/source/blender/blenkernel/intern/gpencil_new_proposal.hh
index 71b54f6b133..d98e2d647ab 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal.hh
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal.hh
@@ -246,17 +246,11 @@ class GPLayer : public ::GPLayer {
   {
   }
 
-  GPLayer(const StringRefNull name)
-  {
-strcpy(this->name, name.c_str());
-  }
+  GPLayer(const StringRefNull name);
 
   ~GPLayer() = default;
 
-  bool operator==(const GPLayer ) const
-  {
-return STREQ(this->name, other.name);
-  }
+  bool operator==(const GPLayer ) const;
 };
 
 class GPData : public ::GPData {

___
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] [20d88e2e6a7] gpencil-new-data-proposal: Adding some comments

2022-11-23 Thread Amelie Fondevilla
Commit: 20d88e2e6a7e77eac0db0c8e2272279aecbb85d0
Author: Amelie Fondevilla
Date:   Wed Nov 23 15:21:57 2022 +0100
Branches: gpencil-new-data-proposal
https://developer.blender.org/rB20d88e2e6a7e77eac0db0c8e2272279aecbb85d0

Adding some comments

===

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

===

diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal.cc 
b/source/blender/blenkernel/intern/gpencil_new_proposal.cc
index e826a07d4a1..2cc5cdf8275 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal.cc
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal.cc
@@ -18,6 +18,7 @@
 
 namespace blender::bke {
 
+/* GPLayerGroup */
 GPLayerGroup::GPLayerGroup()
 {
   this->children = nullptr;
@@ -48,11 +49,13 @@ IndexMask GPLayerGroup::layers_index_mask()
   return {reinterpret_cast(this->layer_indices), 
this->layer_indices_size};
 }
 
+/* GPDataRuntime */
 IndexMask GPDataRuntime::frame_index_masks_cache_for_layer(int layer_index)
 {
   return frame_index_masks_cache.lookup(layer_index).as_span();
 }
 
+/* GPStroke */
 Span GPStroke::points_positions() const
 {
   return {geometry_->positions().begin() + offset_, points_num_};
@@ -73,6 +76,7 @@ void GPStroke::transform(float4x4 matrix)
   });
 }
 
+/* GPFrame */
 GPFrame::GPFrame(int start_frame, int end_frame)
 {
   this->start_time = start_frame;
@@ -205,6 +209,7 @@ GPStroke GPFrame::add_new_stroke(int new_points_num)
   return {reinterpret_cast(this->strokes), new_points_num, 
orig_last_offset};
 }
 
+/* GPData */
 GPData::GPData(const int layers_size, const int frame_size)
 {
   BLI_assert(layers_size >= 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] [7485e8f9aa6] gpencil-new-data-proposal: Move GPLayerGroup function implementations to .cc file

2022-11-23 Thread Amelie Fondevilla
Commit: 7485e8f9aa6cd077ddd545249ed979c4855a86d9
Author: Amelie Fondevilla
Date:   Wed Nov 23 15:09:29 2022 +0100
Branches: gpencil-new-data-proposal
https://developer.blender.org/rB7485e8f9aa6cd077ddd545249ed979c4855a86d9

Move GPLayerGroup function implementations to .cc file

===

M   source/blender/blenkernel/intern/gpencil_new_proposal.cc
M   source/blender/blenkernel/intern/gpencil_new_proposal.hh

===

diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal.cc 
b/source/blender/blenkernel/intern/gpencil_new_proposal.cc
index fefccfc101c..52a0a253c51 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal.cc
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal.cc
@@ -18,6 +18,36 @@
 
 namespace blender::bke {
 
+GPLayerGroup::GPLayerGroup()
+{
+  this->children = nullptr;
+  this->children_size = 0;
+  this->layer_indices = nullptr;
+  this->layer_indices_size = 0;
+}
+
+GPLayerGroup::GPLayerGroup(const StringRefNull name) : GPLayerGroup()
+{
+  BLI_assert(name.size() < 128);
+  strcpy(this->name, name.c_str());
+}
+
+GPLayerGroup::~GPLayerGroup()
+{
+  /* Recursivly free the children of this layer group first. */
+  for (int i = 0; i < this->children_size; i++) {
+MEM_delete(>children[i]);
+  }
+  /* Then free its data. */
+  MEM_SAFE_FREE(this->children);
+  MEM_SAFE_FREE(this->layer_indices);
+}
+
+IndexMask GPLayerGroup::layers_index_mask()
+{
+  return {reinterpret_cast(this->layer_indices), 
this->layer_indices_size};
+}
+
 Span GPStroke::points_positions() const
 {
   return {geometry_->positions().begin() + offset_, points_num_};
diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal.hh 
b/source/blender/blenkernel/intern/gpencil_new_proposal.hh
index 70692148e01..27850f0e5df 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal.hh
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal.hh
@@ -152,35 +152,12 @@ namespace blender::bke {
 
 class GPLayerGroup : ::GPLayerGroup { /* Unused for now. Placeholder class. */
  public:
-  GPLayerGroup()
-  {
-this->children = nullptr;
-this->children_size = 0;
-this->layer_indices = nullptr;
-this->layer_indices_size = 0;
-  }
-
-  GPLayerGroup(const StringRefNull name) : GPLayerGroup()
-  {
-BLI_assert(name.size() < 128);
-strcpy(this->name, name.c_str());
-  }
+  GPLayerGroup();
+  GPLayerGroup(const StringRefNull name);
 
-  ~GPLayerGroup()
-  {
-/* Recursivly free the children of this layer group first. */
-for (int i = 0; i < this->children_size; i++) {
-  MEM_delete(>children[i]);
-}
-/* Then free its data. */
-MEM_SAFE_FREE(this->children);
-MEM_SAFE_FREE(this->layer_indices);
-  }
+  ~GPLayerGroup();
 
-  IndexMask layers_index_mask()
-  {
-return {reinterpret_cast(this->layer_indices), 
this->layer_indices_size};
-  }
+  IndexMask layers_index_mask();
 };
 
 class GPDataRuntime {

___
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] [0691684beb7] gpencil-new-data-proposal: Remove unused import

2022-11-23 Thread Amelie Fondevilla
Commit: 0691684beb7acda6b75d9d1975da73b2b5197691
Author: Amelie Fondevilla
Date:   Wed Nov 23 15:28:40 2022 +0100
Branches: gpencil-new-data-proposal
https://developer.blender.org/rB0691684beb7acda6b75d9d1975da73b2b5197691

Remove unused import

===

M   source/blender/blenkernel/intern/gpencil_new_proposal.hh

===

diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal.hh 
b/source/blender/blenkernel/intern/gpencil_new_proposal.hh
index 0f6afefa692..71b54f6b133 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal.hh
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal.hh
@@ -8,8 +8,6 @@
 
 #include "BKE_curves.hh"
 
-#include "BLI_index_mask_ops.hh"
-
 #include "DNA_ID.h"
 #include "DNA_curves_types.h"
 #include "DNA_customdata_types.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] [87778317b0d] gpencil-new-data-proposal: Move GPData function implementations to .cc file

2022-11-23 Thread Amelie Fondevilla
Commit: 87778317b0db6f660b754b9bc144a2b5dfd9a988
Author: Amelie Fondevilla
Date:   Wed Nov 23 15:02:57 2022 +0100
Branches: gpencil-new-data-proposal
https://developer.blender.org/rB87778317b0db6f660b754b9bc144a2b5dfd9a988

Move GPData function implementations to .cc file

===

M   source/blender/blenkernel/intern/gpencil_new_proposal.cc
M   source/blender/blenkernel/intern/gpencil_new_proposal.hh

===

diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal.cc 
b/source/blender/blenkernel/intern/gpencil_new_proposal.cc
index 7bab439fe8e..fefccfc101c 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal.cc
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal.cc
@@ -170,4 +170,419 @@ GPStroke GPFrame::add_new_stroke(int new_points_num)
   return {reinterpret_cast(this->strokes), new_points_num, 
orig_last_offset};
 }
 
+GPData::GPData(const int layers_size, const int frame_size)
+{
+  BLI_assert(layers_size >= 0);
+  BLI_assert(frame_size >= 0);
+
+  this->frames_size = frame_size;
+  this->layers_size = layers_size;
+
+  if (this->frames_size > 0) {
+this->frames_array = reinterpret_cast<::GPFrame *>(
+MEM_malloc_arrayN(this->frames_size, sizeof(::GPFrame), __func__));
+default_construct_n(reinterpret_cast(this->frames_array), 
this->frames_size);
+  }
+  else {
+this->frames_array = nullptr;
+  }
+  CustomData_reset(>frame_data);
+
+  if (this->layers_size > 0) {
+this->layers_array = reinterpret_cast<::GPLayer *>(
+MEM_malloc_arrayN(this->layers_size, sizeof(::GPLayer), __func__));
+default_construct_n(reinterpret_cast(this->layers_array), 
this->layers_size);
+this->active_layer_index = 0;
+  }
+  else {
+this->layers_array = nullptr;
+this->active_layer_index = -1;
+  }
+
+  this->default_group = MEM_new<::GPLayerGroup>(__func__);
+
+  this->runtime = MEM_new(__func__);
+}
+
+GPData::GPData(const GPData ) : GPData(other.layers_size, 
other.frames_size)
+{
+  copy_gpdata(*this, other);
+}
+
+GPData ::operator=(const GPData )
+{
+  if (this != ) {
+copy_gpdata(*this, other);
+  }
+  return *this;
+}
+
+GPData::GPData(GPData &) : GPData(other.layers_size, other.frames_size)
+{
+  move_gpdata(*this, other);
+}
+
+GPData ::operator=(GPData &)
+{
+  if (this != ) {
+move_gpdata(*this, other);
+  }
+  return *this;
+}
+
+GPData::~GPData()
+{
+  /* Free frames and frame custom data. */
+  destruct_n(reinterpret_cast(this->frames_array), 
this->frames_size);
+  MEM_SAFE_FREE(this->frames_array);
+  CustomData_free(>frame_data, this->frames_size);
+
+  /* Free layer and layer groups. */
+  destruct_n(reinterpret_cast(this->layers_array), 
this->layers_size);
+  MEM_SAFE_FREE(this->layers_array);
+  MEM_delete(reinterpret_cast(this->default_group));
+  this->default_group = nullptr;
+
+  /* Free the runtime structure. */
+  MEM_delete(this->runtime);
+  this->runtime = nullptr;
+}
+
+Span GPData::frames() const
+{
+  return {reinterpret_cast(this->frames_array), 
this->frames_size};
+}
+
+const GPFrame ::frames(int index) const
+{
+  return this->frames()[index];
+}
+
+MutableSpan GPData::frames_for_write()
+{
+  return {reinterpret_cast(this->frames_array), this->frames_size};
+}
+
+GPFrame ::frames_for_write(int index)
+{
+  return this->frames_for_write()[index];
+}
+
+IndexMask GPData::frames_on_layer(int layer_index) const
+{
+  if (layer_index < 0 || layer_index > this->layers_size) {
+return IndexMask();
+  }
+
+  /* If the indices are cached for this layer, use the cache. */
+  if (this->runtime->frame_index_masks_cache.contains(layer_index)) {
+return this->runtime->frame_index_masks_cache_for_layer(layer_index);
+  }
+
+  /* A double checked lock. */
+  std::scoped_lock{this->runtime->frame_index_masks_cache_mutex};
+  if (this->runtime->frame_index_masks_cache.contains(layer_index)) {
+return this->runtime->frame_index_masks_cache_for_layer(layer_index);
+  }
+
+  Vector indices;
+  const IndexMask mask = index_mask_ops::find_indices_based_on_predicate(
+  IndexMask(this->frames_size), 1024, indices, [&](const int index) {
+return this->frames()[index].layer_index == layer_index;
+  });
+
+  /* Cache the resulting index mask. */
+  this->runtime->frame_index_masks_cache.add(layer_index, std::move(indices));
+  return mask;
+}
+
+IndexMask GPData::frames_on_layer(GPLayer ) const
+{
+  int index = this->layers().first_index_try(layer);
+  if (index == -1) {
+return IndexMask();
+  }
+  return frames_on_layer(index);
+}
+
+IndexMask GPData::frames_on_active_layer() const
+{
+  return frames_on_layer(this->active_layer_index);
+}
+
+Span G

[Bf-blender-cvs] [ecac4ce93e9] gpencil-new-data-proposal: Move GPFrame function implementations to .cc file

2022-11-23 Thread Amelie Fondevilla
Commit: ecac4ce93e96fc96b3068fe572f878fcc69525dc
Author: Amelie Fondevilla
Date:   Wed Nov 23 14:38:40 2022 +0100
Branches: gpencil-new-data-proposal
https://developer.blender.org/rBecac4ce93e96fc96b3068fe572f878fcc69525dc

Move GPFrame function implementations to .cc file

===

M   source/blender/blenkernel/intern/gpencil_new_proposal.cc
M   source/blender/blenkernel/intern/gpencil_new_proposal.hh

===

diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal.cc 
b/source/blender/blenkernel/intern/gpencil_new_proposal.cc
index 1a3825ef9ca..7bab439fe8e 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal.cc
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal.cc
@@ -38,4 +38,136 @@ void GPStroke::transform(float4x4 matrix)
   });
 }
 
+GPFrame::GPFrame(int start_frame, int end_frame)
+{
+  this->start_time = start_frame;
+  this->end_time = end_frame;
+  this->strokes = nullptr;
+}
+
+GPFrame::GPFrame(const GPFrame ) : GPFrame(other.start_time, 
other.end_time)
+{
+  if (other.strokes != nullptr) {
+/* Make sure old strokes are freed before copying. */
+MEM_SAFE_FREE(this->strokes);
+this->strokes = MEM_new(__func__);
+
+*reinterpret_cast(this->strokes) = 
CurvesGeometry::wrap(*other.strokes);
+  }
+  this->layer_index = other.layer_index;
+}
+
+GPFrame ::operator=(const GPFrame )
+{
+  if (this !=  && other.strokes != nullptr) {
+/* Make sure old strokes are freed before copying. */
+MEM_SAFE_FREE(this->strokes);
+this->strokes = MEM_new(__func__);
+
+*reinterpret_cast(this->strokes) = 
CurvesGeometry::wrap(*other.strokes);
+  }
+  this->layer_index = other.layer_index;
+  this->start_time = other.start_time;
+  this->end_time = other.end_time;
+  return *this;
+}
+
+GPFrame::GPFrame(GPFrame &) : GPFrame(other.start_time, other.end_time)
+{
+  if (this != ) {
+std::swap(this->strokes, other.strokes);
+other.strokes = nullptr;
+  }
+  this->layer_index = other.layer_index;
+}
+
+GPFrame ::operator=(GPFrame &)
+{
+  if (this != ) {
+std::swap(this->strokes, other.strokes);
+other.strokes = nullptr;
+  }
+  this->layer_index = other.layer_index;
+  this->start_time = other.start_time;
+  this->end_time = other.end_time;
+  return *this;
+}
+
+GPFrame::~GPFrame()
+{
+  MEM_delete(reinterpret_cast(this->strokes));
+  this->strokes = nullptr;
+}
+
+bool GPFrame::operator<(const GPFrame ) const
+{
+  if (this->start_time == other.start_time) {
+return this->layer_index < other.layer_index;
+  }
+  return this->start_time < other.start_time;
+}
+
+bool GPFrame::operator<(const std::pair elem) const
+{
+  if (this->start_time == elem.second) {
+return this->layer_index < elem.first;
+  }
+  return this->start_time < elem.second;
+}
+
+bool GPFrame::operator==(const GPFrame ) const
+{
+  return this->layer_index == other.layer_index && this->start_time == 
other.start_time;
+}
+
+CurvesGeometry ::strokes_as_curves()
+{
+  return CurvesGeometry::wrap(*this->strokes);
+}
+
+int GPFrame::strokes_num() const
+{
+  if (this->strokes == nullptr) {
+return 0;
+  }
+  return this->strokes->curve_num;
+}
+
+int GPFrame::points_num() const
+{
+  if (this->strokes == nullptr) {
+return 0;
+  }
+  return this->strokes->point_num;
+}
+
+Vector GPFrame::strokes_for_write()
+{
+  Vector strokes;
+  for (const int i : 
this->strokes_as_curves().offsets().drop_back(1).index_range()) {
+int offset = this->strokes_as_curves().offsets()[i];
+int length = this->strokes_as_curves().offsets()[i + 1] - offset;
+strokes.append({reinterpret_cast(this->strokes), length, 
offset});
+  }
+  return strokes;
+}
+
+GPStroke GPFrame::add_new_stroke(int new_points_num)
+{
+  if (this->strokes == nullptr) {
+this->strokes = MEM_new(__func__);
+  }
+  CurvesGeometry  = this->strokes_as_curves();
+  int orig_last_offset = strokes.offsets().last();
+
+  strokes.resize(strokes.points_num() + new_points_num, strokes.curves_num() + 
1);
+  strokes.offsets_for_write().last() = strokes.points_num();
+
+  /* Use poly type by default. */
+  strokes.curve_types_for_write().last() = CURVE_TYPE_POLY;
+
+  strokes.tag_topology_changed();
+  return {reinterpret_cast(this->strokes), new_points_num, 
orig_last_offset};
+}
+
 }  // namespace blender::bke
\ No newline at end of file
diff --git a/source/blender/blenkernel/intern/gpencil_new_proposal.hh 
b/source/blender/blenkernel/intern/gpencil_new_proposal.hh
index 80f23169115..1ee5da8550c 100644
--- a/source/blender/blenkernel/intern/gpencil_new_proposal.hh
+++ b/source/blender/blenkernel/intern/gpencil_new_proposal.hh
@@ -125,8 +125,8 @@ typedef struct GPData {
 } GPData;
 
 /**
- * This wo

[Bf-blender-cvs] [d46317cf3c5] master: Fix T101775: grease pencil keyframe not filtered in dopesheet summary

2022-11-15 Thread Amelie Fondevilla
Commit: d46317cf3c5eac11d9a034ed1c14523d5302340c
Author: Amelie Fondevilla
Date:   Tue Nov 15 09:23:19 2022 +0100
Branches: master
https://developer.blender.org/rBd46317cf3c5eac11d9a034ed1c14523d5302340c

Fix T101775: grease pencil keyframe not filtered in dopesheet summary

Grease pencil data keyframes were listed twice in the summary.

First by the generic object data listing,
which did not handle properly grease pencil objects,
and did not account for the grease pencil filter.
Second by the specific grease pencil function.

Now only the second call is made,
and the filter hides keyframes in summary as well.

Reviewed By : Jeroen Bakker, Falk David

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

===

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

===

diff --git a/source/blender/editors/animation/anim_filter.c 
b/source/blender/editors/animation/anim_filter.c
index 3a04873588d..255b9cdffbe 100644
--- a/source/blender/editors/animation/anim_filter.c
+++ b/source/blender/editors/animation/anim_filter.c
@@ -2826,7 +2826,7 @@ static size_t animdata_filter_dopesheet_ob(
 }
 
 /* object data */
-if (ob->data) {
+if ((ob->data) && (ob->type != OB_GPENCIL)) {
   tmp_items += animdata_filter_ds_obdata(ac, _data, ads, ob, 
filter_mode);
 }

___
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] [7f80b5e675c] master: Animation: rearrange grease pencil channels in the main dopesheet

2022-11-15 Thread Amelie Fondevilla
Commit: 7f80b5e675ccffb8fa4d8b98d5bfdc2678dcedaf
Author: Amelie Fondevilla
Date:   Mon Nov 14 17:50:51 2022 +0100
Branches: master
https://developer.blender.org/rB7f80b5e675ccffb8fa4d8b98d5bfdc2678dcedaf

Animation: rearrange grease pencil channels in the main dopesheet

Operations to rearrange channels in the main dopesheet
did not cover grease pencil layer channels.
Now grease pencil layer channels can be moved up and down
in the main dopesheet just like other channels.

Reviewed By: Sybren A. Stüvel

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

===

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 e86e1f16e54..a83266c484e 100644
--- a/source/blender/editors/animation/anim_channels_edit.c
+++ b/source/blender/editors/animation/anim_channels_edit.c
@@ -1444,15 +1444,20 @@ static void rearrange_gpencil_channels(bAnimContext 
*ac, eRearrangeAnimChan_Mode
   }
 
   /* get Grease Pencil datablocks */
-  filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | 
ANIMFILTER_ANIMDATA);
+  filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | 
ANIMFILTER_ANIMDATA |
+ANIMFILTER_LIST_CHANNELS);
   ANIM_animdata_filter(ac, _data, filter, ac->data, ac->datatype);
 
   for (ale = anim_data.first; ale; ale = ale->next) {
+/* only consider grease pencil container channels */
+if (!ELEM(ale->type, ANIMTYPE_GPDATABLOCK, ANIMTYPE_DSGPENCIL)) {
+  continue;
+}
+
 ListBase anim_data_visible = {NULL, NULL};
 bGPdata *gpd = ale->data;
 
 /* only consider layers if this datablock is open */
-BLI_assert(ale->type == ANIMTYPE_GPDATABLOCK);
 if ((gpd->flag & GP_DATA_EXPAND) == 0) {
   continue;
 }
@@ -1510,6 +1515,10 @@ static int animchannels_rearrange_exec(bContext *C, 
wmOperator *op)
 bAnimListElem *ale;
 int filter;
 
+if (ELEM(ac.datatype, ANIMCONT_DOPESHEET, ANIMCONT_TIMELINE)) {
+  rearrange_gpencil_channels(, mode);
+}
+
 /* get animdata blocks */
 filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | 
ANIMFILTER_ANIMDATA |
   ANIMFILTER_FCURVESONLY);

___
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] [567e3f65083] blender-v3.3-release: Fix T101547: Add update notifiers in dopesheet and timeline selection operators

2022-10-26 Thread Amelie Fondevilla
Commit: 567e3f650836ef060912c540013eb8fa0f447fe6
Author: Amelie Fondevilla
Date:   Fri Oct 7 11:44:27 2022 +0200
Branches: blender-v3.3-release
https://developer.blender.org/rB567e3f650836ef060912c540013eb8fa0f447fe6

Fix T101547: Add update notifiers in dopesheet and timeline selection operators

Updates the function checking if a container can have grease pencil layer 
keyframes, to account for dopesheet in main mode, and timeline.

Reviewed By: Sybren A. Stüvel

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

===

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

===

diff --git a/source/blender/editors/animation/anim_filter.c 
b/source/blender/editors/animation/anim_filter.c
index e5deb03358f..6f19c30a6d8 100644
--- a/source/blender/editors/animation/anim_filter.c
+++ b/source/blender/editors/animation/anim_filter.c
@@ -416,7 +416,7 @@ bool ANIM_animdata_get_context(const bContext *C, 
bAnimContext *ac)
 
 bool ANIM_animdata_can_have_greasepencil(const eAnimCont_Types type)
 {
-  return type == ANIMCONT_GPENCIL;
+  return ELEM(type, ANIMCONT_GPENCIL, ANIMCONT_DOPESHEET, ANIMCONT_TIMELINE);
 }
 
 /*  */

___
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] [0b45d3e3866] blender-v3.3-release: Refactor: adding function to check if an animation container has grease pencil layer keyframes.

2022-10-26 Thread Amelie Fondevilla
Commit: 0b45d3e3866225d0277cc8af483f0ad1d589420e
Author: Amelie Fondevilla
Date:   Fri Oct 7 09:59:34 2022 +0200
Branches: blender-v3.3-release
https://developer.blender.org/rB0b45d3e3866225d0277cc8af483f0ad1d589420e

Refactor: adding function to check if an animation container has grease pencil 
layer keyframes.

Used in action_select to refactor the selection operators.

No functional changes.

Reviewed By: Sybren A. Stüvel

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

===

M   source/blender/editors/animation/anim_filter.c
M   source/blender/editors/include/ED_anim_api.h
M   source/blender/editors/space_action/action_select.c

===

diff --git a/source/blender/editors/animation/anim_filter.c 
b/source/blender/editors/animation/anim_filter.c
index d9eeed94868..e5deb03358f 100644
--- a/source/blender/editors/animation/anim_filter.c
+++ b/source/blender/editors/animation/anim_filter.c
@@ -414,6 +414,11 @@ bool ANIM_animdata_get_context(const bContext *C, 
bAnimContext *ac)
   return ANIM_animdata_context_getdata(ac);
 }
 
+bool ANIM_animdata_can_have_greasepencil(const eAnimCont_Types type)
+{
+  return type == ANIMCONT_GPENCIL;
+}
+
 /*  */
 /* Blender Data <-- Filter --> Channels to be operated on */
 
diff --git a/source/blender/editors/include/ED_anim_api.h 
b/source/blender/editors/include/ED_anim_api.h
index ee87de5774a..f5cdc35c38c 100644
--- a/source/blender/editors/include/ED_anim_api.h
+++ b/source/blender/editors/include/ED_anim_api.h
@@ -519,6 +519,11 @@ void ANIM_animdata_update(bAnimContext *ac, ListBase 
*anim_data);
 
 void ANIM_animdata_freelist(ListBase *anim_data);
 
+/**
+ * Check if the given animation container can contain grease pencil layer 
keyframes.
+ */
+bool ANIM_animdata_can_have_greasepencil(const eAnimCont_Types type);
+
 /*  */
 /* ANIMATION CHANNELS LIST */
 /* anim_channels_*.c */
diff --git a/source/blender/editors/space_action/action_select.c 
b/source/blender/editors/space_action/action_select.c
index d1a8592ae9d..dd8cea6c838 100644
--- a/source/blender/editors/space_action/action_select.c
+++ b/source/blender/editors/space_action/action_select.c
@@ -322,7 +322,7 @@ static int actkeys_deselectall_exec(bContext *C, wmOperator 
*op)
 
   /* set notifier that keyframe selection have changed */
   WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
-  if (ac.datatype == ANIMCONT_GPENCIL) {
+  if (ANIM_animdata_can_have_greasepencil(ac.datatype)) {
 WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, NULL);
   }
   return OPERATOR_FINISHED;
@@ -563,7 +563,7 @@ static int actkeys_box_select_exec(bContext *C, wmOperator 
*op)
 
   /* set notifier that keyframe selection have changed */
   WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
-  if (ac.datatype == ANIMCONT_GPENCIL) {
+  if (ANIM_animdata_can_have_greasepencil(ac.datatype)) {
 WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, NULL);
   }
   return OPERATOR_FINISHED;
@@ -800,7 +800,7 @@ static int actkeys_lassoselect_exec(bContext *C, wmOperator 
*op)
 
   /* send notifier that keyframe selection has changed */
   WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
-  if (ac.datatype == ANIMCONT_GPENCIL) {
+  if (ANIM_animdata_can_have_greasepencil(ac.datatype)) {
 WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, NULL);
   }
   return OPERATOR_FINISHED;
@@ -868,7 +868,7 @@ static int action_circle_select_exec(bContext *C, 
wmOperator *op)
 
   /* send notifier that keyframe selection has changed */
   WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
-  if (ac.datatype == ANIMCONT_GPENCIL) {
+  if (ANIM_animdata_can_have_greasepencil(ac.datatype)) {
 WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, NULL);
   }
   return OPERATOR_FINISHED;
@@ -1107,7 +1107,7 @@ static int actkeys_columnselect_exec(bContext *C, 
wmOperator *op)
 
   /* set notifier that keyframe selection have changed */
   WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
-  if (ac.datatype == ANIMCONT_GPENCIL) {
+  if (ANIM_animdata_can_have_greasepencil(ac.datatype)) {
 WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, NULL);
   }
   return OPERATOR_FINISHED;
@@ -1169,7 +1169,7 @@ static int actkeys_select_linked_exec(bContext *C, 
wmOperator *UNUSED(op))
 
   /* set notifier that keyframe selection has changed */
   WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
-  if (ac.datatype == ANIMCONT_GPENCIL) {
+  if (ANIM_animdata_can_have_greasepencil(ac.datatype)) {
 WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED

[Bf-blender-cvs] [f7a781d45fc] master: Fix T101547: Add update notifiers in dopesheet and timeline selection operators

2022-10-07 Thread Amelie Fondevilla
Commit: f7a781d45fcc79844c4d7fc8a17ede3d6cfc1eaf
Author: Amelie Fondevilla
Date:   Fri Oct 7 11:44:27 2022 +0200
Branches: master
https://developer.blender.org/rBf7a781d45fcc79844c4d7fc8a17ede3d6cfc1eaf

Fix T101547: Add update notifiers in dopesheet and timeline selection operators

Updates the function checking if a container can have grease pencil layer 
keyframes, to account for dopesheet in main mode, and timeline.

Reviewed By: Sybren A. Stüvel

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

===

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

===

diff --git a/source/blender/editors/animation/anim_filter.c 
b/source/blender/editors/animation/anim_filter.c
index 302e50e64d7..8fd3c319452 100644
--- a/source/blender/editors/animation/anim_filter.c
+++ b/source/blender/editors/animation/anim_filter.c
@@ -419,7 +419,7 @@ bool ANIM_animdata_get_context(const bContext *C, 
bAnimContext *ac)
 
 bool ANIM_animdata_can_have_greasepencil(const eAnimCont_Types type)
 {
-  return type == ANIMCONT_GPENCIL;
+  return ELEM(type, ANIMCONT_GPENCIL, ANIMCONT_DOPESHEET, ANIMCONT_TIMELINE);
 }
 
 /*  */

___
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] [412d670e9c5] master: Refactor: adding function to check if an animation container has grease pencil layer keyframes.

2022-10-07 Thread Amelie Fondevilla
Commit: 412d670e9c581dcafccd950d661611b6a496299c
Author: Amelie Fondevilla
Date:   Fri Oct 7 09:59:34 2022 +0200
Branches: master
https://developer.blender.org/rB412d670e9c581dcafccd950d661611b6a496299c

Refactor: adding function to check if an animation container has grease pencil 
layer keyframes.

Used in action_select to refactor the selection operators.

No functional changes.

Reviewed By: Sybren A. Stüvel

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

===

M   source/blender/editors/animation/anim_filter.c
M   source/blender/editors/include/ED_anim_api.h
M   source/blender/editors/space_action/action_select.c

===

diff --git a/source/blender/editors/animation/anim_filter.c 
b/source/blender/editors/animation/anim_filter.c
index e0df7328c74..302e50e64d7 100644
--- a/source/blender/editors/animation/anim_filter.c
+++ b/source/blender/editors/animation/anim_filter.c
@@ -417,6 +417,11 @@ bool ANIM_animdata_get_context(const bContext *C, 
bAnimContext *ac)
   return ANIM_animdata_context_getdata(ac);
 }
 
+bool ANIM_animdata_can_have_greasepencil(const eAnimCont_Types type)
+{
+  return type == ANIMCONT_GPENCIL;
+}
+
 /*  */
 /* Blender Data <-- Filter --> Channels to be operated on */
 
diff --git a/source/blender/editors/include/ED_anim_api.h 
b/source/blender/editors/include/ED_anim_api.h
index 6079aca0199..8fe2d0ae60f 100644
--- a/source/blender/editors/include/ED_anim_api.h
+++ b/source/blender/editors/include/ED_anim_api.h
@@ -519,6 +519,11 @@ void ANIM_animdata_update(bAnimContext *ac, ListBase 
*anim_data);
 
 void ANIM_animdata_freelist(ListBase *anim_data);
 
+/**
+ * Check if the given animation container can contain grease pencil layer 
keyframes.
+ */
+bool ANIM_animdata_can_have_greasepencil(const eAnimCont_Types type);
+
 /*  */
 /* ANIMATION CHANNELS LIST */
 /* anim_channels_*.c */
diff --git a/source/blender/editors/space_action/action_select.c 
b/source/blender/editors/space_action/action_select.c
index 9d45a2a3b89..a425026a1ef 100644
--- a/source/blender/editors/space_action/action_select.c
+++ b/source/blender/editors/space_action/action_select.c
@@ -322,7 +322,7 @@ static int actkeys_deselectall_exec(bContext *C, wmOperator 
*op)
 
   /* set notifier that keyframe selection have changed */
   WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
-  if (ac.datatype == ANIMCONT_GPENCIL) {
+  if (ANIM_animdata_can_have_greasepencil(ac.datatype)) {
 WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, NULL);
   }
   return OPERATOR_FINISHED;
@@ -563,7 +563,7 @@ static int actkeys_box_select_exec(bContext *C, wmOperator 
*op)
 
   /* set notifier that keyframe selection have changed */
   WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
-  if (ac.datatype == ANIMCONT_GPENCIL) {
+  if (ANIM_animdata_can_have_greasepencil(ac.datatype)) {
 WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, NULL);
   }
   return OPERATOR_FINISHED;
@@ -800,7 +800,7 @@ static int actkeys_lassoselect_exec(bContext *C, wmOperator 
*op)
 
   /* send notifier that keyframe selection has changed */
   WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
-  if (ac.datatype == ANIMCONT_GPENCIL) {
+  if (ANIM_animdata_can_have_greasepencil(ac.datatype)) {
 WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, NULL);
   }
   return OPERATOR_FINISHED;
@@ -868,7 +868,7 @@ static int action_circle_select_exec(bContext *C, 
wmOperator *op)
 
   /* send notifier that keyframe selection has changed */
   WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
-  if (ac.datatype == ANIMCONT_GPENCIL) {
+  if (ANIM_animdata_can_have_greasepencil(ac.datatype)) {
 WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, NULL);
   }
   return OPERATOR_FINISHED;
@@ -1107,7 +1107,7 @@ static int actkeys_columnselect_exec(bContext *C, 
wmOperator *op)
 
   /* set notifier that keyframe selection have changed */
   WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
-  if (ac.datatype == ANIMCONT_GPENCIL) {
+  if (ANIM_animdata_can_have_greasepencil(ac.datatype)) {
 WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, NULL);
   }
   return OPERATOR_FINISHED;
@@ -1170,7 +1170,7 @@ static int actkeys_select_linked_exec(bContext *C, 
wmOperator *UNUSED(op))
 
   /* set notifier that keyframe selection has changed */
   WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
-  if (ac.datatype == ANIMCONT_GPENCIL) {
+  if (ANIM_animdata_can_have_greasepencil(ac.datatype)) {
 WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, NULL);
   }
   

[Bf-blender-cvs] [fdf34666f00] blender-v3.3-release: Fix Unreported : add F-curves only filter to functions only appliable to F-curves channels.

2022-08-02 Thread Amelie Fondevilla
Commit: fdf34666f00fc0995507b46e30a0e732812cd05e
Author: Amelie Fondevilla
Date:   Tue Aug 2 12:24:30 2022 +0200
Branches: blender-v3.3-release
https://developer.blender.org/rBfdf34666f00fc0995507b46e30a0e732812cd05e

Fix Unreported : add F-curves only filter to functions only appliable to 
F-curves channels.

The filter was missing in some places that are using channel data as if it was 
f-curve channel.
There seems to be no related issue or bug, but still it would be best to have 
them there.

Reviewed By: sybren

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

===

M   source/blender/editors/animation/anim_channels_edit.c
M   source/blender/editors/animation/keyframes_edit.c
M   source/blender/editors/animation/keyframes_keylist.cc
M   source/blender/editors/include/ED_anim_api.h
M   source/blender/editors/space_graph/space_graph.c

===

diff --git a/source/blender/editors/animation/anim_channels_edit.c 
b/source/blender/editors/animation/anim_channels_edit.c
index f371591c3a8..1c7b3496723 100644
--- a/source/blender/editors/animation/anim_channels_edit.c
+++ b/source/blender/editors/animation/anim_channels_edit.c
@@ -1640,7 +1640,8 @@ static void animchannels_group_channels(bAnimContext *ac,
 int filter;
 
 /* find selected F-Curves to re-group */
-filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | 
ANIMFILTER_SEL);
+filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | 
ANIMFILTER_SEL |
+  ANIMFILTER_FCURVESONLY);
 ANIM_animdata_filter(ac, _data, filter, adt_ref, ANIMCONT_CHANNEL);
 
 if (anim_data.first) {
@@ -1754,7 +1755,7 @@ static int animchannels_ungroup_exec(bContext *C, 
wmOperator *UNUSED(op))
 
   /* just selected F-Curves... */
   filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL 
|
-ANIMFILTER_NODUPLIS);
+ANIMFILTER_NODUPLIS | ANIMFILTER_FCURVESONLY);
   ANIM_animdata_filter(, _data, filter, ac.data, ac.datatype);
 
   for (ale = anim_data.first; ale; ale = ale->next) {
@@ -2454,7 +2455,7 @@ static int animchannels_enable_exec(bContext *C, 
wmOperator *UNUSED(op))
   }
 
   /* filter data */
-  filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_NODUPLIS);
+  filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_NODUPLIS | 
ANIMFILTER_FCURVESONLY);
   ANIM_animdata_filter(, _data, filter, ac.data, ac.datatype);
 
   /* loop through filtered data and clean curves */
@@ -3454,7 +3455,8 @@ static bool select_anim_channel_keys(bAnimContext *ac, 
int channel_index, bool e
 
   /* get the channel that was clicked on */
   /* filter channels */
-  filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | 
ANIMFILTER_LIST_CHANNELS);
+  filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | 
ANIMFILTER_LIST_CHANNELS |
+ANIMFILTER_FCURVESONLY);
   ANIM_animdata_filter(ac, _data, filter, ac->data, ac->datatype);
 
   /* get channel from index */
diff --git a/source/blender/editors/animation/keyframes_edit.c 
b/source/blender/editors/animation/keyframes_edit.c
index 706db498a82..63bd5665459 100644
--- a/source/blender/editors/animation/keyframes_edit.c
+++ b/source/blender/editors/animation/keyframes_edit.c
@@ -218,7 +218,7 @@ static short ob_keyframes_loop(KeyframeEditData *ked,
   ac.datatype = ANIMCONT_CHANNEL;
 
   /* get F-Curves to take keyframes from */
-  filter = ANIMFILTER_DATA_VISIBLE; /* curves only */
+  filter = ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FCURVESONLY;
   ANIM_animdata_filter(, _data, filter, ac.data, ac.datatype);
 
   /* Loop through each F-Curve, applying the operation as required,
@@ -267,7 +267,7 @@ static short scene_keyframes_loop(KeyframeEditData *ked,
   ac.datatype = ANIMCONT_CHANNEL;
 
   /* get F-Curves to take keyframes from */
-  filter = ANIMFILTER_DATA_VISIBLE; /* curves only */
+  filter = ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FCURVESONLY;
   ANIM_animdata_filter(, _data, filter, ac.data, ac.datatype);
 
   /* Loop through each F-Curve, applying the operation as required,
diff --git a/source/blender/editors/animation/keyframes_keylist.cc 
b/source/blender/editors/animation/keyframes_keylist.cc
index 8dc598e6e2d..da266dd4253 100644
--- a/source/blender/editors/animation/keyframes_keylist.cc
+++ b/source/blender/editors/animation/keyframes_keylist.cc
@@ -943,7 +943,8 @@ void scene_to_keylist(bDopeSheet *ads, Scene *sce, 
AnimKeylist *keylist, const i
   ac.datatype = ANIMCONT_CHANNEL;
 
   /* get F-Curves to take keyframes from */
-  const eAnimFilter_Flags filter = ANIMFILTER_DATA_VISIBLE; /* curves only */
+  const eAnimFilter_Flags filter = ANIMFILTER_DATA_VISIBLE | 
ANIMFILTER_FCURVESONLY;
+
   ANIM_animdata_filter(
   , _data, filter, ac.data, 
static_cast(ac.datatype));
 
@@ -980,7 +981,7 @@ void ob_to_keylist(bDopeSheet *ads, Object *ob, AnimKeylist 
*keylist, 

[Bf-blender-cvs] [4843b161d6c] master: Fix T99870 : Prevents crash when rearranging channels in dopesheet

2022-07-27 Thread Amelie Fondevilla
Commit: 4843b161d6cc14045f05d8df76f39795d5fcc6b3
Author: Amelie Fondevilla
Date:   Wed Jul 20 12:28:50 2022 +0200
Branches: master
https://developer.blender.org/rB4843b161d6cc14045f05d8df76f39795d5fcc6b3

Fix T99870 : Prevents crash when rearranging channels in dopesheet

The function to rearrange channels only works for F-curves channels for now, 
adding the `FCURVESONLY` filter prevents the function to be called for grease 
pencil channels, thereby fixing the crash.

Reviewed by : sybren
Differential Revision: http://developer.blender.org/D15504

===

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 8464f280c29..f371591c3a8 100644
--- a/source/blender/editors/animation/anim_channels_edit.c
+++ b/source/blender/editors/animation/anim_channels_edit.c
@@ -1498,7 +1498,8 @@ static int animchannels_rearrange_exec(bContext *C, 
wmOperator *op)
 int filter;
 
 /* get animdata blocks */
-filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | 
ANIMFILTER_ANIMDATA);
+filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | 
ANIMFILTER_ANIMDATA |
+  ANIMFILTER_FCURVESONLY);
 ANIM_animdata_filter(, _data, filter, ac.data, ac.datatype);
 
 for (ale = anim_data.first; ale; ale = ale->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