diff options
author | Jeroen Bakker <j.bakker@atmind.nl> | 2019-09-03 14:42:11 +0300 |
---|---|---|
committer | Jeroen Bakker <j.bakker@atmind.nl> | 2019-09-04 09:08:27 +0300 |
commit | 64f8f7db7cce0c8923afcabb523f7400f744387e (patch) | |
tree | c60fe2a51846a9b19860fbe016d1d64cea098880 /source/blender/draw/intern/draw_cache_impl_mesh.c | |
parent | 0cb730146b09b4a38abcc04e9d4660d6c2f43945 (diff) |
Fix T63755: Area Stretching Overlay
Support for UV Stretching overlay during multi object editing. The
VBO now holds the ratios per fase. In the shader these ratios will
be compared against the global ratios. The global rations are created
from all selected objects.
The current implementation does not fit well with the draw module. The
plan is to move the drawing of other spaces towards the draw manager what
leads to a better fit. Currently the details on this solution is unclear
but this requirement will become an attentionpoint in the future design.
Reviewed By: fclem
Differential Revision: https://developer.blender.org/D5665
Diffstat (limited to 'source/blender/draw/intern/draw_cache_impl_mesh.c')
-rw-r--r-- | source/blender/draw/intern/draw_cache_impl_mesh.c | 67 |
1 files changed, 42 insertions, 25 deletions
diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c index 456e21db6ed..96c677dc184 100644 --- a/source/blender/draw/intern/draw_cache_impl_mesh.c +++ b/source/blender/draw/intern/draw_cache_impl_mesh.c @@ -502,14 +502,17 @@ static void mesh_batch_cache_discard_uvedit(MeshBatchCache *cache) GPU_INDEXBUF_DISCARD_SAFE(mbufcache->ibo.edituv_points); GPU_INDEXBUF_DISCARD_SAFE(mbufcache->ibo.edituv_fdots); } - GPU_BATCH_DISCARD_SAFE(cache->batch.edituv_faces_strech_area); - GPU_BATCH_DISCARD_SAFE(cache->batch.edituv_faces_strech_angle); + GPU_BATCH_DISCARD_SAFE(cache->batch.edituv_faces_stretch_area); + GPU_BATCH_DISCARD_SAFE(cache->batch.edituv_faces_stretch_angle); GPU_BATCH_DISCARD_SAFE(cache->batch.edituv_faces); GPU_BATCH_DISCARD_SAFE(cache->batch.edituv_edges); GPU_BATCH_DISCARD_SAFE(cache->batch.edituv_verts); GPU_BATCH_DISCARD_SAFE(cache->batch.edituv_fdots); GPU_BATCH_DISCARD_SAFE(cache->batch.wire_loops_uvs); + cache->tot_area = 0.0f; + cache->tot_uv_area = 0.0f; + cache->batch_ready &= ~MBC_EDITUV; } @@ -577,8 +580,8 @@ void DRW_mesh_batch_cache_dirty_tag(Mesh *me, int mode) GPU_VERTBUF_DISCARD_SAFE(mbufcache->vbo.edituv_data); GPU_VERTBUF_DISCARD_SAFE(mbufcache->vbo.fdots_edituv_data); } - GPU_BATCH_DISCARD_SAFE(cache->batch.edituv_faces_strech_area); - GPU_BATCH_DISCARD_SAFE(cache->batch.edituv_faces_strech_angle); + GPU_BATCH_DISCARD_SAFE(cache->batch.edituv_faces_stretch_area); + GPU_BATCH_DISCARD_SAFE(cache->batch.edituv_faces_stretch_angle); GPU_BATCH_DISCARD_SAFE(cache->batch.edituv_faces); GPU_BATCH_DISCARD_SAFE(cache->batch.edituv_edges); GPU_BATCH_DISCARD_SAFE(cache->batch.edituv_verts); @@ -874,20 +877,34 @@ GPUBatch *DRW_mesh_batch_cache_get_verts_with_select_id(Mesh *me) /** \name UV Image editor API * \{ */ -GPUBatch *DRW_mesh_batch_cache_get_edituv_faces_strech_area(Mesh *me) +/* Creates the GPUBatch for drawing the UV Stretching Area Overlay. + * Optional retrieves the total area or total uv area of the mesh. + * + * The `cache->tot_area` and cache->tot_uv_area` update are calculation are + * only valid after calling `DRW_mesh_batch_cache_create_requested`. */ +GPUBatch *DRW_mesh_batch_cache_get_edituv_faces_stretch_area(Mesh *me, + float *tot_area, + float *tot_uv_area) { MeshBatchCache *cache = mesh_batch_cache_get(me); texpaint_request_active_uv(cache, me); - mesh_batch_cache_add_request(cache, MBC_EDITUV_FACES_STRECH_AREA); - return DRW_batch_request(&cache->batch.edituv_faces_strech_area); + mesh_batch_cache_add_request(cache, MBC_EDITUV_FACES_STRETCH_AREA); + + if (tot_area != NULL) { + *tot_area = cache->tot_area; + } + if (tot_uv_area != NULL) { + *tot_uv_area = cache->tot_uv_area; + } + return DRW_batch_request(&cache->batch.edituv_faces_stretch_area); } -GPUBatch *DRW_mesh_batch_cache_get_edituv_faces_strech_angle(Mesh *me) +GPUBatch *DRW_mesh_batch_cache_get_edituv_faces_stretch_angle(Mesh *me) { MeshBatchCache *cache = mesh_batch_cache_get(me); texpaint_request_active_uv(cache, me); - mesh_batch_cache_add_request(cache, MBC_EDITUV_FACES_STRECH_ANGLE); - return DRW_batch_request(&cache->batch.edituv_faces_strech_angle); + mesh_batch_cache_add_request(cache, MBC_EDITUV_FACES_STRETCH_ANGLE); + return DRW_batch_request(&cache->batch.edituv_faces_stretch_angle); } GPUBatch *DRW_mesh_batch_cache_get_edituv_faces(Mesh *me) @@ -1001,8 +1018,8 @@ void DRW_mesh_batch_cache_create_requested( } if (batch_requested & - (MBC_SURFACE | MBC_SURF_PER_MAT | MBC_WIRE_LOOPS_UVS | MBC_EDITUV_FACES_STRECH_AREA | - MBC_EDITUV_FACES_STRECH_ANGLE | MBC_EDITUV_FACES | MBC_EDITUV_EDGES | MBC_EDITUV_VERTS)) { + (MBC_SURFACE | MBC_SURF_PER_MAT | MBC_WIRE_LOOPS_UVS | MBC_EDITUV_FACES_STRETCH_AREA | + MBC_EDITUV_FACES_STRETCH_ANGLE | MBC_EDITUV_FACES | MBC_EDITUV_EDGES | MBC_EDITUV_VERTS)) { /* Modifiers will only generate an orco layer if the mesh is deformed. */ if (cache->cd_needed.orco != 0) { if (CustomData_get_layer(&me->vdata, CD_ORCO) == NULL) { @@ -1078,8 +1095,8 @@ void DRW_mesh_batch_cache_create_requested( /* We only clear the batches as they may already have been * referenced. */ GPU_BATCH_CLEAR_SAFE(cache->batch.wire_loops_uvs); - GPU_BATCH_CLEAR_SAFE(cache->batch.edituv_faces_strech_area); - GPU_BATCH_CLEAR_SAFE(cache->batch.edituv_faces_strech_angle); + GPU_BATCH_CLEAR_SAFE(cache->batch.edituv_faces_stretch_area); + GPU_BATCH_CLEAR_SAFE(cache->batch.edituv_faces_stretch_angle); GPU_BATCH_CLEAR_SAFE(cache->batch.edituv_faces); GPU_BATCH_CLEAR_SAFE(cache->batch.edituv_edges); GPU_BATCH_CLEAR_SAFE(cache->batch.edituv_verts); @@ -1261,17 +1278,17 @@ void DRW_mesh_batch_cache_create_requested( DRW_vbo_request(cache->batch.edituv_faces, &mbufcache->vbo.uv); DRW_vbo_request(cache->batch.edituv_faces, &mbufcache->vbo.edituv_data); } - if (DRW_batch_requested(cache->batch.edituv_faces_strech_area, GPU_PRIM_TRIS)) { - DRW_ibo_request(cache->batch.edituv_faces_strech_area, &mbufcache->ibo.edituv_tris); - DRW_vbo_request(cache->batch.edituv_faces_strech_area, &mbufcache->vbo.uv); - DRW_vbo_request(cache->batch.edituv_faces_strech_area, &mbufcache->vbo.edituv_data); - DRW_vbo_request(cache->batch.edituv_faces_strech_area, &mbufcache->vbo.stretch_area); - } - if (DRW_batch_requested(cache->batch.edituv_faces_strech_angle, GPU_PRIM_TRIS)) { - DRW_ibo_request(cache->batch.edituv_faces_strech_angle, &mbufcache->ibo.edituv_tris); - DRW_vbo_request(cache->batch.edituv_faces_strech_angle, &mbufcache->vbo.uv); - DRW_vbo_request(cache->batch.edituv_faces_strech_angle, &mbufcache->vbo.edituv_data); - DRW_vbo_request(cache->batch.edituv_faces_strech_angle, &mbufcache->vbo.stretch_angle); + if (DRW_batch_requested(cache->batch.edituv_faces_stretch_area, GPU_PRIM_TRIS)) { + DRW_ibo_request(cache->batch.edituv_faces_stretch_area, &mbufcache->ibo.edituv_tris); + DRW_vbo_request(cache->batch.edituv_faces_stretch_area, &mbufcache->vbo.uv); + DRW_vbo_request(cache->batch.edituv_faces_stretch_area, &mbufcache->vbo.edituv_data); + DRW_vbo_request(cache->batch.edituv_faces_stretch_area, &mbufcache->vbo.stretch_area); + } + if (DRW_batch_requested(cache->batch.edituv_faces_stretch_angle, GPU_PRIM_TRIS)) { + DRW_ibo_request(cache->batch.edituv_faces_stretch_angle, &mbufcache->ibo.edituv_tris); + DRW_vbo_request(cache->batch.edituv_faces_stretch_angle, &mbufcache->vbo.uv); + DRW_vbo_request(cache->batch.edituv_faces_stretch_angle, &mbufcache->vbo.edituv_data); + DRW_vbo_request(cache->batch.edituv_faces_stretch_angle, &mbufcache->vbo.stretch_angle); } if (DRW_batch_requested(cache->batch.edituv_edges, GPU_PRIM_LINES)) { DRW_ibo_request(cache->batch.edituv_edges, &mbufcache->ibo.edituv_lines); |