Geometry Nodes: make field links thinner than other links
This makes it easier to spot which links contain fields and which contain data. Actually, the patch makes all other links a bit thicker. However, with soon-to-be-implemented theme changes, the perceived thickness will be the same as before. This is part of T91563. Differential Revision: https://developer.blender.org/D12646
This commit is contained in:
@@ -3933,9 +3933,11 @@ static struct {
|
|||||||
uint p0_id, p1_id, p2_id, p3_id;
|
uint p0_id, p1_id, p2_id, p3_id;
|
||||||
uint colid_id, muted_id;
|
uint colid_id, muted_id;
|
||||||
uint dim_factor_id;
|
uint dim_factor_id;
|
||||||
|
uint thickness_id;
|
||||||
GPUVertBufRaw p0_step, p1_step, p2_step, p3_step;
|
GPUVertBufRaw p0_step, p1_step, p2_step, p3_step;
|
||||||
GPUVertBufRaw colid_step, muted_step;
|
GPUVertBufRaw colid_step, muted_step;
|
||||||
GPUVertBufRaw dim_factor_step;
|
GPUVertBufRaw dim_factor_step;
|
||||||
|
GPUVertBufRaw thickness_step;
|
||||||
uint count;
|
uint count;
|
||||||
bool enabled;
|
bool enabled;
|
||||||
} g_batch_link;
|
} g_batch_link;
|
||||||
@@ -3952,6 +3954,8 @@ static void nodelink_batch_reset()
|
|||||||
g_batch_link.inst_vbo, g_batch_link.muted_id, &g_batch_link.muted_step);
|
g_batch_link.inst_vbo, g_batch_link.muted_id, &g_batch_link.muted_step);
|
||||||
GPU_vertbuf_attr_get_raw_data(
|
GPU_vertbuf_attr_get_raw_data(
|
||||||
g_batch_link.inst_vbo, g_batch_link.dim_factor_id, &g_batch_link.dim_factor_step);
|
g_batch_link.inst_vbo, g_batch_link.dim_factor_id, &g_batch_link.dim_factor_step);
|
||||||
|
GPU_vertbuf_attr_get_raw_data(
|
||||||
|
g_batch_link.inst_vbo, g_batch_link.thickness_id, &g_batch_link.thickness_step);
|
||||||
g_batch_link.count = 0;
|
g_batch_link.count = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4071,6 +4075,8 @@ static void nodelink_batch_init()
|
|||||||
&format_inst, "domuted", GPU_COMP_U8, 2, GPU_FETCH_INT);
|
&format_inst, "domuted", GPU_COMP_U8, 2, GPU_FETCH_INT);
|
||||||
g_batch_link.dim_factor_id = GPU_vertformat_attr_add(
|
g_batch_link.dim_factor_id = GPU_vertformat_attr_add(
|
||||||
&format_inst, "dim_factor", GPU_COMP_F32, 1, GPU_FETCH_FLOAT);
|
&format_inst, "dim_factor", GPU_COMP_F32, 1, GPU_FETCH_FLOAT);
|
||||||
|
g_batch_link.thickness_id = GPU_vertformat_attr_add(
|
||||||
|
&format_inst, "thickness", GPU_COMP_F32, 1, GPU_FETCH_FLOAT);
|
||||||
g_batch_link.inst_vbo = GPU_vertbuf_create_with_format_ex(&format_inst, GPU_USAGE_STREAM);
|
g_batch_link.inst_vbo = GPU_vertbuf_create_with_format_ex(&format_inst, GPU_USAGE_STREAM);
|
||||||
/* Alloc max count but only draw the range we need. */
|
/* Alloc max count but only draw the range we need. */
|
||||||
GPU_vertbuf_data_alloc(g_batch_link.inst_vbo, NODELINK_GROUP_SIZE);
|
GPU_vertbuf_data_alloc(g_batch_link.inst_vbo, NODELINK_GROUP_SIZE);
|
||||||
@@ -4147,7 +4153,8 @@ static void nodelink_batch_add_link(const SpaceNode *snode,
|
|||||||
int th_col3,
|
int th_col3,
|
||||||
bool drawarrow,
|
bool drawarrow,
|
||||||
bool drawmuted,
|
bool drawmuted,
|
||||||
float dim_factor)
|
float dim_factor,
|
||||||
|
float thickness)
|
||||||
{
|
{
|
||||||
/* Only allow these colors. If more is needed, you need to modify the shader accordingly. */
|
/* Only allow these colors. If more is needed, you need to modify the shader accordingly. */
|
||||||
BLI_assert(ELEM(th_col1, TH_WIRE_INNER, TH_WIRE, TH_ACTIVE, TH_EDGE_SELECT, TH_REDALERT));
|
BLI_assert(ELEM(th_col1, TH_WIRE_INNER, TH_WIRE, TH_ACTIVE, TH_EDGE_SELECT, TH_REDALERT));
|
||||||
@@ -4167,6 +4174,7 @@ static void nodelink_batch_add_link(const SpaceNode *snode,
|
|||||||
char *muted = (char *)GPU_vertbuf_raw_step(&g_batch_link.muted_step);
|
char *muted = (char *)GPU_vertbuf_raw_step(&g_batch_link.muted_step);
|
||||||
muted[0] = drawmuted;
|
muted[0] = drawmuted;
|
||||||
*(float *)GPU_vertbuf_raw_step(&g_batch_link.dim_factor_step) = dim_factor;
|
*(float *)GPU_vertbuf_raw_step(&g_batch_link.dim_factor_step) = dim_factor;
|
||||||
|
*(float *)GPU_vertbuf_raw_step(&g_batch_link.thickness_step) = thickness;
|
||||||
|
|
||||||
if (g_batch_link.count == NODELINK_GROUP_SIZE) {
|
if (g_batch_link.count == NODELINK_GROUP_SIZE) {
|
||||||
nodelink_batch_draw(snode);
|
nodelink_batch_draw(snode);
|
||||||
@@ -4182,6 +4190,13 @@ void node_draw_link_bezier(const View2D *v2d,
|
|||||||
int th_col3)
|
int th_col3)
|
||||||
{
|
{
|
||||||
const float dim_factor = node_link_dim_factor(v2d, link);
|
const float dim_factor = node_link_dim_factor(v2d, link);
|
||||||
|
float thickness = 1.5f;
|
||||||
|
if (snode->edittree->type == NTREE_GEOMETRY) {
|
||||||
|
if (link->fromsock && link->fromsock->display_shape == SOCK_DISPLAY_SHAPE_DIAMOND) {
|
||||||
|
/* Make field links a bit thinner. */
|
||||||
|
thickness = 1.0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
float vec[4][2];
|
float vec[4][2];
|
||||||
const bool highlighted = link->flag & NODE_LINK_TEMP_HIGHLIGHT;
|
const bool highlighted = link->flag & NODE_LINK_TEMP_HIGHLIGHT;
|
||||||
@@ -4205,7 +4220,8 @@ void node_draw_link_bezier(const View2D *v2d,
|
|||||||
th_col3,
|
th_col3,
|
||||||
drawarrow,
|
drawarrow,
|
||||||
drawmuted,
|
drawmuted,
|
||||||
dim_factor);
|
dim_factor,
|
||||||
|
thickness);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* Draw single link. */
|
/* Draw single link. */
|
||||||
@@ -4231,6 +4247,7 @@ void node_draw_link_bezier(const View2D *v2d,
|
|||||||
GPU_batch_uniform_1i(batch, "doArrow", drawarrow);
|
GPU_batch_uniform_1i(batch, "doArrow", drawarrow);
|
||||||
GPU_batch_uniform_1i(batch, "doMuted", drawmuted);
|
GPU_batch_uniform_1i(batch, "doMuted", drawmuted);
|
||||||
GPU_batch_uniform_1f(batch, "dim_factor", dim_factor);
|
GPU_batch_uniform_1f(batch, "dim_factor", dim_factor);
|
||||||
|
GPU_batch_uniform_1f(batch, "thickness", thickness);
|
||||||
GPU_batch_draw(batch);
|
GPU_batch_draw(batch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ in vec2 P3;
|
|||||||
in ivec4 colid_doarrow;
|
in ivec4 colid_doarrow;
|
||||||
in ivec2 domuted;
|
in ivec2 domuted;
|
||||||
in float dim_factor;
|
in float dim_factor;
|
||||||
|
in float thickness;
|
||||||
|
|
||||||
uniform vec4 colors[6];
|
uniform vec4 colors[6];
|
||||||
|
|
||||||
@@ -41,6 +42,7 @@ uniform vec4 colors[3];
|
|||||||
uniform bool doArrow;
|
uniform bool doArrow;
|
||||||
uniform bool doMuted;
|
uniform bool doMuted;
|
||||||
uniform float dim_factor;
|
uniform float dim_factor;
|
||||||
|
uniform float thickness;
|
||||||
|
|
||||||
# define colShadow colors[0]
|
# define colShadow colors[0]
|
||||||
# define colStart colors[1]
|
# define colStart colors[1]
|
||||||
@@ -103,7 +105,7 @@ void main(void)
|
|||||||
finalColor[3] *= dim_factor;
|
finalColor[3] *= dim_factor;
|
||||||
|
|
||||||
/* Expand into a line */
|
/* Expand into a line */
|
||||||
gl_Position.xy += exp_axis * expandSize * expand_dist;
|
gl_Position.xy += exp_axis * expandSize * expand_dist * thickness;
|
||||||
|
|
||||||
/* If the link is not muted or is not a reroute arrow the points are squashed to the center of
|
/* If the link is not muted or is not a reroute arrow the points are squashed to the center of
|
||||||
* the line. Magic numbers are defined in drawnode.c */
|
* the line. Magic numbers are defined in drawnode.c */
|
||||||
|
|||||||
Reference in New Issue
Block a user