UV/Image: Remove Legacy Drawing
With D8234 a new drawing method for UV/Image editor was introduced. For debugging reasons we left the old drawing method in the code base. This patch will remove the old drawing method. Reviewed By: Clément Foucault Differential Revision: https://developer.blender.org/D9011
This commit is contained in:
parent
239eb95ef8
commit
e05ce1ea20
Notes:
blender-bot
2023-02-14 06:46:23 +01:00
Referenced by issue #81953, Python error in UV Editor Overlay popup
|
@ -2218,7 +2218,6 @@ class USERPREF_PT_experimental_debugging(ExperimentalPanel, Panel):
|
|||
context, (
|
||||
({"property": "use_undo_legacy"}, "T60695"),
|
||||
({"property": "use_cycles_debug"}, None),
|
||||
({"property": "use_image_editor_legacy_drawing"}, "T67530"),
|
||||
),
|
||||
)
|
||||
|
||||
|
|
|
@ -897,4 +897,19 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
|
|||
{
|
||||
/* Keep this block, even when empty. */
|
||||
}
|
||||
|
||||
/* Remove options of legacy UV/Image editor */
|
||||
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
|
||||
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
|
||||
LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
|
||||
switch (sl->spacetype) {
|
||||
case SPACE_IMAGE: {
|
||||
SpaceImage *sima = (SpaceImage *)sl;
|
||||
sima->flag &= ~(SI_FLAG_UNUSED_20);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -229,12 +229,6 @@ void ED_uvedit_add_simple_uvs(struct Main *bmain, const struct Scene *scene, str
|
|||
|
||||
/* uvedit_draw.c */
|
||||
void ED_image_draw_cursor(struct ARegion *region, const float cursor[2]);
|
||||
void ED_uvedit_draw_main(struct SpaceImage *sima,
|
||||
const struct Scene *scene,
|
||||
struct ViewLayer *view_layer,
|
||||
struct Object *obedit,
|
||||
struct Object *obact,
|
||||
struct Depsgraph *depsgraph);
|
||||
|
||||
/* uvedit_buttons.c */
|
||||
void ED_uvedit_buttons_register(struct ARegionType *art);
|
||||
|
|
|
@ -634,22 +634,12 @@ static void image_main_region_draw(const bContext *C, ARegion *region)
|
|||
{
|
||||
/* draw entirely, view changes should be handled here */
|
||||
SpaceImage *sima = CTX_wm_space_image(C);
|
||||
Object *obact = CTX_data_active_object(C);
|
||||
Object *obedit = CTX_data_edit_object(C);
|
||||
Depsgraph *depsgraph = CTX_data_expect_evaluated_depsgraph(C);
|
||||
Mask *mask = NULL;
|
||||
bool show_uvedit = false;
|
||||
bool show_curve = false;
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
ViewLayer *view_layer = CTX_data_view_layer(C);
|
||||
View2D *v2d = ®ion->v2d;
|
||||
|
||||
GPUViewport *viewport = WM_draw_region_get_viewport(region);
|
||||
GPUFrameBuffer *framebuffer_default, *framebuffer_overlay;
|
||||
|
||||
framebuffer_default = GPU_viewport_framebuffer_default_get(viewport);
|
||||
framebuffer_overlay = GPU_viewport_framebuffer_overlay_get(viewport);
|
||||
|
||||
/* XXX not supported yet, disabling for now */
|
||||
scene->r.scemode &= ~R_COMP_CROP;
|
||||
|
||||
|
@ -659,83 +649,38 @@ static void image_main_region_draw(const bContext *C, ARegion *region)
|
|||
image_main_region_set_view2d(sima, region);
|
||||
|
||||
/* check for mask (delay draw) */
|
||||
if (ED_space_image_show_uvedit(sima, obedit)) {
|
||||
show_uvedit = true;
|
||||
}
|
||||
else if (sima->mode == SI_MODE_MASK) {
|
||||
if (!ED_space_image_show_uvedit(sima, obedit) && sima->mode == SI_MODE_MASK) {
|
||||
mask = ED_space_image_get_mask(sima);
|
||||
}
|
||||
else if (ED_space_image_paint_curve(C)) {
|
||||
show_curve = true;
|
||||
}
|
||||
|
||||
/* we draw image in pixelspace */
|
||||
if (!U.experimental.use_image_editor_legacy_drawing) {
|
||||
DRW_draw_view(C);
|
||||
draw_image_main_helpers(C, region);
|
||||
DRW_draw_view(C);
|
||||
draw_image_main_helpers(C, region);
|
||||
|
||||
/* Draw Meta data of the image isn't added to the DrawManager as it is
|
||||
* used in other areas as well. */
|
||||
if (sima->flag & SI_DRAW_METADATA) {
|
||||
void *lock;
|
||||
/* `ED_space_image_get_zoom` temporarily locks the image, so this needs to be done before
|
||||
* the image is locked when calling `ED_space_image_acquire_buffer`. */
|
||||
float zoomx, zoomy;
|
||||
ED_space_image_get_zoom(sima, region, &zoomx, &zoomy);
|
||||
ImBuf *ibuf = ED_space_image_acquire_buffer(sima, &lock, 0);
|
||||
if (ibuf) {
|
||||
int x, y;
|
||||
rctf frame;
|
||||
BLI_rctf_init(&frame, 0.0f, ibuf->x, 0.0f, ibuf->y);
|
||||
UI_view2d_view_to_region(®ion->v2d, 0.0f, 0.0f, &x, &y);
|
||||
ED_region_image_metadata_draw(x, y, ibuf, &frame, zoomx, zoomy);
|
||||
ED_space_image_release_buffer(sima, ibuf, lock);
|
||||
}
|
||||
}
|
||||
|
||||
/* sample line */
|
||||
UI_view2d_view_ortho(v2d);
|
||||
draw_image_sample_line(sima);
|
||||
UI_view2d_view_restore(C);
|
||||
}
|
||||
else {
|
||||
GPU_framebuffer_bind(framebuffer_default);
|
||||
GPU_clear_color(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
|
||||
GPU_framebuffer_bind(framebuffer_overlay);
|
||||
|
||||
float col[3];
|
||||
/* clear and setup matrix */
|
||||
UI_GetThemeColor3fv(TH_BACK, col);
|
||||
srgb_to_linearrgb_v3_v3(col, col);
|
||||
GPU_clear_color(col[0], col[1], col[2], 1.0f);
|
||||
GPU_depth_test(GPU_DEPTH_NONE);
|
||||
draw_image_main(C, region);
|
||||
|
||||
/* and uvs in 0.0-1.0 space */
|
||||
UI_view2d_view_ortho(v2d);
|
||||
|
||||
ED_region_draw_cb_draw(C, region, REGION_DRAW_PRE_VIEW);
|
||||
|
||||
ED_uvedit_draw_main(sima, scene, view_layer, obedit, obact, depsgraph);
|
||||
|
||||
ED_region_draw_cb_draw(C, region, REGION_DRAW_POST_VIEW);
|
||||
|
||||
if (sima->flag & SI_SHOW_GPENCIL) {
|
||||
/* Grease Pencil too (in addition to UV's) */
|
||||
draw_image_grease_pencil((bContext *)C, true);
|
||||
}
|
||||
/* sample line */
|
||||
draw_image_sample_line(sima);
|
||||
|
||||
UI_view2d_view_restore(C);
|
||||
|
||||
if (sima->flag & SI_SHOW_GPENCIL) {
|
||||
/* draw Grease Pencil - screen space only */
|
||||
draw_image_grease_pencil((bContext *)C, false);
|
||||
/* Draw Meta data of the image isn't added to the DrawManager as it is
|
||||
* used in other areas as well. */
|
||||
if (sima->flag & SI_DRAW_METADATA) {
|
||||
void *lock;
|
||||
/* `ED_space_image_get_zoom` temporarily locks the image, so this needs to be done before
|
||||
* the image is locked when calling `ED_space_image_acquire_buffer`. */
|
||||
float zoomx, zoomy;
|
||||
ED_space_image_get_zoom(sima, region, &zoomx, &zoomy);
|
||||
ImBuf *ibuf = ED_space_image_acquire_buffer(sima, &lock, 0);
|
||||
if (ibuf) {
|
||||
int x, y;
|
||||
rctf frame;
|
||||
BLI_rctf_init(&frame, 0.0f, ibuf->x, 0.0f, ibuf->y);
|
||||
UI_view2d_view_to_region(®ion->v2d, 0.0f, 0.0f, &x, &y);
|
||||
ED_region_image_metadata_draw(x, y, ibuf, &frame, zoomx, zoomy);
|
||||
ED_space_image_release_buffer(sima, ibuf, lock);
|
||||
}
|
||||
}
|
||||
|
||||
/* sample line */
|
||||
UI_view2d_view_ortho(v2d);
|
||||
draw_image_sample_line(sima);
|
||||
UI_view2d_view_restore(C);
|
||||
|
||||
if (mask) {
|
||||
Image *image = ED_space_image(sima);
|
||||
int width, height, show_viewer;
|
||||
|
@ -773,14 +718,7 @@ static void image_main_region_draw(const bContext *C, ARegion *region)
|
|||
C);
|
||||
}
|
||||
|
||||
if ((show_uvedit || mask || show_curve) && U.experimental.use_image_editor_legacy_drawing) {
|
||||
UI_view2d_view_ortho(v2d);
|
||||
ED_image_draw_cursor(region, sima->cursor);
|
||||
UI_view2d_view_restore(C);
|
||||
}
|
||||
|
||||
WM_gizmomap_draw(region->gizmo_map, C, WM_GIZMOMAP_DRAWSTEP_2D);
|
||||
|
||||
draw_image_cache(C, region);
|
||||
}
|
||||
|
||||
|
|
|
@ -21,78 +21,20 @@
|
|||
* \ingroup eduv
|
||||
*/
|
||||
|
||||
#include <float.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "DNA_material_types.h"
|
||||
#include "DNA_mesh_types.h"
|
||||
#include "DNA_meshdata_types.h"
|
||||
#include "DNA_object_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
#include "DNA_screen_types.h"
|
||||
#include "DNA_space_types.h"
|
||||
|
||||
#include "../../draw/intern/draw_cache_impl.h"
|
||||
|
||||
#include "BLI_math.h"
|
||||
#include "BLI_task.h"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "BKE_deform.h"
|
||||
#include "BKE_editmesh.h"
|
||||
#include "BKE_layer.h"
|
||||
#include "BKE_material.h"
|
||||
#include "DNA_scene_types.h"
|
||||
#include "DNA_screen_types.h"
|
||||
#include "DNA_userdef_types.h"
|
||||
|
||||
#include "BKE_scene.h"
|
||||
|
||||
#include "DEG_depsgraph.h"
|
||||
#include "DEG_depsgraph_query.h"
|
||||
|
||||
#include "GPU_batch.h"
|
||||
#include "GPU_framebuffer.h"
|
||||
#include "GPU_immediate.h"
|
||||
#include "GPU_matrix.h"
|
||||
#include "GPU_state.h"
|
||||
|
||||
#include "ED_image.h"
|
||||
#include "ED_mesh.h"
|
||||
#include "ED_uvedit.h"
|
||||
|
||||
#include "UI_interface.h"
|
||||
#include "UI_resources.h"
|
||||
#include "UI_view2d.h"
|
||||
|
||||
#include "uvedit_intern.h"
|
||||
|
||||
/* Struct containing the needed batches per object.
|
||||
* this optimizes the way how data is requested from
|
||||
* the draw manager. */
|
||||
typedef struct UVEditGPUBatches {
|
||||
Object *ob_eval;
|
||||
GPUBatch *faces;
|
||||
GPUBatch *edges;
|
||||
GPUBatch *verts;
|
||||
GPUBatch *facedots;
|
||||
} UVEditGPUBatches;
|
||||
|
||||
static int draw_uvs_face_check(const ToolSettings *ts)
|
||||
{
|
||||
/* checks if we are selecting only faces */
|
||||
if (ts->uv_flag & UV_SYNC_SELECTION) {
|
||||
if (ts->selectmode == SCE_SELECT_FACE) {
|
||||
return 2;
|
||||
}
|
||||
if (ts->selectmode & SCE_SELECT_FACE) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return (ts->uv_selectmode == UV_SELECT_FACE);
|
||||
}
|
||||
#include "ED_uvedit.h"
|
||||
|
||||
/* ------------------------- */
|
||||
|
||||
|
@ -166,434 +108,3 @@ void ED_image_draw_cursor(ARegion *region, const float cursor[2])
|
|||
|
||||
GPU_matrix_translate_2f(-cursor[0], -cursor[1]);
|
||||
}
|
||||
|
||||
static void uvedit_get_batches(Object *ob,
|
||||
SpaceImage *sima,
|
||||
const Scene *scene,
|
||||
UVEditGPUBatches *batches,
|
||||
float *tot_area,
|
||||
float *tot_area_uv)
|
||||
{
|
||||
float *tmp_tot_area, *tmp_tot_area_uv;
|
||||
int drawfaces = draw_uvs_face_check(scene->toolsettings);
|
||||
const bool draw_stretch = (sima->flag & SI_DRAW_STRETCH) != 0;
|
||||
const bool draw_faces = (sima->flag & SI_NO_DRAWFACES) == 0;
|
||||
|
||||
DRW_mesh_batch_cache_validate(ob->data);
|
||||
batches->edges = DRW_mesh_batch_cache_get_edituv_edges(ob->data);
|
||||
batches->verts = DRW_mesh_batch_cache_get_edituv_verts(ob->data);
|
||||
|
||||
if (drawfaces) {
|
||||
batches->facedots = DRW_mesh_batch_cache_get_edituv_facedots(ob->data);
|
||||
}
|
||||
else {
|
||||
batches->facedots = NULL;
|
||||
}
|
||||
|
||||
if (draw_stretch && (sima->dt_uvstretch == SI_UVDT_STRETCH_AREA)) {
|
||||
batches->faces = DRW_mesh_batch_cache_get_edituv_faces_stretch_area(
|
||||
ob->data, &tmp_tot_area, &tmp_tot_area_uv);
|
||||
}
|
||||
else if (draw_stretch) {
|
||||
batches->faces = DRW_mesh_batch_cache_get_edituv_faces_stretch_angle(ob->data);
|
||||
}
|
||||
else if (draw_faces) {
|
||||
batches->faces = DRW_mesh_batch_cache_get_edituv_faces(ob->data);
|
||||
}
|
||||
else {
|
||||
batches->faces = NULL;
|
||||
}
|
||||
struct TaskGraph *task_graph = BLI_task_graph_create();
|
||||
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)) {
|
||||
/* after create_requested we can load the actual areas */
|
||||
*tot_area += *tmp_tot_area;
|
||||
*tot_area_uv += *tmp_tot_area_uv;
|
||||
}
|
||||
}
|
||||
|
||||
static void draw_uvs_shadow(SpaceImage *sima,
|
||||
const Scene *scene,
|
||||
Object *obedit,
|
||||
Depsgraph *depsgraph)
|
||||
{
|
||||
Object *ob_eval = DEG_get_evaluated_object(depsgraph, obedit);
|
||||
Mesh *me = ob_eval->data;
|
||||
const float overlay_alpha = sima->uv_opacity;
|
||||
float col[4];
|
||||
UI_GetThemeColor4fv(TH_UV_SHADOW, col);
|
||||
|
||||
DRW_mesh_batch_cache_validate(me);
|
||||
GPUBatch *edges = DRW_mesh_batch_cache_get_uv_edges(me);
|
||||
|
||||
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 (sima->flag & SI_SMOOTH_UV) {
|
||||
GPU_line_smooth(true);
|
||||
GPU_blend(GPU_BLEND_ALPHA);
|
||||
}
|
||||
else if (overlay_alpha < 1.0f) {
|
||||
GPU_blend(GPU_BLEND_ALPHA);
|
||||
}
|
||||
|
||||
col[3] = overlay_alpha;
|
||||
GPU_batch_program_set_builtin(edges, GPU_SHADER_2D_UV_UNIFORM_COLOR);
|
||||
GPU_batch_uniform_4fv(edges, "color", col);
|
||||
GPU_batch_draw(edges);
|
||||
|
||||
if (sima->flag & SI_SMOOTH_UV) {
|
||||
GPU_line_smooth(false);
|
||||
GPU_blend(GPU_BLEND_NONE);
|
||||
}
|
||||
else if (overlay_alpha < 1.0f) {
|
||||
GPU_blend(GPU_BLEND_NONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void draw_uvs_texpaint(const Scene *scene, Object *ob, Depsgraph *depsgraph)
|
||||
{
|
||||
Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
|
||||
Mesh *me = ob_eval->data;
|
||||
const ToolSettings *ts = scene->toolsettings;
|
||||
float col[4];
|
||||
UI_GetThemeColor4fv(TH_UV_SHADOW, col);
|
||||
|
||||
if (me->mloopuv == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
DRW_mesh_batch_cache_validate(me);
|
||||
GPUBatch *geom = DRW_mesh_batch_cache_get_uv_edges(me);
|
||||
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_uniform_4fv(geom, "color", col);
|
||||
|
||||
const bool do_material_masking = (ts->uv_flag & UV_SHOW_SAME_IMAGE);
|
||||
if (do_material_masking && me->mloopuv) {
|
||||
/* Render loops that have the active material. Minize draw calls. */
|
||||
MPoly *mpoly = me->mpoly;
|
||||
uint draw_start = 0;
|
||||
uint idx = 0;
|
||||
bool prev_ma_match = (mpoly->mat_nr == (ob_eval->actcol - 1));
|
||||
|
||||
/* TODO(fclem): If drawcall count becomes a problem in the future
|
||||
* we can use multi draw indirect drawcalls for this.
|
||||
* (not implemented in GPU module at the time of writing). */
|
||||
for (int a = 0; a < me->totpoly; a++, mpoly++) {
|
||||
bool ma_match = (mpoly->mat_nr == (ob_eval->actcol - 1));
|
||||
if (ma_match != prev_ma_match) {
|
||||
if (ma_match == false) {
|
||||
GPU_batch_draw_range(geom, draw_start, idx - draw_start);
|
||||
}
|
||||
else {
|
||||
draw_start = idx;
|
||||
}
|
||||
}
|
||||
idx += mpoly->totloop + 1;
|
||||
prev_ma_match = ma_match;
|
||||
}
|
||||
if (prev_ma_match == true) {
|
||||
GPU_batch_draw_range(geom, draw_start, idx - draw_start);
|
||||
}
|
||||
}
|
||||
else {
|
||||
GPU_batch_draw(geom);
|
||||
}
|
||||
}
|
||||
|
||||
/* draws uv's in the image space */
|
||||
static void draw_uvs(SpaceImage *sima,
|
||||
const Scene *scene,
|
||||
Depsgraph *depsgraph,
|
||||
UVEditGPUBatches *batch,
|
||||
float tot_area_ratio,
|
||||
float tot_area_ratio_inv)
|
||||
{
|
||||
Object *ob_eval = batch->ob_eval;
|
||||
const ToolSettings *ts = scene->toolsettings;
|
||||
float col1[4], col2[4], col3[4], transparent[4] = {0.0f, 0.0f, 0.0f, 0.0f};
|
||||
const float overlay_alpha = sima->uv_opacity;
|
||||
|
||||
if (sima->flag & SI_DRAWSHADOW) {
|
||||
bool is_cage_like_final_meshes = false;
|
||||
Mesh *me = (Mesh *)ob_eval->data;
|
||||
BMEditMesh *embm = me->edit_mesh;
|
||||
is_cage_like_final_meshes = embm && embm->mesh_eval_final &&
|
||||
embm->mesh_eval_final->runtime.is_original;
|
||||
|
||||
/* When sync selection is enabled, all faces are drawn (except for hidden)
|
||||
* so if cage is the same as the final, there is no point in drawing this. */
|
||||
if (!((ts->uv_flag & UV_SYNC_SELECTION) && is_cage_like_final_meshes)) {
|
||||
draw_uvs_shadow(sima, scene, ob_eval, depsgraph);
|
||||
}
|
||||
}
|
||||
|
||||
bool interpedges;
|
||||
bool draw_stretch = (sima->flag & SI_DRAW_STRETCH) != 0;
|
||||
if (ts->uv_flag & UV_SYNC_SELECTION) {
|
||||
interpedges = (ts->selectmode & SCE_SELECT_VERTEX) != 0;
|
||||
}
|
||||
else {
|
||||
interpedges = (ts->uv_selectmode == UV_SELECT_VERTEX);
|
||||
}
|
||||
|
||||
GPU_blend(GPU_BLEND_ALPHA);
|
||||
|
||||
if (batch->faces) {
|
||||
GPU_batch_program_set_builtin(batch->faces,
|
||||
(draw_stretch) ? (sima->dt_uvstretch == SI_UVDT_STRETCH_AREA) ?
|
||||
GPU_SHADER_2D_UV_FACES_STRETCH_AREA :
|
||||
GPU_SHADER_2D_UV_FACES_STRETCH_ANGLE :
|
||||
GPU_SHADER_2D_UV_FACES);
|
||||
|
||||
if (!draw_stretch) {
|
||||
GPU_blend(GPU_BLEND_ALPHA);
|
||||
|
||||
UI_GetThemeColor4fv(TH_FACE, col1);
|
||||
UI_GetThemeColor4fv(TH_FACE_SELECT, col2);
|
||||
UI_GetThemeColor4fv(TH_EDITMESH_ACTIVE, col3);
|
||||
|
||||
col1[3] *= overlay_alpha;
|
||||
col2[3] *= overlay_alpha;
|
||||
col3[3] *= overlay_alpha;
|
||||
|
||||
GPU_batch_uniform_4fv(batch->faces, "faceColor", col1);
|
||||
GPU_batch_uniform_4fv(batch->faces, "selectColor", col2);
|
||||
GPU_batch_uniform_4fv(batch->faces, "activeColor", col3);
|
||||
}
|
||||
else if (sima->dt_uvstretch == SI_UVDT_STRETCH_ANGLE) {
|
||||
float asp[2];
|
||||
ED_space_image_get_uv_aspect(sima, &asp[0], &asp[1]);
|
||||
GPU_batch_uniform_2fv(batch->faces, "aspect", asp);
|
||||
}
|
||||
else if (sima->dt_uvstretch == SI_UVDT_STRETCH_AREA) {
|
||||
GPU_batch_uniform_1f(batch->faces, "totalAreaRatio", tot_area_ratio);
|
||||
GPU_batch_uniform_1f(batch->faces, "totalAreaRatioInv", tot_area_ratio_inv);
|
||||
}
|
||||
|
||||
GPU_batch_draw(batch->faces);
|
||||
|
||||
if (!draw_stretch) {
|
||||
GPU_blend(GPU_BLEND_NONE);
|
||||
}
|
||||
}
|
||||
if (batch->edges) {
|
||||
if (sima->flag & SI_SMOOTH_UV) {
|
||||
GPU_line_smooth(true);
|
||||
GPU_blend(GPU_BLEND_ALPHA);
|
||||
}
|
||||
else if (overlay_alpha < 1.0f) {
|
||||
GPU_blend(GPU_BLEND_ALPHA);
|
||||
}
|
||||
|
||||
{
|
||||
/* We could modify the vbo's data filling
|
||||
* instead of modifying the provoking vert. */
|
||||
GPU_provoking_vertex(GPU_VERTEX_FIRST);
|
||||
|
||||
UI_GetThemeColor3fv(TH_EDGE_SELECT, col2);
|
||||
col2[3] = overlay_alpha;
|
||||
|
||||
const float dash_width = (sima->dt_uv == SI_UVDT_DASH) ? (4.0f * UI_DPI_FAC) : 9999.0f;
|
||||
eGPUBuiltinShader shader = (interpedges) ? GPU_SHADER_2D_UV_EDGES_SMOOTH :
|
||||
GPU_SHADER_2D_UV_EDGES;
|
||||
#ifdef __APPLE__
|
||||
if (sima->dt_uv == SI_UVDT_OUTLINE) {
|
||||
/* Apple drivers do not support wide line. This is a workaround awaiting the 2D view
|
||||
* refactor. Limiting to OSX since this will slow down the drawing. (see T76806) */
|
||||
GPU_batch_program_set_builtin(batch->edges, GPU_SHADER_3D_POLYLINE_UNIFORM_COLOR);
|
||||
|
||||
float viewport[4];
|
||||
GPU_viewport_size_get_f(viewport);
|
||||
|
||||
/* No U.pixelsize scaling for now since the inner line is not scalled. */
|
||||
GPU_batch_uniform_1f(batch->edges, "lineWidth", 2.0f);
|
||||
GPU_batch_uniform_4f(batch->edges, "color", 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
GPU_batch_uniform_2fv(batch->edges, "viewportSize", &viewport[2]);
|
||||
|
||||
GPU_batch_draw(batch->edges);
|
||||
}
|
||||
#endif
|
||||
|
||||
GPU_batch_program_set_builtin(batch->edges, shader);
|
||||
|
||||
if (sima->dt_uv == SI_UVDT_OUTLINE) {
|
||||
#ifndef __APPLE__
|
||||
/* Black Outline. */
|
||||
GPU_line_width(3.0f);
|
||||
GPU_batch_uniform_4f(batch->edges, "edgeColor", 0.0f, 0.0f, 0.0f, overlay_alpha);
|
||||
GPU_batch_uniform_4f(batch->edges, "selectColor", 0.0f, 0.0f, 0.0f, overlay_alpha);
|
||||
GPU_batch_uniform_1f(batch->edges, "dashWidth", dash_width);
|
||||
GPU_batch_draw(batch->edges);
|
||||
#endif
|
||||
UI_GetThemeColor3fv(TH_WIRE_EDIT, col1);
|
||||
}
|
||||
else if (sima->dt_uv == SI_UVDT_BLACK) {
|
||||
copy_v3_fl3(col1, 0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
else {
|
||||
copy_v3_fl3(col1, 1.0f, 1.0f, 1.0f);
|
||||
}
|
||||
col1[3] = overlay_alpha;
|
||||
|
||||
GPU_batch_program_set_builtin(batch->edges, shader);
|
||||
|
||||
/* Inner Line. Use depth test to insure selection is drawn on top. */
|
||||
GPU_depth_test(GPU_DEPTH_LESS_EQUAL);
|
||||
GPU_line_width(1.0f);
|
||||
GPU_batch_uniform_4fv(batch->edges, "edgeColor", col1);
|
||||
GPU_batch_uniform_4fv(batch->edges, "selectColor", col2);
|
||||
GPU_batch_uniform_1f(batch->edges, "dashWidth", dash_width);
|
||||
GPU_batch_draw(batch->edges);
|
||||
GPU_depth_test(GPU_DEPTH_NONE);
|
||||
|
||||
GPU_provoking_vertex(GPU_VERTEX_LAST);
|
||||
}
|
||||
|
||||
if (sima->flag & SI_SMOOTH_UV) {
|
||||
GPU_line_smooth(false);
|
||||
GPU_blend(GPU_BLEND_NONE);
|
||||
}
|
||||
else if (overlay_alpha < 1.0f) {
|
||||
GPU_blend(GPU_BLEND_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
if (batch->verts || batch->facedots) {
|
||||
UI_GetThemeColor4fv(TH_VERTEX_SELECT, col2);
|
||||
if (batch->verts) {
|
||||
const float point_size = UI_GetThemeValuef(TH_VERTEX_SIZE);
|
||||
const float pinned_col[4] = {1.0f, 0.0f, 0.0f, 1.0f}; /* TODO Theme? */
|
||||
UI_GetThemeColor4fv(TH_VERTEX, col1);
|
||||
GPU_blend(GPU_BLEND_ALPHA);
|
||||
GPU_program_point_size(true);
|
||||
|
||||
GPU_batch_program_set_builtin(batch->verts, GPU_SHADER_2D_UV_VERTS);
|
||||
GPU_batch_uniform_4f(batch->verts, "vertColor", col1[0], col1[1], col1[2], 1.0f);
|
||||
GPU_batch_uniform_4fv(batch->verts, "selectColor", transparent);
|
||||
GPU_batch_uniform_4fv(batch->verts, "pinnedColor", pinned_col);
|
||||
GPU_batch_uniform_1f(batch->verts, "pointSize", (point_size + 1.5f) * M_SQRT2);
|
||||
GPU_batch_uniform_1f(batch->verts, "outlineWidth", 0.75f);
|
||||
|
||||
/* #GPU_batch_draw_advanced is needed as unbinding the shader and redrawing
|
||||
* causes the vertices not to draw at the right size. */
|
||||
GPU_shader_bind(batch->verts->shader);
|
||||
|
||||
GPU_batch_draw_advanced(batch->verts, 0, 0, 0, 0);
|
||||
|
||||
/* We have problem in this mode when face order make some verts
|
||||
* appear unselected because an adjacent face is not selected and
|
||||
* render after the selected face.
|
||||
* So, to avoid sorting verts by state we just render selected verts
|
||||
* on top. A bit overkill but it's simple. */
|
||||
GPU_batch_uniform_4fv(batch->verts, "vertColor", transparent);
|
||||
GPU_batch_uniform_4fv(batch->verts, "selectColor", col2);
|
||||
|
||||
GPU_batch_draw_advanced(batch->verts, 0, 0, 0, 0);
|
||||
|
||||
GPU_shader_unbind();
|
||||
/* Finish #GPU_batch_draw_advanced drawing. */
|
||||
|
||||
GPU_blend(GPU_BLEND_NONE);
|
||||
GPU_program_point_size(false);
|
||||
}
|
||||
if (batch->facedots) {
|
||||
const float point_size = UI_GetThemeValuef(TH_FACEDOT_SIZE);
|
||||
GPU_point_size(point_size);
|
||||
|
||||
UI_GetThemeColor4fv(TH_WIRE, col1);
|
||||
GPU_batch_program_set_builtin(batch->facedots, GPU_SHADER_2D_UV_FACEDOTS);
|
||||
GPU_batch_uniform_4fv(batch->facedots, "vertColor", col1);
|
||||
GPU_batch_uniform_4fv(batch->facedots, "selectColor", col2);
|
||||
GPU_batch_draw(batch->facedots);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void draw_uv_shadows_get(
|
||||
SpaceImage *sima, Object *ob, Object *obedit, bool *r_show_shadow, bool *r_show_texpaint)
|
||||
{
|
||||
*r_show_shadow = *r_show_texpaint = false;
|
||||
|
||||
if (ED_space_image_show_render(sima) || (sima->flag & SI_NO_DRAW_TEXPAINT)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ((sima->mode == SI_MODE_PAINT) && obedit && obedit->type == OB_MESH) {
|
||||
struct BMEditMesh *em = BKE_editmesh_from_object(obedit);
|
||||
|
||||
*r_show_shadow = EDBM_uv_check(em);
|
||||
}
|
||||
|
||||
*r_show_texpaint = (ob && ob->type == OB_MESH && ob->mode == OB_MODE_TEXTURE_PAINT);
|
||||
}
|
||||
|
||||
void ED_uvedit_draw_main(SpaceImage *sima,
|
||||
const Scene *scene,
|
||||
ViewLayer *view_layer,
|
||||
Object *obedit,
|
||||
Object *obact,
|
||||
Depsgraph *depsgraph)
|
||||
{
|
||||
bool show_uvedit, show_uvshadow, show_texpaint_uvshadow;
|
||||
|
||||
show_uvedit = ED_space_image_show_uvedit(sima, obedit);
|
||||
draw_uv_shadows_get(sima, obact, obedit, &show_uvshadow, &show_texpaint_uvshadow);
|
||||
|
||||
if (show_uvedit || show_uvshadow || show_texpaint_uvshadow) {
|
||||
if (show_uvshadow) {
|
||||
draw_uvs_shadow(sima, scene, obedit, depsgraph);
|
||||
}
|
||||
else if (show_uvedit) {
|
||||
uint objects_len = 0;
|
||||
Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(
|
||||
view_layer, ((View3D *)NULL), &objects_len);
|
||||
if (objects_len > 0) {
|
||||
GPU_depth_mask(true);
|
||||
GPU_clear_depth(1.0f);
|
||||
}
|
||||
|
||||
/* go over all objects and create the batches + add their areas to the total */
|
||||
UVEditGPUBatches *batches = MEM_mallocN(sizeof(UVEditGPUBatches) * objects_len, __func__);
|
||||
float tot_area = 0.0f;
|
||||
float tot_area_uv = 0.0f;
|
||||
float tot_area_ratio = 0.0f;
|
||||
float tot_area_ratio_inv = 0.0f;
|
||||
|
||||
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
|
||||
Object *ob_iter = objects[ob_index];
|
||||
Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob_iter);
|
||||
batches[ob_index].ob_eval = ob_eval;
|
||||
uvedit_get_batches(ob_eval, sima, scene, &batches[ob_index], &tot_area, &tot_area_uv);
|
||||
}
|
||||
|
||||
if (tot_area > FLT_EPSILON && tot_area_uv > FLT_EPSILON) {
|
||||
tot_area_ratio = tot_area / tot_area_uv;
|
||||
tot_area_ratio_inv = tot_area_uv / tot_area;
|
||||
}
|
||||
|
||||
/* go over all batches created in the previous loop and draw them */
|
||||
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
|
||||
UVEditGPUBatches *batch = &batches[ob_index];
|
||||
draw_uvs(sima, scene, depsgraph, batch, tot_area_ratio, tot_area_ratio_inv);
|
||||
}
|
||||
MEM_freeN(batches);
|
||||
MEM_freeN(objects);
|
||||
}
|
||||
else {
|
||||
draw_uvs_texpaint(scene, obact, depsgraph);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1169,7 +1169,7 @@ typedef enum eSpaceImage_Flag {
|
|||
* in the image view, it's unrelated to UDIM tiles.
|
||||
*/
|
||||
SI_DRAW_TILE = (1 << 19),
|
||||
SI_SMOOTH_UV = (1 << 20),
|
||||
SI_FLAG_UNUSED_20 = (1 << 20), /* cleared */
|
||||
SI_DRAW_STRETCH = (1 << 21),
|
||||
SI_SHOW_GPENCIL = (1 << 22),
|
||||
SI_FLAG_UNUSED_23 = (1 << 23), /* cleared */
|
||||
|
|
|
@ -626,7 +626,6 @@ typedef struct UserDef_Experimental {
|
|||
/* Debug options, always available. */
|
||||
char use_undo_legacy;
|
||||
char use_cycles_debug;
|
||||
char use_image_editor_legacy_drawing;
|
||||
char SANITIZE_AFTER_HERE;
|
||||
/* The following options are automatically sanitized (set to 0)
|
||||
* when the release cycle is not alpha. */
|
||||
|
@ -636,7 +635,7 @@ typedef struct UserDef_Experimental {
|
|||
char use_tools_missing_icons;
|
||||
char use_switch_object_operator;
|
||||
char use_sculpt_tools_tilt;
|
||||
char _pad[6];
|
||||
char _pad[7];
|
||||
/** `makesdna` does not allow empty structs. */
|
||||
} UserDef_Experimental;
|
||||
|
||||
|
|
|
@ -2923,11 +2923,6 @@ static void rna_def_space_image_uv(BlenderRNA *brna)
|
|||
RNA_def_property_ui_text(prop, "Display As", "Display style for UV edges");
|
||||
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL);
|
||||
|
||||
prop = RNA_def_property(srna, "show_smooth_edges", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_SMOOTH_UV);
|
||||
RNA_def_property_ui_text(prop, "Display Smooth Edges", "Display UV edges anti-aliased");
|
||||
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL);
|
||||
|
||||
prop = RNA_def_property(srna, "show_stretch", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_DRAW_STRETCH);
|
||||
RNA_def_property_ui_text(
|
||||
|
|
|
@ -6170,11 +6170,6 @@ static void rna_def_userdef_experimental(BlenderRNA *brna)
|
|||
RNA_def_property_ui_text(
|
||||
prop, "Switch Object Operator", "Enable the operator to switch objects by pressing D");
|
||||
|
||||
prop = RNA_def_property(srna, "use_image_editor_legacy_drawing", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "use_image_editor_legacy_drawing", 1);
|
||||
RNA_def_property_ui_text(
|
||||
prop, "Image Editor Legacy Drawing", "Use legacy UV/Image editor drawing");
|
||||
|
||||
prop = RNA_def_property(srna, "use_tools_missing_icons", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "use_tools_missing_icons", 1);
|
||||
RNA_def_property_ui_text(prop, "Tools with Missing Icons", "Show tools with missing icons");
|
||||
|
|
Loading…
Reference in New Issue