Blender V5.3
overlay_common.bsl.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2026 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
9#include "select_lib.bsl.hh"
10
11/* Wire Color Types, matching eV3DShadingColorType. */
17
18namespace overlay {
19
23
24struct Clipping {
26
28
30 float &dist0,
31 float &dist1,
32 float &dist2,
33 float &dist3,
34 float &dist4,
35 float &dist5) const
36 {
38 float4 pos_4d = float4(ws_P, 1.0f);
39 dist0 = dot(drw_clipping_[0], pos_4d);
40 dist1 = dot(drw_clipping_[1], pos_4d);
41 dist2 = dot(drw_clipping_[2], pos_4d);
42 dist3 = dot(drw_clipping_[3], pos_4d);
43 dist4 = dot(drw_clipping_[4], pos_4d);
44 dist5 = dot(drw_clipping_[5], pos_4d);
45 }
46 }
47};
48
54
59
60struct Uniform {
62
63 /* project to screen space */
64 float2 proj(float4 pos) const
65 {
66 return (0.5f * (pos.xy / pos.w) + 0.5f) * uniform_buf.size_viewport;
67 }
68};
69
71{
72 float2 dir = normalize(v2 - v0);
73 dir = float2(dir.y, -dir.x);
74 return dir;
75}
76
78{
79 constexpr float div = 1.0f / 255.0f;
80 int a = int(mat[0][3]);
81 int b = int(mat[1][3]);
82 int c = int(mat[2][3]);
83 int d = int(mat[3][3]);
84 dataA = float4(a & 0xFF, a >> 8, b & 0xFF, b >> 8) * div;
85 dataB = float4(c & 0xFF, c >> 8, d & 0xFF, d >> 8) * div;
86 mat[0][3] = mat[1][3] = mat[2][3] = 0.0f;
87 mat[3][3] = 1.0f;
88 return mat;
89}
90
91[[fragment]]
93 [[frag_coord]] const float4 frag_co,
94 [[in]] const VertOut &v_out,
95 [[in, condition(selectable)]] const draw::SelectOut &sel_out,
96 [[out]] FragOut &frag_out)
97{
98 frag_out.line_output = overlay::pack_line_data(frag_co.xy, v_out.edge_start, v_out.edge_pos);
99 frag_out.color = v_out.final_color;
100 if (sel.consts.selectable) [[static_branch]] {
101 sel.select_id_output(sel_out.select_id, frag_co);
102 }
103}
104
105} // namespace overlay
#define DRW_CLIPPING_UBO_SLOT
#define OVERLAY_GLOBALS_SLOT
#define uniform(slot)
#define flat
#define frag_coord
#define compilation_constant
#define resource_table
#define static_branch
#define fragment
#define no_perspective
#define condition(cond)
#define frag_color(slot)
VecBase< float, D > normalize(VecOp< float, D >) RET
float dot(VecOp< float, D >, VecOp< float, D >) RET
MatBase< float, 4, 4 > float4x4
float4 pack_line_data(float2 frag_co, float2 edge_start, float2 edge_pos)
void wire_frag(draw::Select &sel, const float4 frag_co, const VertOut &v_out, const draw::SelectOut &sel_out, FragOut &frag_out)
float2 compute_dir(float2 v0, float2, float2 v2)
float4x4 extract_matrix_packed_data(float4x4 mat, float4 &dataA, float4 &dataB)
eV3DShadingColorType
@ V3D_SHADING_OBJECT_COLOR
@ V3D_SHADING_RANDOM_COLOR
@ V3D_SHADING_SINGLE_COLOR
float x
float y
float w
Definition sky_math.h:225
ClippingConstant constants
const float4(& drw_clipping_)[6]
void set_clipping_distances(float3 ws_P, float &dist0, float &dist1, float &dist2, float &dist3, float &dist4, float &dist5) const
float2 proj(float4 pos) const