Compare commits
6 Commits
temp-move-
...
temp-long-
Author | SHA1 | Date | |
---|---|---|---|
61ff6676cf | |||
dcd3d096cd | |||
10ea5981ec | |||
d7cef6461d | |||
589d2bd655 | |||
97b8f1b933 |
@@ -22,6 +22,8 @@
|
||||
* \brief lower level node drawing for nodes (boarders, headers etc), also node layout.
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "BLI_blenlib.h"
|
||||
#include "BLI_math.h"
|
||||
#include "BLI_system.h"
|
||||
@@ -3911,8 +3913,10 @@ static struct {
|
||||
GPUVertBuf *inst_vbo;
|
||||
uint p0_id, p1_id, p2_id, p3_id;
|
||||
uint colid_id, muted_id;
|
||||
uint dim_factor_id;
|
||||
GPUVertBufRaw p0_step, p1_step, p2_step, p3_step;
|
||||
GPUVertBufRaw colid_step, muted_step;
|
||||
GPUVertBufRaw dim_factor_step;
|
||||
uint count;
|
||||
bool enabled;
|
||||
} g_batch_link;
|
||||
@@ -3927,6 +3931,8 @@ static void nodelink_batch_reset()
|
||||
g_batch_link.inst_vbo, g_batch_link.colid_id, &g_batch_link.colid_step);
|
||||
GPU_vertbuf_attr_get_raw_data(
|
||||
g_batch_link.inst_vbo, g_batch_link.muted_id, &g_batch_link.muted_step);
|
||||
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.count = 0;
|
||||
}
|
||||
|
||||
@@ -4044,6 +4050,8 @@ static void nodelink_batch_init()
|
||||
&format_inst, "colid_doarrow", GPU_COMP_U8, 4, GPU_FETCH_INT);
|
||||
g_batch_link.muted_id = GPU_vertformat_attr_add(
|
||||
&format_inst, "domuted", GPU_COMP_U8, 2, GPU_FETCH_INT);
|
||||
g_batch_link.dim_factor_id = GPU_vertformat_attr_add(
|
||||
&format_inst, "dim_factor", GPU_COMP_F32, 1, GPU_FETCH_FLOAT);
|
||||
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. */
|
||||
GPU_vertbuf_data_alloc(g_batch_link.inst_vbo, NODELINK_GROUP_SIZE);
|
||||
@@ -4119,7 +4127,8 @@ static void nodelink_batch_add_link(const SpaceNode *snode,
|
||||
int th_col2,
|
||||
int th_col3,
|
||||
bool drawarrow,
|
||||
bool drawmuted)
|
||||
bool drawmuted,
|
||||
float dim_factor)
|
||||
{
|
||||
/* 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));
|
||||
@@ -4138,6 +4147,7 @@ static void nodelink_batch_add_link(const SpaceNode *snode,
|
||||
colid[3] = drawarrow;
|
||||
char *muted = (char *)GPU_vertbuf_raw_step(&g_batch_link.muted_step);
|
||||
muted[0] = drawmuted;
|
||||
*(float *)GPU_vertbuf_raw_step(&g_batch_link.dim_factor_step) = dim_factor;
|
||||
|
||||
if (g_batch_link.count == NODELINK_GROUP_SIZE) {
|
||||
nodelink_batch_draw(snode);
|
||||
@@ -4152,6 +4162,8 @@ void node_draw_link_bezier(const View2D *v2d,
|
||||
int th_col2,
|
||||
int th_col3)
|
||||
{
|
||||
const float dim_factor = node_link_dim_factor(v2d, link);
|
||||
|
||||
float vec[4][2];
|
||||
const bool highlighted = link->flag & NODE_LINK_TEMP_HIGHLIGHT;
|
||||
if (node_link_bezier_handles(v2d, snode, link, vec)) {
|
||||
@@ -4164,8 +4176,17 @@ void node_draw_link_bezier(const View2D *v2d,
|
||||
|
||||
if (g_batch_link.enabled && !highlighted) {
|
||||
/* Add link to batch. */
|
||||
nodelink_batch_add_link(
|
||||
snode, vec[0], vec[1], vec[2], vec[3], th_col1, th_col2, th_col3, drawarrow, drawmuted);
|
||||
nodelink_batch_add_link(snode,
|
||||
vec[0],
|
||||
vec[1],
|
||||
vec[2],
|
||||
vec[3],
|
||||
th_col1,
|
||||
th_col2,
|
||||
th_col3,
|
||||
drawarrow,
|
||||
drawmuted,
|
||||
dim_factor);
|
||||
}
|
||||
else {
|
||||
/* Draw single link. */
|
||||
@@ -4190,6 +4211,7 @@ void node_draw_link_bezier(const View2D *v2d,
|
||||
GPU_batch_uniform_1f(batch, "arrowSize", ARROW_SIZE);
|
||||
GPU_batch_uniform_1i(batch, "doArrow", drawarrow);
|
||||
GPU_batch_uniform_1i(batch, "doMuted", drawmuted);
|
||||
GPU_batch_uniform_1f(batch, "dim_factor", dim_factor);
|
||||
GPU_batch_draw(batch);
|
||||
}
|
||||
}
|
||||
|
@@ -260,7 +260,7 @@ static int add_reroute_exec(bContext *C, wmOperator *op)
|
||||
BLI_listbase_clear(&input_links);
|
||||
|
||||
for (link = (bNodeLink *)ntree->links.first; link; link = link->next) {
|
||||
if (nodeLinkIsHidden(link)) {
|
||||
if (node_link_is_hidden_or_dimmed(®ion->v2d, link)) {
|
||||
continue;
|
||||
}
|
||||
if (add_reroute_intersect_check(link, mcoords, i, insert_point)) {
|
||||
|
@@ -21,6 +21,8 @@
|
||||
* \ingroup spnode
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "DNA_light_types.h"
|
||||
@@ -1226,6 +1228,28 @@ int node_find_indicated_socket(
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ****************** Link Dimming *********************** */
|
||||
|
||||
float node_link_dim_factor(const View2D *v2d, const bNodeLink *link)
|
||||
{
|
||||
const float min_endpoint_distance = std::min(
|
||||
std::max(BLI_rctf_length_x(&v2d->cur, link->fromsock->locx),
|
||||
BLI_rctf_length_y(&v2d->cur, link->fromsock->locy)),
|
||||
std::max(BLI_rctf_length_x(&v2d->cur, link->tosock->locx),
|
||||
BLI_rctf_length_y(&v2d->cur, link->tosock->locy)));
|
||||
|
||||
if (min_endpoint_distance == 0.0f) {
|
||||
return 1.0f;
|
||||
}
|
||||
const float viewport_width = BLI_rctf_size_x(&v2d->cur);
|
||||
return clamp_f(1.0f - min_endpoint_distance / viewport_width * 10.0f, 0.05f, 1.0f);
|
||||
}
|
||||
|
||||
bool node_link_is_hidden_or_dimmed(const View2D *v2d, const bNodeLink *link)
|
||||
{
|
||||
return nodeLinkIsHidden(link) || node_link_dim_factor(v2d, link) < 0.5f;
|
||||
}
|
||||
|
||||
/* ****************** Duplicate *********************** */
|
||||
|
||||
static void node_duplicate_reparent_recursive(bNode *node)
|
||||
|
@@ -268,6 +268,8 @@ int node_find_indicated_socket(struct SpaceNode *snode,
|
||||
struct bNodeSocket **sockp,
|
||||
const float cursor[2],
|
||||
int in_out);
|
||||
float node_link_dim_factor(const struct View2D *v2d, const struct bNodeLink *link);
|
||||
bool node_link_is_hidden_or_dimmed(const struct View2D *v2d, const struct bNodeLink *link);
|
||||
|
||||
void NODE_OT_duplicate(struct wmOperatorType *ot);
|
||||
void NODE_OT_delete(struct wmOperatorType *ot);
|
||||
|
@@ -36,6 +36,7 @@
|
||||
#include "BKE_lib_id.h"
|
||||
#include "BKE_main.h"
|
||||
#include "BKE_node.h"
|
||||
#include "BKE_screen.h"
|
||||
|
||||
#include "ED_node.h" /* own include */
|
||||
#include "ED_render.h"
|
||||
@@ -1332,7 +1333,7 @@ static int cut_links_exec(bContext *C, wmOperator *op)
|
||||
ED_preview_kill_jobs(CTX_wm_manager(C), bmain);
|
||||
|
||||
LISTBASE_FOREACH_MUTABLE (bNodeLink *, link, &snode->edittree->links) {
|
||||
if (nodeLinkIsHidden(link)) {
|
||||
if (node_link_is_hidden_or_dimmed(®ion->v2d, link)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1429,7 +1430,7 @@ static int mute_links_exec(bContext *C, wmOperator *op)
|
||||
/* Count intersected links and clear test flag. */
|
||||
int tot = 0;
|
||||
LISTBASE_FOREACH (bNodeLink *, link, &snode->edittree->links) {
|
||||
if (nodeLinkIsHidden(link)) {
|
||||
if (node_link_is_hidden_or_dimmed(®ion->v2d, link)) {
|
||||
continue;
|
||||
}
|
||||
link->flag &= ~NODE_LINK_TEST;
|
||||
@@ -1443,7 +1444,7 @@ static int mute_links_exec(bContext *C, wmOperator *op)
|
||||
|
||||
/* Mute links. */
|
||||
LISTBASE_FOREACH (bNodeLink *, link, &snode->edittree->links) {
|
||||
if (nodeLinkIsHidden(link) || (link->flag & NODE_LINK_TEST)) {
|
||||
if (node_link_is_hidden_or_dimmed(®ion->v2d, link) || (link->flag & NODE_LINK_TEST)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1458,7 +1459,7 @@ static int mute_links_exec(bContext *C, wmOperator *op)
|
||||
|
||||
/* Clear remaining test flags. */
|
||||
LISTBASE_FOREACH (bNodeLink *, link, &snode->edittree->links) {
|
||||
if (nodeLinkIsHidden(link)) {
|
||||
if (node_link_is_hidden_or_dimmed(®ion->v2d, link)) {
|
||||
continue;
|
||||
}
|
||||
link->flag &= ~NODE_LINK_TEST;
|
||||
@@ -1894,9 +1895,11 @@ static bool ed_node_link_conditions(ScrArea *area,
|
||||
return false;
|
||||
}
|
||||
|
||||
ARegion *region = BKE_area_find_region_type(area, RGN_TYPE_WINDOW);
|
||||
|
||||
/* test node for links */
|
||||
LISTBASE_FOREACH (bNodeLink *, link, &snode->edittree->links) {
|
||||
if (nodeLinkIsHidden(link)) {
|
||||
if (node_link_is_hidden_or_dimmed(®ion->v2d, link)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1927,13 +1930,15 @@ void ED_node_link_intersect_test(ScrArea *area, int test)
|
||||
return;
|
||||
}
|
||||
|
||||
ARegion *region = BKE_area_find_region_type(area, RGN_TYPE_WINDOW);
|
||||
|
||||
/* find link to select/highlight */
|
||||
bNodeLink *selink = nullptr;
|
||||
float dist_best = FLT_MAX;
|
||||
LISTBASE_FOREACH (bNodeLink *, link, &snode->edittree->links) {
|
||||
float coord_array[NODE_LINK_RESOL + 1][2];
|
||||
|
||||
if (nodeLinkIsHidden(link)) {
|
||||
if (node_link_is_hidden_or_dimmed(®ion->v2d, link)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@@ -18,6 +18,7 @@ in vec2 P2;
|
||||
in vec2 P3;
|
||||
in ivec4 colid_doarrow;
|
||||
in ivec2 domuted;
|
||||
in float dim_factor;
|
||||
|
||||
uniform vec4 colors[6];
|
||||
|
||||
@@ -39,6 +40,7 @@ uniform vec2 bezierPts[4];
|
||||
uniform vec4 colors[3];
|
||||
uniform bool doArrow;
|
||||
uniform bool doMuted;
|
||||
uniform float dim_factor;
|
||||
|
||||
# define colShadow colors[0]
|
||||
# define colStart colors[1]
|
||||
@@ -98,6 +100,8 @@ void main(void)
|
||||
}
|
||||
}
|
||||
|
||||
finalColor[3] *= dim_factor;
|
||||
|
||||
/* Expand into a line */
|
||||
gl_Position.xy += exp_axis * expandSize * expand_dist;
|
||||
|
||||
|
Reference in New Issue
Block a user