Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2019-02-25 21:37:08 +0300
committerClément Foucault <foucault.clem@gmail.com>2019-02-25 21:37:16 +0300
commit753e73009f7886d61aa80ae0ec56e87dd203bfe7 (patch)
treed386ed0e6f7b33f60fac7f5d0093794a331c93b3 /source/blender/draw/intern/draw_cache_impl_displist.c
parenta7acd4690c20a2363e665b29cd41dbf520454e2e (diff)
Fix T61801: Wireframes on curves not working
Diffstat (limited to 'source/blender/draw/intern/draw_cache_impl_displist.c')
-rw-r--r--source/blender/draw/intern/draw_cache_impl_displist.c75
1 files changed, 26 insertions, 49 deletions
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. */
- uchar sharpness = 0xFF;
- GPU_vertbuf_attr_set(dwt->vbo, dwt->wd_id, indices[i], &sharpness);
- }
+ GPUIndexBufBuilder *eld = (GPUIndexBufBuilder *)thunk;
+ GPU_indexbuf_add_line_verts(eld, v1, v2);
+ GPU_indexbuf_add_line_verts(eld, v2, v3);
+ GPU_indexbuf_add_line_verts(eld, v3, v1);
}
static void set_overlay_wires_quad_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. */
- uchar sharpness = (i == 0) ? 0x00 : 0xFF;
- GPU_vertbuf_attr_set(dwt->vbo, dwt->wd_id, indices[i], &sharpness);
- }
+ GPUIndexBufBuilder *eld = (GPUIndexBufBuilder *)thunk;
+ GPU_indexbuf_add_line_verts(eld, v1, v3);
+ GPU_indexbuf_add_line_verts(eld, v3, v2);
}
-/* TODO reuse the position and normals from other tesselation vertbuf. */
-void DRW_displist_vertbuf_create_wireframe_data_tess(ListBase *lb, GPUVertBuf *vbo)
+void DRW_displist_indexbuf_create_lines_in_order(ListBase *lb, GPUIndexBuf *ibo)
{
- static DRWDisplistWireThunk thunk;
- static GPUVertFormat format = {0};
- if (format.attr_len == 0) {
- thunk.wd_id = GPU_vertformat_attr_add(&format, "wd", GPU_COMP_U8, 1, GPU_FETCH_INT_TO_FLOAT_UNIT);
- GPU_vertformat_triple_load(&format);
- }
-
- GPU_vertbuf_init_with_format(vbo, &format);
- thunk.vbo = vbo;
+ const int tri_len = curve_render_surface_tri_len_get(lb);
+ const int vert_len = curve_render_surface_vert_len_get(lb);
- int vert_len = curve_render_surface_tri_len_get(lb) * 3;
- GPU_vertbuf_data_alloc(thunk.vbo, vert_len);
+ GPUIndexBufBuilder elb;
+ GPU_indexbuf_init(&elb, GPU_PRIM_LINES, tri_len * 3, vert_len);
- thunk.ofs = 0;
+ int ofs = 0;
for (const DispList *dl = lb->first; dl; dl = dl->next) {
- thunk.dl = dl;
- /* TODO consider non-manifold edges correctly. */
- thunk.ofs = displist_indexbufbuilder_tess_set(
- set_overlay_wires_tri_indices,
- set_overlay_wires_quad_tri_indices,
- &thunk, dl, thunk.ofs);
+ displist_indexbufbuilder_set(
+ (SetTriIndicesFn *)set_overlay_wires_tri_indices,
+ (SetTriIndicesFn *)set_overlay_wires_quad_tri_indices,
+ &elb, dl, ofs);
+ ofs += dl_vert_len(dl);
}
- if (thunk.ofs < vert_len) {
- GPU_vertbuf_data_resize(thunk.vbo, thunk.ofs);
- }
+ GPU_indexbuf_build_in_place(&elb, ibo);
}
static void surf_uv_quad(const DispList *dl, const uint quad[4], float r_uv[4][2])
@@ -364,7 +341,7 @@ static void displist_vertbuf_attr_set_tri_pos_nor_uv(
}
}
-void DRW_displist_vertbuf_create_pos_and_nor_and_uv_tess(
+void DRW_displist_vertbuf_create_loop_pos_and_nor_and_uv(
ListBase *lb,
GPUVertBuf *vbo_pos_nor, GPUVertBuf *vbo_uv)
{