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