Move noodle correctly when the node it's connected to moves
This commit is contained in:
parent
8078a72deb
commit
f03dad33a2
@ -8,6 +8,7 @@
|
||||
#define IO_INPUT_COUNT 0
|
||||
#define OP_INPUT_COUNT 2
|
||||
#define EMPTY_NODE 0
|
||||
#define NODE_START 1
|
||||
|
||||
typedef i32 (*node_func)(i32 a, i32 b);
|
||||
typedef enum node_type node_type;
|
||||
|
@ -153,7 +153,7 @@ i32 run_main_loop(void) {
|
||||
}
|
||||
}
|
||||
|
||||
for (u64 i = 0; i < comp.count; ++i) {
|
||||
for (u64 i = NODE_START; i <= comp.count; ++i) {
|
||||
node *node_elem = &(comp.nodes[i]);
|
||||
|
||||
f64 angle = 90.0;
|
||||
@ -178,7 +178,7 @@ i32 run_main_loop(void) {
|
||||
ndl->ln.p0.y += comp.ctx.rel_y;
|
||||
break;
|
||||
case NOODLE_ACTION_RELEASED:
|
||||
for (u64 k = 0; k < comp.count; ++k) {
|
||||
for (u64 k = NODE_START; k <= comp.count; ++k) {
|
||||
if (k == i) {
|
||||
continue;
|
||||
}
|
||||
@ -228,6 +228,25 @@ i32 run_main_loop(void) {
|
||||
ndl->ln.p1.x += comp.ctx.rel_x;
|
||||
ndl->ln.p1.y += comp.ctx.rel_y;
|
||||
}
|
||||
|
||||
for (u64 j = NODE_START; j <= comp.count; ++j) {
|
||||
if (j == i) {
|
||||
continue;
|
||||
}
|
||||
|
||||
node *nd = &(comp.nodes[j]);
|
||||
if (nd->inputs == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (u64 k = 0; k < nd->inputs; ++k) {
|
||||
noodle *ndl = &(nd->noodles[k]);
|
||||
if (ndl->connected_node == i) {
|
||||
ndl->ln.p0.x += comp.ctx.rel_x;
|
||||
ndl->ln.p0.y += comp.ctx.rel_y;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user