Files
armorpaint/paint/sources/logic_node.c
T

58 lines
1.6 KiB
C
Raw Normal View History

2026-03-09 13:17:15 +01:00
#include "global.h"
2026-03-06 12:56:38 +01:00
logic_node_t *logic_node_create(logic_node_ext_t *ext) {
2026-08-21 22:35:41 +02:00
logic_node_t *n = ALLOC_INIT(logic_node_t, {0});
2026-03-08 08:39:29 +01:00
n->inputs = any_array_create_from_raw((void *[]){}, 0);
n->outputs = any_array_create_from_raw((void *[]){}, 0);
2026-03-06 12:56:38 +01:00
n->ext = ext;
return n;
}
2026-04-04 21:38:20 +02:00
logic_node_input_t *logic_node_input_create(logic_node_ext_t *node, i32 from) {
2026-08-21 22:35:41 +02:00
logic_node_input_t *inp = ALLOC_INIT(logic_node_input_t, {0});
2026-04-04 21:38:20 +02:00
inp->node = node;
inp->from = from;
return inp;
}
2026-03-06 12:56:38 +01:00
void logic_node_add_input(logic_node_t *self, logic_node_ext_t *node, i32 from) {
any_array_push(self->inputs, logic_node_input_create(node, from));
}
void logic_node_add_outputs(logic_node_t *self, logic_node_t_array_t *nodes) {
any_array_push(self->outputs, nodes);
}
2026-04-21 10:52:27 +02:00
void *logic_node_get(logic_node_t *self, i32 from) {
2026-03-07 21:12:59 +01:00
if (self->get != NULL) {
2026-03-06 12:56:38 +01:00
return self->get(self->ext, from);
}
2026-03-07 21:12:59 +01:00
return NULL;
2026-03-06 12:56:38 +01:00
}
gpu_texture_t *logic_node_get_as_image(logic_node_t *self, i32 from) {
2026-03-07 21:12:59 +01:00
if (self->get_as_image != NULL) {
2026-03-06 12:56:38 +01:00
return self->get_as_image(self->ext, from);
}
2026-03-07 21:12:59 +01:00
return NULL;
2026-03-06 12:56:38 +01:00
}
2026-04-21 10:52:27 +02:00
void logic_node_set(logic_node_t *self, void *value) {
2026-03-07 21:12:59 +01:00
if (self->set != NULL) {
2026-03-06 12:56:38 +01:00
self->set(self->ext, value);
}
}
logic_node_value_t *logic_node_input_get(logic_node_input_t *self) {
return logic_node_get(self->node->base, self->from);
}
gpu_texture_t *logic_node_input_get_as_image(logic_node_input_t *self) {
return logic_node_get_as_image(self->node->base, self->from);
}
void logic_node_input_set(logic_node_input_t *self, f32_array_t *value) {
logic_node_set(self->node->base, value);
}