Cleanup: Overlay: Remove overlay_private.hh and share uv line style enum

This commit is contained in:
Clément Foucault
2025-04-16 20:34:49 +02:00
parent 0f71bb6c71
commit 2cc0dad451
9 changed files with 21 additions and 57 deletions

View File

@@ -12,8 +12,10 @@
#include "DNA_brush_types.h"
#include "DNA_screen_types.h"
#include "DNA_space_types.h"
#include "ED_view3d.hh"
#include "UI_view2d.hh"
#include "overlay_next_base.hh"
namespace blender::draw::overlay {

View File

@@ -14,6 +14,7 @@
#include "BLI_function_ref.hh"
#include "DNA_space_types.h"
#include "DNA_world_types.h"
#include "GPU_matrix.hh"
@@ -31,9 +32,6 @@
#include "draw_common.hh"
/* Needed for BoneInstanceData. */
#include "overlay_private.hh"
namespace blender::draw::overlay {
struct BoneInstanceData {

View File

@@ -1,40 +0,0 @@
/* SPDX-FileCopyrightText: 2019 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup DNA
*/
#pragma once
#include "BKE_global.hh"
#include "BLI_math_matrix.hh"
#include "DRW_gpu_wrapper.hh"
#include "DRW_render.hh"
#include "UI_resources.hh"
#include "draw_handle.hh"
#include "overlay_shader_shared.hh"
/* Needed for eSpaceImage_UVDT_Stretch and eMaskOverlayMode */
#include "DNA_mask_types.h"
#include "DNA_space_types.h"
/* Forward declarations */
enum OVERLAY_UVLineStyle {
OVERLAY_UV_LINE_STYLE_OUTLINE = 0,
OVERLAY_UV_LINE_STYLE_DASH = 1,
OVERLAY_UV_LINE_STYLE_BLACK = 2,
OVERLAY_UV_LINE_STYLE_WHITE = 3,
OVERLAY_UV_LINE_STYLE_SHADOW = 4,
};
struct OVERLAY_Data {
void *engine_type;
void *instance;
};

View File

@@ -20,7 +20,15 @@
#define BG_SOLID_CHECKER 4
#define BG_MASK 5
enum OVERLAY_GridBits {
enum OVERLAY_UVLineStyle : uint32_t {
OVERLAY_UV_LINE_STYLE_OUTLINE = 0u,
OVERLAY_UV_LINE_STYLE_DASH = 1u,
OVERLAY_UV_LINE_STYLE_BLACK = 2u,
OVERLAY_UV_LINE_STYLE_WHITE = 3u,
OVERLAY_UV_LINE_STYLE_SHADOW = 4u,
};
enum OVERLAY_GridBits : uint32_t {
SHOW_AXIS_X = (1u << 0u),
SHOW_AXIS_Y = (1u << 1u),
SHOW_AXIS_Z = (1u << 2u),

View File

@@ -329,6 +329,7 @@ VERTEX_OUT(overlay_edit_uv_iface)
FRAGMENT_OUT(0, float4, fragColor)
VERTEX_SOURCE("overlay_edit_uv_edges_vert.glsl")
FRAGMENT_SOURCE("overlay_edit_uv_edges_frag.glsl")
TYPEDEF_SOURCE("overlay_shader_shared.hh")
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_modelmat)
ADDITIONAL_INFO(draw_object_infos)

View File

@@ -107,7 +107,7 @@ DO_STATIC_COMPILATION()
DEFINE("WIREFRAME")
STORAGE_BUF_FREQ(0, READ, float, au[], GEOMETRY)
PUSH_CONSTANT(int2, gpu_attr_0)
DEFINE_VALUE("lineStyle", "4" /* OVERLAY_UV_LINE_STYLE_SHADOW */)
DEFINE_VALUE("lineStyle", "4u" /* OVERLAY_UV_LINE_STYLE_SHADOW */)
DEFINE_VALUE("dashLength", "1" /* Not used by this line style */)
DEFINE_VALUE("use_edge_select", "false")
PUSH_CONSTANT(bool, doSmoothWire)
@@ -117,6 +117,7 @@ FRAGMENT_OUT(0, float4, fragColor)
/* Note: Reuse edit mode shader as it is mostly the same. */
VERTEX_SOURCE("overlay_edit_uv_edges_vert.glsl")
FRAGMENT_SOURCE("overlay_edit_uv_edges_frag.glsl")
TYPEDEF_SOURCE("overlay_shader_shared.hh")
ADDITIONAL_INFO(draw_view)
ADDITIONAL_INFO(draw_modelmat)
ADDITIONAL_INFO(draw_object_infos)

View File

@@ -6,12 +6,6 @@
#include "draw_view_lib.glsl"
#define OVERLAY_UV_LINE_STYLE_OUTLINE 0
#define OVERLAY_UV_LINE_STYLE_DASH 1
#define OVERLAY_UV_LINE_STYLE_BLACK 2
#define OVERLAY_UV_LINE_STYLE_WHITE 3
#define OVERLAY_UV_LINE_STYLE_SHADOW 4
/* Wire Color Types, matching eV3DShadingColorType. */
#define V3D_SHADING_SINGLE_COLOR 2
#define V3D_SHADING_OBJECT_COLOR 4

View File

@@ -30,7 +30,7 @@ void main()
float2 dd = fwidth(stipplePos);
float line_distance = distance(stipplePos, stippleStart) / max(dd.x, dd.y);
if (lineStyle == OVERLAY_UV_LINE_STYLE_OUTLINE) {
if (OVERLAY_UVLineStyle(lineStyle) == OVERLAY_UV_LINE_STYLE_OUTLINE) {
if (use_edge_select) {
/* TODO(@ideasman42): The current wire-edit color contrast enough against the selection.
* Look into changing the default theme color instead of reducing contrast with edge-select.
@@ -42,20 +42,20 @@ void main()
}
outer_color = float4(float3(0.0f), 1.0f);
}
else if (lineStyle == OVERLAY_UV_LINE_STYLE_DASH) {
else if (OVERLAY_UVLineStyle(lineStyle) == OVERLAY_UV_LINE_STYLE_DASH) {
if (fract(line_distance / dashLength) < 0.5f) {
inner_color = mix(float4(float3(0.35f), 1.0f), colorEdgeSelect, selectionFac);
}
}
else if (lineStyle == OVERLAY_UV_LINE_STYLE_BLACK) {
else if (OVERLAY_UVLineStyle(lineStyle) == OVERLAY_UV_LINE_STYLE_BLACK) {
float4 base_color = float4(float3(0.0f), 1.0f);
inner_color = mix(base_color, colorEdgeSelect, selectionFac);
}
else if (lineStyle == OVERLAY_UV_LINE_STYLE_WHITE) {
else if (OVERLAY_UVLineStyle(lineStyle) == OVERLAY_UV_LINE_STYLE_WHITE) {
float4 base_color = float4(1.0f);
inner_color = mix(base_color, colorEdgeSelect, selectionFac);
}
else if (lineStyle == OVERLAY_UV_LINE_STYLE_SHADOW) {
else if (OVERLAY_UVLineStyle(lineStyle) == OVERLAY_UV_LINE_STYLE_SHADOW) {
inner_color = colorUVShadow;
}

View File

@@ -111,7 +111,7 @@ void geometry_main(VertOut geom_in[2],
float half_size = sizeEdge;
/* Enlarge edge for outline drawing. */
/* Factor of 3.0 out of nowhere! Seems to fix issues with float imprecision. */
half_size += (lineStyle == OVERLAY_UV_LINE_STYLE_OUTLINE) ?
half_size += (OVERLAY_UVLineStyle(lineStyle) == OVERLAY_UV_LINE_STYLE_OUTLINE) ?
max(sizeEdge * (doSmoothWire ? 1.0f : 3.0f), 1.0f) :
0.0f;
/* Add 1 PX for AA. */