diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2020-01-16 21:47:13 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2020-01-16 21:47:19 +0300 |
commit | d72ffb5e9a40fc2a29e76c999915103e57bffd32 (patch) | |
tree | 89330288c66cf673a547c6b29752d68d85e1d8c3 /source/blender/draw | |
parent | 5d5add5de2b384797851d5b9d964b2cf0e1410c7 (diff) |
Overlay: Fix wrong 3D icon for cubemap lightprobes
Diffstat (limited to 'source/blender/draw')
-rw-r--r-- | source/blender/draw/engines/overlay/overlay_extra.c | 4 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_cache.c | 71 |
2 files changed, 41 insertions, 34 deletions
diff --git a/source/blender/draw/engines/overlay/overlay_extra.c b/source/blender/draw/engines/overlay/overlay_extra.c index 6f4fe5573ec..3b04e99b5b2 100644 --- a/source/blender/draw/engines/overlay/overlay_extra.c +++ b/source/blender/draw/engines/overlay/overlay_extra.c @@ -140,7 +140,7 @@ void OVERLAY_extra_cache_init(OVERLAY_Data *vedata) cb->light_point = BUF_INSTANCE(grp_sub, format, DRW_cache_light_point_lines_get()); cb->light_spot = BUF_INSTANCE(grp_sub, format, DRW_cache_light_spot_lines_get()); cb->light_sun = BUF_INSTANCE(grp_sub, format, DRW_cache_light_sun_lines_get()); - cb->probe_cube = BUF_INSTANCE(grp_sub, format, DRW_cache_lightprobe_planar_get()); + cb->probe_cube = BUF_INSTANCE(grp_sub, format, DRW_cache_lightprobe_cube_get()); cb->probe_grid = BUF_INSTANCE(grp_sub, format, DRW_cache_lightprobe_grid_get()); cb->probe_planar = BUF_INSTANCE(grp_sub, format, DRW_cache_lightprobe_planar_get()); cb->solid_quad = BUF_INSTANCE(grp_sub, format, DRW_cache_quad_get()); @@ -707,7 +707,7 @@ void OVERLAY_lightprobe_cache_populate(OVERLAY_Data *vedata, Object *ob) case LIGHTPROBE_TYPE_CUBE: instdata.clip_sta = show_clipping ? prb->clipsta : -1.0; instdata.clip_end = show_clipping ? prb->clipend : -1.0; - DRW_buffer_add_entry(cb->probe_grid, color_p, &instdata); + DRW_buffer_add_entry(cb->probe_cube, color_p, &instdata); DRW_buffer_add_entry(cb->groundline, instdata.pos); if (show_influence) { diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c index 69135f8ade3..4d10e781e79 100644 --- a/source/blender/draw/intern/draw_cache.c +++ b/source/blender/draw/intern/draw_cache.c @@ -1636,45 +1636,52 @@ GPUBatch *DRW_cache_speaker_get(void) GPUBatch *DRW_cache_lightprobe_cube_get(void) { if (!SHC.drw_lightprobe_cube) { - int v_idx = 0; + GPUVertFormat format = extra_vert_format(); + + int v_len = (6 + 3 + (1 + 2 * DIAMOND_NSEGMENTS) * 6) * 2; + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, v_len); + + const float r = 14.0f; + int v = 0; + int flag = VCLASS_SCREENSPACE; + /* Icon */ const float sin_pi_3 = 0.86602540378f; const float cos_pi_3 = 0.5f; - const float v[7][3] = { - {0.0f, 1.0f, 0.0f}, - {sin_pi_3, cos_pi_3, 0.0f}, - {sin_pi_3, -cos_pi_3, 0.0f}, - {0.0f, -1.0f, 0.0f}, - {-sin_pi_3, -cos_pi_3, 0.0f}, - {-sin_pi_3, cos_pi_3, 0.0f}, - {0.0f, 0.0f, 0.0f}, + const float p[7][2] = { + {0.0f, 1.0f}, + {sin_pi_3, cos_pi_3}, + {sin_pi_3, -cos_pi_3}, + {0.0f, -1.0f}, + {-sin_pi_3, -cos_pi_3}, + {-sin_pi_3, cos_pi_3}, + {0.0f, 0.0f}, }; - - /* Position Only 3D format */ - static GPUVertFormat format = {0}; - static struct { - uint pos; - } attr_id; - if (format.attr_len == 0) { - attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + for (int i = 0; i < 6; i++) { + float t1[2], t2[2]; + copy_v2_v2(t1, p[i]); + copy_v2_v2(t2, p[(i + 1) % 6]); + GPU_vertbuf_vert_set(vbo, v++, &(Vert){{t1[0] * r, t1[1] * r, 0.0f}, flag}); + GPU_vertbuf_vert_set(vbo, v++, &(Vert){{t2[0] * r, t2[1] * r, 0.0f}, flag}); } - - GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); - GPU_vertbuf_data_alloc(vbo, (6 + 3) * 2); - + GPU_vertbuf_vert_set(vbo, v++, &(Vert){{p[1][0] * r, p[1][1] * r, 0.0f}, flag}); + GPU_vertbuf_vert_set(vbo, v++, &(Vert){{p[6][0] * r, p[6][1] * r, 0.0f}, flag}); + GPU_vertbuf_vert_set(vbo, v++, &(Vert){{p[5][0] * r, p[5][1] * r, 0.0f}, flag}); + GPU_vertbuf_vert_set(vbo, v++, &(Vert){{p[6][0] * r, p[6][1] * r, 0.0f}, flag}); + GPU_vertbuf_vert_set(vbo, v++, &(Vert){{p[3][0] * r, p[3][1] * r, 0.0f}, flag}); + GPU_vertbuf_vert_set(vbo, v++, &(Vert){{p[6][0] * r, p[6][1] * r, 0.0f}, flag}); + /* Direction Lines */ + flag = VCLASS_LIGHT_DIST | VCLASS_SCREENSPACE; for (int i = 0; i < 6; i++) { - GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[i]); - GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[(i + 1) % 6]); + char axes[] = "zZyYxX"; + float zsta = light_distance_z_get(axes[i], true); + float zend = light_distance_z_get(axes[i], false); + GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0f, 0.0f, zsta}, flag}); + GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0f, 0.0f, zend}, flag}); + circle_verts(vbo, &v, DIAMOND_NSEGMENTS, 1.2f, zsta, flag); + circle_verts(vbo, &v, DIAMOND_NSEGMENTS, 1.2f, zend, flag); } - GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[1]); - GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[6]); - - GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[5]); - GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[6]); - - GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[3]); - GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[6]); - SHC.drw_lightprobe_cube = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); } return SHC.drw_lightprobe_cube; |