[Bf-blender-cvs] [caa004c6bc3] soc-2019-npr: LANPR: GP update will now delete data in the original frame.

YimingWu noreply at git.blender.org
Wed Jul 3 08:34:06 CEST 2019


Commit: caa004c6bc3545bee0fcae3eef78e7f6587db2f2
Author: YimingWu
Date:   Wed Jul 3 14:33:37 2019 +0800
Branches: soc-2019-npr
https://developer.blender.org/rBcaa004c6bc3545bee0fcae3eef78e7f6587db2f2

LANPR: GP update will now delete data in the original frame.

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

M	release/scripts/startup/bl_ui/properties_data_modifier.py
M	source/blender/draw/engines/lanpr/lanpr_ops.c
M	source/blender/makesdna/DNA_gpencil_types.h

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

diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index 8d2c201aaa4..bb4586e6e3a 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -1708,7 +1708,8 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
                 row.label(text = "Target GP has self transformations.")
                 row = layout.row()
                 row.operator("lanpr.reset_object_transfromations").obj=md.target.name
-            layout.prop(md,'replace', text='Replace existing frames')
+            #remove this for now.
+            #layout.prop(md,'replace', text='Replace existing frames')
             row = layout.row()
             row.prop(md,'layer')
             row.prop(md,'material')
diff --git a/source/blender/draw/engines/lanpr/lanpr_ops.c b/source/blender/draw/engines/lanpr/lanpr_ops.c
index 5d03c482297..e13c3f81fbd 100644
--- a/source/blender/draw/engines/lanpr/lanpr_ops.c
+++ b/source/blender/draw/engines/lanpr/lanpr_ops.c
@@ -4517,6 +4517,27 @@ int lanpr_auto_create_line_layer_exec(struct bContext *C, struct wmOperator *op)
   return OPERATOR_FINISHED;
 }
 
+void lanpr_clear_gp_lanpr_flags(Depsgraph *dg, int frame)
+{
+  DEG_OBJECT_ITER_BEGIN (dg,
+                         o,
+                         DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY | DEG_ITER_OBJECT_FLAG_VISIBLE |
+                             DEG_ITER_OBJECT_FLAG_DUPLI | DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET) {
+    if (o->type == OB_GPENCIL) {
+      bGPdata *gpd = ((Object *)o->id.orig_id)->data;
+      bGPDlayer *gpl;
+      for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
+        bGPDframe *gpf = BKE_gpencil_layer_find_frame(gpl, frame);
+        if (!gpf) {
+          continue;
+        }
+        gpf->flag &= ~GP_FRAME_LANPR_CLEARED;
+      }
+    }
+  }
+  DEG_OBJECT_ITER_END;
+}
+
 void lanpr_update_gp_strokes_recursive(Depsgraph *dg, struct Collection *col, int frame)
 {
   Object *ob;
@@ -4541,8 +4562,11 @@ void lanpr_update_gp_strokes_recursive(Depsgraph *dg, struct Collection *col, in
             gpl = BKE_gpencil_layer_addnew(gpd, "lanpr_layer", true);
           }
           gpf = BKE_gpencil_layer_getframe(gpl, frame, GP_GETFRAME_ADD_NEW);
-          /* BKE_gpencil_free_strokes(gpf);   will be overwritten. need another solution */
-          /* Please manually delete those strokes before clicking Update once again. */
+
+          if (!(gpf->flag & GP_FRAME_LANPR_CLEARED)) {
+            BKE_gpencil_free_strokes(gpf);
+            gpf->flag |= GP_FRAME_LANPR_CLEARED;
+          }
 
           lanpr_generate_gpencil_from_chain(dg,
                                             ob,
@@ -4591,8 +4615,11 @@ void lanpr_update_gp_strokes_collection(Depsgraph *dg, struct Collection *col, i
     gpl = BKE_gpencil_layer_addnew(gpd, "lanpr_layer", true);
   }
   gpf = BKE_gpencil_layer_getframe(gpl, frame, GP_GETFRAME_ADD_NEW);
-  /* BKE_gpencil_free_strokes(gpf);   will be overwritten. need another solution */
-  /* Please manually delete those strokes before clicking Update once again. */
+
+  if (!(gpf->flag & GP_FRAME_LANPR_CLEARED)) {
+    BKE_gpencil_free_strokes(gpf);
+    gpf->flag |= GP_FRAME_LANPR_CLEARED;
+  }
 
   lanpr_generate_gpencil_from_chain(dg,
                                     NULL,
@@ -4613,7 +4640,8 @@ int lanpr_update_gp_strokes_exec(struct bContext *C, struct wmOperator *op)
   SceneLANPR *lanpr = &scene->lanpr;
   int frame = scene->r.cfra;
 
-  if (lanpr_share.render_buffer_shared->cached_for_frame != frame) {
+  if (!lanpr_share.render_buffer_shared ||
+      lanpr_share.render_buffer_shared->cached_for_frame != frame) {
     lanpr_compute_feature_lines_internal(dg, 0);
   }
 
@@ -4623,6 +4651,8 @@ int lanpr_update_gp_strokes_exec(struct bContext *C, struct wmOperator *op)
 
   lanpr_update_gp_strokes_collection(dg, scene->master_collection, frame);
 
+  lanpr_clear_gp_lanpr_flags(dg, frame);
+
   WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED | ND_SPACE_PROPERTIES, NULL);
 
   return OPERATOR_FINISHED;
diff --git a/source/blender/makesdna/DNA_gpencil_types.h b/source/blender/makesdna/DNA_gpencil_types.h
index dbcacbcdcfe..b2a50598567 100644
--- a/source/blender/makesdna/DNA_gpencil_types.h
+++ b/source/blender/makesdna/DNA_gpencil_types.h
@@ -282,6 +282,7 @@ typedef enum eGPDframe_Flag {
   GP_FRAME_PAINT = (1 << 0),
   /* for editing in Action Editor */
   GP_FRAME_SELECT = (1 << 1),
+  GP_FRAME_LANPR_CLEARED = (1 << 2),
 } eGPDframe_Flag;
 
 /* ***************************************** */



More information about the Bf-blender-cvs mailing list