Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/intern/draw_cache_impl_mesh.c
| Show First 20 Lines • Show All 496 Lines • ▼ Show 20 Lines | FOREACH_MESH_BUFFER_CACHE(cache, mbufcache) | ||||
| GPU_VERTBUF_DISCARD_SAFE(mbufcache->vbo.edituv_data); | GPU_VERTBUF_DISCARD_SAFE(mbufcache->vbo.edituv_data); | ||||
| GPU_VERTBUF_DISCARD_SAFE(mbufcache->vbo.fdots_uv); | GPU_VERTBUF_DISCARD_SAFE(mbufcache->vbo.fdots_uv); | ||||
| GPU_VERTBUF_DISCARD_SAFE(mbufcache->vbo.fdots_edituv_data); | GPU_VERTBUF_DISCARD_SAFE(mbufcache->vbo.fdots_edituv_data); | ||||
| GPU_INDEXBUF_DISCARD_SAFE(mbufcache->ibo.edituv_tris); | GPU_INDEXBUF_DISCARD_SAFE(mbufcache->ibo.edituv_tris); | ||||
| GPU_INDEXBUF_DISCARD_SAFE(mbufcache->ibo.edituv_lines); | GPU_INDEXBUF_DISCARD_SAFE(mbufcache->ibo.edituv_lines); | ||||
| GPU_INDEXBUF_DISCARD_SAFE(mbufcache->ibo.edituv_points); | GPU_INDEXBUF_DISCARD_SAFE(mbufcache->ibo.edituv_points); | ||||
| GPU_INDEXBUF_DISCARD_SAFE(mbufcache->ibo.edituv_fdots); | 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_stretch_area); | ||||
| GPU_BATCH_DISCARD_SAFE(cache->batch.edituv_faces_strech_angle); | 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_faces); | ||||
| GPU_BATCH_DISCARD_SAFE(cache->batch.edituv_edges); | GPU_BATCH_DISCARD_SAFE(cache->batch.edituv_edges); | ||||
| GPU_BATCH_DISCARD_SAFE(cache->batch.edituv_verts); | GPU_BATCH_DISCARD_SAFE(cache->batch.edituv_verts); | ||||
| GPU_BATCH_DISCARD_SAFE(cache->batch.edituv_fdots); | GPU_BATCH_DISCARD_SAFE(cache->batch.edituv_fdots); | ||||
| GPU_BATCH_DISCARD_SAFE(cache->batch.wire_loops_uvs); | GPU_BATCH_DISCARD_SAFE(cache->batch.wire_loops_uvs); | ||||
| cache->batch_ready &= ~MBC_EDITUV; | cache->batch_ready &= ~MBC_EDITUV; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | case BKE_MESH_BATCH_DIRTY_UVEDIT_ALL: | ||||
| mesh_batch_cache_discard_uvedit(cache); | mesh_batch_cache_discard_uvedit(cache); | ||||
| break; | break; | ||||
| case BKE_MESH_BATCH_DIRTY_UVEDIT_SELECT: | case BKE_MESH_BATCH_DIRTY_UVEDIT_SELECT: | ||||
| FOREACH_MESH_BUFFER_CACHE(cache, mbufcache) | FOREACH_MESH_BUFFER_CACHE(cache, mbufcache) | ||||
| { | { | ||||
| GPU_VERTBUF_DISCARD_SAFE(mbufcache->vbo.edituv_data); | GPU_VERTBUF_DISCARD_SAFE(mbufcache->vbo.edituv_data); | ||||
| GPU_VERTBUF_DISCARD_SAFE(mbufcache->vbo.fdots_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_stretch_area); | ||||
| GPU_BATCH_DISCARD_SAFE(cache->batch.edituv_faces_strech_angle); | 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_faces); | ||||
| GPU_BATCH_DISCARD_SAFE(cache->batch.edituv_edges); | GPU_BATCH_DISCARD_SAFE(cache->batch.edituv_edges); | ||||
| GPU_BATCH_DISCARD_SAFE(cache->batch.edituv_verts); | GPU_BATCH_DISCARD_SAFE(cache->batch.edituv_verts); | ||||
| GPU_BATCH_DISCARD_SAFE(cache->batch.edituv_fdots); | GPU_BATCH_DISCARD_SAFE(cache->batch.edituv_fdots); | ||||
| cache->batch_ready &= ~MBC_EDITUV; | cache->batch_ready &= ~MBC_EDITUV; | ||||
| break; | break; | ||||
| default: | default: | ||||
| BLI_assert(0); | BLI_assert(0); | ||||
| ▲ Show 20 Lines • Show All 279 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| /* ---------------------------------------------------------------------- */ | /* ---------------------------------------------------------------------- */ | ||||
| /** \name UV Image editor API | /** \name UV Image editor API | ||||
| * \{ */ | * \{ */ | ||||
| GPUBatch *DRW_mesh_batch_cache_get_edituv_faces_strech_area(Mesh *me) | 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); | MeshBatchCache *cache = mesh_batch_cache_get(me); | ||||
| texpaint_request_active_uv(cache, me); | texpaint_request_active_uv(cache, me); | ||||
| mesh_batch_cache_add_request(cache, MBC_EDITUV_FACES_STRECH_AREA); | mesh_batch_cache_add_request(cache, MBC_EDITUV_FACES_STRETCH_AREA); | ||||
| return DRW_batch_request(&cache->batch.edituv_faces_strech_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); | MeshBatchCache *cache = mesh_batch_cache_get(me); | ||||
| texpaint_request_active_uv(cache, me); | texpaint_request_active_uv(cache, me); | ||||
| mesh_batch_cache_add_request(cache, MBC_EDITUV_FACES_STRECH_ANGLE); | mesh_batch_cache_add_request(cache, MBC_EDITUV_FACES_STRETCH_ANGLE); | ||||
| return DRW_batch_request(&cache->batch.edituv_faces_strech_angle); | return DRW_batch_request(&cache->batch.edituv_faces_stretch_angle); | ||||
| } | } | ||||
| GPUBatch *DRW_mesh_batch_cache_get_edituv_faces(Mesh *me) | GPUBatch *DRW_mesh_batch_cache_get_edituv_faces(Mesh *me) | ||||
| { | { | ||||
| MeshBatchCache *cache = mesh_batch_cache_get(me); | MeshBatchCache *cache = mesh_batch_cache_get(me); | ||||
| texpaint_request_active_uv(cache, me); | texpaint_request_active_uv(cache, me); | ||||
| mesh_batch_cache_add_request(cache, MBC_EDITUV_FACES); | mesh_batch_cache_add_request(cache, MBC_EDITUV_FACES); | ||||
| return DRW_batch_request(&cache->batch.edituv_faces); | return DRW_batch_request(&cache->batch.edituv_faces); | ||||
| ▲ Show 20 Lines • Show All 97 Lines • ▼ Show 20 Lines | if ((cache->batch.surface_weights != NULL) && (ts != NULL)) { | ||||
| drw_mesh_weight_state_extract(ob, me, ts, is_paint_mode, &wstate); | drw_mesh_weight_state_extract(ob, me, ts, is_paint_mode, &wstate); | ||||
| mesh_batch_cache_check_vertex_group(cache, &wstate); | mesh_batch_cache_check_vertex_group(cache, &wstate); | ||||
| drw_mesh_weight_state_copy(&cache->weight_state, &wstate); | drw_mesh_weight_state_copy(&cache->weight_state, &wstate); | ||||
| drw_mesh_weight_state_clear(&wstate); | drw_mesh_weight_state_clear(&wstate); | ||||
| } | } | ||||
| } | } | ||||
| if (batch_requested & | if (batch_requested & | ||||
| (MBC_SURFACE | MBC_SURF_PER_MAT | MBC_WIRE_LOOPS_UVS | MBC_EDITUV_FACES_STRECH_AREA | | (MBC_SURFACE | MBC_SURF_PER_MAT | MBC_WIRE_LOOPS_UVS | MBC_EDITUV_FACES_STRETCH_AREA | | ||||
| MBC_EDITUV_FACES_STRECH_ANGLE | MBC_EDITUV_FACES | MBC_EDITUV_EDGES | MBC_EDITUV_VERTS)) { | 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. */ | /* Modifiers will only generate an orco layer if the mesh is deformed. */ | ||||
| if (cache->cd_needed.orco != 0) { | if (cache->cd_needed.orco != 0) { | ||||
| if (CustomData_get_layer(&me->vdata, CD_ORCO) == NULL) { | if (CustomData_get_layer(&me->vdata, CD_ORCO) == NULL) { | ||||
| /* Skip orco calculation */ | /* Skip orco calculation */ | ||||
| cache->cd_needed.orco = 0; | cache->cd_needed.orco = 0; | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | if (ts != NULL) { | ||||
| GPU_VERTBUF_DISCARD_SAFE(mbuffercache->vbo.fdots_uv); | GPU_VERTBUF_DISCARD_SAFE(mbuffercache->vbo.fdots_uv); | ||||
| GPU_INDEXBUF_DISCARD_SAFE(mbuffercache->ibo.edituv_tris); | GPU_INDEXBUF_DISCARD_SAFE(mbuffercache->ibo.edituv_tris); | ||||
| GPU_INDEXBUF_DISCARD_SAFE(mbuffercache->ibo.edituv_lines); | GPU_INDEXBUF_DISCARD_SAFE(mbuffercache->ibo.edituv_lines); | ||||
| GPU_INDEXBUF_DISCARD_SAFE(mbuffercache->ibo.edituv_points); | GPU_INDEXBUF_DISCARD_SAFE(mbuffercache->ibo.edituv_points); | ||||
| } | } | ||||
| /* We only clear the batches as they may already have been | /* We only clear the batches as they may already have been | ||||
| * referenced. */ | * referenced. */ | ||||
| GPU_BATCH_CLEAR_SAFE(cache->batch.wire_loops_uvs); | 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_stretch_area); | ||||
| GPU_BATCH_CLEAR_SAFE(cache->batch.edituv_faces_strech_angle); | 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_faces); | ||||
| GPU_BATCH_CLEAR_SAFE(cache->batch.edituv_edges); | GPU_BATCH_CLEAR_SAFE(cache->batch.edituv_edges); | ||||
| GPU_BATCH_CLEAR_SAFE(cache->batch.edituv_verts); | GPU_BATCH_CLEAR_SAFE(cache->batch.edituv_verts); | ||||
| GPU_BATCH_CLEAR_SAFE(cache->batch.edituv_fdots); | GPU_BATCH_CLEAR_SAFE(cache->batch.edituv_fdots); | ||||
| cache->batch_ready &= ~MBC_EDITUV; | cache->batch_ready &= ~MBC_EDITUV; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 165 Lines • ▼ Show 20 Lines | #endif | ||||
| mbufcache = (do_uvcage) ? &cache->uv_cage : &cache->final; | mbufcache = (do_uvcage) ? &cache->uv_cage : &cache->final; | ||||
| /* Edit UV */ | /* Edit UV */ | ||||
| if (DRW_batch_requested(cache->batch.edituv_faces, GPU_PRIM_TRIS)) { | if (DRW_batch_requested(cache->batch.edituv_faces, GPU_PRIM_TRIS)) { | ||||
| DRW_ibo_request(cache->batch.edituv_faces, &mbufcache->ibo.edituv_tris); | DRW_ibo_request(cache->batch.edituv_faces, &mbufcache->ibo.edituv_tris); | ||||
| DRW_vbo_request(cache->batch.edituv_faces, &mbufcache->vbo.uv); | DRW_vbo_request(cache->batch.edituv_faces, &mbufcache->vbo.uv); | ||||
| DRW_vbo_request(cache->batch.edituv_faces, &mbufcache->vbo.edituv_data); | DRW_vbo_request(cache->batch.edituv_faces, &mbufcache->vbo.edituv_data); | ||||
| } | } | ||||
| if (DRW_batch_requested(cache->batch.edituv_faces_strech_area, GPU_PRIM_TRIS)) { | if (DRW_batch_requested(cache->batch.edituv_faces_stretch_area, GPU_PRIM_TRIS)) { | ||||
| DRW_ibo_request(cache->batch.edituv_faces_strech_area, &mbufcache->ibo.edituv_tris); | DRW_ibo_request(cache->batch.edituv_faces_stretch_area, &mbufcache->ibo.edituv_tris); | ||||
| DRW_vbo_request(cache->batch.edituv_faces_strech_area, &mbufcache->vbo.uv); | DRW_vbo_request(cache->batch.edituv_faces_stretch_area, &mbufcache->vbo.uv); | ||||
| DRW_vbo_request(cache->batch.edituv_faces_strech_area, &mbufcache->vbo.edituv_data); | DRW_vbo_request(cache->batch.edituv_faces_stretch_area, &mbufcache->vbo.edituv_data); | ||||
| DRW_vbo_request(cache->batch.edituv_faces_strech_area, &mbufcache->vbo.stretch_area); | DRW_vbo_request(cache->batch.edituv_faces_stretch_area, &mbufcache->vbo.stretch_area); | ||||
| } | } | ||||
| if (DRW_batch_requested(cache->batch.edituv_faces_strech_angle, GPU_PRIM_TRIS)) { | if (DRW_batch_requested(cache->batch.edituv_faces_stretch_angle, GPU_PRIM_TRIS)) { | ||||
| DRW_ibo_request(cache->batch.edituv_faces_strech_angle, &mbufcache->ibo.edituv_tris); | DRW_ibo_request(cache->batch.edituv_faces_stretch_angle, &mbufcache->ibo.edituv_tris); | ||||
| DRW_vbo_request(cache->batch.edituv_faces_strech_angle, &mbufcache->vbo.uv); | DRW_vbo_request(cache->batch.edituv_faces_stretch_angle, &mbufcache->vbo.uv); | ||||
| DRW_vbo_request(cache->batch.edituv_faces_strech_angle, &mbufcache->vbo.edituv_data); | DRW_vbo_request(cache->batch.edituv_faces_stretch_angle, &mbufcache->vbo.edituv_data); | ||||
| DRW_vbo_request(cache->batch.edituv_faces_strech_angle, &mbufcache->vbo.stretch_angle); | DRW_vbo_request(cache->batch.edituv_faces_stretch_angle, &mbufcache->vbo.stretch_angle); | ||||
| } | } | ||||
| if (DRW_batch_requested(cache->batch.edituv_edges, GPU_PRIM_LINES)) { | if (DRW_batch_requested(cache->batch.edituv_edges, GPU_PRIM_LINES)) { | ||||
| DRW_ibo_request(cache->batch.edituv_edges, &mbufcache->ibo.edituv_lines); | DRW_ibo_request(cache->batch.edituv_edges, &mbufcache->ibo.edituv_lines); | ||||
| DRW_vbo_request(cache->batch.edituv_edges, &mbufcache->vbo.uv); | DRW_vbo_request(cache->batch.edituv_edges, &mbufcache->vbo.uv); | ||||
| DRW_vbo_request(cache->batch.edituv_edges, &mbufcache->vbo.edituv_data); | DRW_vbo_request(cache->batch.edituv_edges, &mbufcache->vbo.edituv_data); | ||||
| } | } | ||||
| if (DRW_batch_requested(cache->batch.edituv_verts, GPU_PRIM_POINTS)) { | if (DRW_batch_requested(cache->batch.edituv_verts, GPU_PRIM_POINTS)) { | ||||
| DRW_ibo_request(cache->batch.edituv_verts, &mbufcache->ibo.edituv_points); | DRW_ibo_request(cache->batch.edituv_verts, &mbufcache->ibo.edituv_points); | ||||
| ▲ Show 20 Lines • Show All 53 Lines • Show Last 20 Lines | |||||