[Bf-blender-cvs] [3afe60b2c46] soc-2019-npr: LANPR: Auto update GPencil when in other engines.

YimingWu noreply at git.blender.org
Tue Jul 16 14:23:25 CEST 2019


Commit: 3afe60b2c46c8839b57088ea913f9ae9fe8724a2
Author: YimingWu
Date:   Tue Jul 16 20:23:01 2019 +0800
Branches: soc-2019-npr
https://developer.blender.org/rB3afe60b2c46c8839b57088ea913f9ae9fe8724a2

LANPR: Auto update GPencil when in other engines.

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

M	source/blender/editors/include/ED_lanpr.h
M	source/blender/editors/lanpr/lanpr_ops.c
M	source/blender/editors/render/render_update.c

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

diff --git a/source/blender/editors/include/ED_lanpr.h b/source/blender/editors/include/ED_lanpr.h
index 7699b41ad84..7b570a244f4 100644
--- a/source/blender/editors/include/ED_lanpr.h
+++ b/source/blender/editors/include/ED_lanpr.h
@@ -837,4 +837,6 @@ LANPR_LineLayerComponent *ED_lanpr_new_line_component(struct SceneLANPR *lanpr);
 LANPR_BoundingArea *ED_lanpr_get_point_bounding_area(LANPR_RenderBuffer *rb, real x, real y);
 LANPR_BoundingArea *ED_lanpr_get_point_bounding_area_deep(LANPR_RenderBuffer *rb, real x, real y);
 
+void ED_lanpr_post_frame_update_external(struct Scene* s, struct Depsgraph* dg);
+
 #endif /* __ED_LANPR_H__ */
diff --git a/source/blender/editors/lanpr/lanpr_ops.c b/source/blender/editors/lanpr/lanpr_ops.c
index 0c5edf23e45..11a7b0799bb 100644
--- a/source/blender/editors/lanpr/lanpr_ops.c
+++ b/source/blender/editors/lanpr/lanpr_ops.c
@@ -4454,10 +4454,7 @@ static void lanpr_update_gp_strokes_collection(
                                     col->lanpr.types);
   DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_COPY_ON_WRITE);
 }
-static int lanpr_update_gp_strokes_exec(struct bContext *C, struct wmOperator *op)
-{
-  Scene *scene = CTX_data_scene(C);
-  Depsgraph *dg = CTX_data_depsgraph(C);
+static void lanpr_update_gp_strokes_actual(Scene* scene, Depsgraph* dg){
   SceneLANPR *lanpr = &scene->lanpr;
   int frame = scene->r.cfra;
 
@@ -4473,6 +4470,13 @@ static int lanpr_update_gp_strokes_exec(struct bContext *C, struct wmOperator *o
   lanpr_update_gp_strokes_collection(dg, scene->master_collection, frame, 0, NULL);
 
   lanpr_clear_gp_lanpr_flags(dg, frame);
+}
+static int lanpr_update_gp_strokes_exec(struct bContext *C, struct wmOperator *op)
+{
+  Scene *scene = CTX_data_scene(C);
+  Depsgraph *dg = CTX_data_depsgraph(C);
+
+  lanpr_update_gp_strokes_actual(scene,dg);
 
   WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED | ND_SPACE_PROPERTIES, NULL);
 
@@ -4617,7 +4621,23 @@ void OBJECT_OT_lanpr_update_gp_source(struct wmOperatorType *ot)
 
 /* Post-frame updater */
 
+void ED_lanpr_post_frame_update_external(Scene* s, Depsgraph* dg){
+  if(s->lanpr.master_mode != LANPR_MASTER_MODE_SOFTWARE || !s->lanpr.auto_update){
+    return;
+  }
+  if(strcmp(s->r.engine, RE_engine_id_BLENDER_LANPR)){
+    /* Not LANPR engine, do GPencil updates. */
+    /* LANPR engine will automatically update when drawing the viewport. */
+    if (!lanpr_share.render_buffer_shared ||
+      lanpr_share.render_buffer_shared->cached_for_frame != s->r.cfra) {
+      ED_lanpr_compute_feature_lines_internal(dg, 0);
+      lanpr_update_gp_strokes_actual(s,dg);
+    }
+  }
+}
+
 
+/* Inspect below */
 static void lanpr_post_frame_updater(struct Main *UNUSED(_1),
                                      struct ID *scene,
                                      void *UNUSED(_3))
@@ -4627,8 +4647,6 @@ static void lanpr_post_frame_updater(struct Main *UNUSED(_1),
     return;
   }
   if(strcmp(s->r.engine, RE_engine_id_BLENDER_LANPR)){
-    /* Not LANPR engine, do GPencil updates. */
-    /* LANPR engine will automatically update when drawing the viewport. */
 
     /* No depsgraph reference here in the callback. Not working :? */
     
diff --git a/source/blender/editors/render/render_update.c b/source/blender/editors/render/render_update.c
index 64869b71746..114a81e87d7 100644
--- a/source/blender/editors/render/render_update.c
+++ b/source/blender/editors/render/render_update.c
@@ -59,6 +59,8 @@
 #include "ED_render.h"
 #include "ED_view3d.h"
 
+#include "ED_lanpr.h"
+
 #include "DEG_depsgraph.h"
 
 #include "WM_api.h"
@@ -95,6 +97,9 @@ void ED_render_scene_update(const DEGEditorUpdateContext *update_ctx, int update
     return;
   }
 
+  /* Temporary solution for updating LANPR GPencil targets. */
+  ED_lanpr_post_frame_update_external(scene,update_ctx->depsgraph);
+
   recursive_check = true;
 
   C = CTX_create();



More information about the Bf-blender-cvs mailing list