diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2019-03-06 18:39:07 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2019-03-06 19:33:09 +0300 |
commit | b94ec178a2062244cb4227301b6ff9370bfbd46d (patch) | |
tree | 5d36330af3318f5b16e39b65f8911141d4959c15 /source/blender/draw/intern/draw_cache.c | |
parent | 0ec98863e27250a1e86274b8ee3689abbd8542c8 (diff) |
Fix stereoscopy convergence plane placement
Note this was broken even in 2.7x.
We had a different logic for the plane wire, as for the plane itself.
And they were both wrong when changing the camera shift or the stereo
pivot.
Both of their logic is now unified and correct.
Also I had to create a new gpu batch for the quad wires, since there is
no state that allows me to filter out the geometry, and the square gpu
batch is quite different than the quad one (2d x 3d and orientation).
Diffstat (limited to 'source/blender/draw/intern/draw_cache.c')
-rw-r--r-- | source/blender/draw/intern/draw_cache.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c index 845cab620bd..28a897a4c35 100644 --- a/source/blender/draw/intern/draw_cache.c +++ b/source/blender/draw/intern/draw_cache.c @@ -53,6 +53,7 @@ static struct DRWShapeCache { GPUBatch *drw_fullscreen_quad; GPUBatch *drw_fullscreen_quad_texcoord; GPUBatch *drw_quad; + GPUBatch *drw_quad_wires; GPUBatch *drw_grid; GPUBatch *drw_sphere; GPUBatch *drw_screenspace_circle; @@ -324,6 +325,32 @@ GPUBatch *DRW_cache_quad_get(void) return SHC.drw_quad; } +/* Just a regular quad with 4 vertices - wires. */ +GPUBatch *DRW_cache_quad_wires_get(void) +{ + if (!SHC.drw_quad_wires) { + float pos[4][2] = {{-1.0f, -1.0f}, { 1.0f, -1.0f}, {1.0f, 1.0f}, {-1.0f, 1.0f}}; + + /* Position Only 2D 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, 2, GPU_FETCH_FLOAT); + } + + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, 8); + + for (int i = 0; i < 4; i++) { + GPU_vertbuf_attr_set(vbo, attr_id.pos, i * 2, pos[i % 4]); + GPU_vertbuf_attr_set(vbo, attr_id.pos, i * 2 + 1, pos[(i + 1) % 4]); + } + + SHC.drw_quad_wires = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); + } + return SHC.drw_quad_wires; +} + /* Grid */ GPUBatch *DRW_cache_grid_get(void) { |