[Bf-blender-cvs] [c7a0d397988] temp-gpencil-bezier-stroke-type: GPencil: reproject curves

Falk David noreply at git.blender.org
Mon Mar 15 00:36:25 CET 2021


Commit: c7a0d397988d16bcab473c2582adc98e59284caf
Author: Falk David
Date:   Sun Mar 14 19:20:13 2021 +0100
Branches: temp-gpencil-bezier-stroke-type
https://developer.blender.org/rBc7a0d397988d16bcab473c2582adc98e59284caf

GPencil: reproject curves

This is using the "easy" way of reprojecting the points first,
then refitting the curve. A better solution would be to project the
curve points and then recalculate the stroke. This would also be less
computational expensive since fitting the curve is slower.

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

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

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

diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c
index 6058f7390ab..0a7246d5410 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -3959,7 +3959,6 @@ static int gpencil_strokes_reproject_exec(bContext *C, wmOperator *op)
   int oldframe = (int)DEG_get_ctime(depsgraph);
   const eGP_ReprojectModes mode = RNA_enum_get(op->ptr, "type");
   const bool keep_original = RNA_boolean_get(op->ptr, "keep_original");
-  const bool is_curve_edit = (bool)GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd);
 
   /* Init snap context for geometry projection. */
   SnapObjectContext *sctx = NULL;
@@ -3973,33 +3972,32 @@ static int gpencil_strokes_reproject_exec(bContext *C, wmOperator *op)
 
   /* Go through each editable + selected stroke, adjusting each of its points one by one... */
   GP_EDITABLE_STROKES_BEGIN (gpstroke_iter, C, gpl, gps) {
-    bool curve_select = false;
-    if (is_curve_edit && gps->editcurve != NULL) {
-      curve_select = gps->editcurve->flag & GP_CURVE_SELECT;
-    }
-
-    if (gps->flag & GP_STROKE_SELECT || curve_select) {
+    bool is_stroke_selected = GPENCIL_STROKE_TYPE_BEZIER(gps) ?
+                                  (bool)(gps->editcurve->flag & GP_CURVE_SELECT) :
+                                  (bool)(gps->flag & GP_STROKE_SELECT);
 
-      /* update frame to get the new location of objects */
-      if ((mode == GP_REPROJECT_SURFACE) && (cfra_prv != gpf_->framenum)) {
-        cfra_prv = gpf_->framenum;
-        CFRA = gpf_->framenum;
-        BKE_scene_graph_update_for_newframe(depsgraph);
-      }
-
-      ED_gpencil_stroke_reproject(depsgraph, &gsc, sctx, gpl, gpf_, gps, mode, keep_original);
+    if (!is_stroke_selected) {
+      continue;
+    }
 
-      // if (is_curve_edit && gps->editcurve != NULL) {
-      //   BKE_gpencil_stroke_editcurve_update(gpd, gpl, gps);
-      //   /* Update the selection from the stroke to the curve. */
-      //   BKE_gpencil_editcurve_stroke_sync_selection(gps, gps->editcurve);
+    /* update frame to get the new location of objects */
+    if ((mode == GP_REPROJECT_SURFACE) && (cfra_prv != gpf_->framenum)) {
+      cfra_prv = gpf_->framenum;
+      CFRA = gpf_->framenum;
+      BKE_scene_graph_update_for_newframe(depsgraph);
+    }
 
-      //   gps->flag |= GP_STROKE_NEEDS_CURVE_UPDATE;
-      //   BKE_gpencil_stroke_geometry_update(gpd, gps);
-      // }
+    ED_gpencil_stroke_reproject(depsgraph, &gsc, sctx, gpl, gpf_, gps, mode, keep_original);
 
-      changed = true;
+    /* TODO: Reproject curve data and regenerate stroke.
+     * Right now we are using the projected points to regenerate the curve. This will most likely
+     * change the handles which is usually not wanted.*/
+    if (GPENCIL_STROKE_TYPE_BEZIER(gps)) {
+      gps->editcurve->flag |= GP_CURVE_NEEDS_STROKE_UPDATE;
+      BKE_gpencil_stroke_geometry_update(gpd, gps);
     }
+
+    changed = true;
   }
   GP_EDITABLE_STROKES_END(gpstroke_iter);



More information about the Bf-blender-cvs mailing list