Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/uvedit/uvedit_draw.c
| Show All 33 Lines | |||||
| #include "DNA_object_types.h" | #include "DNA_object_types.h" | ||||
| #include "DNA_scene_types.h" | #include "DNA_scene_types.h" | ||||
| #include "DNA_screen_types.h" | #include "DNA_screen_types.h" | ||||
| #include "DNA_space_types.h" | #include "DNA_space_types.h" | ||||
| #include "../../draw/intern/draw_cache_impl.h" | #include "../../draw/intern/draw_cache_impl.h" | ||||
| #include "BLI_math.h" | #include "BLI_math.h" | ||||
| #include "BLI_task.h" | |||||
| #include "BLI_utildefines.h" | #include "BLI_utildefines.h" | ||||
| #include "BKE_deform.h" | #include "BKE_deform.h" | ||||
| #include "BKE_editmesh.h" | #include "BKE_editmesh.h" | ||||
| #include "BKE_layer.h" | #include "BKE_layer.h" | ||||
| #include "BKE_material.h" | #include "BKE_material.h" | ||||
| #include "BKE_scene.h" | #include "BKE_scene.h" | ||||
| ▲ Show 20 Lines • Show All 151 Lines • ▼ Show 20 Lines | else if (draw_stretch) { | ||||
| batches->faces = DRW_mesh_batch_cache_get_edituv_faces_stretch_angle(ob->data); | batches->faces = DRW_mesh_batch_cache_get_edituv_faces_stretch_angle(ob->data); | ||||
| } | } | ||||
| else if (draw_faces) { | else if (draw_faces) { | ||||
| batches->faces = DRW_mesh_batch_cache_get_edituv_faces(ob->data); | batches->faces = DRW_mesh_batch_cache_get_edituv_faces(ob->data); | ||||
| } | } | ||||
| else { | else { | ||||
| batches->faces = NULL; | batches->faces = NULL; | ||||
| } | } | ||||
| struct TaskGraph *task_graph = BLI_task_graph_create(); | |||||
fclem: Is the taskgraph creation almost free? This function runs every redraw for the UV editor. | |||||
jbakkerAuthorUnsubmitted Done Inline ActionsIt is very cheap. MEM_alloc + cpp template initialization. jbakker: It is very cheap. MEM_alloc + cpp template initialization. | |||||
| DRW_mesh_batch_cache_create_requested(ob, ob->data, scene, false, false); | DRW_mesh_batch_cache_create_requested(task_graph, ob, ob->data, scene, false, false); | ||||
| BLI_task_graph_work_and_wait(task_graph); | |||||
| BLI_task_graph_free(task_graph); | |||||
| if (draw_stretch && (sima->dt_uvstretch == SI_UVDT_STRETCH_AREA)) { | if (draw_stretch && (sima->dt_uvstretch == SI_UVDT_STRETCH_AREA)) { | ||||
| /* after create_requested we can load the actual areas */ | /* after create_requested we can load the actual areas */ | ||||
| *tot_area += *tmp_tot_area; | *tot_area += *tmp_tot_area; | ||||
| *tot_area_uv += *tmp_tot_area_uv; | *tot_area_uv += *tmp_tot_area_uv; | ||||
| } | } | ||||
| } | } | ||||
| static void draw_uvs_shadow(SpaceImage *sima, | static void draw_uvs_shadow(SpaceImage *sima, | ||||
| const Scene *scene, | const Scene *scene, | ||||
| Object *obedit, | Object *obedit, | ||||
| Depsgraph *depsgraph) | Depsgraph *depsgraph) | ||||
| { | { | ||||
| Object *ob_eval = DEG_get_evaluated_object(depsgraph, obedit); | Object *ob_eval = DEG_get_evaluated_object(depsgraph, obedit); | ||||
| Mesh *me = ob_eval->data; | Mesh *me = ob_eval->data; | ||||
| const float overlay_alpha = sima->uv_opacity; | const float overlay_alpha = sima->uv_opacity; | ||||
| float col[4]; | float col[4]; | ||||
| UI_GetThemeColor4fv(TH_UV_SHADOW, col); | UI_GetThemeColor4fv(TH_UV_SHADOW, col); | ||||
| DRW_mesh_batch_cache_validate(me); | DRW_mesh_batch_cache_validate(me); | ||||
| GPUBatch *edges = DRW_mesh_batch_cache_get_uv_edges(me); | GPUBatch *edges = DRW_mesh_batch_cache_get_uv_edges(me); | ||||
| DRW_mesh_batch_cache_create_requested(ob_eval, me, scene, false, false); | |||||
| struct TaskGraph *task_graph = BLI_task_graph_create(); | |||||
| DRW_mesh_batch_cache_create_requested(task_graph, ob_eval, me, scene, false, false); | |||||
| BLI_task_graph_work_and_wait(task_graph); | |||||
| BLI_task_graph_free(task_graph); | |||||
| if (edges) { | if (edges) { | ||||
| if (sima->flag & SI_SMOOTH_UV) { | if (sima->flag & SI_SMOOTH_UV) { | ||||
| GPU_line_smooth(true); | GPU_line_smooth(true); | ||||
| GPU_blend(true); | GPU_blend(true); | ||||
| } | } | ||||
| else if (overlay_alpha < 1.0f) { | else if (overlay_alpha < 1.0f) { | ||||
| GPU_blend(true); | GPU_blend(true); | ||||
| Show All 23 Lines | static void draw_uvs_texpaint(const Scene *scene, Object *ob, Depsgraph *depsgraph) | ||||
| UI_GetThemeColor4fv(TH_UV_SHADOW, col); | UI_GetThemeColor4fv(TH_UV_SHADOW, col); | ||||
| if (me->mloopuv == NULL) { | if (me->mloopuv == NULL) { | ||||
| return; | return; | ||||
| } | } | ||||
| DRW_mesh_batch_cache_validate(me); | DRW_mesh_batch_cache_validate(me); | ||||
| GPUBatch *geom = DRW_mesh_batch_cache_get_uv_edges(me); | GPUBatch *geom = DRW_mesh_batch_cache_get_uv_edges(me); | ||||
| DRW_mesh_batch_cache_create_requested(ob_eval, me, scene, false, false); | struct TaskGraph *task_graph = BLI_task_graph_create(); | ||||
| DRW_mesh_batch_cache_create_requested(task_graph, ob_eval, me, scene, false, false); | |||||
| BLI_task_graph_work_and_wait(task_graph); | |||||
| BLI_task_graph_free(task_graph); | |||||
| GPU_batch_program_set_builtin(geom, GPU_SHADER_2D_UV_UNIFORM_COLOR); | GPU_batch_program_set_builtin(geom, GPU_SHADER_2D_UV_UNIFORM_COLOR); | ||||
| GPU_batch_uniform_4fv(geom, "color", col); | GPU_batch_uniform_4fv(geom, "color", col); | ||||
| const bool do_material_masking = (ts->uv_flag & UV_SHOW_SAME_IMAGE); | const bool do_material_masking = (ts->uv_flag & UV_SHOW_SAME_IMAGE); | ||||
| if (do_material_masking && me->mloopuv) { | if (do_material_masking && me->mloopuv) { | ||||
| /* Render loops that have the active material. Minize draw calls. */ | /* Render loops that have the active material. Minize draw calls. */ | ||||
| MPoly *mpoly = me->mpoly; | MPoly *mpoly = me->mpoly; | ||||
| ▲ Show 20 Lines • Show All 310 Lines • Show Last 20 Lines | |||||
Is the taskgraph creation almost free? This function runs every redraw for the UV editor.