591 lines
45 KiB
C
591 lines
45 KiB
C
|
|
#include "global.h"
|
|
|
|
ui_node_t_array_t *nodes_brush_category0;
|
|
|
|
void nodes_brush_init() {
|
|
gc_unroot(nodes_brush_creates);
|
|
nodes_brush_creates = any_map_create();
|
|
gc_root(nodes_brush_creates);
|
|
any_map_set(nodes_brush_creates, "brush_output_node", brush_output_node_create);
|
|
// any_map_set(nodes_brush_creates, "tex_image_node", tex_image_node_create);
|
|
any_map_set(nodes_brush_creates, "TEX_IMAGE", tex_image_node_create);
|
|
any_map_set(nodes_brush_creates, "input_node", input_node_create);
|
|
any_map_set(nodes_brush_creates, "math_node", math_node_create);
|
|
any_map_set(nodes_brush_creates, "random_node", random_node_create);
|
|
any_map_set(nodes_brush_creates, "separate_vector_node", separate_vector_node_create);
|
|
any_map_set(nodes_brush_creates, "time_node", time_node_create);
|
|
any_map_set(nodes_brush_creates, "float_node", float_node_create);
|
|
any_map_set(nodes_brush_creates, "vector_node", vector_node_create);
|
|
any_map_set(nodes_brush_creates, "vector_math_node", vector_math_node_create);
|
|
|
|
nodes_brush_list_init();
|
|
}
|
|
|
|
void nodes_brush_list_init() {
|
|
if (nodes_brush_list != NULL) {
|
|
return;
|
|
}
|
|
|
|
ui_node_t *tex_image_node_def =
|
|
GC_ALLOC_INIT(ui_node_t, {.id = 0,
|
|
.name = _tr("Image Texture"),
|
|
// type: "tex_image_node",
|
|
.type = "TEX_IMAGE",
|
|
.x = 0,
|
|
.y = 0,
|
|
.color = 0xff4982a0,
|
|
.inputs = any_array_create_from_raw(
|
|
(void *[]){
|
|
GC_ALLOC_INIT(ui_node_socket_t, {.id = 0,
|
|
.node_id = 0,
|
|
.name = _tr("Vector"),
|
|
.type = "VECTOR",
|
|
.color = 0xff6363c7,
|
|
.default_value = f32_array_create_xyz(0.0, 0.0, 0.0),
|
|
.min = 0.0,
|
|
.max = 1.0,
|
|
.precision = 100,
|
|
.display = 0}),
|
|
},
|
|
1),
|
|
.outputs = any_array_create_from_raw(
|
|
(void *[]){
|
|
GC_ALLOC_INIT(ui_node_socket_t, {.id = 0,
|
|
.node_id = 0,
|
|
.name = _tr("Color"),
|
|
.type = "VALUE", // Match brush output socket type
|
|
.color = 0xffc7c729,
|
|
.default_value = f32_array_create_xyzw(0.0, 0.0, 0.0, 1.0),
|
|
.min = 0.0,
|
|
.max = 1.0,
|
|
.precision = 100,
|
|
.display = 0}),
|
|
GC_ALLOC_INIT(ui_node_socket_t, {.id = 0,
|
|
.node_id = 0,
|
|
.name = _tr("Alpha"),
|
|
.type = "VALUE",
|
|
.color = 0xffa1a1a1,
|
|
.default_value = f32_array_create_x(1.0),
|
|
.min = 0.0,
|
|
.max = 1.0,
|
|
.precision = 100,
|
|
.display = 0}),
|
|
},
|
|
2),
|
|
.buttons = any_array_create_from_raw(
|
|
(void *[]){
|
|
GC_ALLOC_INIT(ui_node_button_t, {.name = _tr("file"),
|
|
.type = "ENUM",
|
|
.output = -1,
|
|
.default_value = f32_array_create_x(0),
|
|
.data = u8_array_create_from_string(""),
|
|
.min = 0.0,
|
|
.max = 1.0,
|
|
.precision = 100,
|
|
.height = 0}),
|
|
GC_ALLOC_INIT(ui_node_button_t, {.name = _tr("color_space"),
|
|
.type = "ENUM",
|
|
.output = -1,
|
|
.default_value = f32_array_create_x(0),
|
|
.data = u8_array_create_from_string("linear\nsrgb"),
|
|
.min = 0.0,
|
|
.max = 1.0,
|
|
.precision = 100,
|
|
.height = 0}),
|
|
},
|
|
2),
|
|
.width = 0,
|
|
.flags = 0});
|
|
|
|
ui_node_t *random_node_def =
|
|
GC_ALLOC_INIT(ui_node_t, {.id = 0,
|
|
.name = _tr("Random"),
|
|
.type = "random_node",
|
|
.x = 0,
|
|
.y = 0,
|
|
.color = 0xffb34f5a,
|
|
.inputs = any_array_create_from_raw(
|
|
(void *[]){
|
|
GC_ALLOC_INIT(ui_node_socket_t, {.id = 0,
|
|
.node_id = 0,
|
|
.name = _tr("Min"),
|
|
.type = "VALUE",
|
|
.color = 0xffa1a1a1,
|
|
.default_value = f32_array_create_x(0.0),
|
|
.min = 0.0,
|
|
.max = 1.0,
|
|
.precision = 100,
|
|
.display = 0}),
|
|
GC_ALLOC_INIT(ui_node_socket_t, {.id = 0,
|
|
.node_id = 0,
|
|
.name = _tr("Max"),
|
|
.type = "VALUE",
|
|
.color = 0xffa1a1a1,
|
|
.default_value = f32_array_create_x(1.0),
|
|
.min = 0.0,
|
|
.max = 1.0,
|
|
.precision = 100,
|
|
.display = 0}),
|
|
},
|
|
2),
|
|
.outputs = any_array_create_from_raw(
|
|
(void *[]){
|
|
GC_ALLOC_INIT(ui_node_socket_t, {.id = 0,
|
|
.node_id = 0,
|
|
.name = _tr("Value"),
|
|
.type = "VALUE",
|
|
.color = 0xffa1a1a1,
|
|
.default_value = f32_array_create_x(0.5),
|
|
.min = 0.0,
|
|
.max = 1.0,
|
|
.precision = 100,
|
|
.display = 0}),
|
|
},
|
|
1),
|
|
.buttons = any_array_create_from_raw((void *[]){}, 0),
|
|
.width = 0,
|
|
.flags = 0});
|
|
|
|
ui_node_t *input_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0,
|
|
.name = _tr("Input"),
|
|
.type = "input_node",
|
|
.x = 0,
|
|
.y = 0,
|
|
.color = 0xff4982a0,
|
|
.inputs = any_array_create_from_raw(
|
|
(void *[]){
|
|
GC_ALLOC_INIT(ui_node_socket_t, {.id = 0,
|
|
.node_id = 0,
|
|
.name = _tr("Lazy Radius"),
|
|
.type = "VALUE",
|
|
.color = 0xffa1a1a1,
|
|
.default_value = f32_array_create_x(0.0),
|
|
.min = 0.0,
|
|
.max = 1.0,
|
|
.precision = 100,
|
|
.display = 0}),
|
|
GC_ALLOC_INIT(ui_node_socket_t, {.id = 0,
|
|
.node_id = 0,
|
|
.name = _tr("Lazy Step"),
|
|
.type = "VALUE",
|
|
.color = 0xffa1a1a1,
|
|
.default_value = f32_array_create_x(0.0),
|
|
.min = 0.0,
|
|
.max = 1.0,
|
|
.precision = 100,
|
|
.display = 0}),
|
|
},
|
|
2),
|
|
.outputs = any_array_create_from_raw(
|
|
(void *[]){
|
|
GC_ALLOC_INIT(ui_node_socket_t, {.id = 0,
|
|
.node_id = 0,
|
|
.name = _tr("Position"),
|
|
.type = "VECTOR",
|
|
.color = 0xff63c763,
|
|
.default_value = f32_array_create_xyz(0.0, 0.0, 0.0),
|
|
.min = 0.0,
|
|
.max = 1.0,
|
|
.precision = 100,
|
|
.display = 0}),
|
|
},
|
|
1),
|
|
.buttons = any_array_create_from_raw((void *[]){}, 0),
|
|
.width = 0,
|
|
.flags = 0});
|
|
|
|
ui_node_t *math_node_def =
|
|
GC_ALLOC_INIT(ui_node_t, {.id = 0,
|
|
.name = _tr("Math"),
|
|
.type = "math_node",
|
|
.x = 0,
|
|
.y = 0,
|
|
.color = 0xff4982a0,
|
|
.inputs = any_array_create_from_raw(
|
|
(void *[]){
|
|
GC_ALLOC_INIT(ui_node_socket_t, {.id = 0,
|
|
.node_id = 0,
|
|
.name = _tr("Value"),
|
|
.type = "VALUE",
|
|
.color = 0xffa1a1a1,
|
|
.default_value = f32_array_create_x(0.5),
|
|
.min = 0.0,
|
|
.max = 1.0,
|
|
.precision = 100,
|
|
.display = 0}),
|
|
GC_ALLOC_INIT(ui_node_socket_t, {.id = 0,
|
|
.node_id = 0,
|
|
.name = _tr("Value"),
|
|
.type = "VALUE",
|
|
.color = 0xffa1a1a1,
|
|
.default_value = f32_array_create_x(0.5),
|
|
.min = 0.0,
|
|
.max = 1.0,
|
|
.precision = 100,
|
|
.display = 0}),
|
|
},
|
|
2),
|
|
.outputs = any_array_create_from_raw(
|
|
(void *[]){
|
|
GC_ALLOC_INIT(ui_node_socket_t, {.id = 0,
|
|
.node_id = 0,
|
|
.name = _tr("Value"),
|
|
.type = "VALUE",
|
|
.color = 0xffa1a1a1,
|
|
.default_value = f32_array_create_x(0.0),
|
|
.min = 0.0,
|
|
.max = 1.0,
|
|
.precision = 100,
|
|
.display = 0}),
|
|
},
|
|
1),
|
|
.buttons = any_array_create_from_raw(
|
|
(void *[]){
|
|
GC_ALLOC_INIT(ui_node_button_t, {.name = _tr("operation"),
|
|
.type = "ENUM",
|
|
.output = 0,
|
|
.default_value = f32_array_create_x(0),
|
|
.data = u8_array_create_from_string(
|
|
"Add\nSubtract\nMultiply\nDivide\nPower\nLogarithm\nSquare Root\nInverse "
|
|
"Square Root\nAbsolute\nExponent\nMinimum\nMaximum\nLess Than\nGreater "
|
|
"Than\nSign\nRound\nFloor\nCeil\nTruncate\nFraction\nModulo\nSnap\nPing-"
|
|
"Pong\nSine\nCosine\nTangent\nArcsine\nArccosine\nArctangent\nArctan2\nHyperb"
|
|
"olic Sine\nHyperbolic Cosine\nHyperbolic Tangent\nTo Radians\nTo Degrees"),
|
|
.min = 0.0,
|
|
.max = 1.0,
|
|
.precision = 100,
|
|
.height = 0}),
|
|
GC_ALLOC_INIT(ui_node_button_t, {.name = _tr("Clamp"),
|
|
.type = "BOOL",
|
|
.output = 0,
|
|
.default_value = f32_array_create_x(0),
|
|
.data = NULL,
|
|
.min = 0.0,
|
|
.max = 1.0,
|
|
.precision = 100,
|
|
.height = 0}),
|
|
},
|
|
2),
|
|
.width = 0,
|
|
.flags = 0});
|
|
|
|
ui_node_t *vector_node_def =
|
|
GC_ALLOC_INIT(ui_node_t, {.id = 0,
|
|
.name = _tr("Vector"),
|
|
.type = "vector_node",
|
|
.x = 0,
|
|
.y = 0,
|
|
.color = 0xff4982a0,
|
|
.inputs = any_array_create_from_raw(
|
|
(void *[]){
|
|
GC_ALLOC_INIT(ui_node_socket_t, {.id = 0,
|
|
.node_id = 0,
|
|
.name = _tr("X"),
|
|
.type = "VALUE",
|
|
.color = 0xffa1a1a1,
|
|
.default_value = f32_array_create_x(0.0),
|
|
.min = 0.0,
|
|
.max = 1.0,
|
|
.precision = 100,
|
|
.display = 0}),
|
|
GC_ALLOC_INIT(ui_node_socket_t, {.id = 0,
|
|
.node_id = 0,
|
|
.name = _tr("Y"),
|
|
.type = "VALUE",
|
|
.color = 0xffa1a1a1,
|
|
.default_value = f32_array_create_x(0.0),
|
|
.min = 0.0,
|
|
.max = 1.0,
|
|
.precision = 100,
|
|
.display = 0}),
|
|
GC_ALLOC_INIT(ui_node_socket_t, {.id = 0,
|
|
.node_id = 0,
|
|
.name = _tr("Z"),
|
|
.type = "VALUE",
|
|
.color = 0xffa1a1a1,
|
|
.default_value = f32_array_create_x(0.0),
|
|
.min = 0.0,
|
|
.max = 1.0,
|
|
.precision = 100,
|
|
.display = 0}),
|
|
},
|
|
3),
|
|
.outputs = any_array_create_from_raw(
|
|
(void *[]){
|
|
GC_ALLOC_INIT(ui_node_socket_t, {.id = 0,
|
|
.node_id = 0,
|
|
.name = _tr("Vector"),
|
|
.type = "VECTOR",
|
|
.color = 0xff6363c7,
|
|
.default_value = f32_array_create_xyz(0.0, 0.0, 0.0),
|
|
.min = 0.0,
|
|
.max = 1.0,
|
|
.precision = 100,
|
|
.display = 0}),
|
|
},
|
|
1),
|
|
.buttons = any_array_create_from_raw((void *[]){}, 0),
|
|
.width = 0,
|
|
.flags = 0});
|
|
|
|
ui_node_t *time_node_def =
|
|
GC_ALLOC_INIT(ui_node_t, {.id = 0,
|
|
.name = _tr("Time"),
|
|
.type = "time_node",
|
|
.x = 0,
|
|
.y = 0,
|
|
.color = 0xff4982a0,
|
|
.inputs = any_array_create_from_raw((void *[]){}, 0),
|
|
.outputs = any_array_create_from_raw(
|
|
(void *[]){
|
|
GC_ALLOC_INIT(ui_node_socket_t, {.id = 0,
|
|
.node_id = 0,
|
|
.name = _tr("Time"),
|
|
.type = "VALUE",
|
|
.color = 0xffa1a1a1,
|
|
.default_value = f32_array_create_x(0.0),
|
|
.min = 0.0,
|
|
.max = 1.0,
|
|
.precision = 100,
|
|
.display = 0}),
|
|
GC_ALLOC_INIT(ui_node_socket_t, {.id = 0,
|
|
.node_id = 0,
|
|
.name = _tr("Delta"),
|
|
.type = "VALUE",
|
|
.color = 0xffa1a1a1,
|
|
.default_value = f32_array_create_x(0.0),
|
|
.min = 0.0,
|
|
.max = 1.0,
|
|
.precision = 100,
|
|
.display = 0}),
|
|
GC_ALLOC_INIT(ui_node_socket_t, {.id = 0,
|
|
.node_id = 0,
|
|
.name = _tr("Brush"),
|
|
.type = "VALUE",
|
|
.color = 0xffa1a1a1,
|
|
.default_value = f32_array_create_x(0.0),
|
|
.min = 0.0,
|
|
.max = 1.0,
|
|
.precision = 100,
|
|
.display = 0}),
|
|
},
|
|
3),
|
|
.buttons = any_array_create_from_raw((void *[]){}, 0),
|
|
.width = 0,
|
|
.flags = 0});
|
|
|
|
ui_node_t *vector_math_node_def =
|
|
GC_ALLOC_INIT(ui_node_t, {.id = 0,
|
|
.name = _tr("Vector Math"),
|
|
.type = "vector_math_node",
|
|
.x = 0,
|
|
.y = 0,
|
|
.color = 0xff4982a0,
|
|
.inputs = any_array_create_from_raw(
|
|
(void *[]){
|
|
GC_ALLOC_INIT(ui_node_socket_t, {.id = 0,
|
|
.node_id = 0,
|
|
.name = _tr("Vector"),
|
|
.type = "VECTOR",
|
|
.color = 0xff6363c7,
|
|
.default_value = f32_array_create_xyz(0.0, 0.0, 0.0),
|
|
.min = 0.0,
|
|
.max = 1.0,
|
|
.precision = 100,
|
|
.display = 0}),
|
|
GC_ALLOC_INIT(ui_node_socket_t, {.id = 0,
|
|
.node_id = 0,
|
|
.name = _tr("Vector"),
|
|
.type = "VECTOR",
|
|
.color = 0xff6363c7,
|
|
.default_value = f32_array_create_xyz(0.0, 0.0, 0.0),
|
|
.min = 0.0,
|
|
.max = 1.0,
|
|
.precision = 100,
|
|
.display = 0}),
|
|
},
|
|
2),
|
|
.outputs = any_array_create_from_raw(
|
|
(void *[]){
|
|
GC_ALLOC_INIT(ui_node_socket_t, {.id = 0,
|
|
.node_id = 0,
|
|
.name = _tr("Vector"),
|
|
.type = "VECTOR",
|
|
.color = 0xff6363c7,
|
|
.default_value = f32_array_create_xyz(0.0, 0.0, 0.0),
|
|
.min = 0.0,
|
|
.max = 1.0,
|
|
.precision = 100,
|
|
.display = 0}),
|
|
GC_ALLOC_INIT(ui_node_socket_t, {.id = 0,
|
|
.node_id = 0,
|
|
.name = _tr("Value"),
|
|
.type = "VALUE",
|
|
.color = 0xffa1a1a1,
|
|
.default_value = f32_array_create_x(0.0),
|
|
.min = 0.0,
|
|
.max = 1.0,
|
|
.precision = 100,
|
|
.display = 0}),
|
|
},
|
|
2),
|
|
.buttons = any_array_create_from_raw(
|
|
(void *[]){
|
|
GC_ALLOC_INIT(ui_node_button_t, {.name = _tr("operation"),
|
|
.type = "ENUM",
|
|
.output = 0,
|
|
.default_value = f32_array_create_x(0),
|
|
.data = u8_array_create_from_string(
|
|
"Add\nSubtract\nMultiply\nDivide\nAverage\nCross Product\nProject\nReflect\nDot "
|
|
"Product\nDistance\nLength\nScale\nNormalize\nAbsolute\nMinimum\nMaximum\nFloor"
|
|
"\nCeil\nFraction\nModulo\nSnap\nSine\nCosine\nTangent"),
|
|
.min = 0.0,
|
|
.max = 1.0,
|
|
.precision = 100,
|
|
.height = 0}),
|
|
},
|
|
1),
|
|
.width = 0,
|
|
.flags = 0});
|
|
|
|
ui_node_t *float_node_def =
|
|
GC_ALLOC_INIT(ui_node_t, {.id = 0,
|
|
.name = _tr("Value"),
|
|
.type = "float_node",
|
|
.x = 0,
|
|
.y = 0,
|
|
.color = 0xffb34f5a,
|
|
.inputs = any_array_create_from_raw(
|
|
(void *[]){
|
|
GC_ALLOC_INIT(ui_node_socket_t, {.id = 0,
|
|
.node_id = 0,
|
|
.name = _tr("Value"),
|
|
.type = "VALUE",
|
|
.color = 0xffa1a1a1,
|
|
.default_value = f32_array_create_x(0.5),
|
|
.min = 0.0,
|
|
.max = 10.0,
|
|
.precision = 100,
|
|
.display = 0}),
|
|
},
|
|
1),
|
|
.outputs = any_array_create_from_raw(
|
|
(void *[]){
|
|
GC_ALLOC_INIT(ui_node_socket_t, {.id = 0,
|
|
.node_id = 0,
|
|
.name = _tr("Value"),
|
|
.type = "VALUE",
|
|
.color = 0xffa1a1a1,
|
|
.default_value = f32_array_create_x(0.5),
|
|
.min = 0.0,
|
|
.max = 1.0,
|
|
.precision = 100,
|
|
.display = 0}),
|
|
},
|
|
1),
|
|
.buttons = any_array_create_from_raw((void *[]){}, 0),
|
|
.width = 0,
|
|
.flags = 0});
|
|
|
|
ui_node_t *separate_vector_node_def =
|
|
GC_ALLOC_INIT(ui_node_t, {.id = 0,
|
|
.name = _tr("Separate Vector"),
|
|
.type = "separate_vector_node",
|
|
.x = 0,
|
|
.y = 0,
|
|
.color = 0xff4982a0,
|
|
.inputs = any_array_create_from_raw(
|
|
(void *[]){
|
|
GC_ALLOC_INIT(ui_node_socket_t, {.id = 0,
|
|
.node_id = 0,
|
|
.name = _tr("Vector"),
|
|
.type = "VECTOR",
|
|
.color = 0xff6363c7,
|
|
.default_value = f32_array_create_xyz(0.0, 0.0, 0.0),
|
|
.min = 0.0,
|
|
.max = 1.0,
|
|
.precision = 100,
|
|
.display = 0}),
|
|
},
|
|
1),
|
|
.outputs = any_array_create_from_raw(
|
|
(void *[]){
|
|
GC_ALLOC_INIT(ui_node_socket_t, {.id = 0,
|
|
.node_id = 0,
|
|
.name = _tr("X"),
|
|
.type = "VALUE",
|
|
.color = 0xffa1a1a1,
|
|
.default_value = f32_array_create_x(0.0),
|
|
.min = 0.0,
|
|
.max = 1.0,
|
|
.precision = 100,
|
|
.display = 0}),
|
|
GC_ALLOC_INIT(ui_node_socket_t, {.id = 0,
|
|
.node_id = 0,
|
|
.name = _tr("Y"),
|
|
.type = "VALUE",
|
|
.color = 0xffa1a1a1,
|
|
.default_value = f32_array_create_x(0.0),
|
|
.min = 0.0,
|
|
.max = 1.0,
|
|
.precision = 100,
|
|
.display = 0}),
|
|
GC_ALLOC_INIT(ui_node_socket_t, {.id = 0,
|
|
.node_id = 0,
|
|
.name = _tr("Z"),
|
|
.type = "VALUE",
|
|
.color = 0xffa1a1a1,
|
|
.default_value = f32_array_create_x(0.0),
|
|
.min = 0.0,
|
|
.max = 1.0,
|
|
.precision = 100,
|
|
.display = 0}),
|
|
},
|
|
3),
|
|
.buttons = any_array_create_from_raw((void *[]){}, 0),
|
|
.width = 0,
|
|
.flags = 0});
|
|
|
|
gc_unroot(nodes_brush_category0);
|
|
nodes_brush_category0 = any_array_create_from_raw(
|
|
(void *[]){
|
|
tex_image_node_def,
|
|
input_node_def,
|
|
math_node_def,
|
|
random_node_def,
|
|
separate_vector_node_def,
|
|
time_node_def,
|
|
float_node_def,
|
|
vector_node_def,
|
|
vector_math_node_def,
|
|
},
|
|
9);
|
|
gc_root(nodes_brush_category0);
|
|
|
|
gc_unroot(nodes_brush_list);
|
|
nodes_brush_list = any_array_create_from_raw(
|
|
(void *[]){
|
|
nodes_brush_category0,
|
|
},
|
|
1);
|
|
gc_root(nodes_brush_list);
|
|
}
|
|
|
|
ui_node_t *nodes_brush_create_node(char *node_type) {
|
|
for (i32 i = 0; i < nodes_brush_list->length; ++i) {
|
|
ui_node_t_array_t *c = nodes_brush_list->buffer[i];
|
|
for (i32 i = 0; i < c->length; ++i) {
|
|
ui_node_t *n = c->buffer[i];
|
|
if (string_equals(n->type, node_type)) {
|
|
ui_node_canvas_t *canvas = g_context->brush->canvas;
|
|
ui_nodes_t *nodes = g_context->brush->nodes;
|
|
ui_node_t *node = ui_nodes_make_node(n, nodes, canvas);
|
|
any_array_push(canvas->nodes, node);
|
|
return node;
|
|
}
|
|
}
|
|
}
|
|
return NULL;
|
|
}
|