Commit: 29f1a8f175725a82b5590c12c569632b51e062b8
Author: Yiming Wu
Date:   Thu May 30 19:21:58 2019 +0800
Branches: soc-2019-npr
https://developer.blender.org/rB29f1a8f175725a82b5590c12c569632b51e062b8

Added LANPR chain conversion funcitons. Now LANPR to GP is able to run.

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

M       source/blender/draw/engines/lanpr/lanpr_access.c
M       source/blender/draw/engines/lanpr/lanpr_access.h
M       source/blender/draw/engines/lanpr/lanpr_ops.c
M       source/blender/gpencil_modifiers/intern/MOD_gpencilstroke.c

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

diff --git a/source/blender/draw/engines/lanpr/lanpr_access.c 
b/source/blender/draw/engines/lanpr/lanpr_access.c
index f618888e256..29fa64f2984 100644
--- a/source/blender/draw/engines/lanpr/lanpr_access.c
+++ b/source/blender/draw/engines/lanpr/lanpr_access.c
@@ -23,6 +23,7 @@
 #include "BKE_mesh_mapping.h"
 
 #include "lanpr_all.h"
+#include "lanpr_access.h"
 
 static BMVert* split_edge_and_move(BMesh *bm, BMEdge *edge, const float 
new_pos[3]){
        //Split edge one time and move the created vert to new_pos
@@ -119,9 +120,9 @@ void lanpr_generate_gpencil_geometry(
        BM_ITER_MESH (vert, &iter, bm, BM_VERTS_OF_MESH) {
 
         //Have we already used this vert?
-               if(!BM_elem_flag_test(vert, BM_ELEM_SELECT)){
-                       continue;
-               }
+               //if(!BM_elem_flag_test(vert, BM_ELEM_SELECT)){
+               //      continue;
+               //}
 
                BMVert *prepend_vert = NULL;
                BMVert *next_vert = vert;
@@ -230,4 +231,56 @@ void lanpr_generate_gpencil_geometry(
        }
 
        BM_mesh_free(bm);
-}
\ No newline at end of file
+}
+
+void lanpr_generate_gpencil_from_chain(
+        GpencilModifierData *md, Depsgraph *depsgraph,
+        Object *ob, bGPDlayer *gpl, bGPDframe *gpf)
+{
+       StrokeGpencilModifierData *gpmd = (StrokeGpencilModifierData *)md;
+       Scene *scene = DEG_get_evaluated_scene(depsgraph);
+       LANPR_RenderBuffer *rb = scene->lanpr.render_buffer;
+
+       if( rb == NULL ){
+               printf("NULL LANPR rb!\n");
+               return;
+       }
+
+       int color_idx = 0;
+       int tot_points = 0;
+       short thickness = 1;
+
+       float mat[4][4];
+
+       unit_m4(mat);
+
+       //Split countour lines at occlution points and deselect occluded segment
+       LANPR_RenderLine *rl;
+       LANPR_RenderLineSegment *rls, *irls;
+
+       LANPR_RenderLineChain* rlc;
+       LANPR_RenderLineChainItem* rlci;
+       for (rlc = rb->chains.first;rlc;rlc=rlc->item.next){
+
+               int array_idx = 0;
+               int count = lanpr_count_chain(rlc);
+               bGPDstroke *gps = BKE_gpencil_add_stroke(gpf, color_idx, count, 
thickness);
+
+               float *stroke_data = BLI_array_alloca(stroke_data, count * 
GP_PRIM_DATABUF_SIZE);
+
+               for(rlci = rlc->chain.first;rlci;rlci=rlci->item.next){
+                       float opatity=rlci->occlusion?0.1f:1.0f;
+                       stroke_data[array_idx] = rlci->pos[0];
+                       stroke_data[array_idx + 1] = rlci->pos[1];
+                       stroke_data[array_idx + 2] = rlci->pos[2];
+                       stroke_data[array_idx + 3] = opatity; //thickness
+                       stroke_data[array_idx + 4] = opatity; //hardness?
+                       array_idx+=5;
+               }
+
+               BKE_gpencil_stroke_add_points(gps, stroke_data, count, mat);
+
+       }
+
+}
+
diff --git a/source/blender/draw/engines/lanpr/lanpr_access.h 
b/source/blender/draw/engines/lanpr/lanpr_access.h
index 755c57c67a2..ad3f47e1dc8 100644
--- a/source/blender/draw/engines/lanpr/lanpr_access.h
+++ b/source/blender/draw/engines/lanpr/lanpr_access.h
@@ -8,8 +8,16 @@
 
 #include "BKE_gpencil.h"
 
+typedef struct LANPR_RenderLineChain LANPR_RenderLineChain;
+
 void lanpr_generate_gpencil_geometry(
         GpencilModifierData *md, Depsgraph *depsgraph,
         Object *ob, bGPDlayer *gpl, bGPDframe *gpf);
 
+void lanpr_generate_gpencil_from_chain(
+        GpencilModifierData *md, Depsgraph *depsgraph,
+        Object *ob, bGPDlayer *gpl, bGPDframe *gpf);
+
+int lanpr_count_chain(LANPR_RenderLineChain *rlc);
+
 #endif
diff --git a/source/blender/draw/engines/lanpr/lanpr_ops.c 
b/source/blender/draw/engines/lanpr/lanpr_ops.c
index aba292f6eac..2ab9f6f3d24 100644
--- a/source/blender/draw/engines/lanpr/lanpr_ops.c
+++ b/source/blender/draw/engines/lanpr/lanpr_ops.c
@@ -60,7 +60,7 @@ int lanpr_triangle_line_imagespace_intersection_v2(SpinLock 
*spl,
                                                    double *To);
 void lanpr_compute_view_Vector(LANPR_RenderBuffer *rb);
 
-int use_smooth_contour_modifier_contour = 1;  // debug purpose
+int use_smooth_contour_modifier_contour = 0;  // debug purpose
 
 /* ====================================== base structures
  * =========================================== */
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilstroke.c 
b/source/blender/gpencil_modifiers/intern/MOD_gpencilstroke.c
index 4b8b3595c19..104e5bddb44 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilstroke.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilstroke.c
@@ -92,7 +92,7 @@ static void bakeModifier(
 
        for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
                for (bGPDframe *gpf = gpl->frames.first; gpf; gpf = gpf->next) {
-                       lanpr_generate_gpencil_geometry(md, depsgraph, ob, gpl, 
gpf);
+                       //lanpr_generate_gpencil_geometry(md, depsgraph, ob, 
gpl, gpf);
                        return;
                }
        }
@@ -105,7 +105,8 @@ static void generateStrokes(
         GpencilModifierData *md, Depsgraph *depsgraph,
         Object *ob, bGPDlayer *gpl, bGPDframe *gpf)
 {
-       lanpr_generate_gpencil_geometry(md, depsgraph, ob, gpl, gpf);
+       //lanpr_generate_gpencil_geometry(md, depsgraph, ob, gpl, gpf);
+       lanpr_generate_gpencil_from_chain(md, depsgraph, ob, gpl, gpf);
 }
 
 static void updateDepsgraph(GpencilModifierData *md, const 
ModifierUpdateDepsgraphContext *ctx)

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to