[Bf-blender-cvs] [d603c9c7ecb] temp-gpencil-bezier-v2: WIP: Add runtime data for curves

Falk David noreply at git.blender.org
Sat Mar 6 11:24:20 CET 2021


Commit: d603c9c7ecb6caf319a9d9d7aed76b71c9b33e7e
Author: Falk David
Date:   Sat Mar 6 11:23:22 2021 +0100
Branches: temp-gpencil-bezier-v2
https://developer.blender.org/rBd603c9c7ecb6caf319a9d9d7aed76b71c9b33e7e

WIP: Add runtime data for curves

===================================================================

M	source/blender/blenkernel/intern/gpencil.c
M	source/blender/blenkernel/intern/gpencil_modifier.c
M	source/blender/gpencil_modifiers/intern/MOD_gpenciloffset.c
M	source/blender/makesdna/DNA_gpencil_types.h

===================================================================

diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index b76c60b8512..9607608b833 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -2779,19 +2779,38 @@ void BKE_gpencil_frame_original_pointers_update(const struct bGPDframe *gpf_orig
     /* Assign original stroke pointer. */
     if (gps_eval != NULL) {
       gps_eval->runtime.gps_orig = gps_orig;
+      if (GPENCIL_STROKE_IS_CURVE(gps_orig)) {
+        bGPDcurve *gpc_orig = gps_orig->editcurve;
+        bGPDcurve *gpc_eval = gps_eval->editcurve;
 
-      /* Assign original point pointer. */
-      for (int i = 0; i < gps_orig->totpoints; i++) {
-        if (i > gps_eval->totpoints - 1) {
-          break;
+        gpc_eval->runtime.gpc_orig = gpc_orig;
+        for (int i = 0; i < gpc_orig->tot_curve_points; i++) {
+          if (i > gpc_eval->tot_curve_points - 1) {
+            break;
+          }
+          bGPDcurve_point *gpc_pt_orig = &gpc_orig->curve_points[i];
+          bGPDcurve_point *gpc_pt_eval = &gpc_eval->curve_points[i];
+          gpc_pt_orig->runtime.gpc_pt_orig = NULL;
+          gpc_pt_orig->runtime.idx_orig = i;
+          gpc_pt_eval->runtime.gpc_pt_orig = gpc_pt_orig;
+          gpc_pt_eval->runtime.idx_orig = i;
+        }
+      }
+      else {
+        /* Assign original point pointer. */
+        for (int i = 0; i < gps_orig->totpoints; i++) {
+          if (i > gps_eval->totpoints - 1) {
+            break;
+          }
+          bGPDspoint *pt_orig = &gps_orig->points[i];
+          bGPDspoint *pt_eval = &gps_eval->points[i];
+          pt_orig->runtime.pt_orig = NULL;
+          pt_orig->runtime.idx_orig = i;
+          pt_eval->runtime.pt_orig = pt_orig;
+          pt_eval->runtime.idx_orig = i;
         }
-        bGPDspoint *pt_orig = &gps_orig->points[i];
-        bGPDspoint *pt_eval = &gps_eval->points[i];
-        pt_orig->runtime.pt_orig = NULL;
-        pt_orig->runtime.idx_orig = i;
-        pt_eval->runtime.pt_orig = pt_orig;
-        pt_eval->runtime.idx_orig = i;
       }
+      
       /* Increase pointer. */
       gps_eval = gps_eval->next;
     }
diff --git a/source/blender/blenkernel/intern/gpencil_modifier.c b/source/blender/blenkernel/intern/gpencil_modifier.c
index 938ced6cfe5..f734241eecb 100644
--- a/source/blender/blenkernel/intern/gpencil_modifier.c
+++ b/source/blender/blenkernel/intern/gpencil_modifier.c
@@ -754,9 +754,8 @@ void BKE_gpencil_modifiers_calc(Depsgraph *depsgraph, Scene *scene, Object *ob)
   bGPdata *gpd = (bGPdata *)ob->data;
   const bool is_edit = GPENCIL_ANY_EDIT_MODE(gpd);
   const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd);
-  const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd);
   const bool is_render = (bool)(DEG_get_mode(depsgraph) == DAG_EVAL_RENDER);
-  const bool do_modifiers = (bool)((!is_multiedit) && (!is_curve_edit) &&
+  const bool do_modifiers = (bool)((!is_multiedit) &&
                                    (ob->greasepencil_modifiers.first != NULL) &&
                                    (!GPENCIL_SIMPLIFY_MODIF(scene)));
   if (!do_modifiers) {
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpenciloffset.c b/source/blender/gpencil_modifiers/intern/MOD_gpenciloffset.c
index 4e009e25ce3..bc5dd763630 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpenciloffset.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpenciloffset.c
@@ -125,6 +125,11 @@ static void deformStroke(GpencilModifierData *md,
 
     mul_m4_v3(mat, &pt->x);
   }
+
+  if (GPENCIL_STROKE_IS_CURVE(gps)) {
+    gps->editcurve->flag |= GP_CURVE_NEEDS_STROKE_UPDATE;
+  }
+
   /* Calc geometry data. */
   BKE_gpencil_stroke_geometry_update(gpd, gps);
 }
diff --git a/source/blender/makesdna/DNA_gpencil_types.h b/source/blender/makesdna/DNA_gpencil_types.h
index f8d6a187cf0..54f21112e08 100644
--- a/source/blender/makesdna/DNA_gpencil_types.h
+++ b/source/blender/makesdna/DNA_gpencil_types.h
@@ -180,6 +180,14 @@ typedef enum eGPDpalette_Flag {
 /* ***************************************** */
 /* GP Curve Point */
 
+typedef struct bGPDcpoint_Runtime {
+  /* Original curve point */
+  struct bGPDcurve_point *gpc_pt_orig;
+  /* Original index array position */
+  int idx_orig;
+  char _pad0[4];
+} bGPDcpoint_Runtime;
+
 typedef struct bGPDcurve_point {
   /** Bezier Triple for the handles and control points. */
   BezTriple bezt;
@@ -202,7 +210,8 @@ typedef struct bGPDcurve_point {
 
   /** Vertex Color RGBA (A=mix factor). */
   float vert_color[4];
-  char _pad[4];
+  
+  bGPDcpoint_Runtime runtime;
 } bGPDcurve_point;
 
 /* bGPDcurve_point->flag */
@@ -213,6 +222,11 @@ typedef enum eGPDcurve_point_Flag {
 /* ***************************************** */
 /* GP Curve */
 
+typedef struct bGPDcurve_Runtime {
+  struct bGPDcurve *gpc_orig;
+  void *_pad;
+} bGPDcurve_Runtime;
+
 /* Curve for Bezier Editing. */
 typedef struct bGPDcurve {
   /** Array of curve points. */
@@ -222,6 +236,7 @@ typedef struct bGPDcurve {
   /** General flag. */
   short flag;
   char _pad[2];
+  bGPDcurve_Runtime runtime;
 } bGPDcurve;
 
 /* bGPDcurve_Flag->flag */



More information about the Bf-blender-cvs mailing list