Commit: 753e73009f7886d61aa80ae0ec56e87dd203bfe7
Author: Clément Foucault
Date:   Mon Feb 25 19:37:08 2019 +0100
Branches: master
https://developer.blender.org/rB753e73009f7886d61aa80ae0ec56e87dd203bfe7

Fix T61801: Wireframes on curves not working

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

M       source/blender/draw/intern/draw_cache_impl.h
M       source/blender/draw/intern/draw_cache_impl_curve.c
M       source/blender/draw/intern/draw_cache_impl_displist.c
M       source/blender/draw/intern/draw_cache_impl_metaball.c

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

diff --git a/source/blender/draw/intern/draw_cache_impl.h 
b/source/blender/draw/intern/draw_cache_impl.h
index f56caa12fd5..2ec4ab526ef 100644
--- a/source/blender/draw/intern/draw_cache_impl.h
+++ b/source/blender/draw/intern/draw_cache_impl.h
@@ -81,12 +81,12 @@ struct GPUBatch 
**DRW_metaball_batch_cache_get_surface_shaded(
 struct GPUBatch *DRW_metaball_batch_cache_get_wireframes_face(struct Object 
*ob);
 
 /* DispList */
-void DRW_displist_vertbuf_create_pos_and_nor(struct ListBase *lb, struct 
GPUVertBuf *vbo);
-void DRW_displist_vertbuf_create_pos_and_nor_and_uv_tess(
+void DRW_displist_vertbuf_create_pos_and_nor_and_wiredata(struct ListBase *lb, 
struct GPUVertBuf *vbo);
+void DRW_displist_vertbuf_create_loop_pos_and_nor_and_uv(
         struct ListBase *lb, struct GPUVertBuf *vbo_pos_nor, struct GPUVertBuf 
*vbo_uv);
-void DRW_displist_vertbuf_create_wireframe_data_tess(struct ListBase *lb, 
struct GPUVertBuf *vbo);
-void DRW_displist_indexbuf_create_triangles_in_order(struct ListBase *lb, 
struct GPUIndexBuf *vbo);
-void DRW_displist_indexbuf_create_triangles_tess_split_by_material(
+void DRW_displist_indexbuf_create_lines_in_order(struct ListBase *lb, struct 
GPUIndexBuf *ibo);
+void DRW_displist_indexbuf_create_triangles_in_order(struct ListBase *lb, 
struct GPUIndexBuf *ibo);
+void DRW_displist_indexbuf_create_triangles_loop_split_by_material(
         struct ListBase *lb, struct GPUIndexBuf **ibo_mat, uint mat_len);
 
 /* Lattice */
diff --git a/source/blender/draw/intern/draw_cache_impl_curve.c 
b/source/blender/draw/intern/draw_cache_impl_curve.c
index aef24dd0a72..d40e33ab6e7 100644
--- a/source/blender/draw/intern/draw_cache_impl_curve.c
+++ b/source/blender/draw/intern/draw_cache_impl_curve.c
@@ -347,14 +347,10 @@ typedef struct CurveBatchCache {
        struct {
                GPUVertBuf *pos_nor;
                GPUVertBuf *curves_pos;
-       } ordered;
-
-       struct {
-               GPUVertBuf *pos_nor;
-               GPUVertBuf *uv;
 
-               GPUVertBuf *wireframe_data;
-       } tess;
+               GPUVertBuf *loop_pos_nor;
+               GPUVertBuf *loop_uv;
+       } ordered;
 
        struct {
                /* Curve points. Aligned with ordered.pos_nor */
@@ -367,6 +363,7 @@ typedef struct CurveBatchCache {
 
        struct {
                GPUIndexBuf *surfaces_tris;
+               GPUIndexBuf *surfaces_lines;
                GPUIndexBuf *curves_lines;
                /* Edit mode */
                GPUIndexBuf *edit_verts_points; /* Only control points. Not 
handles. */
@@ -375,14 +372,13 @@ typedef struct CurveBatchCache {
 
        struct {
                GPUBatch *surfaces;
+               GPUBatch *surfaces_edges;
                GPUBatch *curves;
                /* control handles and vertices */
                GPUBatch *edit_edges;
                GPUBatch *edit_verts;
                GPUBatch *edit_handles_verts;
                GPUBatch *edit_normals;
-               /* Triangles for object mode wireframe. */
-               GPUBatch *wire_triangles;
        } batch;
 
        GPUIndexBuf **surf_per_mat_tris;
@@ -506,10 +502,6 @@ static void curve_batch_cache_clear(Curve *cu)
                GPUVertBuf **vbo = (GPUVertBuf **)&cache->ordered;
                GPU_VERTBUF_DISCARD_SAFE(vbo[i]);
        }
-       for (int i = 0; i < sizeof(cache->tess) / sizeof(void *); ++i) {
-               GPUVertBuf **vbo = (GPUVertBuf **)&cache->tess;
-               GPU_VERTBUF_DISCARD_SAFE(vbo[i]);
-       }
        for (int i = 0; i < sizeof(cache->edit) / sizeof(void *); ++i) {
                GPUVertBuf **vbo = (GPUVertBuf **)&cache->edit;
                GPU_VERTBUF_DISCARD_SAFE(vbo[i]);
@@ -884,7 +876,7 @@ GPUBatch **DRW_curve_batch_cache_get_surface_shaded(
 GPUBatch *DRW_curve_batch_cache_get_wireframes_face(Curve *cu)
 {
        CurveBatchCache *cache = curve_batch_cache_get(cu);
-       return DRW_batch_request(&cache->batch.wire_triangles);
+       return DRW_batch_request(&cache->batch.surfaces_edges);
 }
 
 /** \} */
@@ -920,14 +912,14 @@ void DRW_curve_batch_cache_create_requested(Object *ob)
                DRW_ibo_request(cache->batch.surfaces, 
&cache->ibo.surfaces_tris);
                DRW_vbo_request(cache->batch.surfaces, &cache->ordered.pos_nor);
        }
+       if (DRW_batch_requested(cache->batch.surfaces_edges, GPU_PRIM_LINES)) {
+               DRW_ibo_request(cache->batch.surfaces_edges, 
&cache->ibo.surfaces_lines);
+               DRW_vbo_request(cache->batch.surfaces_edges, 
&cache->ordered.pos_nor);
+       }
        if (DRW_batch_requested(cache->batch.curves, GPU_PRIM_LINE_STRIP)) {
                DRW_ibo_request(cache->batch.curves, &cache->ibo.curves_lines);
                DRW_vbo_request(cache->batch.curves, 
&cache->ordered.curves_pos);
        }
-       if (DRW_batch_requested(cache->batch.wire_triangles, GPU_PRIM_TRIS)) {
-               DRW_vbo_request(cache->batch.wire_triangles, 
&cache->tess.pos_nor);
-               DRW_vbo_request(cache->batch.wire_triangles, 
&cache->tess.wireframe_data);
-       }
 
        /* Edit mode */
        if (DRW_batch_requested(cache->batch.edit_edges, GPU_PRIM_LINES)) {
@@ -953,9 +945,9 @@ void DRW_curve_batch_cache_create_requested(Object *ob)
                                DRW_ibo_request(cache->surf_per_mat[i], 
&cache->surf_per_mat_tris[i]);
                        }
                        if (cache->cd_used & CD_MLOOPUV) {
-                               DRW_vbo_request(cache->surf_per_mat[i], 
&cache->tess.uv);
+                               DRW_vbo_request(cache->surf_per_mat[i], 
&cache->ordered.loop_uv);
                        }
-                       DRW_vbo_request(cache->surf_per_mat[i], 
&cache->tess.pos_nor);
+                       DRW_vbo_request(cache->surf_per_mat[i], 
&cache->ordered.loop_pos_nor);
                }
        }
 
@@ -963,10 +955,10 @@ void DRW_curve_batch_cache_create_requested(Object *ob)
        int mr_flag = 0;
        DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_flag, cache->ordered.pos_nor, 
CU_DATATYPE_SURFACE);
        DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_flag, cache->ordered.curves_pos, 
CU_DATATYPE_WIRE);
-       DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_flag, cache->tess.pos_nor, 
CU_DATATYPE_SURFACE);
-       DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_flag, cache->tess.uv, 
CU_DATATYPE_SURFACE);
-       DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_flag, cache->tess.wireframe_data, 
CU_DATATYPE_SURFACE);
+       DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_flag, cache->ordered.loop_pos_nor, 
CU_DATATYPE_SURFACE);
+       DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_flag, cache->ordered.loop_uv, 
CU_DATATYPE_SURFACE);
        DRW_ADD_FLAG_FROM_IBO_REQUEST(mr_flag, cache->ibo.surfaces_tris, 
CU_DATATYPE_SURFACE);
+       DRW_ADD_FLAG_FROM_IBO_REQUEST(mr_flag, cache->ibo.surfaces_lines, 
CU_DATATYPE_SURFACE);
        DRW_ADD_FLAG_FROM_IBO_REQUEST(mr_flag, cache->ibo.curves_lines, 
CU_DATATYPE_WIRE);
 
        DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_flag, cache->edit.pos, 
CU_DATATYPE_OVERLAY);
@@ -987,23 +979,20 @@ void DRW_curve_batch_cache_create_requested(Object *ob)
 
        /* Generate VBOs */
        if (DRW_vbo_requested(cache->ordered.pos_nor)) {
-               DRW_displist_vertbuf_create_pos_and_nor(lb, 
cache->ordered.pos_nor);
+               DRW_displist_vertbuf_create_pos_and_nor_and_wiredata(lb, 
cache->ordered.pos_nor);
        }
        if (DRW_vbo_requested(cache->ordered.curves_pos)) {
                curve_create_curves_pos(rdata, cache->ordered.curves_pos);
        }
 
-       if (DRW_vbo_requested(cache->tess.pos_nor) ||
-           DRW_vbo_requested(cache->tess.uv))
+       if (DRW_vbo_requested(cache->ordered.loop_pos_nor) ||
+           DRW_vbo_requested(cache->ordered.loop_uv))
        {
-               DRW_displist_vertbuf_create_pos_and_nor_and_uv_tess(lb, 
cache->tess.pos_nor, cache->tess.uv);
-       }
-       if (DRW_vbo_requested(cache->tess.wireframe_data)) {
-               DRW_displist_vertbuf_create_wireframe_data_tess(lb, 
cache->tess.wireframe_data);
+               DRW_displist_vertbuf_create_loop_pos_and_nor_and_uv(lb, 
cache->ordered.loop_pos_nor, cache->ordered.loop_uv);
        }
 
        if (DRW_ibo_requested(cache->surf_per_mat_tris[0])) {
-               
DRW_displist_indexbuf_create_triangles_tess_split_by_material(lb, 
cache->surf_per_mat_tris, cache->mat_len);
+               
DRW_displist_indexbuf_create_triangles_loop_split_by_material(lb, 
cache->surf_per_mat_tris, cache->mat_len);
        }
 
        if (DRW_ibo_requested(cache->ibo.curves_lines)) {
@@ -1012,6 +1001,9 @@ void DRW_curve_batch_cache_create_requested(Object *ob)
        if (DRW_ibo_requested(cache->ibo.surfaces_tris)) {
                DRW_displist_indexbuf_create_triangles_in_order(lb, 
cache->ibo.surfaces_tris);
        }
+       if (DRW_ibo_requested(cache->ibo.surfaces_lines)) {
+               DRW_displist_indexbuf_create_lines_in_order(lb, 
cache->ibo.surfaces_lines);
+       }
 
        if (DRW_vbo_requested(cache->edit.pos) ||
            DRW_vbo_requested(cache->edit.data) ||
diff --git a/source/blender/draw/intern/draw_cache_impl_displist.c 
b/source/blender/draw/intern/draw_cache_impl_displist.c
index a63c4bfdba1..b93c63503db 100644
--- a/source/blender/draw/intern/draw_cache_impl_displist.c
+++ b/source/blender/draw/intern/draw_cache_impl_displist.c
@@ -165,14 +165,15 @@ static int displist_indexbufbuilder_tess_set(
        return v_idx;
 }
 
-void DRW_displist_vertbuf_create_pos_and_nor(ListBase *lb, GPUVertBuf *vbo)
+void DRW_displist_vertbuf_create_pos_and_nor_and_wiredata(ListBase *lb, 
GPUVertBuf *vbo)
 {
        static GPUVertFormat format = { 0 };
-       static struct { uint pos, nor; } attr_id;
+       static struct { uint pos, nor, wd; } attr_id;
        if (format.attr_len == 0) {
                /* initialize vertex format */
                attr_id.pos = GPU_vertformat_attr_add(&format, "pos", 
GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
                attr_id.nor = GPU_vertformat_attr_add(&format, "nor", 
GPU_COMP_I16, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
+               attr_id.wd  = GPU_vertformat_attr_add(&format, "wd",  
GPU_COMP_U8,  1, GPU_FETCH_INT_TO_FLOAT_UNIT);
        }
 
        GPU_vertbuf_init_with_format(vbo, &format);
@@ -188,6 +189,8 @@ void DRW_displist_vertbuf_create_pos_and_nor(ListBase *lb, 
GPUVertBuf *vbo)
                        const float *fp_no = dl->nors;
                        const int vbo_end = vbo_len_used + dl_vert_len(dl);
                        while (vbo_len_used < vbo_end) {
+                               uchar sharpness = 0xFF;
+                               GPU_vertbuf_attr_set(vbo, attr_id.wd, 
vbo_len_used, &sharpness);
                                GPU_vertbuf_attr_set(vbo, attr_id.pos, 
vbo_len_used, fp_co);
                                if (fp_no) {
                                        static short short_no[4];
@@ -224,7 +227,7 @@ void 
DRW_displist_indexbuf_create_triangles_in_order(ListBase *lb, GPUIndexBuf *
        GPU_indexbuf_build_in_place(&elb, ibo);
 }
 
-void DRW_displist_indexbuf_create_triangles_tess_split_by_material(
+void DRW_displist_indexbuf_create_triangles_loop_split_by_material(
         ListBase *lb,
         GPUIndexBuf **ibo_mats, uint mat_len)
 {
@@ -252,65 +255,39 @@ void 
DRW_displist_indexbuf_create_triangles_tess_split_by_material(
        }
 }
 
-typedef struct DRWDisplistWireThunk {
-       uint wd_id, ofs;
-       const DispList *dl;
-       GPUVertBuf *vbo;
-} DRWDisplistWireThunk;
-
 static void set_overlay_wires_tri_indices(void *thunk, uint v1, uint v2, uint 
v3)
 {
-       DRWDisplistWireThunk *dwt = (DRWDisplistWireThunk *)thunk;
-       uint indices[3] = {v1, v2, v3};
-
-       for (int i = 0; i < 3; ++i) {
-               /* TODO: Compute sharpness. For now, only tag real egdes. */

@@ Diff output truncated at 10240 characters. @@

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

Reply via email to