From 3c11f14e0593a618fe312b7627fcc338902b5942 Mon Sep 17 00:00:00 2001 From: luboslenco Date: Sun, 5 Apr 2026 16:09:00 +0200 Subject: [PATCH] paint: cleanup --- base/tools/pad/main.c | 6 - paint/sources/args.c | 13 + paint/sources/base.c | 28 + paint/sources/box_export.c | 11 +- paint/sources/box_preferences.c | 46 +- paint/sources/box_projects.c | 7 +- paint/sources/brush_nodes/input_node.c | 16 +- paint/sources/brush_nodes/random_node.c | 5 + paint/sources/camera.c | 4 + paint/sources/compass.c | 56 +- paint/sources/config.c | 13 +- paint/sources/console.c | 2 + paint/sources/enums.h | 47 -- paint/sources/export_exr.c | 12 +- paint/sources/export_player.c | 7 + paint/sources/export_texture.c | 8 +- paint/sources/functions.h | 1 - paint/sources/globals.h | 752 +++++------------- paint/sources/import_arm.c | 2 + paint/sources/import_asset.c | 12 +- paint/sources/import_blend_material.c | 2 + paint/sources/import_envmap.c | 27 +- paint/sources/import_mesh.c | 3 + paint/sources/import_texture.c | 5 + paint/sources/kickstart.c | 527 ------------ paint/sources/make_material.c | 3 + paint/sources/material_nodes/attribute_node.c | 134 ++-- paint/sources/material_nodes/blur_node.c | 95 ++- .../material_nodes/brick_texture_node.c | 3 +- .../material_nodes/brightness_contrast_node.c | 3 +- paint/sources/material_nodes/bump_node.c | 149 ++-- .../material_nodes/camera_texture_node.c | 50 +- .../material_nodes/checker_texture_node.c | 5 +- paint/sources/material_nodes/clamp_node.c | 142 ++-- .../sources/material_nodes/color_mask_node.c | 3 +- .../sources/material_nodes/color_ramp_node.c | 3 +- .../material_nodes/combine_color_node.c | 3 +- .../sources/material_nodes/combine_xyz_node.c | 116 ++- .../material_nodes/curvature_bake_node.c | 3 +- .../sources/material_nodes/float_curve_node.c | 3 +- .../material_nodes/gabor_texture_node.c | 5 +- paint/sources/material_nodes/gamma_node.c | 95 ++- paint/sources/material_nodes/geometry_node.c | 149 ++-- .../material_nodes/gradient_texture_node.c | 122 +-- paint/sources/material_nodes/group_node.c | 51 +- .../hue_saturation_value_node.c | 3 +- .../material_nodes/image_texture_node.c | 7 +- .../material_nodes/invert_color_node.c | 3 +- .../sources/material_nodes/layer_mask_node.c | 74 +- paint/sources/material_nodes/layer_node.c | 234 +++--- .../material_nodes/magic_texture_node.c | 23 +- paint/sources/material_nodes/map_range_node.c | 180 ++--- paint/sources/material_nodes/mapping_node.c | 3 +- paint/sources/material_nodes/material_node.c | 238 +++--- paint/sources/material_nodes/math2_node.c | 138 ++-- paint/sources/material_nodes/mix_color_node.c | 186 ++--- .../material_nodes/mix_normal_map_node.c | 5 +- .../material_nodes/noise_texture_node.c | 11 +- .../sources/material_nodes/normal_map_node.c | 96 +-- paint/sources/material_nodes/normal_node.c | 120 +-- .../sources/material_nodes/object_info_node.c | 110 ++- paint/sources/material_nodes/picker_node.c | 209 +++-- paint/sources/material_nodes/quantize_node.c | 96 +-- .../material_nodes/replace_color_node.c | 3 +- .../sources/material_nodes/rgb_curves_node.c | 120 +-- paint/sources/material_nodes/rgb_node.c | 74 +- paint/sources/material_nodes/rgb_to_bw_node.c | 76 +- paint/sources/material_nodes/script_node.c | 91 ++- .../material_nodes/separate_color_node.c | 3 +- .../material_nodes/separate_xyz_node.c | 116 ++- paint/sources/material_nodes/shader_node.c | 75 +- .../material_nodes/text_texture_node.c | 3 +- .../material_nodes/texture_coordinate_node.c | 3 +- paint/sources/material_nodes/uv_map_node.c | 75 +- paint/sources/material_nodes/value_node.c | 74 +- .../material_nodes/vector_curves_node.c | 120 +-- .../material_nodes/vector_math2_node.c | 11 +- .../material_nodes/vector_rotate_node.c | 3 +- .../material_nodes/vector_transform_node.c | 3 +- .../material_nodes/voronoi_texture_node.c | 7 +- paint/sources/material_nodes/warp_node.c | 115 ++- .../material_nodes/wave_texture_node.c | 3 +- paint/sources/material_nodes/wireframe_node.c | 100 +-- paint/sources/neural_nodes/edit_image_node.c | 100 +-- .../neural_nodes/image_to_3d_mesh_node.c | 7 +- .../neural_nodes/image_to_depth_node.c | 5 +- .../neural_nodes/image_to_normal_map_node.c | 5 +- .../sources/neural_nodes/image_to_pbr_node.c | 14 +- .../sources/neural_nodes/inpaint_image_node.c | 122 +-- .../neural_nodes/outpaint_image_node.c | 5 +- .../sources/neural_nodes/text_to_image_node.c | 98 +-- paint/sources/neural_nodes/tile_image_node.c | 102 +-- .../sources/neural_nodes/upscale_image_node.c | 102 +-- paint/sources/neural_nodes/vary_image_node.c | 102 +-- paint/sources/nodes_brush.c | 522 ++++++++++++ paint/sources/parser_logic.c | 5 + paint/sources/parser_material.c | 11 +- paint/sources/physics_sim.c | 3 + paint/sources/plugin.c | 4 +- paint/sources/project.c | 26 +- paint/sources/render_path_base.c | 15 +- paint/sources/render_path_paint.c | 17 + paint/sources/render_path_raytrace.c | 5 + paint/sources/render_path_raytrace_bake.c | 6 + paint/sources/slot_brush.c | 2 + paint/sources/slot_layer.c | 14 + paint/sources/slot_material.c | 2 + paint/sources/tab_browser.c | 5 + paint/sources/tab_brushes.c | 10 +- paint/sources/tab_fonts.c | 8 +- paint/sources/tab_layers.c | 21 +- paint/sources/tab_materials.c | 2 + paint/sources/tab_meshes.c | 6 +- paint/sources/tab_scene.c | 2 + paint/sources/tab_scripts.c | 2 + paint/sources/tab_swatches.c | 10 +- paint/sources/tab_textures.c | 10 +- paint/sources/translator.c | 11 +- paint/sources/types.h | 93 +-- paint/sources/ui_box.c | 39 +- paint/sources/ui_files.c | 76 +- paint/sources/ui_header.c | 22 +- paint/sources/ui_menu.c | 6 + paint/sources/ui_menubar.c | 33 +- paint/sources/ui_nodes.c | 54 +- paint/sources/ui_sidebar.c | 3 + paint/sources/ui_statusbar.c | 2 + paint/sources/ui_toolbar.c | 3 + paint/sources/ui_view2d.c | 21 +- paint/sources/util_mesh.c | 6 +- paint/sources/util_render.c | 3 + paint/sources/util_uv.c | 13 +- 132 files changed, 3577 insertions(+), 3738 deletions(-) diff --git a/base/tools/pad/main.c b/base/tools/pad/main.c index acc2fc24..f565b374 100644 --- a/base/tools/pad/main.c +++ b/base/tools/pad/main.c @@ -17,12 +17,6 @@ typedef struct config { char *server; } config_t; -typedef struct ui_coloring_t_array { - ui_coloring_t **buffer; - int length; - int capacity; -} ui_coloring_t_array_t; - extern any_map_t *ui_children; ui_t *ui_create(ui_options_t *ops); diff --git a/paint/sources/args.c b/paint/sources/args.c index 5dfc6a30..8e20553f 100644 --- a/paint/sources/args.c +++ b/paint/sources/args.c @@ -1,6 +1,19 @@ #include "global.h" +bool args_use = false; +char *args_asset_path = ""; +bool args_background = false; +bool args_export_textures = false; +char *args_export_textures_type = ""; +char *args_export_textures_preset = ""; +char *args_export_textures_path = ""; +bool args_reimport_mesh = false; +bool args_export_mesh = false; +char *args_export_mesh_path = ""; +bool args_export_material = false; +char *args_export_material_path = ""; + void args_parse() { if (iron_get_arg_count() > 1) { args_use = true; diff --git a/paint/sources/base.c b/paint/sources/base.c index bda63fc3..cbd919f5 100644 --- a/paint/sources/base.c +++ b/paint/sources/base.c @@ -1,6 +1,34 @@ #include "global.h" +typedef enum { + BORDER_SIDE_LEFT = 0, + BORDER_SIDE_RIGHT = 1, + BORDER_SIDE_TOP = 2, + BORDER_SIDE_BOTTOm = 3, +} border_side_t; + +i32 base_drag_tint = 0xffffffff; +i32 base_drag_size = -1; +rect_t *base_drag_rect = NULL; +f32 base_drag_start = 0.0; +f32 base_drop_x = 0.0; +f32 base_drop_y = 0.0; +gpu_texture_t *base_color_wheel; +gpu_texture_t *base_color_wheel_gradient; +i32 base_appx = 0; +i32 base_appy = 0; +i32 base_last_window_width = 0; +i32 base_last_window_height = 0; +i32 _base_material_count; +i32 ui_base_border_started = 0; +ui_handle_t *ui_base_border_handle = NULL; +char *ui_base_action_paint_remap = ""; +i32 ui_base_operator_search_offset = 0; +f32 ui_base_undo_tap_time = 0.0; +f32 ui_base_redo_tap_time = 0.0; +bool _ui_base_operator_search_first; + void base_on_shutdown() { #if defined(IRON_ANDROID) || defined(IRON_IOS) project_save(false); diff --git a/paint/sources/box_export.c b/paint/sources/box_export.c index 733b4a6b..d1552e24 100644 --- a/paint/sources/box_export.c +++ b/paint/sources/box_export.c @@ -1,6 +1,11 @@ #include "global.h" +bool _box_export_bake_material; +export_preset_texture_t *_box_export_t; +bool _box_export_apply_displacement; +bool _box_export_merge_vertices; + void box_export_tab_export_textures_run(void *_) { export_texture_run(context_raw->texture_export_path, _box_export_bake_material); } @@ -113,9 +118,9 @@ void box_export_tab_export_textures(char *title, bool bake_material) { ui->enabled = true; ui_row2(); - ui->enabled = !bake_material; - ui_handle_t *layers_export_handle = ui_handle(__ID__); - layers_export_handle->i = context_raw->layers_export; + ui->enabled = !bake_material; + ui_handle_t *layers_export_handle = ui_handle(__ID__); + layers_export_handle->i = context_raw->layers_export; string_array_t *layers_export_combo = any_array_create_from_raw( (void *[]){ tr("Visible"), diff --git a/paint/sources/box_preferences.c b/paint/sources/box_preferences.c index 6395a0e8..285374ca 100644 --- a/paint/sources/box_preferences.c +++ b/paint/sources/box_preferences.c @@ -1,6 +1,13 @@ #include "global.h" +string_array_t *box_preferences_files_keymap = NULL; +string_array_t *box_preferences_locales = NULL; +string_array_t *box_preferences_themes = NULL; +char *_box_preferences_f; +ui_handle_t *_box_preferences_h; +i32 _box_preferences_i; + void box_preferences_interface_tab_reset_layout_menu() { if (ui_menu_button(tr("Confirm"), "", ICON_CHECK)) { config_init_layout(); @@ -320,7 +327,7 @@ void box_preferences_theme_tab() { } if (ui->changed) { ui->elements_baked = false; - ui->font_size = ui->ops->theme->FONT_SIZE; + ui->font_size = ui->ops->theme->FONT_SIZE; } } ui->input_enabled = true; @@ -452,8 +459,8 @@ void box_preferences_usage_tab() { } void box_preferences_camera_tab() { - ui_handle_t *h_camera_pivot = ui_handle(__ID__); - h_camera_pivot->i = config_raw->camera_pivot; + ui_handle_t *h_camera_pivot = ui_handle(__ID__); + h_camera_pivot->i = config_raw->camera_pivot; string_array_t *camera_pivot_combo = any_array_create_from_raw( (void *[]){ tr("Cursor"), @@ -462,8 +469,8 @@ void box_preferences_camera_tab() { 2); config_raw->camera_pivot = ui_combo(h_camera_pivot, camera_pivot_combo, tr("Default Camera Pivot"), true, UI_ALIGN_LEFT, true); - ui_handle_t *h_camera_controls = ui_handle(__ID__); - h_camera_controls->i = config_raw->camera_controls; + ui_handle_t *h_camera_controls = ui_handle(__ID__); + h_camera_controls->i = config_raw->camera_controls; string_array_t *camera_controls_combo = any_array_create_from_raw( (void *[]){ tr("Orbit"), @@ -489,8 +496,8 @@ void box_preferences_camera_tab() { h_speed->f = config_raw->camera_pan_speed; config_raw->camera_pan_speed = ui_slider(h_speed, tr("Camera Pan Speed"), 0.1, 4.0, true, 100.0, true, UI_ALIGN_RIGHT, true); - ui_handle_t *h_zoom_direction = ui_handle(__ID__); - h_zoom_direction->i = config_raw->zoom_direction; + ui_handle_t *h_zoom_direction = ui_handle(__ID__); + h_zoom_direction->i = config_raw->zoom_direction; string_array_t *zoom_direction_combo = any_array_create_from_raw( (void *[]){ tr("Vertical"), @@ -543,8 +550,8 @@ void box_preferences_pen_tab() { } void box_preferences_viewport_tab() { - ui_handle_t *h_mode = ui_handle(__ID__); - h_mode->i = config_raw->viewport_mode; + ui_handle_t *h_mode = ui_handle(__ID__); + h_mode->i = config_raw->viewport_mode; string_array_t *mode_combo = any_array_create_from_raw( (void *[]){ tr("Lit"), @@ -556,8 +563,8 @@ void box_preferences_viewport_tab() { config_raw->viewport_mode = h_mode->i; } - ui_handle_t *h_pathtrace_mode = ui_handle(__ID__); - h_pathtrace_mode->i = config_raw->pathtrace_mode; + ui_handle_t *h_pathtrace_mode = ui_handle(__ID__); + h_pathtrace_mode->i = config_raw->pathtrace_mode; string_array_t *pathtrace_mode_combo = any_array_create_from_raw( (void *[]){ tr("Fast"), @@ -571,8 +578,8 @@ void box_preferences_viewport_tab() { context_raw->ddirty = 2; } - ui_handle_t *h_render_mode = ui_handle(__ID__); - h_render_mode->i = config_raw->render_mode; + ui_handle_t *h_render_mode = ui_handle(__ID__); + h_render_mode->i = config_raw->render_mode; string_array_t *render_mode_combo = any_array_create_from_raw( (void *[]){ tr("Desktop"), @@ -584,8 +591,8 @@ void box_preferences_viewport_tab() { context_set_render_path(); } - ui_handle_t *h_supersample = ui_handle(__ID__); - h_supersample->i = config_get_super_sample_quality(config_raw->rp_supersample); + ui_handle_t *h_supersample = ui_handle(__ID__); + h_supersample->i = config_get_super_sample_quality(config_raw->rp_supersample); string_array_t *supersample_combo = any_array_create_from_raw( (void *[]){ "0.25x", @@ -794,8 +801,8 @@ void box_preferences_keymap_tab() { ui_separator(8, false); - i32 index = 0; - ui->changed = false; + i32 index = 0; + ui->changed = false; string_array_t *keys = map_keys(config_keymap); array_sort(keys, NULL); for (i32 i = 0; i < keys->length; ++i) { @@ -910,7 +917,8 @@ void box_preferences_plugins_tab_new_box() { ui_handle_t *h1;\n\ void on_ui() {\n\ if (ui_panel(h1, \"New Plugin\", false, false, false)) {\n\ - if (ui_button(\"Button\", UI_ALIGN_CENTER, "")) {\n\ + if (ui_button(\"Button\", UI_ALIGN_CENTER, " + ")) {\n\ console_info(\"Hello\");\n\ }\n\ }\n\ @@ -963,7 +971,7 @@ void box_preferences_plugins_tab() { h->b = false; } for (i32 i = 0; i < box_preferences_files_plugin->length; ++i) { - char *f = box_preferences_files_plugin->buffer[i]; + char *f = box_preferences_files_plugin->buffer[i]; bool is_c = ends_with(f, ".c"); if (!is_c) { continue; diff --git a/paint/sources/box_projects.c b/paint/sources/box_projects.c index e67665b1..a097699e 100644 --- a/paint/sources/box_projects.c +++ b/paint/sources/box_projects.c @@ -1,6 +1,11 @@ #include "global.h" +any_map_t *box_projects_icon_map = NULL; +char *_box_projects_path; +char *_box_projects_icon_path; +i32 _box_projects_i; + void box_projects_tab_menu_on_next_frame(void *_) { iron_delete_file(_box_projects_path); iron_delete_file(_box_projects_icon_path); @@ -64,7 +69,7 @@ void box_projects_tab() { return; } string_array_t *recent_projects = config_raw->recent_projects; - bool show_asset_names = true; + bool show_asset_names = true; for (i32 row = 0; row < math_ceil(recent_projects->length / (float)num); ++row) { i32 mult = show_asset_names ? 2 : 1; diff --git a/paint/sources/brush_nodes/input_node.c b/paint/sources/brush_nodes/input_node.c index bac784c7..ca5b95d8 100644 --- a/paint/sources/brush_nodes/input_node.c +++ b/paint/sources/brush_nodes/input_node.c @@ -1,15 +1,25 @@ #include "../global.h" +f32 input_node_start_x = 0.0; +f32 input_node_start_y = 0.0; +// Brush ruler +bool input_node_lock_begin = false; +bool input_node_lock_x = false; +bool input_node_lock_y = false; +f32 input_node_lock_start_x = 0.0; +f32 input_node_lock_start_y = 0.0; +bool input_node_registered = false; + void input_node_update(float_node_t *self) { if (context_raw->split_view) { context_raw->view_index = mouse_view_x() > base_w() / 2.0 ? 1 : 0; } - bool decal_mask = context_is_decal_mask_paint(); + bool decal_mask = context_is_decal_mask_paint(); char *ruler_paint = string("%s+%s", any_map_get(config_keymap, "brush_ruler"), any_map_get(config_keymap, "action_paint")); - bool lazy_paint = context_raw->brush_lazy_radius > 0 && (operator_shortcut(any_map_get(config_keymap, "action_paint"), SHORTCUT_TYPE_DOWN) || - operator_shortcut(ruler_paint, SHORTCUT_TYPE_DOWN) || decal_mask); + bool lazy_paint = context_raw->brush_lazy_radius > 0 && (operator_shortcut(any_map_get(config_keymap, "action_paint"), SHORTCUT_TYPE_DOWN) || + operator_shortcut(ruler_paint, SHORTCUT_TYPE_DOWN) || decal_mask); f32 paint_x = mouse_view_x() / (float)sys_w(); f32 paint_y = mouse_view_y() / (float)sys_h(); diff --git a/paint/sources/brush_nodes/random_node.c b/paint/sources/brush_nodes/random_node.c index bb35f070..bb5b7aa3 100644 --- a/paint/sources/brush_nodes/random_node.c +++ b/paint/sources/brush_nodes/random_node.c @@ -1,6 +1,11 @@ #include "../global.h" +i32 random_node_a; +i32 random_node_b; +i32 random_node_c; +i32 random_node_d = -1; + void random_node_set_seed(i32 seed); i32 random_node_get_int() { diff --git a/paint/sources/camera.c b/paint/sources/camera.c index b0f6ee7c..cca4dcc9 100644 --- a/paint/sources/camera.c +++ b/paint/sources/camera.c @@ -1,6 +1,10 @@ #include "global.h" +i32 camera_redraws = 0; +f32 camera_ease = 1.0; +bool camera_controls_down = false; + static bool camera_wrap_mouse() { if (mouse_view_x() < 0 || mouse_view_x() > sys_w() || mouse_view_y() < 0 || mouse_view_y() > sys_h()) { if (!config_raw->wrap_mouse || !camera_controls_down) { diff --git a/paint/sources/compass.c b/paint/sources/compass.c index 7a75c3dc..50cdc90c 100644 --- a/paint/sources/compass.c +++ b/paint/sources/compass.c @@ -1,32 +1,38 @@ #include "global.h" +object_t *_compass_hitbox_x; +object_t *_compass_hitbox_y; +object_t *_compass_hitbox_z; +object_t *_compass_hovered = NULL; +object_t *_compass_hovered_last = NULL; + void compass_render() { if (!context_raw->show_compass || config_raw->workspace == WORKSPACE_PLAYER) { return; } - camera_object_t *cam = scene_camera; - mesh_object_t *compass = scene_get_child(".Compass")->ext; + camera_object_t *cam = scene_camera; + mesh_object_t *compass = scene_get_child(".Compass")->ext; - bool _visible = compass->base->visible; - object_t *_parent = compass->base->parent; - quat_t crot = cam->base->transform->rot; - f32 ratio = sys_w() / (float)sys_h(); - mat4_t _P = cam->p; - cam->p = mat4_ortho(-8 * ratio, 8 * ratio, -8, 8, -2, 2); - compass->base->visible = true; - compass->base->parent = cam->base; + bool _visible = compass->base->visible; + object_t *_parent = compass->base->parent; + quat_t crot = cam->base->transform->rot; + f32 ratio = sys_w() / (float)sys_h(); + mat4_t _P = cam->p; + cam->p = mat4_ortho(-8 * ratio, 8 * ratio, -8, 8, -2, 2); + compass->base->visible = true; + compass->base->parent = cam->base; - f32 compass_x = 7.4; - f32 compass_y = 7.0; - bool compass_down = false; + f32 compass_x = 7.4; + f32 compass_y = 7.0; + bool compass_down = false; - #ifdef IRON_IOS +#ifdef IRON_IOS if (config_is_iphone()) { compass_down = true; } - #endif +#endif if (compass_down) { compass_x = 6.0; @@ -70,11 +76,11 @@ void compass_init_hitbox() { _compass_hitbox_y->transform->scale = vec4_create(0.15, 0.15, 0.15, 1.0); _compass_hitbox_z->transform->scale = vec4_create(0.15, 0.15, 0.15, 1.0); - _compass_hitbox_x->transform->loc = vec4_create(1.5, 0, 0, 1.0); - _compass_hitbox_y->transform->loc = vec4_create(0, 1.5, 0, 1.0); - _compass_hitbox_z->transform->loc = vec4_create(0, 0, 1.5, 1.0); + _compass_hitbox_x->transform->loc = vec4_create(1.5, 0, 0, 1.0); + _compass_hitbox_y->transform->loc = vec4_create(0, 1.5, 0, 1.0); + _compass_hitbox_z->transform->loc = vec4_create(0, 0, 1.5, 1.0); - object_t *compass = scene_get_child(".Compass"); + object_t *compass = scene_get_child(".Compass"); object_set_parent(_compass_hitbox_x, compass); object_set_parent(_compass_hitbox_y, compass); object_set_parent(_compass_hitbox_z, compass); @@ -98,9 +104,9 @@ void compass_update() { gc_unroot(_compass_hovered); _compass_hovered = NULL; - f32 x = mouse_view_x() / (float)sys_w(); - f32 y = mouse_view_y() / (float)sys_h(); - bool hover = x > 0.9 && x < 1.0 && y < 0.14 && y > 0.0; + f32 x = mouse_view_x() / (float)sys_w(); + f32 y = mouse_view_y() / (float)sys_h(); + bool hover = x > 0.9 && x < 1.0 && y < 0.14 && y > 0.0; if (hover) { compass_init_hitbox(); @@ -130,7 +136,7 @@ void compass_update() { // Flip between left / right _compass_compare_quat(quat_from_euler(math_pi() / 2.0, 0, math_pi() / 2.0), cq) ? viewport_set_view(-1, 0, 0, math_pi() / 2.0, 0, -math_pi() / 2.0) // Left - : viewport_set_view(1, 0, 0, math_pi() / 2.0, 0, math_pi() / 2.0); // Right + : viewport_set_view(1, 0, 0, math_pi() / 2.0, 0, math_pi() / 2.0); // Right } gc_unroot(_compass_hovered); _compass_hovered = _compass_hitbox_x; @@ -140,7 +146,7 @@ void compass_update() { else if (t == _compass_hitbox_y->transform) { if (mouse_started("left")) { _compass_compare_quat(quat_from_euler(math_pi() / 2.0, 0, math_pi()), cq) - ? viewport_set_view(0, -1, 0, math_pi() / 2.0, 0, 0) // Front + ? viewport_set_view(0, -1, 0, math_pi() / 2.0, 0, 0) // Front : viewport_set_view(0, 1, 0, math_pi() / 2.0, 0, math_pi()); // Back } gc_unroot(_compass_hovered); @@ -151,7 +157,7 @@ void compass_update() { else { if (mouse_started("left")) { _compass_compare_quat(quat_from_euler(0, 0, 0), cq) ? viewport_set_view(0, 0, -1, math_pi(), 0, math_pi()) // Bottom - : viewport_set_view(0, 0, 1, 0, 0, 0); // Top + : viewport_set_view(0, 0, 1, 0, 0, 0); // Top } gc_unroot(_compass_hovered); _compass_hovered = _compass_hitbox_z; diff --git a/paint/sources/config.c b/paint/sources/config.c index 89bc6d35..1bfd2cab 100644 --- a/paint/sources/config.c +++ b/paint/sources/config.c @@ -1,6 +1,13 @@ #include "global.h" +typedef struct version { + char *sha; + char *date; +} version_t; + +bool config_loaded = false; + void config_load() { char *path = ""; if (path_is_protected()) { @@ -273,8 +280,8 @@ void config_init_layout() { i32_array_t *new_layout = i32_array_create_from_raw((i32[]){}, 0); i32_array_push(new_layout, math_floor(ui_sidebar_default_w * raw->window_scale)); // LayoutSidebarW - i32_array_push(new_layout, math_floor(iron_window_height() / 2.0)); // LayoutSidebarH0 - i32_array_push(new_layout, math_floor(iron_window_height() / 2.0)); // LayoutSidebarH1 + i32_array_push(new_layout, math_floor(iron_window_height() / 2.0)); // LayoutSidebarH0 + i32_array_push(new_layout, math_floor(iron_window_height() / 2.0)); // LayoutSidebarH1 #ifdef IRON_IOS i32_array_push(new_layout, show2d ? math_floor((sys_w() + raw->layout->buffer[LAYOUT_SIZE_NODES_W]) * 0.473) : math_floor(sys_w() * 0.473)); // LayoutNodesW @@ -286,7 +293,7 @@ void config_init_layout() { : math_floor(sys_w() * 0.515)); // Align with ui header controls #endif - i32_array_push(new_layout, math_floor(sys_h() / 2.0)); // LayoutNodesH + i32_array_push(new_layout, math_floor(sys_h() / 2.0)); // LayoutNodesH i32_array_push(new_layout, math_floor(ui_statusbar_default_h * raw->window_scale)); // LayoutStatusH #if defined(IRON_ANDROID) || defined(IRON_IOS) diff --git a/paint/sources/console.c b/paint/sources/console.c index 59e020f2..e35ceb72 100644 --- a/paint/sources/console.c +++ b/paint/sources/console.c @@ -1,6 +1,8 @@ #include "global.h" +char *console_progress_text = NULL; + void console_draw_toast(char *s) { draw_begin(NULL, false, 0); draw_set_color(0x55000000); diff --git a/paint/sources/enums.h b/paint/sources/enums.h index 0366fe92..f4cf4355 100644 --- a/paint/sources/enums.h +++ b/paint/sources/enums.h @@ -83,15 +83,6 @@ typedef enum { WORKFLOW_BASE = 1, } workflow_t; -typedef enum { - CHANNEL_TYPE_BASE_COLOR = 0, - CHANNEL_TYPE_OCCLUSION = 1, - CHANNEL_TYPE_ROUGHNESS = 2, - CHANNEL_TYPE_METALLIC = 3, - CHANNEL_TYPE_NORMAL_MAP = 4, - CHANNEL_TYPE_HEIGHT = 5, -} channel_type_t; - typedef enum { RENDER_MODE_DEFERRED = 0, RENDER_MODE_FORWARD = 1, @@ -110,13 +101,6 @@ typedef enum { EXPORT_DESTINATION_PACK_INTO_PROJECT = 1, } export_destination_t; -typedef enum { - PLAYER_TARGET_WEB = 0, - PLAYER_TARGET_WINDOWS = 1, - PLAYER_TARGET_LINUX = 2, - PLAYER_TARGET_MACOS = 3, -} player_target_t; - typedef enum { PATHTRACE_MODE_FAST = 0, PATHTRACE_MODE_QUALITY = 1, @@ -188,25 +172,11 @@ typedef enum { TEXTURE_LDR_FORMAT_JPG = 1, } texture_ldr_format_t; -typedef enum { - TEXTURE_HDR_FORMAT_EXR = 0, -} texture_hdr_format_t; - typedef enum { MESH_FORMAT_OBJ = 0, MESH_FORMAT_ARM = 1, } mesh_format_t; -typedef enum { - MENUBAR_CATEGORY_FILE = 0, - MENUBAR_CATEGORY_EDIT = 1, - MENUBAR_CATEGORY_VIEWPORT = 2, - MENUBAR_CATEGORY_MODE = 3, - MENUBAR_CATEGORY_CAMERA = 4, - MENUBAR_CATEGORY_WORKSPACE = 5, - MENUBAR_CATEGORY_HELP = 6, -} menubar_category_t; - typedef enum { CANVAS_TYPE_MATERIAL = 0, CANVAS_TYPE_BRUSH = 1, @@ -224,13 +194,6 @@ typedef enum { VIEW_2D_LAYER_MODE_SELECTED = 1, } view_2d_layer_mode_t; -typedef enum { - BORDER_SIDE_LEFT = 0, - BORDER_SIDE_RIGHT = 1, - BORDER_SIDE_TOP = 2, - BORDER_SIDE_BOTTOm = 3, -} border_side_t; - typedef enum { PAINT_TEX_BASE = 0, PAINT_TEX_OPACITY = 1, @@ -273,16 +236,6 @@ typedef enum { TOOL_TYPE_GIZMO = 13, } tool_type_t; -typedef enum { - AREA_TYPE_MINUS_ONE = -1, - AREA_TYPE_VIEW3D = 0, - AREA_TYPE_VIEW2D = 1, - AREA_TYPE_LAYERS = 2, - AREA_TYPE_MATERIALS = 3, - AREA_TYPE_NODES = 4, - AREA_TYPE_BROWSER = 5, -} area_type_t; - typedef enum { TAB_AREA_SIDEBAR0 = 0, TAB_AREA_SIDEBAR1 = 1, diff --git a/paint/sources/export_exr.c b/paint/sources/export_exr.c index 41d22e5a..cf5c3a33 100644 --- a/paint/sources/export_exr.c +++ b/paint/sources/export_exr.c @@ -5,6 +5,12 @@ // https://github.com/aras-p/miniexr // https://www.openexr.com/documentation/openexrfilelayout.pdf +i32 _export_exr_width; +i32 _export_exr_stride; +u8_array_t *_export_exr_out; +buffer_t *_export_exr_src_view; +void (*_export_exr_write_line)(i32); + void export_exr_write_string(u8_array_t *out, char *str) { for (i32 i = 0; i < string_length(str); ++i) { u8_array_push(out, char_code_at(str, i)); @@ -281,7 +287,7 @@ buffer_t *export_exr_run(i32 width, i32 height, buffer_t *src, i32 bits, i32 typ i32 full_row_size = pixel_row_size + 8; // line offset table - i32 ofs = k_header_size + k_scanline_table_size; + i32 ofs = k_header_size + k_scanline_table_size; for (i32 y = 0; y < height; ++y) { u8_array_push(out, ofs & 0xff); u8_array_push(out, (ofs >> 8) & 0xff); @@ -295,8 +301,8 @@ buffer_t *export_exr_run(i32 width, i32 height, buffer_t *src, i32 bits, i32 typ } // scanline data - i32 stride = channels * byte_size; - i32 pos = 0; + i32 stride = channels * byte_size; + i32 pos = 0; _export_exr_width = width; _export_exr_stride = stride; diff --git a/paint/sources/export_player.c b/paint/sources/export_player.c index 46630ce4..04868239 100644 --- a/paint/sources/export_player.c +++ b/paint/sources/export_player.c @@ -1,6 +1,13 @@ #include "global.h" +typedef enum { + PLAYER_TARGET_WEB = 0, + PLAYER_TARGET_WINDOWS = 1, + PLAYER_TARGET_LINUX = 2, + PLAYER_TARGET_MACOS = 3, +} player_target_t; + static char *export_player_readme = "\ To start the player locally, use 'python -m http.server'\ and open http://localhost:8000/ in the browser.\n\ diff --git a/paint/sources/export_texture.c b/paint/sources/export_texture.c index b19bdfcb..0a4ca8db 100644 --- a/paint/sources/export_texture.c +++ b/paint/sources/export_texture.c @@ -1,6 +1,8 @@ #include "global.h" +f32 export_texture_gamma = 1.0 / 2.2; + void export_texture_write_texture(char *file, buffer_t *pixels, i32 type, i32 off) { i32 res_x = config_get_texture_res_x(); i32 res_y = config_get_texture_res_y(); @@ -32,8 +34,8 @@ void export_texture_write_texture(char *file, buffer_t *pixels, i32 type, i32 of gpu_texture_t *image = gpu_create_texture_from_bytes(pixels, res_x, res_y, GPU_TEXTURE_FORMAT_RGBA32); any_map_set(data_cached_images, file, image); string_array_t *ar = string_split(file, PATH_SEP); - char *name = ar->buffer[ar->length - 1]; - asset_t *asset = GC_ALLOC_INIT(asset_t, {.name = name, .file = file, .id = project_asset_id++}); + char *name = ar->buffer[ar->length - 1]; + asset_t *asset = GC_ALLOC_INIT(asset_t, {.name = name, .file = file, .id = project_asset_id++}); any_array_push(project_assets, asset); if (project_raw->assets == NULL) { project_raw->assets = any_array_create_from_raw((void *[]){}, 0); @@ -301,7 +303,7 @@ void export_texture_run_layers(char *path, slot_layer_t_array_t *layers, char *o for (i32 i = 0; i < preset->textures->length; ++i) { export_preset_texture_t *t = preset->textures->buffer[i]; - string_array_t *c = t->channels; + string_array_t *c = t->channels; char *tex_name = !string_equals(t->name, "") ? string("_%s", t->name) : ""; bool single_channel = c->buffer[0] == c->buffer[1] && c->buffer[1] == c->buffer[2] && string_equals(c->buffer[3], "1.0"); char *out_path = string("%s%s%s%s%s", path, PATH_SEP, f, tex_name, ext); diff --git a/paint/sources/functions.h b/paint/sources/functions.h index a9e1360e..bcc129f2 100644 --- a/paint/sources/functions.h +++ b/paint/sources/functions.h @@ -131,7 +131,6 @@ void import_blend_material_run(char *path); void import_texture_run(char *path, bool hdr_as_envmap); void ui_files_show(char *filters, bool is_save, bool open_multiple, void (*files_done)(char *)); char *ui_files_file_browser(ui_handle_t *handle, bool drag_files, char *search, bool refresh, void (*context_menu)(char *)); -void ui_files_make_icon(ui_files_make_icon_t *args); void ui_files_go_up(ui_handle_t *handle); void base_init(); i32 base_w(); diff --git a/paint/sources/globals.h b/paint/sources/globals.h index 5288395a..ae3e08bf 100644 --- a/paint/sources/globals.h +++ b/paint/sources/globals.h @@ -5,110 +5,69 @@ #include "types.h" #include -any_map_t *ui_children; -any_map_t *ui_nodes_custom_buttons; -gpu_texture_t *_tab_swatches_empty; -i32 tab_swatches_drag_pos = -1; -i32 _tab_swatches_draw_i; -buffer_t *slot_brush_default_canvas = NULL; -gpu_texture_t *layers_temp_image = NULL; -gpu_texture_t *layers_expa = NULL; -gpu_texture_t *layers_expb = NULL; -gpu_texture_t *layers_expc = NULL; -f32 layers_default_base = 0.5; -f32 layers_default_rough = 0.4; -#if defined(IRON_ANDROID) || defined(IRON_IOS) -i32 layers_max_layers = 18; -#else -i32 layers_max_layers = 255; -#endif -uv_type_t _layers_uv_type; -mat4_t _layers_decal_mat; -i32 _layers_position; -i32 _layers_base_color; -f32 _layers_occlusion; -f32 _layers_roughness; -f32 _layers_metallic; -any_map_t *operator_ops; -object_t *_compass_hitbox_x; -object_t *_compass_hitbox_y; -object_t *_compass_hitbox_z; -object_t *_compass_hovered = NULL; -object_t *_compass_hovered_last = NULL; -config_t *config_raw = NULL; -any_map_t *config_keymap; -bool config_loaded = false; -ui_align_t config_button_align = UI_ALIGN_LEFT; -char *config_button_spacing = " "; -any_imap_t *physics_body_object_map; -ui_handle_t *box_export_htab; -string_array_t *box_export_files = NULL; -ui_handle_t *box_export_mesh_handle; -ui_handle_t *box_export_hpreset; -export_preset_t *box_export_preset = NULL; -string_array_t *box_export_channels; -string_array_t *box_export_color_spaces; -ui_handle_t *box_export_h_export_player_target; -bool _box_export_bake_material; -export_preset_texture_t *_box_export_t; -bool _box_export_apply_displacement; -bool _box_export_merge_vertices; -gpu_texture_t *_tab_textures_draw_img; -char *_tab_textures_draw_path; -asset_t *_tab_textures_draw_asset; -i32 _tab_textures_draw_i; -bool _tab_textures_draw_is_packed; -buffer_t *slot_material_default_canvas = NULL; -i32 _tab_brushes_draw_i; -gpu_pipeline_t *pipes_copy; -gpu_pipeline_t *pipes_copy8; -gpu_pipeline_t *pipes_copy64; -gpu_pipeline_t *pipes_copy128; -gpu_pipeline_t *pipes_copy_bgra; -gpu_pipeline_t *pipes_copy_rgb = NULL; -// let pipes_copy_r: gpu_pipeline_t; -// let pipes_copy_g: gpu_pipeline_t; -// let pipes_copy_a: gpu_pipeline_t; -// let pipes_copy_a_tex: i32; -gpu_pipeline_t *pipes_merge = NULL; -gpu_pipeline_t *pipes_merge_r = NULL; -gpu_pipeline_t *pipes_merge_g = NULL; -gpu_pipeline_t *pipes_merge_b = NULL; -gpu_pipeline_t *pipes_merge_mask; -gpu_pipeline_t *pipes_invert8; -gpu_pipeline_t *pipes_apply_mask; -gpu_pipeline_t *pipes_colorid_to_mask; -i32 pipes_tex0; -i32 pipes_tex1; -i32 pipes_texmask; -i32 pipes_texa; -i32 pipes_opac; -i32 pipes_blending; -i32 pipes_tex1w; -i32 pipes_tex0_mask; -i32 pipes_texa_mask; -i32 pipes_tex0_merge_mask; -i32 pipes_texa_merge_mask; -i32 pipes_tex_colorid; -i32 pipes_texpaint_colorid; -i32 pipes_opac_merge_mask; -i32 pipes_blending_merge_mask; -gpu_texture_t *pipes_temp_mask_image = NULL; -gpu_pipeline_t *pipes_inpaint_preview; -i32 pipes_tex0_inpaint_preview; -i32 pipes_texa_inpaint_preview; -gpu_pipeline_t *pipes_cursor; -i32 pipes_cursor_vp; -i32 pipes_cursor_inv_vp; -i32 pipes_cursor_mouse; -i32 pipes_cursor_tex_step; -i32 pipes_cursor_radius; -i32 pipes_cursor_camera_right; -i32 pipes_cursor_tint; -i32 pipes_cursor_gbufferd; -i32 pipes_offset; -char *_import_blend_material_path; -any_map_t *import_texture_importers; +any_map_t *ui_children; +any_map_t *ui_nodes_custom_buttons; +gpu_texture_t *layers_temp_image = NULL; +gpu_texture_t *layers_expa = NULL; +gpu_texture_t *layers_expb = NULL; +gpu_texture_t *layers_expc = NULL; +f32 layers_default_base = 0.5; +f32 layers_default_rough = 0.4; +any_map_t *operator_ops; +config_t *config_raw = NULL; +any_map_t *config_keymap; +ui_align_t config_button_align = UI_ALIGN_LEFT; +char *config_button_spacing = " "; +any_imap_t *physics_body_object_map; +ui_handle_t *box_export_htab; +string_array_t *box_export_files = NULL; +ui_handle_t *box_export_mesh_handle; +ui_handle_t *box_export_hpreset; +export_preset_t *box_export_preset = NULL; +string_array_t *box_export_channels; +string_array_t *box_export_color_spaces; +ui_handle_t *box_export_h_export_player_target; +gpu_pipeline_t *pipes_copy; +gpu_pipeline_t *pipes_copy8; +gpu_pipeline_t *pipes_copy64; +gpu_pipeline_t *pipes_copy128; +gpu_pipeline_t *pipes_copy_bgra; +gpu_pipeline_t *pipes_copy_rgb = NULL; +gpu_pipeline_t *pipes_merge = NULL; +gpu_pipeline_t *pipes_merge_r = NULL; +gpu_pipeline_t *pipes_merge_g = NULL; +gpu_pipeline_t *pipes_merge_b = NULL; +gpu_pipeline_t *pipes_merge_mask; +gpu_pipeline_t *pipes_invert8; +gpu_pipeline_t *pipes_apply_mask; +gpu_pipeline_t *pipes_colorid_to_mask; +i32 pipes_tex0; +i32 pipes_tex1; +i32 pipes_texmask; +i32 pipes_texa; +i32 pipes_opac; +i32 pipes_blending; +i32 pipes_tex1w; +i32 pipes_tex0_mask; +i32 pipes_texa_mask; +i32 pipes_tex0_merge_mask; +i32 pipes_texa_merge_mask; +i32 pipes_tex_colorid; +i32 pipes_texpaint_colorid; +i32 pipes_opac_merge_mask; +i32 pipes_blending_merge_mask; +gpu_texture_t *pipes_temp_mask_image = NULL; +gpu_pipeline_t *pipes_cursor; +i32 pipes_cursor_vp; +i32 pipes_cursor_inv_vp; +i32 pipes_cursor_mouse; +i32 pipes_cursor_tex_step; +i32 pipes_cursor_radius; +i32 pipes_cursor_camera_right; +i32 pipes_cursor_tint; +i32 pipes_cursor_gbufferd; +i32 pipes_offset; +any_map_t *import_texture_importers; #ifdef IRON_WINDOWS char *ui_files_default_path = "C:\\Users"; @@ -122,16 +81,7 @@ char *ui_files_default_path = "/"; char *ui_files_filename; char *ui_files_path; -char *ui_files_last_path = ""; -char *ui_files_last_search = ""; -string_array_t *ui_files_files = NULL; -any_map_t *ui_files_icon_map = NULL; -any_map_t *ui_files_icon_file_map = NULL; -i32 ui_files_selected = -1; -bool ui_files_show_extensions = false; -bool ui_files_offline = false; -ui_handle_t *_ui_files_file_browser_handle; -char *_ui_files_file_browser_f; +char *ui_files_last_path = ""; bool base_ui_enabled = true; bool base_view3d_show = true; bool base_is_dragging = false; @@ -140,42 +90,22 @@ asset_t *base_drag_asset = NULL; swatch_color_t *base_drag_swatch = NULL; char *base_drag_file = NULL; gpu_texture_t *base_drag_file_icon = NULL; -i32 base_drag_tint = 0xffffffff; -i32 base_drag_size = -1; -rect_t *base_drag_rect = NULL; f32 base_drag_off_x = 0.0; f32 base_drag_off_y = 0.0; -f32 base_drag_start = 0.0; -f32 base_drop_x = 0.0; -f32 base_drop_y = 0.0; draw_font_t *base_font = NULL; ui_theme_t *base_theme; -gpu_texture_t *base_color_wheel; -gpu_texture_t *base_color_wheel_gradient; i32 base_default_element_w = 100; i32 base_default_element_h = 28; i32 base_default_font_size = 13; ui_handle_t *base_res_handle; ui_handle_t *base_bits_handle; string_array_t *base_drop_paths; -i32 base_appx = 0; -i32 base_appy = 0; -i32 base_last_window_width = 0; -i32 base_last_window_height = 0; -slot_material_t *base_drag_material = NULL; -slot_layer_t *base_drag_layer = NULL; -bool base_player_lock = false; -i32 _base_material_count; +slot_material_t *base_drag_material = NULL; +slot_layer_t *base_drag_layer = NULL; +bool base_player_lock = false; ui_t *ui; -bool ui_base_show = true; -i32 ui_base_border_started = 0; -ui_handle_t *ui_base_border_handle = NULL; -char *ui_base_action_paint_remap = ""; -i32 ui_base_operator_search_offset = 0; -f32 ui_base_undo_tap_time = 0.0; -f32 ui_base_redo_tap_time = 0.0; +bool ui_base_show = true; i32 ui_base_viewport_col; -bool _ui_base_operator_search_first; ui_handle_t_array_t *ui_base_hwnds; ui_handle_t_array_t *ui_base_htabs; tab_draw_array_t_array_t *ui_base_hwnd_tabs; @@ -186,137 +116,72 @@ quat_t gizmo_q0; context_t *context_raw; i32 ui_toolbar_default_w = 36; ui_handle_t *ui_toolbar_handle; -i32 ui_toolbar_last_tool = 0; string_array_t *ui_toolbar_tool_names; string_array_t *ui_toolbar_tooltip_extras; -i32 _ui_toolbar_i; -f32 _import_asset_drop_x; -f32 _import_asset_drop_y; -bool _import_asset_show_box; -bool _import_asset_hdr_as_envmap; -void (*_import_asset_done)(void); -mat4_t uniforms_ext_ortho_p; -ui_handle_t *box_projects_htab; -ui_handle_t *box_projects_hsearch; -any_map_t *box_projects_icon_map = NULL; -char *_box_projects_path; -char *_box_projects_icon_path; -i32 _box_projects_i; -history_step_t_array_t *history_steps; -i32 history_undo_i = 0; // Undo layer -i32 history_undos = 0; // Undos available -i32 history_redos = 0; // Redos available -bool history_push_undo = false; // Store undo on next paint -slot_layer_t_array_t *history_undo_layers = NULL; -ui_handle_t *tab_scripts_hscript; -ui_text_coloring_t *tab_scripts_text_coloring = NULL; -bool import_mesh_clear_layers = true; -any_array_t *import_mesh_meshes_to_unwrap = NULL; -any_map_t *import_mesh_importers; -i32 ui_menubar_default_w = 406; -ui_handle_t *ui_menubar_hwnd; -ui_handle_t *ui_menubar_menu_handle; -ui_handle_t *ui_menubar_tab; -i32 ui_menubar_w; -i32 ui_menubar_category = 0; -mat4_t _ui_menubar_saved_camera; -mesh_object_t *_ui_menubar_plane = NULL; -any_map_t *translator_translations; -// The font index is a value specific to font_cjk.ttc -i32_map_t *translator_cjk_font_indices = NULL; -char *translator_last_locale = "en"; -char *_translator_load_translations_cjk_font_path; -char *_translator_load_translations_cjk_font_disk_path; -bool _translator_init_font_cjk; -char *_translator_init_font_font_path; -f32 _translator_init_font_font_scale; -scene_t *scene_raw_gc; -i32 _tab_fonts_draw_i; -physics_world_t *physics_world_active; -bool ui_menu_show = false; -bool ui_menu_nested = false; -i32 ui_menu_x = 0; -i32 ui_menu_y = 0; -i32 ui_menu_h = 0; -bool ui_menu_keep_open = false; -void (*ui_menu_commands)(void) = NULL; -bool ui_menu_show_first = true; -bool ui_menu_hide_flag = false; -i32 ui_menu_sub_x = 0; -i32 ui_menu_sub_y = 0; -ui_handle_t *ui_menu_sub_handle = NULL; -char *_ui_menu_render_msg; -i32 render_path_base_taa_frame = 0; -f32 render_path_base_super_sample = 1.0; -f32 render_path_base_last_x = -1.0; -f32 render_path_base_last_y = -1.0; -render_target_t_array_t *render_path_base_bloom_mipmaps; -i32 render_path_base_bloom_current_mip = 0; -f32 render_path_base_bloom_sample_scale; -bool render_path_base_buf_swapped = false; -project_format_t *project_raw; -char *project_filepath = ""; -asset_t_array_t *project_assets; -string_array_t *project_asset_names; -i32 project_asset_id = 0; -string_array_t *project_mesh_assets; -node_group_t_array_t *project_material_groups; -mesh_object_t_array_t *project_paint_objects = NULL; -any_imap_t *project_asset_map; // gpu_texture_t | font_t -string_array_t *project_mesh_list = NULL; -slot_material_t_array_t *project_materials; -slot_brush_t_array_t *project_brushes; -slot_layer_t_array_t *project_layers; -slot_font_t_array_t *project_fonts; -i32_array_t *project_atlas_objects = NULL; -string_array_t *project_atlas_names = NULL; -bool _project_save_and_quit; -bool _project_import_mesh_replace_existing; -void (*_project_import_mesh_done)(void); -char *_project_import_mesh_box_path; -bool _project_import_mesh_box_replace_existing; -bool _project_import_mesh_box_clear_layers; -void (*_project_import_mesh_box_done)(void); -raw_mesh_t *_project_unwrap_mesh_box_mesh; -void (*_project_unwrap_mesh_box_done)(raw_mesh_t *); -bool _project_unwrap_mesh_box_skip_ui; -bool _project_import_asset_hdr_as_envmap; -bool _project_import_swatches_replace_existing; -asset_t *_project_reimport_texture_asset; -scene_t *_project_scene_mesh_gc; -i32 _project_unwrap_by = 0; +mat4_t uniforms_ext_ortho_p; +ui_handle_t *box_projects_htab; +ui_handle_t *box_projects_hsearch; +history_step_t_array_t *history_steps; +i32 history_undo_i = 0; // Undo layer +i32 history_undos = 0; // Undos available +i32 history_redos = 0; // Redos available +bool history_push_undo = false; // Store undo on next paint +slot_layer_t_array_t *history_undo_layers = NULL; +ui_handle_t *tab_scripts_hscript; +any_map_t *import_mesh_importers; +i32 ui_menubar_default_w = 406; +ui_handle_t *ui_menubar_hwnd; +ui_handle_t *ui_menubar_menu_handle; +ui_handle_t *ui_menubar_tab; +i32 ui_menubar_w; +any_map_t *translator_translations; +physics_world_t *physics_world_active; +bool ui_menu_show = false; +bool ui_menu_nested = false; +i32 ui_menu_x = 0; +i32 ui_menu_y = 0; +i32 ui_menu_h = 0; +bool ui_menu_keep_open = false; +void (*ui_menu_commands)(void) = NULL; +bool ui_menu_show_first = true; +i32 render_path_base_taa_frame = 0; +i32 render_path_base_bloom_current_mip = 0; +f32 render_path_base_bloom_sample_scale; +bool render_path_base_buf_swapped = false; +project_format_t *project_raw; +char *project_filepath = ""; +asset_t_array_t *project_assets; +string_array_t *project_asset_names; +i32 project_asset_id = 0; +string_array_t *project_mesh_assets; +node_group_t_array_t *project_material_groups; +mesh_object_t_array_t *project_paint_objects = NULL; +any_imap_t *project_asset_map; // gpu_texture_t | font_t +string_array_t *project_mesh_list = NULL; +slot_material_t_array_t *project_materials; +slot_brush_t_array_t *project_brushes; +slot_layer_t_array_t *project_layers; +slot_font_t_array_t *project_fonts; +i32_array_t *project_atlas_objects = NULL; +string_array_t *project_atlas_names = NULL; gpu_pipeline_t *ui_view2d_pipe; i32 ui_view2d_channel_loc; -bool ui_view2d_text_input_hover = false; -bool ui_view2d_uvmap_show = false; -paint_tex_t ui_view2d_tex_type = PAINT_TEX_BASE; -view_2d_layer_mode_t ui_view2d_layer_mode = VIEW_2D_LAYER_MODE_SELECTED; -view_2d_type_t ui_view2d_type = VIEW_2D_TYPE_LAYER; -bool ui_view2d_show = false; +view_2d_type_t ui_view2d_type = VIEW_2D_TYPE_LAYER; +bool ui_view2d_show = false; i32 ui_view2d_wx; i32 ui_view2d_wy; i32 ui_view2d_ww; i32 ui_view2d_wh; ui_handle_t *ui_view2d_hwnd; -f32 ui_view2d_pan_x = 0.0; -f32 ui_view2d_pan_y = 0.0; -f32 ui_view2d_pan_scale = 1.0; -bool ui_view2d_tiled_show = false; -bool ui_view2d_controls_down = false; -gpu_texture_t *_ui_view2d_render_tex; -f32 _ui_view2d_render_x; -f32 _ui_view2d_render_y; -f32 _ui_view2d_render_tw; -f32 _ui_view2d_render_th; -gpu_texture_t *ui_view2d_grid = NULL; +f32 ui_view2d_pan_x = 0.0; +f32 ui_view2d_pan_y = 0.0; +f32 ui_view2d_pan_scale = 1.0; +bool ui_view2d_tiled_show = false; bool ui_view2d_grid_redraw = true; ui_handle_t *ui_view2d_htab; -bool ui_view2d_layer_touched = false; -bool sim_running = false; -mat4_box_t_array_t *sim_transforms; +bool sim_running = false; any_map_t *sim_object_script_map; bool sim_record = false; -bool sim_initialized = false; bool viewport_recording = false; node_shader_context_t *parser_material_con; node_shader_t *parser_material_kong; @@ -326,14 +191,10 @@ ui_node_t_array_t *parser_material_parents; ui_node_canvas_t_array_t *parser_material_canvases; ui_node_t_array_t *parser_material_nodes; ui_node_link_t_array_t *parser_material_links; -bool parser_material_cotangent_frame_written; -char *parser_material_tex_coord = "tex_coord"; -f32 parser_material_eps = 0.000001; +f32 parser_material_eps = 0.000001; any_map_t *parser_material_node_values; any_map_t *parser_material_node_vectors; any_map_t *parser_material_custom_nodes; -bool parser_material_parse_surface = true; -bool parser_material_parse_opacity = true; bool parser_material_parse_height = false; bool parser_material_parse_height_as_channel = false; bool parser_material_parse_emission = false; @@ -349,106 +210,47 @@ bool parser_material_bake_passthrough = false; ui_node_canvas_t *parser_material_start_group = NULL; ui_node_t_array_t *parser_material_start_parents = NULL; ui_node_t *parser_material_start_node = NULL; -bool parser_material_arm_export_tangents = true; char *parser_material_out_normaltan; // Raw tangent space normal parsed from normal map any_map_t *parser_material_script_links = NULL; any_map_t *parser_material_parsed_map; any_map_t *parser_material_texture_map; -bool parser_material_is_frag = true; -bool args_use = false; -char *args_asset_path = ""; -bool args_background = false; -bool args_player = false; -bool args_export_textures = false; -char *args_export_textures_type = ""; -char *args_export_textures_preset = ""; -char *args_export_textures_path = ""; -bool args_reimport_mesh = false; -bool args_export_mesh = false; -char *args_export_mesh_path = ""; -bool args_export_material = false; -char *args_export_material_path = ""; -i32 util_render_material_preview_size = 256; -i32 util_render_node_preview_size = 512; -i32 util_render_decal_preview_size = 512; -i32 util_render_layer_preview_size = 200; -i32 util_render_font_preview_size = 200; -gpu_buffer_t *util_render_screen_aligned_full_vb = NULL; -gpu_buffer_t *util_render_screen_aligned_full_ib = NULL; -i32 _tab_materials_draw_slots; +bool parser_material_is_frag = true; +bool args_player = false; +i32 util_render_material_preview_size = 256; +i32 util_render_node_preview_size = 512; +i32 util_render_decal_preview_size = 512; +i32 util_render_layer_preview_size = 200; +i32 util_render_font_preview_size = 200; ui_handle_t *tab_browser_hpath; ui_handle_t *tab_browser_hsearch; -bool tab_browser_known = false; -char *tab_browser_last_path = ""; -char *_tab_browser_draw_file; -char *_tab_browser_draw_b; bool tab_browser_refresh = false; any_map_t *util_mesh_unwrappers; -i16_array_t *util_mesh_va0; -i32_array_t *util_mesh_quantized; i32 ui_header_default_h = 30; i32 ui_header_h; ui_handle_t *ui_header_handle; -ui_handle_t *_ui_header_draw_tool_properties_h; any_map_t *plugin_map; -char *_plugin_name; any_map_t *parser_logic_custom_nodes; -ui_node_t_array_t *parser_logic_nodes; -ui_node_link_t_array_t *parser_logic_links; -string_array_t *parser_logic_parsed_nodes = NULL; -any_map_t *parser_logic_node_map; any_map_t *resource_bundled; -i32 render_path_raytrace_bake_rays_pix = 0; -i32 render_path_raytrace_bake_rays_sec = 0; -i32 render_path_raytrace_bake_current_sample = 0; -f32 render_path_raytrace_bake_rays_timer = 0.0; -i32 render_path_raytrace_bake_rays_counter = 0; -gpu_texture_t *render_path_raytrace_bake_last_layer = NULL; -i32 render_path_raytrace_bake_last_bake_type = 0; -i32 render_path_raytrace_bake_last_bake_type2 = 0; -shader_context_t *make_material_default_scon = NULL; -material_context_t *make_material_default_mcon = NULL; -bool make_material_opac_used = false; -bool make_material_height_used = false; -bool make_material_emis_used = false; -bool make_material_subs_used = false; -bool ui_nodes_show = false; +i32 render_path_raytrace_bake_rays_pix = 0; +i32 render_path_raytrace_bake_rays_sec = 0; +i32 render_path_raytrace_bake_current_sample = 0; +bool make_material_opac_used = false; +bool make_material_height_used = false; +bool make_material_emis_used = false; +bool make_material_subs_used = false; +bool ui_nodes_show = false; i32 ui_nodes_wx; i32 ui_nodes_wy; i32 ui_nodes_ww; i32 ui_nodes_wh; -canvas_type_t ui_nodes_canvas_type = CANVAS_TYPE_MATERIAL; -bool ui_nodes_show_menu = false; -bool ui_nodes_show_menu_first = true; -bool ui_nodes_hide_menu = false; -i32 ui_nodes_menu_category = 0; -f32 ui_nodes_popup_x = 0.0; -f32 ui_nodes_popup_y = 0.0; -i32 ui_nodes_node_search_x; -i32 ui_nodes_node_search_y; -bool ui_nodes_uichanged_last = false; -bool ui_nodes_recompile_mat = false; // Mat preview -bool ui_nodes_recompile_mat_final = false; -ui_node_t *ui_nodes_node_search_spawn = NULL; -i32 ui_nodes_node_search_offset = 0; -ui_node_canvas_t *ui_nodes_last_canvas = NULL; -i32 ui_nodes_last_node_selected_id = -1; -bool ui_nodes_release_link = false; -bool ui_nodes_is_node_menu_op = false; -gpu_texture_t *ui_nodes_grid = NULL; -bool ui_nodes_grid_redraw = true; -i32 ui_nodes_grid_cell_w = 200; -i32 ui_nodes_grid_small_cell_w = 40; +canvas_type_t ui_nodes_canvas_type = CANVAS_TYPE_MATERIAL; +bool ui_nodes_grid_redraw = true; +i32 ui_nodes_grid_cell_w = 200; +i32 ui_nodes_grid_small_cell_w = 40; ui_handle_t *ui_nodes_hwnd; node_group_t_array_t *ui_nodes_group_stack; -bool ui_nodes_controls_down = false; -slot_material_t_array_t *ui_nodes_tabs = NULL; ui_handle_t *ui_nodes_htab; f32 ui_nodes_last_zoom = 1.0; -ui_node_link_t *_ui_nodes_on_link_drag_link_drag; -ui_node_t *_ui_nodes_on_link_drag_node; -ui_node_socket_t *_ui_nodes_on_socket_released_socket; -ui_node_t *_ui_nodes_on_socket_released_node; ui_handle_t *_ui_nodes_htype; ui_handle_t *_ui_nodes_hname; ui_handle_t *_ui_nodes_hmin; @@ -457,37 +259,26 @@ ui_handle_t *_ui_nodes_hval0; ui_handle_t *_ui_nodes_hval1; ui_handle_t *_ui_nodes_hval2; ui_handle_t *_ui_nodes_hval3; -ui_node_t *_ui_nodes_on_canvas_released_selected; -bool _ui_nodes_node_search_first; -void (*_ui_nodes_node_search_done)(void); -ui_node_t *ui_nodes_node_changed = NULL; -void (*_ui_nodes_render_tmp)(i32); -string_array_t *nodes_brush_categories; -ui_node_t_array_t *nodes_brush_category0; -node_list_t_array_t *nodes_brush_list; -any_map_t *nodes_brush_creates; -char *manifest_title = "ArmorPaint"; -char *manifest_version = "1.0 alpha"; -char *manifest_version_project = "4"; -char *manifest_version_config = "1"; -char *manifest_url = "https://armorpaint.org"; -char *manifest_url_android = "https://play.google.com/store/apps/details?id=org.armorpaint"; -char *manifest_url_ios = "https://apps.apple.com/app/armorpaint/id1533967534"; -i32 _export_exr_width; -i32 _export_exr_stride; -u8_array_t *_export_exr_out; -buffer_t *_export_exr_src_view; -void (*_export_exr_write_line)(i32); -string_array_t *nodes_material_categories; -ui_node_t_array_t *nodes_material_input; -ui_node_t_array_t *nodes_material_texture; -ui_node_t_array_t *nodes_material_color; -ui_node_t_array_t *nodes_material_utilities; -ui_node_t_array_t *nodes_material_neural; -ui_node_t_array_t *nodes_material_group; -node_list_t_array_t *nodes_material_list = NULL; -i32 make_mesh_layer_pass_count = 1; -char *str_cotangent_frame = "\ +string_array_t *nodes_brush_categories; +node_list_t_array_t *nodes_brush_list; +any_map_t *nodes_brush_creates; +char *manifest_title = "ArmorPaint"; +char *manifest_version = "1.0 alpha"; +char *manifest_version_project = "4"; +char *manifest_version_config = "1"; +char *manifest_url = "https://armorpaint.org"; +char *manifest_url_android = "https://play.google.com/store/apps/details?id=org.armorpaint"; +char *manifest_url_ios = "https://apps.apple.com/app/armorpaint/id1533967534"; +string_array_t *nodes_material_categories; +ui_node_t_array_t *nodes_material_input; +ui_node_t_array_t *nodes_material_texture; +ui_node_t_array_t *nodes_material_color; +ui_node_t_array_t *nodes_material_utilities; +ui_node_t_array_t *nodes_material_neural; +ui_node_t_array_t *nodes_material_group; +node_list_t_array_t *nodes_material_list = NULL; +i32 make_mesh_layer_pass_count = 1; +char *str_cotangent_frame = "\ fun cotangent_frame(n: float3, p: float3, tex_coord: float2): float3x3 { \ var duv1: float2 = ddx2(tex_coord); \ var duv2: float2 = ddy2(tex_coord); \ @@ -594,95 +385,46 @@ fun dither_bayer(uv: float2): float { \ i32 ui_sidebar_default_w_mini = 56; i32 ui_sidebar_default_w_full = 280; i32 ui_sidebar_default_w; -i32 ui_sidebar_tabx = 0; ui_handle_t *ui_sidebar_hminimized; i32 ui_sidebar_w_mini; -i32 ui_sidebar_last_tab = 0; char *console_message = ""; f32 console_message_timer = 0.0; i32 console_message_color = 0x00000000; string_array_t *console_last_traces; -char *console_progress_text = NULL; vec4_box_t_array_t *camera_origins; mat4_box_t_array_t *camera_views; -i32 camera_redraws = 0; vec4_t camera_dir; -f32 camera_ease = 1.0; -bool camera_controls_down = false; ui_handle_t *box_preferences_htab; string_array_t *box_preferences_files_plugin = NULL; -string_array_t *box_preferences_files_keymap = NULL; ui_handle_t *box_preferences_h_theme; ui_handle_t *box_preferences_h_preset; -string_array_t *box_preferences_locales = NULL; -string_array_t *box_preferences_themes = NULL; -char *_box_preferences_f; -ui_handle_t *_box_preferences_h; -i32 _box_preferences_i; slot_layer_t *render_path_paint_live_layer = NULL; i32 render_path_paint_live_layer_drawn = 0; bool render_path_paint_live_layer_locked = false; -bool render_path_paint_dilated = true; bool render_path_paint_push_undo_last; -mesh_object_t *render_path_paint_painto = NULL; -mesh_object_t *render_path_paint_planeo = NULL; -u8_array_t *render_path_paint_visibles = NULL; -bool render_path_paint_merged_object_visible = false; -f32 render_path_paint_saved_fov = 0.0; -bool render_path_paint_baking = false; -render_target_t *_render_path_paint_texpaint; -render_target_t *_render_path_paint_texpaint_nor; -render_target_t *_render_path_paint_texpaint_pack; -render_target_t *_render_path_paint_texpaint_undo; -render_target_t *_render_path_paint_texpaint_nor_undo; -render_target_t *_render_path_paint_texpaint_pack_undo; -f32 render_path_paint_last_x = -1.0; -f32 render_path_paint_last_y = -1.0; -bake_type_t _render_path_paint_bake_type; -f32 export_texture_gamma = 1.0 / 2.2; -bool ui_box_show = false; -bool ui_box_draggable = true; +bool ui_box_show = false; ui_handle_t *ui_box_hwnd; -char *ui_box_title = ""; -char *ui_box_text = ""; -void (*ui_box_commands)(void) = NULL; -bool ui_box_click_to_hide = true; -i32 ui_box_modalw = 400; -i32 ui_box_modalh = 170; -void (*ui_box_modal_on_hide)(void) = NULL; -i32 ui_box_draws = 0; -bool ui_box_copyable = false; -f32 ui_box_tween_alpha = 0.0; -i32 _tab_meshes_draw_i; -i32 tab_scene_line_counter = 0; -i32 _tab_scene_paint_object_length = 1; -i32 tab_layers_layer_name_edit = -1; -ui_handle_t *tab_layers_layer_name_handle; -bool tab_layers_show_context_menu = false; -slot_layer_t *tab_layers_l; -bool tab_layers_mini; -gpu_texture_t *util_uv_uvmap = NULL; -bool util_uv_uvmap_cached = false; -gpu_texture_t *util_uv_trianglemap = NULL; -bool util_uv_trianglemap_cached = false; -gpu_texture_t *util_uv_dilatemap = NULL; -bool util_uv_dilatemap_cached = false; -gpu_texture_t *util_uv_uvislandmap = NULL; -bool util_uv_uvislandmap_cached = false; -buffer_t *util_uv_dilate_bytes = NULL; -gpu_pipeline_t *util_uv_pipe_dilate = NULL; -i32 render_path_raytrace_frame = 0; -bool render_path_raytrace_ready = false; -i32 render_path_raytrace_dirty = 0; -f32 render_path_raytrace_uv_scale = 1.0; -bool render_path_raytrace_init_shader = true; -f32_array_t *render_path_raytrace_f32a; -mat4_t render_path_raytrace_help_mat; -mat4_t render_path_raytrace_transform; -gpu_buffer_t *render_path_raytrace_vb; -gpu_buffer_t *render_path_raytrace_ib; -gpu_texture_t *render_path_raytrace_last_envmap = NULL; -bool render_path_raytrace_is_bake = false; +bool ui_box_click_to_hide = true; +i32 ui_box_modalw = 400; +i32 ui_box_modalh = 170; +i32 _tab_scene_paint_object_length = 1; +ui_handle_t *tab_layers_layer_name_handle; +gpu_texture_t *util_uv_uvmap = NULL; +bool util_uv_uvmap_cached = false; +gpu_texture_t *util_uv_trianglemap = NULL; +bool util_uv_trianglemap_cached = false; +gpu_texture_t *util_uv_dilatemap = NULL; +bool util_uv_dilatemap_cached = false; +gpu_texture_t *util_uv_uvislandmap = NULL; +bool util_uv_uvislandmap_cached = false; +i32 render_path_raytrace_frame = 0; +bool render_path_raytrace_ready = false; +i32 render_path_raytrace_dirty = 0; +bool render_path_raytrace_init_shader = true; +f32_array_t *render_path_raytrace_f32a; +mat4_t render_path_raytrace_help_mat; +gpu_texture_t *render_path_raytrace_last_envmap = NULL; +bool render_path_raytrace_is_bake = false; #ifdef IRON_DIRECT3D12 char *render_path_raytrace_ext = ".cso"; @@ -692,44 +434,15 @@ char *render_path_raytrace_ext = ".metal"; char *render_path_raytrace_ext = ".spirv"; #endif -gpu_texture_t *render_path_raytrace_last_texpaint = NULL; -bool sculpt_push_undo = false; -i32 ui_statusbar_default_h = 33; -i32 ui_statusbar_last_tab = 0; -gpu_pipeline_t *import_envmap_pipeline = NULL; -i32 import_envmap_params_loc; -vec4_t import_envmap_params; -vec4_t import_envmap_n; -i32 import_envmap_radiance_loc; -gpu_texture_t *import_envmap_radiance = NULL; -i32 import_envmap_noise_loc; -gpu_texture_t_array_t *import_envmap_mips = NULL; -ui_node_t *image_texture_node_def; -ui_node_t *material_node_def; -ui_node_t *uv_map_node_def; -ui_node_t *wave_texture_node_def; -ui_node_t *clamp_node_def; -char *parser_material_bake_passthrough_strength = "0.0"; -char *parser_material_bake_passthrough_radius = "0.0"; -char *parser_material_bake_passthrough_offset = "0.0"; -ui_node_t *curvature_bake_node_def; -ui_node_t *blur_node_def; -ui_node_t *text_texture_node_def; -ui_node_t *gradient_texture_node_def; -ui_node_t *object_info_node_def; -ui_node_t *magic_texture_node_def; -ui_node_t *warp_node_def; -ui_node_t *normal_node_def; -ui_node_t *mapping_node_def; -ui_node_t *normal_map_node_def; -ui_node_t *invert_color_node_def; -ui_node_t *wireframe_node_def; -ui_node_t *gamma_node_def; -ui_node_t *vector_math2_node_def; -ui_node_t *vector_rotate_node_def; -ui_node_t *vector_transform_node_def; -ui_node_t *checker_texture_node_def; -char *str_hue_sat = "\ +bool sculpt_push_undo = false; +i32 ui_statusbar_default_h = 33; +vec4_t import_envmap_params; +vec4_t import_envmap_n; +char *parser_material_bake_passthrough_strength = "0.0"; +char *parser_material_bake_passthrough_radius = "0.0"; +char *parser_material_bake_passthrough_offset = "0.0"; + +char *str_hue_sat = "\ fun hsv_to_rgb(c: float3): float3 { \ var K: float4 = float4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); \ var p: float3 = abs3(frac3(c.xxx + K.xyz) * 6.0 - K.www); \ @@ -751,92 +464,17 @@ fun hue_sat(col: float3, shift: float4): float3 { \ return lerp3(hsv_to_rgb(hsv), col, shift.w); \ } \ "; -ui_node_t *hue_saturation_value_node_def; -ui_node_t *separate_color_node_def; -ui_node_t *separate_xyz_node_def; -ui_node_t *math2_node_def; -ui_node_t *geometry_node_def; -ui_node_t *mix_color_node_def; -ui_node_t *quantize_node_def; -ui_node_t *layer_node_def; -ui_node_t *float_curve_node_def; -ui_node_t *map_range_node_def; -ui_node_t *voronoi_texture_node_def; -ui_node_t *color_ramp_node_def; -ui_node_t *picker_node_def; -ui_node_t *replace_color_node_def; -ui_node_t *bump_node_def; -ui_node_t *gabor_texture_node_def; -ui_node_t *mix_normal_map_node_def; -ui_node_t *script_node_def; -ui_node_t *combine_color_node_def; -ui_node_t *combine_xyz_node_def; -ui_node_t *noise_texture_node_def; -char *str_brightcontrast = "\ + +char *str_brightcontrast = "\ fun brightcontrast(col: float3, bright: float, contr: float): float3 { \ var a: float = 1.0 + contr; \ var b: float = bright - contr * 0.5; \ return max3(a * col + b, float3(0.0, 0.0, 0.0)); \ } \ "; -ui_node_t *brightness_contrast_node_def; -ui_node_t *color_mask_node_def; -ui_node_t *rgb_curves_node_def; -ui_node_t *vector_curves_node_def; -ui_node_t *layer_mask_node_def; -ui_node_t *camera_texture_node_def; -ui_node_t *value_node_def; -ui_node_t *texture_coordinate_node_def; -ui_nodes_t *_nodes_material_nodes; -ui_node_t *_nodes_material_node; -ui_node_socket_t_array_t *_nodes_material_sockets; -ui_node_t *group_node_def; -ui_node_t *brick_texture_node_def; -ui_node_t *rgb_node_def; -ui_node_t *rgb_to_bw_node_def; -ui_node_t *attribute_node_def; -ui_node_t *shader_node_def; -ui_node_t *upscale_image_node_def; -gpu_texture_t *image_to_pbr_node_result_base = NULL; -gpu_texture_t *image_to_pbr_node_result_normal = NULL; -gpu_texture_t *image_to_pbr_node_result_occlusion = NULL; -gpu_texture_t *image_to_pbr_node_result_height = NULL; -gpu_texture_t *image_to_pbr_node_result_roughness = NULL; -gpu_texture_t *image_to_pbr_node_result_metallic = NULL; -ui_node_t *image_to_pbr_node_def; -ui_node_t *inpaint_image_node_def; -ui_node_t *text_to_image_node_def; -ui_node_t *outpaint_image_node_def; + any_imap_t *neural_node_results; ui_node_t *neural_node_current; i32 neural_node_downloading = 0; neural_node_model_t_array_t *neural_node_models = NULL; -ui_node_t *edit_image_node_def; -ui_node_t *tile_image_node_def; -ui_node_t *image_to_3d_mesh_node_def; -ui_node_t *vary_image_node_def; -ui_node_t *image_to_normal_map_node_def; -ui_node_t *image_to_depth_node_def; -ui_node_t *tex_image_node_def; -i32 random_node_a; -i32 random_node_b; -i32 random_node_c; -i32 random_node_d = -1; -ui_node_t *random_node_def; vec4_t input_node_coords; -f32 input_node_start_x = 0.0; -f32 input_node_start_y = 0.0; -// Brush ruler -bool input_node_lock_begin = false; -bool input_node_lock_x = false; -bool input_node_lock_y = false; -f32 input_node_lock_start_x = 0.0; -f32 input_node_lock_start_y = 0.0; -bool input_node_registered = false; -ui_node_t *input_node_def; -ui_node_t *math_node_def; -ui_node_t *vector_node_def; -ui_node_t *time_node_def; -ui_node_t *vector_math_node_def; -ui_node_t *float_node_def; -ui_node_t *separate_vector_node_def; diff --git a/paint/sources/import_arm.c b/paint/sources/import_arm.c index 5ade7dbf..e13ab29d 100644 --- a/paint/sources/import_arm.c +++ b/paint/sources/import_arm.c @@ -1,6 +1,8 @@ #include "global.h" +scene_t *scene_raw_gc; + void import_arm_run_project_on_next_frame(void *_) { // Once envmap is imported scene_world->strength = project_raw->envmap_strength; diff --git a/paint/sources/import_asset.c b/paint/sources/import_asset.c index 6a39bc0c..c1d37c34 100644 --- a/paint/sources/import_asset.c +++ b/paint/sources/import_asset.c @@ -1,6 +1,12 @@ #include "global.h" +f32 _import_asset_drop_x; +f32 _import_asset_drop_y; +bool _import_asset_show_box; +bool _import_asset_hdr_as_envmap; +void (*_import_asset_done)(void); + void import_asset_run_cache_cloud_done(char *abs) { if (abs == NULL) { return; @@ -10,11 +16,11 @@ void import_asset_run_cache_cloud_done(char *abs) { void import_asset_run(char *path, f32 drop_x, f32 drop_y, bool show_box, bool hdr_as_envmap, void (*done)(void)) { if (starts_with(path, "cloud")) { - #ifdef IRON_ANDROID +#ifdef IRON_ANDROID console_toast(tr("Downloading")); - #else +#else console_info(tr("Downloading")); - #endif +#endif _import_asset_drop_x = drop_x; _import_asset_drop_y = drop_y; diff --git a/paint/sources/import_blend_material.c b/paint/sources/import_blend_material.c index 3bac194d..595f0471 100644 --- a/paint/sources/import_blend_material.c +++ b/paint/sources/import_blend_material.c @@ -1,6 +1,8 @@ #include "global.h" +char *_import_blend_material_path; + void _import_blend_material_on_next_frame(void *_) { char *save; if (path_is_protected()) { diff --git a/paint/sources/import_envmap.c b/paint/sources/import_envmap.c index be1b882d..6b2e2a40 100644 --- a/paint/sources/import_envmap.c +++ b/paint/sources/import_envmap.c @@ -1,14 +1,21 @@ #include "global.h" +gpu_pipeline_t *import_envmap_pipeline = NULL; +i32 import_envmap_params_loc; +i32 import_envmap_radiance_loc; +gpu_texture_t *import_envmap_radiance = NULL; +i32 import_envmap_noise_loc; +gpu_texture_t_array_t *import_envmap_mips = NULL; + void import_envmap_get_radiance_mip(gpu_texture_t *mip, i32 level, gpu_texture_t *radiance) { - #ifdef IRON_METAL +#ifdef IRON_METAL i32 pass_count = 8; // 32; import_envmap_params.y = 512; - #else +#else i32 pass_count = 1; import_envmap_params.y = 1024 * 16; - #endif +#endif import_envmap_params.z = 1.0 / (float)pass_count; import_envmap_params.x = (level + 1) / 10.0; @@ -28,8 +35,8 @@ void import_envmap_get_radiance_mip(gpu_texture_t *mip, i32 level, gpu_texture_t } vec4_t import_envmap_reverse_equirect(f32 x, f32 y) { - f32 theta = x * math_pi() * 2 - math_pi(); - f32 phi = y * math_pi(); + f32 theta = x * math_pi() * 2 - math_pi(); + f32 phi = y * math_pi(); // return n.set(math_sin(phi) * math_cos(theta), -(math_sin(phi) * math_sin(theta)), math_cos(phi)); import_envmap_n = vec4_create(-math_cos(phi), math_sin(phi) * math_cos(theta), -(math_sin(phi) * math_sin(theta)), 1.0); return import_envmap_n; @@ -91,9 +98,9 @@ void import_envmap_run(char *path, gpu_texture_t *image) { import_envmap_pipeline->blend_destination = GPU_BLEND_ONE; gpu_vertex_structure_t *vs = GC_ALLOC_INIT(gpu_vertex_structure_t, {0}); gpu_vertex_struct_add(vs, "pos", GPU_VERTEX_DATA_F32_2X); - import_envmap_pipeline->input_layout = vs; - import_envmap_pipeline->color_attachment_count = 1; - import_envmap_pipeline->color_attachment[0] = GPU_TEXTURE_FORMAT_RGBA64; + import_envmap_pipeline->input_layout = vs; + import_envmap_pipeline->color_attachment_count = 1; + import_envmap_pipeline->color_attachment[0] = GPU_TEXTURE_FORMAT_RGBA64; gpu_pipeline_compile(import_envmap_pipeline); import_envmap_params_loc = 0; @@ -127,8 +134,8 @@ void import_envmap_run(char *path, gpu_texture_t *image) { } // Irradiance - buffer_t *radiance_pixels = gpu_get_texture_pixels(import_envmap_radiance); - scene_world->_->irradiance = import_envmap_get_spherical_harmonics(radiance_pixels, import_envmap_radiance->width, import_envmap_radiance->height); + buffer_t *radiance_pixels = gpu_get_texture_pixels(import_envmap_radiance); + scene_world->_->irradiance = import_envmap_get_spherical_harmonics(radiance_pixels, import_envmap_radiance->width, import_envmap_radiance->height); // World scene_world->strength = 1.0; diff --git a/paint/sources/import_mesh.c b/paint/sources/import_mesh.c index b4a5c921..2c662e84 100644 --- a/paint/sources/import_mesh.c +++ b/paint/sources/import_mesh.c @@ -1,6 +1,9 @@ #include "global.h" +bool import_mesh_clear_layers = true; +any_array_t *import_mesh_meshes_to_unwrap = NULL; + void import_mesh_run(char *path, bool _clear_layers, bool replace_existing) { if (!path_is_mesh(path)) { if (!context_enable_import_plugin(path)) { diff --git a/paint/sources/import_texture.c b/paint/sources/import_texture.c index 5cedd202..077a76f3 100644 --- a/paint/sources/import_texture.c +++ b/paint/sources/import_texture.c @@ -1,6 +1,11 @@ #include "global.h" +typedef struct import_texture_data { + char *path; + struct gpu_texture *image; +} import_texture_data_t; + gpu_texture_t *import_texture_default_importer(char *path) { return data_get_image(path); } diff --git a/paint/sources/kickstart.c b/paint/sources/kickstart.c index 3166e979..993c7ef4 100644 --- a/paint/sources/kickstart.c +++ b/paint/sources/kickstart.c @@ -158,7 +158,6 @@ void _kickstart() { ui_menubar_tab = ui_handle_create(); gc_root(ui_menubar_tab); ui_menubar_w = ui_menubar_default_w; - _ui_menubar_saved_camera = mat4_nan(); translator_translations = any_map_create(); gc_root(translator_translations); @@ -338,532 +337,6 @@ void _kickstart() { gc_root(neural_node_results); input_node_coords = vec4_create(0.0, 0.0, 0.0, 1.0); - - 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}); - gc_root(tex_image_node_def); - - 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}); - gc_root(random_node_def); - - 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}); - gc_root(input_node_def); - - 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}); - gc_root(math_node_def); - - 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}); - gc_root(vector_node_def); - - 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}); - gc_root(time_node_def); - - 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}); - gc_root(vector_math_node_def); - - 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}); - gc_root(float_node_def); - - 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_root(separate_vector_node_def); - sys_on_resize = base_on_resize; sys_on_w = base_w; sys_on_h = base_h; diff --git a/paint/sources/make_material.c b/paint/sources/make_material.c index 60791122..00d44530 100644 --- a/paint/sources/make_material.c +++ b/paint/sources/make_material.c @@ -1,6 +1,9 @@ #include "global.h" +shader_context_t *make_material_default_scon = NULL; +material_context_t *make_material_default_mcon = NULL; + bool make_material_get_mout() { for (i32 i = 0; i < context_raw->material->canvas->nodes->length; ++i) { ui_node_t *n = context_raw->material->canvas->nodes->buffer[i]; diff --git a/paint/sources/material_nodes/attribute_node.c b/paint/sources/material_nodes/attribute_node.c index 43eebacd..24681650 100644 --- a/paint/sources/material_nodes/attribute_node.c +++ b/paint/sources/material_nodes/attribute_node.c @@ -24,73 +24,73 @@ char *attribute_node_value(ui_node_t *node, ui_node_socket_t *socket) { void attribute_node_init() { - attribute_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, - .name = _tr("Attribute"), - .type = "ATTRIBUTE", - .x = 0, - .y = 0, - .color = 0xffb34f5a, - .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("Color"), - .type = "RGBA", - .color = 0xffc7c729, - .default_value = f32_array_create_xyzw(0.8, 0.8, 0.8, 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("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("Factor"), - .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("Alpha"), - .type = "VALUE", - .color = 0xffa1a1a1, - .default_value = f32_array_create_x(0.0), - .min = 0.0, - .max = 1.0, - .precision = 100, - .display = 0}), - }, - 4), - .buttons = any_array_create_from_raw( - (void *[]){ - GC_ALLOC_INIT(ui_node_button_t, {.name = _tr("Name"), - .type = "STRING", - .output = -1, - .default_value = f32_array_create_x(0), - .data = NULL, - .min = 0.0, - .max = 1.0, - .precision = 100, - .height = 0}), - }, - 1), - .width = 0, - .flags = 0}); - gc_root(attribute_node_def); + ui_node_t *attribute_node_def = + GC_ALLOC_INIT(ui_node_t, {.id = 0, + .name = _tr("Attribute"), + .type = "ATTRIBUTE", + .x = 0, + .y = 0, + .color = 0xffb34f5a, + .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("Color"), + .type = "RGBA", + .color = 0xffc7c729, + .default_value = f32_array_create_xyzw(0.8, 0.8, 0.8, 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("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("Factor"), + .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("Alpha"), + .type = "VALUE", + .color = 0xffa1a1a1, + .default_value = f32_array_create_x(0.0), + .min = 0.0, + .max = 1.0, + .precision = 100, + .display = 0}), + }, + 4), + .buttons = any_array_create_from_raw( + (void *[]){ + GC_ALLOC_INIT(ui_node_button_t, {.name = _tr("Name"), + .type = "STRING", + .output = -1, + .default_value = f32_array_create_x(0), + .data = NULL, + .min = 0.0, + .max = 1.0, + .precision = 100, + .height = 0}), + }, + 1), + .width = 0, + .flags = 0}); any_array_push(nodes_material_input, attribute_node_def); any_map_set(parser_material_node_vectors, "ATTRIBUTE", attribute_node_vector); diff --git a/paint/sources/material_nodes/blur_node.c b/paint/sources/material_nodes/blur_node.c index 27494fef..60a48baa 100644 --- a/paint/sources/material_nodes/blur_node.c +++ b/paint/sources/material_nodes/blur_node.c @@ -25,54 +25,53 @@ char *blur_node_vector(ui_node_t *node, ui_node_socket_t *socket) { void blur_node_init() { - blur_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, - .name = _tr("Blur"), - .type = "BLUR", // extension - .x = 0, - .y = 0, - .color = 0xff448c6d, - .inputs = any_array_create_from_raw( - (void *[]){ - GC_ALLOC_INIT(ui_node_socket_t, {.id = 0, - .node_id = 0, - .name = _tr("Color"), - .type = "RGBA", - .color = 0xffc7c729, - .default_value = f32_array_create_xyzw(0.8, 0.8, 0.8, 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("Strength"), - .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("Color"), - .type = "RGBA", - .color = 0xffc7c729, - .default_value = f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0), - .min = 0.0, - .max = 1.0, - .precision = 100, - .display = 0}), - }, - 1), - .buttons = any_array_create_from_raw((void *[]){}, 0), - .width = 0, - .flags = 0}); - gc_root(blur_node_def); + ui_node_t *blur_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, + .name = _tr("Blur"), + .type = "BLUR", // extension + .x = 0, + .y = 0, + .color = 0xff448c6d, + .inputs = any_array_create_from_raw( + (void *[]){ + GC_ALLOC_INIT(ui_node_socket_t, {.id = 0, + .node_id = 0, + .name = _tr("Color"), + .type = "RGBA", + .color = 0xffc7c729, + .default_value = f32_array_create_xyzw(0.8, 0.8, 0.8, 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("Strength"), + .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("Color"), + .type = "RGBA", + .color = 0xffc7c729, + .default_value = f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0), + .min = 0.0, + .max = 1.0, + .precision = 100, + .display = 0}), + }, + 1), + .buttons = any_array_create_from_raw((void *[]){}, 0), + .width = 0, + .flags = 0}); any_array_push(nodes_material_color, blur_node_def); any_map_set(parser_material_node_vectors, "BLUR", blur_node_vector); diff --git a/paint/sources/material_nodes/brick_texture_node.c b/paint/sources/material_nodes/brick_texture_node.c index 0babbc22..fcb000da 100644 --- a/paint/sources/material_nodes/brick_texture_node.c +++ b/paint/sources/material_nodes/brick_texture_node.c @@ -88,7 +88,7 @@ char *brick_texture_node_value(ui_node_t *node, ui_node_socket_t *socket) { void brick_texture_node_init() { - brick_texture_node_def = + ui_node_t *brick_texture_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, .name = _tr("Brick Texture"), .type = "TEX_BRICK", @@ -266,7 +266,6 @@ void brick_texture_node_init() { .buttons = any_array_create_from_raw((void *[]){}, 0), .width = 0, .flags = 0}); - gc_root(brick_texture_node_def); any_array_push(nodes_material_texture, brick_texture_node_def); any_map_set(parser_material_node_vectors, "TEX_BRICK", brick_texture_node_vector); diff --git a/paint/sources/material_nodes/brightness_contrast_node.c b/paint/sources/material_nodes/brightness_contrast_node.c index aebec2b9..6b8c1101 100644 --- a/paint/sources/material_nodes/brightness_contrast_node.c +++ b/paint/sources/material_nodes/brightness_contrast_node.c @@ -11,7 +11,7 @@ char *brightness_contrast_node_vector(ui_node_t *node, ui_node_socket_t *socket) void brightness_contrast_node_init() { - brightness_contrast_node_def = + ui_node_t *brightness_contrast_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, .name = _tr("Brightness/Contrast"), .type = "BRIGHTCONTRAST", @@ -69,7 +69,6 @@ void brightness_contrast_node_init() { .buttons = any_array_create_from_raw((void *[]){}, 0), .width = 0, .flags = 0}); - gc_root(brightness_contrast_node_def); any_array_push(nodes_material_color, brightness_contrast_node_def); any_map_set(parser_material_node_vectors, "BRIGHTCONTRAST", brightness_contrast_node_vector); diff --git a/paint/sources/material_nodes/bump_node.c b/paint/sources/material_nodes/bump_node.c index 9fbefbcb..240d2a29 100644 --- a/paint/sources/material_nodes/bump_node.c +++ b/paint/sources/material_nodes/bump_node.c @@ -16,82 +16,79 @@ char *bump_node_vector(ui_node_t *node, ui_node_socket_t *socket) { void bump_node_init() { - bump_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, - .name = _tr("Bump"), - .type = "BUMP", - .x = 0, - .y = 0, - .color = 0xff522c99, - .inputs = any_array_create_from_raw( - (void *[]){ - GC_ALLOC_INIT(ui_node_socket_t, {.id = 0, - .node_id = 0, - .name = _tr("Strength"), - .type = "VALUE", - .color = 0xffa1a1a1, - .default_value = f32_array_create_x(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("Distance"), - .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("Height"), - .type = "VALUE", - .color = 0xffa1a1a1, - .default_value = f32_array_create_x(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("Normal"), - .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}), - }, - 4), - .outputs = any_array_create_from_raw( - (void *[]){ - GC_ALLOC_INIT(ui_node_socket_t, {.id = 0, - .node_id = 0, - .name = _tr("Normal Map"), - .type = "VECTOR", - .color = -10238109, - .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 *[]){ - GC_ALLOC_INIT(ui_node_button_t, {.name = _tr("Invert"), - .type = "BOOL", - .output = 0, - .default_value = f32_array_create_x(0), - .height = 0}), - }, - 1), - .width = 0, - .flags = 0}); - gc_root(bump_node_def); + ui_node_t *bump_node_def = GC_ALLOC_INIT( + ui_node_t, + {.id = 0, + .name = _tr("Bump"), + .type = "BUMP", + .x = 0, + .y = 0, + .color = 0xff522c99, + .inputs = any_array_create_from_raw( + (void *[]){ + GC_ALLOC_INIT(ui_node_socket_t, {.id = 0, + .node_id = 0, + .name = _tr("Strength"), + .type = "VALUE", + .color = 0xffa1a1a1, + .default_value = f32_array_create_x(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("Distance"), + .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("Height"), + .type = "VALUE", + .color = 0xffa1a1a1, + .default_value = f32_array_create_x(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("Normal"), + .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}), + }, + 4), + .outputs = any_array_create_from_raw( + (void *[]){ + GC_ALLOC_INIT(ui_node_socket_t, {.id = 0, + .node_id = 0, + .name = _tr("Normal Map"), + .type = "VECTOR", + .color = -10238109, + .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 *[]){ + GC_ALLOC_INIT(ui_node_button_t, {.name = _tr("Invert"), .type = "BOOL", .output = 0, .default_value = f32_array_create_x(0), .height = 0}), + }, + 1), + .width = 0, + .flags = 0}); any_array_push(nodes_material_utilities, bump_node_def); any_map_set(parser_material_node_vectors, "BUMP", bump_node_vector); diff --git a/paint/sources/material_nodes/camera_texture_node.c b/paint/sources/material_nodes/camera_texture_node.c index 4ff2dece..6673d318 100644 --- a/paint/sources/material_nodes/camera_texture_node.c +++ b/paint/sources/material_nodes/camera_texture_node.c @@ -11,31 +11,31 @@ char *camera_texture_node_vector(ui_node_t *node, ui_node_socket_t *socket) { void camera_texture_node_init() { - camera_texture_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, - .name = _tr("Camera Texture"), - .type = "TEX_CAMERA", // extension - .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("Color"), - .type = "RGBA", - .color = 0xffc7c729, - .default_value = f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0), - .min = 0.0, - .max = 1.0, - .precision = 100, - .display = 0}), - }, - 1), - .buttons = any_array_create_from_raw((void *[]){}, 0), - .width = 0, - .flags = 0}); - gc_root(camera_texture_node_def); + ui_node_t *camera_texture_node_def = + GC_ALLOC_INIT(ui_node_t, {.id = 0, + .name = _tr("Camera Texture"), + .type = "TEX_CAMERA", // extension + .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("Color"), + .type = "RGBA", + .color = 0xffc7c729, + .default_value = f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0), + .min = 0.0, + .max = 1.0, + .precision = 100, + .display = 0}), + }, + 1), + .buttons = any_array_create_from_raw((void *[]){}, 0), + .width = 0, + .flags = 0}); any_array_push(nodes_material_texture, camera_texture_node_def); any_map_set(parser_material_node_vectors, "TEX_CAMERA", camera_texture_node_vector); diff --git a/paint/sources/material_nodes/checker_texture_node.c b/paint/sources/material_nodes/checker_texture_node.c index da2297c9..2fe1f122 100644 --- a/paint/sources/material_nodes/checker_texture_node.c +++ b/paint/sources/material_nodes/checker_texture_node.c @@ -1,7 +1,7 @@ #include "../global.h" -char *str_tex_checker = "\ +char *str_tex_checker = "\ fun tex_checker(co: float3, col1: float3, col2: float3, scale: float): float3 { \ /* Prevent precision issues on unit coordinates */ \ var p: float3 = (co + 0.000001 * 0.999999) * scale; \ @@ -48,7 +48,7 @@ char *checker_texture_node_value(ui_node_t *node, ui_node_socket_t *socket) { void checker_texture_node_init() { - checker_texture_node_def = + ui_node_t *checker_texture_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, .name = _tr("Checker Texture"), .type = "TEX_CHECKER", @@ -126,7 +126,6 @@ void checker_texture_node_init() { .buttons = any_array_create_from_raw((void *[]){}, 0), .width = 0, .flags = 0}); - gc_root(checker_texture_node_def); any_array_push(nodes_material_texture, checker_texture_node_def); any_map_set(parser_material_node_vectors, "TEX_CHECKER", checker_texture_node_vector); diff --git a/paint/sources/material_nodes/clamp_node.c b/paint/sources/material_nodes/clamp_node.c index 5227cb5f..b38b79f6 100644 --- a/paint/sources/material_nodes/clamp_node.c +++ b/paint/sources/material_nodes/clamp_node.c @@ -18,77 +18,77 @@ char *clamp_node_value(ui_node_t *node, ui_node_socket_t *socket) { void clamp_node_init() { - char *clamp_operation_data = string("%s\n%s", _tr("Min Max"), _tr("Range")); - clamp_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, - .name = _tr("Clamp"), - .type = "CLAMP", - .x = 0, - .y = 0, - .color = 0xff62676d, - .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("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}), - }, - 3), - .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(clamp_operation_data), - .min = 0.0, - .max = 1.0, - .precision = 100, - .height = 0}), - }, - 1), - .width = 0, - .flags = 0}); - gc_root(clamp_node_def); + char *clamp_operation_data = string("%s\n%s", _tr("Min Max"), _tr("Range")); + ui_node_t *clamp_node_def = + GC_ALLOC_INIT(ui_node_t, {.id = 0, + .name = _tr("Clamp"), + .type = "CLAMP", + .x = 0, + .y = 0, + .color = 0xff62676d, + .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("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}), + }, + 3), + .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(clamp_operation_data), + .min = 0.0, + .max = 1.0, + .precision = 100, + .height = 0}), + }, + 1), + .width = 0, + .flags = 0}); any_array_push(nodes_material_utilities, clamp_node_def); any_map_set(parser_material_node_values, "CLAMP", clamp_node_value); diff --git a/paint/sources/material_nodes/color_mask_node.c b/paint/sources/material_nodes/color_mask_node.c index 3777c8e7..02265a37 100644 --- a/paint/sources/material_nodes/color_mask_node.c +++ b/paint/sources/material_nodes/color_mask_node.c @@ -12,7 +12,7 @@ char *color_mask_node_value(ui_node_t *node, ui_node_socket_t *socket) { void color_mask_node_init() { - color_mask_node_def = + ui_node_t *color_mask_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, .name = _tr("Color Mask"), .type = "COLMASK", // extension @@ -80,7 +80,6 @@ void color_mask_node_init() { .buttons = any_array_create_from_raw((void *[]){}, 0), .width = 0, .flags = 0}); - gc_root(color_mask_node_def); any_array_push(nodes_material_color, color_mask_node_def); any_map_set(parser_material_node_values, "COLMASK", color_mask_node_value); diff --git a/paint/sources/material_nodes/color_ramp_node.c b/paint/sources/material_nodes/color_ramp_node.c index 74ff06f3..4ee9b927 100644 --- a/paint/sources/material_nodes/color_ramp_node.c +++ b/paint/sources/material_nodes/color_ramp_node.c @@ -242,7 +242,7 @@ void nodes_material_color_ramp_button(i32 node_id) { void color_ramp_node_init() { - color_ramp_node_def = GC_ALLOC_INIT( + ui_node_t *color_ramp_node_def = GC_ALLOC_INIT( ui_node_t, {.id = 0, .name = _tr("Color Ramp"), @@ -303,7 +303,6 @@ void color_ramp_node_init() { 1), .width = 0, .flags = 0}); - gc_root(color_ramp_node_def); any_array_push(nodes_material_color, color_ramp_node_def); any_map_set(parser_material_node_vectors, "VALTORGB", color_ramp_node_vector); diff --git a/paint/sources/material_nodes/combine_color_node.c b/paint/sources/material_nodes/combine_color_node.c index b2783ae1..f1c2281c 100644 --- a/paint/sources/material_nodes/combine_color_node.c +++ b/paint/sources/material_nodes/combine_color_node.c @@ -10,7 +10,7 @@ char *combine_color_node_vector(ui_node_t *node, ui_node_socket_t *socket) { void combine_color_node_init() { - combine_color_node_def = + ui_node_t *combine_color_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, .name = _tr("Combine Color"), .type = "COMBINE_COLOR", @@ -68,7 +68,6 @@ void combine_color_node_init() { .buttons = any_array_create_from_raw((void *[]){}, 0), .width = 0, .flags = 0}); - gc_root(combine_color_node_def); any_array_push(nodes_material_color, combine_color_node_def); any_map_set(parser_material_node_vectors, "COMBINE_COLOR", combine_color_node_vector); diff --git a/paint/sources/material_nodes/combine_xyz_node.c b/paint/sources/material_nodes/combine_xyz_node.c index 9e2ef6a0..f434a2f1 100644 --- a/paint/sources/material_nodes/combine_xyz_node.c +++ b/paint/sources/material_nodes/combine_xyz_node.c @@ -10,65 +10,63 @@ char *combine_xyz_node_vector(ui_node_t *node, ui_node_socket_t *socket) { void combine_xyz_node_init() { - combine_xyz_node_def = - GC_ALLOC_INIT(ui_node_t, {.id = 0, - .name = _tr("Combine XYZ"), - .type = "COMBXYZ", - .x = 0, - .y = 0, - .color = 0xff62676d, - .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}); - gc_root(combine_xyz_node_def); + ui_node_t *combine_xyz_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, + .name = _tr("Combine XYZ"), + .type = "COMBXYZ", + .x = 0, + .y = 0, + .color = 0xff62676d, + .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}); any_array_push(nodes_material_utilities, combine_xyz_node_def); any_map_set(parser_material_node_vectors, "COMBXYZ", combine_xyz_node_vector); diff --git a/paint/sources/material_nodes/curvature_bake_node.c b/paint/sources/material_nodes/curvature_bake_node.c index f32b534a..281d0082 100644 --- a/paint/sources/material_nodes/curvature_bake_node.c +++ b/paint/sources/material_nodes/curvature_bake_node.c @@ -23,7 +23,7 @@ char *curvature_bake_node_value(ui_node_t *node, ui_node_socket_t *socket) { void curvature_bake_node_init() { - curvature_bake_node_def = + ui_node_t *curvature_bake_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, .name = _tr("Curvature Texture"), .type = "BAKE_CURVATURE", // extension @@ -81,7 +81,6 @@ void curvature_bake_node_init() { .buttons = any_array_create_from_raw((void *[]){}, 0), .width = 0, .flags = 0}); - gc_root(curvature_bake_node_def); any_array_push(nodes_material_texture, curvature_bake_node_def); any_map_set(parser_material_node_values, "BAKE_CURVATURE", curvature_bake_node_value); diff --git a/paint/sources/material_nodes/float_curve_node.c b/paint/sources/material_nodes/float_curve_node.c index 18791d32..8a4a7f10 100644 --- a/paint/sources/material_nodes/float_curve_node.c +++ b/paint/sources/material_nodes/float_curve_node.c @@ -112,7 +112,7 @@ void nodes_material_float_curve_button(i32 node_id) { void float_curve_node_init() { - float_curve_node_def = + ui_node_t *float_curve_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, .name = _tr("Float Curve"), .type = "FLOAT_CURVE", @@ -172,7 +172,6 @@ void float_curve_node_init() { 1), .width = 0, .flags = 0}); - gc_root(float_curve_node_def); any_array_push(nodes_material_utilities, float_curve_node_def); any_map_set(parser_material_node_values, "FLOAT_CURVE", float_curve_node_value); diff --git a/paint/sources/material_nodes/gabor_texture_node.c b/paint/sources/material_nodes/gabor_texture_node.c index 70410e29..fe034343 100644 --- a/paint/sources/material_nodes/gabor_texture_node.c +++ b/paint/sources/material_nodes/gabor_texture_node.c @@ -135,8 +135,8 @@ char *gabor_texture_node_value(ui_node_t *node, ui_node_socket_t *socket) { void gabor_texture_node_init() { - char *gabor_dimensions_data = string("%s\n%s", _tr("2D"), _tr("3D")); - gabor_texture_node_def = + char *gabor_dimensions_data = string("%s\n%s", _tr("2D"), _tr("3D")); + ui_node_t *gabor_texture_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, .name = _tr("Gabor Texture"), .type = "TEX_GABOR", @@ -256,7 +256,6 @@ void gabor_texture_node_init() { 1), .width = 0, .flags = 0}); - gc_root(gabor_texture_node_def); any_array_push(nodes_material_texture, gabor_texture_node_def); any_map_set(parser_material_node_values, "TEX_GABOR", gabor_texture_node_value); diff --git a/paint/sources/material_nodes/gamma_node.c b/paint/sources/material_nodes/gamma_node.c index 848d7bf7..b458de71 100644 --- a/paint/sources/material_nodes/gamma_node.c +++ b/paint/sources/material_nodes/gamma_node.c @@ -9,54 +9,53 @@ char *gamma_node_vector(ui_node_t *node, ui_node_socket_t *socket) { void gamma_node_init() { - gamma_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, - .name = _tr("Gamma"), - .type = "GAMMA", - .x = 0, - .y = 0, - .color = 0xff448c6d, - .inputs = any_array_create_from_raw( - (void *[]){ - GC_ALLOC_INIT(ui_node_socket_t, {.id = 0, - .node_id = 0, - .name = _tr("Color"), - .type = "RGBA", - .color = 0xffc7c729, - .default_value = f32_array_create_xyzw(0.8, 0.8, 0.8, 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("Gamma"), - .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("Color"), - .type = "RGBA", - .color = 0xffc7c729, - .default_value = f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0), - .min = 0.0, - .max = 1.0, - .precision = 100, - .display = 0}), - }, - 1), - .buttons = any_array_create_from_raw((void *[]){}, 0), - .width = 0, - .flags = 0}); - gc_root(gamma_node_def); + ui_node_t *gamma_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, + .name = _tr("Gamma"), + .type = "GAMMA", + .x = 0, + .y = 0, + .color = 0xff448c6d, + .inputs = any_array_create_from_raw( + (void *[]){ + GC_ALLOC_INIT(ui_node_socket_t, {.id = 0, + .node_id = 0, + .name = _tr("Color"), + .type = "RGBA", + .color = 0xffc7c729, + .default_value = f32_array_create_xyzw(0.8, 0.8, 0.8, 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("Gamma"), + .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("Color"), + .type = "RGBA", + .color = 0xffc7c729, + .default_value = f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0), + .min = 0.0, + .max = 1.0, + .precision = 100, + .display = 0}), + }, + 1), + .buttons = any_array_create_from_raw((void *[]){}, 0), + .width = 0, + .flags = 0}); any_array_push(nodes_material_color, gamma_node_def); any_map_set(parser_material_node_vectors, "GAMMA", gamma_node_vector); diff --git a/paint/sources/material_nodes/geometry_node.c b/paint/sources/material_nodes/geometry_node.c index c1db0dbb..e84c9d93 100644 --- a/paint/sources/material_nodes/geometry_node.c +++ b/paint/sources/material_nodes/geometry_node.c @@ -44,81 +44,80 @@ char *geometry_node_value(ui_node_t *node, ui_node_socket_t *socket) { void geometry_node_init() { - geometry_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, - .name = _tr("Geometry"), - .type = "NEW_GEOMETRY", - .x = 0, - .y = 0, - .color = 0xffb34f5a, - .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("Position"), - .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("Normal"), - .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("Tangent"), - .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("Incoming"), - .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("Parametric"), - .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("Pointiness"), - .type = "VALUE", - .color = 0xffa1a1a1, - .default_value = f32_array_create_x(0.0), - .min = 0.0, - .max = 1.0, - .precision = 100, - .display = 0}), - }, - 6), - .buttons = any_array_create_from_raw((void *[]){}, 0), - .width = 0, - .flags = 0}); - gc_root(geometry_node_def); + ui_node_t *geometry_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, + .name = _tr("Geometry"), + .type = "NEW_GEOMETRY", + .x = 0, + .y = 0, + .color = 0xffb34f5a, + .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("Position"), + .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("Normal"), + .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("Tangent"), + .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("Incoming"), + .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("Parametric"), + .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("Pointiness"), + .type = "VALUE", + .color = 0xffa1a1a1, + .default_value = f32_array_create_x(0.0), + .min = 0.0, + .max = 1.0, + .precision = 100, + .display = 0}), + }, + 6), + .buttons = any_array_create_from_raw((void *[]){}, 0), + .width = 0, + .flags = 0}); any_array_push(nodes_material_input, geometry_node_def); any_map_set(parser_material_node_vectors, "NEW_GEOMETRY", geometry_node_vector); diff --git a/paint/sources/material_nodes/gradient_texture_node.c b/paint/sources/material_nodes/gradient_texture_node.c index 3fbc0df5..1ea103b4 100644 --- a/paint/sources/material_nodes/gradient_texture_node.c +++ b/paint/sources/material_nodes/gradient_texture_node.c @@ -45,67 +45,67 @@ char *gradient_texture_node_value(ui_node_t *node, ui_node_socket_t *socket) { void gradient_texture_node_init() { - char *gradient_type_data = string("%s\n%s\n%s\n%s", _tr("Linear"), _tr("Diagonal"), _tr("Radial"), _tr("Spherical")); - gradient_texture_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, - .name = _tr("Gradient Texture"), - .type = "TEX_GRADIENT", - .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 = "RGBA", - .color = 0xffc7c729, - .default_value = f32_array_create_xyzw(0.8, 0.8, 0.8, 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("Factor"), - .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("gradient_type"), - .type = "ENUM", - .output = 0, - .default_value = f32_array_create_x(0), - .data = u8_array_create_from_string(gradient_type_data), - .min = 0.0, - .max = 1.0, - .precision = 100, - .height = 0}), - }, - 1), - .width = 0, - .flags = 0}); - gc_root(gradient_texture_node_def); + char *gradient_type_data = string("%s\n%s\n%s\n%s", _tr("Linear"), _tr("Diagonal"), _tr("Radial"), _tr("Spherical")); + ui_node_t *gradient_texture_node_def = + GC_ALLOC_INIT(ui_node_t, {.id = 0, + .name = _tr("Gradient Texture"), + .type = "TEX_GRADIENT", + .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 = "RGBA", + .color = 0xffc7c729, + .default_value = f32_array_create_xyzw(0.8, 0.8, 0.8, 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("Factor"), + .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("gradient_type"), + .type = "ENUM", + .output = 0, + .default_value = f32_array_create_x(0), + .data = u8_array_create_from_string(gradient_type_data), + .min = 0.0, + .max = 1.0, + .precision = 100, + .height = 0}), + }, + 1), + .width = 0, + .flags = 0}); any_array_push(nodes_material_texture, gradient_texture_node_def); any_map_set(parser_material_node_vectors, "TEX_GRADIENT", gradient_texture_node_vector); diff --git a/paint/sources/material_nodes/group_node.c b/paint/sources/material_nodes/group_node.c index cfeb698c..6dea0562 100644 --- a/paint/sources/material_nodes/group_node.c +++ b/paint/sources/material_nodes/group_node.c @@ -1,6 +1,10 @@ #include "../global.h" +ui_nodes_t *_nodes_material_nodes; +ui_node_t *_nodes_material_node; +ui_node_socket_t_array_t *_nodes_material_sockets; + char *group_node_vector(ui_node_t *node, ui_node_socket_t *socket) { return parser_material_parse_group(node, socket); } @@ -202,30 +206,29 @@ ui_node_socket_t *nodes_material_create_socket(ui_nodes_t *nodes, ui_node_t *nod void group_node_init() { - group_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, - .name = _tr("New Group"), - .type = "GROUP", - .x = 0, - .y = 0, - .color = 0xffb34f5a, - .inputs = any_array_create_from_raw((void *[]){}, 0), - .outputs = any_array_create_from_raw((void *[]){}, 0), - .buttons = any_array_create_from_raw( - (void *[]){ - GC_ALLOC_INIT(ui_node_button_t, {.name = "nodes_material_new_group_button", - .type = "CUSTOM", - .output = -1, - .default_value = f32_array_create_x(0), - .data = NULL, - .min = 0.0, - .max = 1.0, - .precision = 100, - .height = 1}), - }, - 1), - .width = 0, - .flags = 0}); - gc_root(group_node_def); + ui_node_t *group_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, + .name = _tr("New Group"), + .type = "GROUP", + .x = 0, + .y = 0, + .color = 0xffb34f5a, + .inputs = any_array_create_from_raw((void *[]){}, 0), + .outputs = any_array_create_from_raw((void *[]){}, 0), + .buttons = any_array_create_from_raw( + (void *[]){ + GC_ALLOC_INIT(ui_node_button_t, {.name = "nodes_material_new_group_button", + .type = "CUSTOM", + .output = -1, + .default_value = f32_array_create_x(0), + .data = NULL, + .min = 0.0, + .max = 1.0, + .precision = 100, + .height = 1}), + }, + 1), + .width = 0, + .flags = 0}); any_array_push(nodes_material_group, group_node_def); any_map_set(parser_material_node_vectors, "GROUP", group_node_vector); diff --git a/paint/sources/material_nodes/hue_saturation_value_node.c b/paint/sources/material_nodes/hue_saturation_value_node.c index d453aa20..80035b60 100644 --- a/paint/sources/material_nodes/hue_saturation_value_node.c +++ b/paint/sources/material_nodes/hue_saturation_value_node.c @@ -13,7 +13,7 @@ char *hue_saturation_value_node_vector(ui_node_t *node, ui_node_socket_t *socket void hue_saturation_value_node_init() { - hue_saturation_value_node_def = + ui_node_t *hue_saturation_value_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, .name = _tr("Hue/Saturation/Value"), .type = "HUE_SAT", @@ -91,7 +91,6 @@ void hue_saturation_value_node_init() { .buttons = any_array_create_from_raw((void *[]){}, 0), .width = 0, .flags = 0}); - gc_root(hue_saturation_value_node_def); any_array_push(nodes_material_color, hue_saturation_value_node_def); any_map_set(parser_material_node_vectors, "HUE_SAT", hue_saturation_value_node_vector); diff --git a/paint/sources/material_nodes/image_texture_node.c b/paint/sources/material_nodes/image_texture_node.c index 25cb120b..0d1d786f 100644 --- a/paint/sources/material_nodes/image_texture_node.c +++ b/paint/sources/material_nodes/image_texture_node.c @@ -1,6 +1,8 @@ #include "../global.h" +char *parser_material_tex_coord = "tex_coord"; + bind_tex_t *parser_material_make_texture(ui_node_t *image_node, char *tex_name) { i32 i = image_node->buttons->buffer[0]->default_value->buffer[0]; if (i > 9000) { // 9999 - Texture deleted, use pink now @@ -114,8 +116,8 @@ char *image_texture_node_value(ui_node_t *node, ui_node_socket_t *socket) { void image_texture_node_init() { - char *image_texture_color_space_data = string("%s\n%s\n%s\n%s", _tr("Auto"), _tr("Linear"), _tr("sRGB"), _tr("DirectX Normal Map")); - image_texture_node_def = + char *image_texture_color_space_data = string("%s\n%s\n%s\n%s", _tr("Auto"), _tr("Linear"), _tr("sRGB"), _tr("DirectX Normal Map")); + ui_node_t *image_texture_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, .name = _tr("Image Texture"), .type = "TEX_IMAGE", @@ -184,7 +186,6 @@ void image_texture_node_init() { 2), .width = 0, .flags = 0}); - gc_root(image_texture_node_def); any_array_push(nodes_material_texture, image_texture_node_def); any_map_set(parser_material_node_vectors, "TEX_IMAGE", image_texture_node_vector); diff --git a/paint/sources/material_nodes/invert_color_node.c b/paint/sources/material_nodes/invert_color_node.c index 12ac8b09..40497250 100644 --- a/paint/sources/material_nodes/invert_color_node.c +++ b/paint/sources/material_nodes/invert_color_node.c @@ -9,7 +9,7 @@ char *invert_color_node_vector(ui_node_t *node, ui_node_socket_t *socket) { void invert_color_node_init() { - invert_color_node_def = + ui_node_t *invert_color_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, .name = _tr("Invert Color"), .type = "INVERT_COLOR", @@ -57,7 +57,6 @@ void invert_color_node_init() { .buttons = any_array_create_from_raw((void *[]){}, 0), .width = 0, .flags = 0}); - gc_root(invert_color_node_def); any_array_push(nodes_material_color, invert_color_node_def); any_map_set(parser_material_node_vectors, "INVERT_COLOR", invert_color_node_vector); diff --git a/paint/sources/material_nodes/layer_mask_node.c b/paint/sources/material_nodes/layer_mask_node.c index b1b2e95a..955ccf08 100644 --- a/paint/sources/material_nodes/layer_mask_node.c +++ b/paint/sources/material_nodes/layer_mask_node.c @@ -9,43 +9,43 @@ char *layer_mask_node_value(ui_node_t *node, ui_node_socket_t *socket) { void layer_mask_node_init() { - layer_mask_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, - .name = _tr("Layer Mask"), - .type = "LAYER_MASK", // extension - .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("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("Layer"), - .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}), - }, - 1), - .width = 0, - .flags = 0}); - gc_root(layer_mask_node_def); + ui_node_t *layer_mask_node_def = + GC_ALLOC_INIT(ui_node_t, {.id = 0, + .name = _tr("Layer Mask"), + .type = "LAYER_MASK", // extension + .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("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("Layer"), + .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}), + }, + 1), + .width = 0, + .flags = 0}); any_array_push(nodes_material_input, layer_mask_node_def); any_map_set(parser_material_node_values, "LAYER_MASK", layer_mask_node_value); diff --git a/paint/sources/material_nodes/layer_node.c b/paint/sources/material_nodes/layer_node.c index f492db0d..c5f631db 100644 --- a/paint/sources/material_nodes/layer_node.c +++ b/paint/sources/material_nodes/layer_node.c @@ -47,123 +47,123 @@ char *layer_node_value(ui_node_t *node, ui_node_socket_t *socket) { void layer_node_init() { - layer_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, - .name = _tr("Layer"), - .type = "LAYER", // extension - .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("Base Color"), - .type = "RGBA", - .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("Opacity"), - .type = "VALUE", - .color = 0xffa1a1a1, - .default_value = f32_array_create_x(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("Occlusion"), - .type = "VALUE", - .color = 0xffa1a1a1, - .default_value = f32_array_create_x(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("Roughness"), - .type = "VALUE", - .color = 0xffa1a1a1, - .default_value = f32_array_create_x(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("Metallic"), - .type = "VALUE", - .color = 0xffa1a1a1, - .default_value = f32_array_create_x(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("Normal Map"), - .type = "VECTOR", - .color = -10238109, - .default_value = f32_array_create_xyz(0.5, 0.5, 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("Emission"), - .type = "VALUE", - .color = 0xffa1a1a1, - .default_value = f32_array_create_x(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("Height"), - .type = "VALUE", - .color = 0xffa1a1a1, - .default_value = f32_array_create_x(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("Subsurface"), - .type = "VALUE", - .color = 0xffa1a1a1, - .default_value = f32_array_create_x(1.0), - .min = 0.0, - .max = 1.0, - .precision = 100, - .display = 0}), - }, - 9), - .buttons = any_array_create_from_raw( - (void *[]){ - GC_ALLOC_INIT(ui_node_button_t, {.name = _tr("Layer"), - .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}), - }, - 1), - .width = 0, - .flags = 0}); - gc_root(layer_node_def); + ui_node_t *layer_node_def = + GC_ALLOC_INIT(ui_node_t, {.id = 0, + .name = _tr("Layer"), + .type = "LAYER", // extension + .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("Base Color"), + .type = "RGBA", + .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("Opacity"), + .type = "VALUE", + .color = 0xffa1a1a1, + .default_value = f32_array_create_x(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("Occlusion"), + .type = "VALUE", + .color = 0xffa1a1a1, + .default_value = f32_array_create_x(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("Roughness"), + .type = "VALUE", + .color = 0xffa1a1a1, + .default_value = f32_array_create_x(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("Metallic"), + .type = "VALUE", + .color = 0xffa1a1a1, + .default_value = f32_array_create_x(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("Normal Map"), + .type = "VECTOR", + .color = -10238109, + .default_value = f32_array_create_xyz(0.5, 0.5, 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("Emission"), + .type = "VALUE", + .color = 0xffa1a1a1, + .default_value = f32_array_create_x(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("Height"), + .type = "VALUE", + .color = 0xffa1a1a1, + .default_value = f32_array_create_x(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("Subsurface"), + .type = "VALUE", + .color = 0xffa1a1a1, + .default_value = f32_array_create_x(1.0), + .min = 0.0, + .max = 1.0, + .precision = 100, + .display = 0}), + }, + 9), + .buttons = any_array_create_from_raw( + (void *[]){ + GC_ALLOC_INIT(ui_node_button_t, {.name = _tr("Layer"), + .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}), + }, + 1), + .width = 0, + .flags = 0}); any_array_push(nodes_material_input, layer_node_def); any_map_set(parser_material_node_vectors, "LAYER", layer_node_vector); diff --git a/paint/sources/material_nodes/magic_texture_node.c b/paint/sources/material_nodes/magic_texture_node.c index ec22a604..a0b21792 100644 --- a/paint/sources/material_nodes/magic_texture_node.c +++ b/paint/sources/material_nodes/magic_texture_node.c @@ -66,25 +66,25 @@ fun tex_magic_f(co: float3, distortion: float, depth: float): float { \ char *magic_texture_node_vector(ui_node_t *node, ui_node_socket_t *socket) { node_shader_add_function(parser_material_kong, str_tex_magic); - char *co = parser_material_get_coord(node); - char *scale = parser_material_parse_value_input(node->inputs->buffer[1], false); - char *distortion = parser_material_parse_value_input(node->inputs->buffer[2], false); - i32 depth = (i32)node->outputs->buffer[0]->default_value->buffer[0]; + char *co = parser_material_get_coord(node); + char *scale = parser_material_parse_value_input(node->inputs->buffer[1], false); + char *distortion = parser_material_parse_value_input(node->inputs->buffer[2], false); + i32 depth = (i32)node->outputs->buffer[0]->default_value->buffer[0]; return string("tex_magic(%s * %s, %s, %d.0)", co, scale, distortion, depth); } char *magic_texture_node_value(ui_node_t *node, ui_node_socket_t *socket) { node_shader_add_function(parser_material_kong, str_tex_magic); - char *co = parser_material_get_coord(node); - char *scale = parser_material_parse_value_input(node->inputs->buffer[1], false); - char *distortion = parser_material_parse_value_input(node->inputs->buffer[2], false); - i32 depth = (i32)node->outputs->buffer[0]->default_value->buffer[0]; + char *co = parser_material_get_coord(node); + char *scale = parser_material_parse_value_input(node->inputs->buffer[1], false); + char *distortion = parser_material_parse_value_input(node->inputs->buffer[2], false); + i32 depth = (i32)node->outputs->buffer[0]->default_value->buffer[0]; return string("tex_magic_f(%s * %s, %s, %d.0)", co, scale, distortion, depth); } void magic_texture_node_init() { - magic_texture_node_def = + ui_node_t *magic_texture_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, .name = _tr("Magic Texture"), .type = "TEX_MAGIC", @@ -162,9 +162,8 @@ void magic_texture_node_init() { .height = 0}), }, 1), - .width = 0, - .flags = 0}); - gc_root(magic_texture_node_def); + .width = 0, + .flags = 0}); any_array_push(nodes_material_texture, magic_texture_node_def); any_map_set(parser_material_node_vectors, "TEX_MAGIC", magic_texture_node_vector); diff --git a/paint/sources/material_nodes/map_range_node.c b/paint/sources/material_nodes/map_range_node.c index 30b17274..91b177a9 100644 --- a/paint/sources/material_nodes/map_range_node.c +++ b/paint/sources/material_nodes/map_range_node.c @@ -20,96 +20,96 @@ char *map_range_node_value(ui_node_t *node, ui_node_socket_t *socket) { void map_range_node_init() { - map_range_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, - .name = _tr("Map Range"), - .type = "MAPRANGE", - .x = 0, - .y = 0, - .color = 0xff62676d, - .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("From 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("From Max"), - .type = "VALUE", - .color = 0xffa1a1a1, - .default_value = f32_array_create_x(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("To 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("To Max"), - .type = "VALUE", - .color = 0xffa1a1a1, - .default_value = f32_array_create_x(1.0), - .min = 0.0, - .max = 1.0, - .precision = 100, - .display = 0}), - }, - 5), - .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("Clamp"), - .type = "BOOL", - .output = 0, - .default_value = f32_array_create_x(0), - .data = NULL, - .min = 0.0, - .max = 1.0, - .precision = 100, - .height = 0}), - }, - 1), - .width = 0, - .flags = 0}); - gc_root(map_range_node_def); + ui_node_t *map_range_node_def = + GC_ALLOC_INIT(ui_node_t, {.id = 0, + .name = _tr("Map Range"), + .type = "MAPRANGE", + .x = 0, + .y = 0, + .color = 0xff62676d, + .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("From 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("From Max"), + .type = "VALUE", + .color = 0xffa1a1a1, + .default_value = f32_array_create_x(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("To 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("To Max"), + .type = "VALUE", + .color = 0xffa1a1a1, + .default_value = f32_array_create_x(1.0), + .min = 0.0, + .max = 1.0, + .precision = 100, + .display = 0}), + }, + 5), + .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("Clamp"), + .type = "BOOL", + .output = 0, + .default_value = f32_array_create_x(0), + .data = NULL, + .min = 0.0, + .max = 1.0, + .precision = 100, + .height = 0}), + }, + 1), + .width = 0, + .flags = 0}); any_array_push(nodes_material_utilities, map_range_node_def); any_map_set(parser_material_node_values, "MAPRANGE", map_range_node_value); diff --git a/paint/sources/material_nodes/mapping_node.c b/paint/sources/material_nodes/mapping_node.c index 7191a7e5..0bba8de3 100644 --- a/paint/sources/material_nodes/mapping_node.c +++ b/paint/sources/material_nodes/mapping_node.c @@ -34,7 +34,7 @@ char *mapping_node_vector(ui_node_t *node, ui_node_socket_t *socket) { void mapping_node_init() { - mapping_node_def = + ui_node_t *mapping_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, .name = _tr("Mapping"), .type = "MAPPING", @@ -102,7 +102,6 @@ void mapping_node_init() { .buttons = any_array_create_from_raw((void *[]){}, 0), .width = 0, .flags = 0}); - gc_root(mapping_node_def); any_array_push(nodes_material_utilities, mapping_node_def); any_map_set(parser_material_node_vectors, "MAPPING", mapping_node_vector); diff --git a/paint/sources/material_nodes/material_node.c b/paint/sources/material_nodes/material_node.c index 2532620a..51850d15 100644 --- a/paint/sources/material_nodes/material_node.c +++ b/paint/sources/material_nodes/material_node.c @@ -3,7 +3,7 @@ char *material_node_vector(ui_node_t *node, ui_node_socket_t *socket) { char *result = "float3(0.0, 0.0, 0.0)"; - i32 mi = node->buttons->buffer[0]->default_value->buffer[0]; + i32 mi = node->buttons->buffer[0]->default_value->buffer[0]; if (mi >= project_materials->length) { return result; } @@ -36,7 +36,7 @@ char *material_node_vector(ui_node_t *node, ui_node_socket_t *socket) { char *material_node_value(ui_node_t *node, ui_node_socket_t *socket) { char *result = "0.0"; - i32 mi = node->buttons->buffer[0]->default_value->buffer[0]; + i32 mi = node->buttons->buffer[0]->default_value->buffer[0]; if (mi >= project_materials->length) return result; slot_material_t *m = project_materials->buffer[mi]; @@ -77,123 +77,123 @@ char *material_node_value(ui_node_t *node, ui_node_socket_t *socket) { void material_node_init() { - material_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, - .name = _tr("Material"), - .type = "MATERIAL", // extension - .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("Base Color"), - .type = "RGBA", - .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("Opacity"), - .type = "VALUE", - .color = 0xffa1a1a1, - .default_value = f32_array_create_x(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("Occlusion"), - .type = "VALUE", - .color = 0xffa1a1a1, - .default_value = f32_array_create_x(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("Roughness"), - .type = "VALUE", - .color = 0xffa1a1a1, - .default_value = f32_array_create_x(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("Metallic"), - .type = "VALUE", - .color = 0xffa1a1a1, - .default_value = f32_array_create_x(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("Normal Map"), - .type = "VECTOR", - .color = -10238109, - .default_value = f32_array_create_xyz(0.5, 0.5, 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("Emission"), - .type = "VALUE", - .color = 0xffa1a1a1, - .default_value = f32_array_create_x(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("Height"), - .type = "VALUE", - .color = 0xffa1a1a1, - .default_value = f32_array_create_x(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("Subsurface"), - .type = "VALUE", - .color = 0xffa1a1a1, - .default_value = f32_array_create_x(1.0), - .min = 0.0, - .max = 1.0, - .precision = 100, - .display = 0}), - }, - 9), - .buttons = any_array_create_from_raw( - (void *[]){ - GC_ALLOC_INIT(ui_node_button_t, {.name = _tr("Material"), - .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}), - }, - 1), - .width = 0, - .flags = 0}); - gc_root(material_node_def); + ui_node_t *material_node_def = + GC_ALLOC_INIT(ui_node_t, {.id = 0, + .name = _tr("Material"), + .type = "MATERIAL", // extension + .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("Base Color"), + .type = "RGBA", + .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("Opacity"), + .type = "VALUE", + .color = 0xffa1a1a1, + .default_value = f32_array_create_x(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("Occlusion"), + .type = "VALUE", + .color = 0xffa1a1a1, + .default_value = f32_array_create_x(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("Roughness"), + .type = "VALUE", + .color = 0xffa1a1a1, + .default_value = f32_array_create_x(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("Metallic"), + .type = "VALUE", + .color = 0xffa1a1a1, + .default_value = f32_array_create_x(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("Normal Map"), + .type = "VECTOR", + .color = -10238109, + .default_value = f32_array_create_xyz(0.5, 0.5, 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("Emission"), + .type = "VALUE", + .color = 0xffa1a1a1, + .default_value = f32_array_create_x(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("Height"), + .type = "VALUE", + .color = 0xffa1a1a1, + .default_value = f32_array_create_x(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("Subsurface"), + .type = "VALUE", + .color = 0xffa1a1a1, + .default_value = f32_array_create_x(1.0), + .min = 0.0, + .max = 1.0, + .precision = 100, + .display = 0}), + }, + 9), + .buttons = any_array_create_from_raw( + (void *[]){ + GC_ALLOC_INIT(ui_node_button_t, {.name = _tr("Material"), + .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}), + }, + 1), + .width = 0, + .flags = 0}); any_array_push(nodes_material_input, material_node_def); any_map_set(parser_material_node_vectors, "MATERIAL", material_node_vector); diff --git a/paint/sources/material_nodes/math2_node.c b/paint/sources/material_nodes/math2_node.c index bfdeba23..dd23a4ac 100644 --- a/paint/sources/material_nodes/math2_node.c +++ b/paint/sources/material_nodes/math2_node.c @@ -152,75 +152,75 @@ void math2_node_init() { _tr("Ceil"), _tr("Truncate"), _tr("Fraction"), _tr("Truncated Modulo"), _tr("Floored Modulo"), _tr("Snap"), _tr("Ping-Pong"), _tr("Sine"), _tr("Cosine"), _tr("Tangent"), _tr("Arcsine"), _tr("Arccosine"), _tr("Arctangent"), _tr("Arctan2"), _tr("Hyperbolic Sine"), _tr("Hyperbolic Cosine"), _tr("Hyperbolic Tangent"), _tr("To Radians"), _tr("To Degrees")); - math2_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, - .name = _tr("Math"), - .type = "MATH", - .x = 0, - .y = 0, - .color = 0xff62676d, - .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(math_operation_data), - .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}); - gc_root(math2_node_def); + ui_node_t *math2_node_def = + GC_ALLOC_INIT(ui_node_t, {.id = 0, + .name = _tr("Math"), + .type = "MATH", + .x = 0, + .y = 0, + .color = 0xff62676d, + .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(math_operation_data), + .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}); any_array_push(nodes_material_utilities, math2_node_def); any_map_set(parser_material_node_values, "MATH", math2_node_value); diff --git a/paint/sources/material_nodes/mix_color_node.c b/paint/sources/material_nodes/mix_color_node.c index 80be307d..fe26832d 100644 --- a/paint/sources/material_nodes/mix_color_node.c +++ b/paint/sources/material_nodes/mix_color_node.c @@ -7,11 +7,11 @@ char *mix_color_node_vector(ui_node_t *node, ui_node_socket_t *socket) { parser_material_write(parser_material_kong, string("var %s: float = %s;", fac_var, fac)); char *col1 = parser_material_parse_vector_input(node->inputs->buffer[1]); char *col2 = parser_material_parse_vector_input(node->inputs->buffer[2]); - ui_node_button_t *but = node->buttons->buffer[0]; // blend_type - char *blend = to_upper_case(u8_array_string_at(but->data, but->default_value->buffer[0])); - blend = string_copy(string_replace_all(blend, " ", "_")); - bool clamp_factor = node->buttons->buffer[1]->default_value->buffer[0] > 0; - bool clamp_result = node->buttons->buffer[2]->default_value->buffer[0] > 0; + ui_node_button_t *but = node->buttons->buffer[0]; // blend_type + char *blend = to_upper_case(u8_array_string_at(but->data, but->default_value->buffer[0])); + blend = string_copy(string_replace_all(blend, " ", "_")); + bool clamp_factor = node->buttons->buffer[1]->default_value->buffer[0] > 0; + bool clamp_result = node->buttons->buffer[2]->default_value->buffer[0] > 0; if (clamp_factor) { parser_material_write(parser_material_kong, string("%s = clamp(%s, 0.0, 1.0);", fac_var, fac_var)); } @@ -117,94 +117,94 @@ void mix_color_node_init() { string("%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s", _tr("Mix"), _tr("Darken"), _tr("Multiply"), _tr("Burn"), _tr("Lighten"), _tr("Screen"), _tr("Dodge"), _tr("Add"), _tr("Overlay"), _tr("Soft Light"), _tr("Linear Light"), _tr("Difference"), _tr("Exclusion"), _tr("Subtract"), _tr("Divide"), _tr("Hue"), _tr("Saturation"), _tr("Color"), _tr("Value")); - mix_color_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, - .name = _tr("Mix Color"), - .type = "MIX_RGB", - .x = 0, - .y = 0, - .color = 0xff448c6d, - .inputs = any_array_create_from_raw( - (void *[]){ - GC_ALLOC_INIT(ui_node_socket_t, {.id = 0, - .node_id = 0, - .name = _tr("Factor"), - .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("Color 1"), - .type = "RGBA", - .color = 0xffc7c729, - .default_value = f32_array_create_xyzw(0.5, 0.5, 0.5, 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("Color 2"), - .type = "RGBA", - .color = 0xffc7c729, - .default_value = f32_array_create_xyzw(0.5, 0.5, 0.5, 1.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("Color"), - .type = "RGBA", - .color = 0xffc7c729, - .default_value = f32_array_create_xyzw(0.8, 0.8, 0.8, 1.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("blend_type"), - .type = "ENUM", - .output = 0, - .default_value = f32_array_create_x(0), - .data = u8_array_create_from_string(mix_color_blend_type_data), - .min = 0.0, - .max = 1.0, - .precision = 100, - .height = 0}), - GC_ALLOC_INIT(ui_node_button_t, {.name = _tr("Clamp Factor"), - .type = "BOOL", - .output = 0, - .default_value = f32_array_create_x(0), - .data = NULL, - .min = 0.0, - .max = 1.0, - .precision = 100, - .height = 0}), - GC_ALLOC_INIT(ui_node_button_t, {.name = _tr("Clamp Result"), - .type = "BOOL", - .output = 0, - .default_value = f32_array_create_x(0), - .data = NULL, - .min = 0.0, - .max = 1.0, - .precision = 100, - .height = 0}), - }, - 3), - .width = 0, - .flags = 0}); - gc_root(mix_color_node_def); + ui_node_t *mix_color_node_def = + GC_ALLOC_INIT(ui_node_t, {.id = 0, + .name = _tr("Mix Color"), + .type = "MIX_RGB", + .x = 0, + .y = 0, + .color = 0xff448c6d, + .inputs = any_array_create_from_raw( + (void *[]){ + GC_ALLOC_INIT(ui_node_socket_t, {.id = 0, + .node_id = 0, + .name = _tr("Factor"), + .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("Color 1"), + .type = "RGBA", + .color = 0xffc7c729, + .default_value = f32_array_create_xyzw(0.5, 0.5, 0.5, 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("Color 2"), + .type = "RGBA", + .color = 0xffc7c729, + .default_value = f32_array_create_xyzw(0.5, 0.5, 0.5, 1.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("Color"), + .type = "RGBA", + .color = 0xffc7c729, + .default_value = f32_array_create_xyzw(0.8, 0.8, 0.8, 1.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("blend_type"), + .type = "ENUM", + .output = 0, + .default_value = f32_array_create_x(0), + .data = u8_array_create_from_string(mix_color_blend_type_data), + .min = 0.0, + .max = 1.0, + .precision = 100, + .height = 0}), + GC_ALLOC_INIT(ui_node_button_t, {.name = _tr("Clamp Factor"), + .type = "BOOL", + .output = 0, + .default_value = f32_array_create_x(0), + .data = NULL, + .min = 0.0, + .max = 1.0, + .precision = 100, + .height = 0}), + GC_ALLOC_INIT(ui_node_button_t, {.name = _tr("Clamp Result"), + .type = "BOOL", + .output = 0, + .default_value = f32_array_create_x(0), + .data = NULL, + .min = 0.0, + .max = 1.0, + .precision = 100, + .height = 0}), + }, + 3), + .width = 0, + .flags = 0}); any_array_push(nodes_material_color, mix_color_node_def); any_map_set(parser_material_node_vectors, "MIX_RGB", mix_color_node_vector); diff --git a/paint/sources/material_nodes/mix_normal_map_node.c b/paint/sources/material_nodes/mix_normal_map_node.c index 67cd7f77..b4488fe8 100644 --- a/paint/sources/material_nodes/mix_normal_map_node.c +++ b/paint/sources/material_nodes/mix_normal_map_node.c @@ -30,8 +30,8 @@ char *mix_normal_map_node_vector(ui_node_t *node, ui_node_socket_t *socket) { void mix_normal_map_node_init() { - char *mix_normal_map_blend_type_data = string("%s\n%s\n%s", _tr("Partial Derivative"), _tr("Whiteout"), _tr("Reoriented")); - mix_normal_map_node_def = + char *mix_normal_map_blend_type_data = string("%s\n%s\n%s", _tr("Partial Derivative"), _tr("Whiteout"), _tr("Reoriented")); + ui_node_t *mix_normal_map_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, .name = _tr("Mix Normal Map"), .type = "MIX_NORMAL_MAP", // extension @@ -91,7 +91,6 @@ void mix_normal_map_node_init() { 1), .width = 0, .flags = 0}); - gc_root(mix_normal_map_node_def); any_array_push(nodes_material_utilities, mix_normal_map_node_def); any_map_set(parser_material_node_vectors, "MIX_NORMAL_MAP", mix_normal_map_node_vector); diff --git a/paint/sources/material_nodes/noise_texture_node.c b/paint/sources/material_nodes/noise_texture_node.c index 676afe7f..3e95e003 100644 --- a/paint/sources/material_nodes/noise_texture_node.c +++ b/paint/sources/material_nodes/noise_texture_node.c @@ -66,9 +66,9 @@ char *noise_texture_node_value(ui_node_t *node, ui_node_socket_t *socket) { void noise_texture_node_init() { - char *noise_dimensions_data = string("%s", _tr("3D")); - char *noise_feature_data = string("%s", _tr("fBM")); - noise_texture_node_def = + char *noise_dimensions_data = string("%s", _tr("3D")); + char *noise_feature_data = string("%s", _tr("fBM")); + ui_node_t *noise_texture_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, .name = _tr("Noise Texture"), .type = "TEX_NOISE", @@ -194,9 +194,8 @@ void noise_texture_node_init() { .height = 0}), }, 3), - .width = 0, - .flags = 0}); - gc_root(noise_texture_node_def); + .width = 0, + .flags = 0}); any_array_push(nodes_material_texture, noise_texture_node_def); any_map_set(parser_material_node_vectors, "TEX_NOISE", noise_texture_node_vector); diff --git a/paint/sources/material_nodes/normal_map_node.c b/paint/sources/material_nodes/normal_map_node.c index 449d9496..2578fe2d 100644 --- a/paint/sources/material_nodes/normal_map_node.c +++ b/paint/sources/material_nodes/normal_map_node.c @@ -15,54 +15,54 @@ char *normal_map_node_vector(ui_node_t *node, ui_node_socket_t *socket) { void normal_map_node_init() { - normal_map_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, - .name = _tr("Normal Map"), - .type = "NORMAL_MAP", - .x = 0, - .y = 0, - .color = 0xff522c99, - .inputs = any_array_create_from_raw( - (void *[]){ - GC_ALLOC_INIT(ui_node_socket_t, {.id = 0, - .node_id = 0, - .name = _tr("Strength"), - .type = "VALUE", - .color = 0xffa1a1a1, - .default_value = f32_array_create_x(1.0), - .min = 0.0, - .max = 2.0, - .precision = 100, - .display = 0}), - GC_ALLOC_INIT(ui_node_socket_t, {.id = 0, - .node_id = 0, - .name = _tr("Normal Map"), - .type = "VECTOR", - .color = -10238109, - .default_value = f32_array_create_xyz(0.5, 0.5, 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("Normal Map"), - .type = "VECTOR", - .color = -10238109, - .default_value = f32_array_create_xyz(0.5, 0.5, 1.0), - .min = 0.0, - .max = 1.0, - .precision = 100, - .display = 0}), - }, - 1), - .buttons = any_array_create_from_raw((void *[]){}, 0), - .width = 0, - .flags = 0}); - gc_root(normal_map_node_def); + ui_node_t *normal_map_node_def = + GC_ALLOC_INIT(ui_node_t, {.id = 0, + .name = _tr("Normal Map"), + .type = "NORMAL_MAP", + .x = 0, + .y = 0, + .color = 0xff522c99, + .inputs = any_array_create_from_raw( + (void *[]){ + GC_ALLOC_INIT(ui_node_socket_t, {.id = 0, + .node_id = 0, + .name = _tr("Strength"), + .type = "VALUE", + .color = 0xffa1a1a1, + .default_value = f32_array_create_x(1.0), + .min = 0.0, + .max = 2.0, + .precision = 100, + .display = 0}), + GC_ALLOC_INIT(ui_node_socket_t, {.id = 0, + .node_id = 0, + .name = _tr("Normal Map"), + .type = "VECTOR", + .color = -10238109, + .default_value = f32_array_create_xyz(0.5, 0.5, 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("Normal Map"), + .type = "VECTOR", + .color = -10238109, + .default_value = f32_array_create_xyz(0.5, 0.5, 1.0), + .min = 0.0, + .max = 1.0, + .precision = 100, + .display = 0}), + }, + 1), + .buttons = any_array_create_from_raw((void *[]){}, 0), + .width = 0, + .flags = 0}); any_array_push(nodes_material_utilities, normal_map_node_def); any_map_set(parser_material_node_vectors, "NORMAL_MAP", normal_map_node_vector); diff --git a/paint/sources/material_nodes/normal_node.c b/paint/sources/material_nodes/normal_node.c index 5d50a87b..caf836a1 100644 --- a/paint/sources/material_nodes/normal_node.c +++ b/paint/sources/material_nodes/normal_node.c @@ -12,66 +12,66 @@ char *normal_node_value(ui_node_t *node, ui_node_socket_t *socket) { } void normal_node_init() { - normal_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, - .name = _tr("Normal"), - .type = "NORMAL", - .x = 0, - .y = 0, - .color = 0xff522c99, - .inputs = any_array_create_from_raw( - (void *[]){ - GC_ALLOC_INIT(ui_node_socket_t, {.id = 0, - .node_id = 0, - .name = _tr("Normal"), - .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("Normal"), - .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("Dot"), - .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("Vector"), - .type = "VECTOR", - .output = 0, - .default_value = f32_array_create_xyz(0.0, 0.0, 0.0), - .data = NULL, - .min = 0.0, - .max = 1.0, - .precision = 100, - .height = 0}), - }, - 1), - .width = 0, - .flags = 0}); - gc_root(normal_node_def); + ui_node_t *normal_node_def = + GC_ALLOC_INIT(ui_node_t, {.id = 0, + .name = _tr("Normal"), + .type = "NORMAL", + .x = 0, + .y = 0, + .color = 0xff522c99, + .inputs = any_array_create_from_raw( + (void *[]){ + GC_ALLOC_INIT(ui_node_socket_t, {.id = 0, + .node_id = 0, + .name = _tr("Normal"), + .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("Normal"), + .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("Dot"), + .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("Vector"), + .type = "VECTOR", + .output = 0, + .default_value = f32_array_create_xyz(0.0, 0.0, 0.0), + .data = NULL, + .min = 0.0, + .max = 1.0, + .precision = 100, + .height = 0}), + }, + 1), + .width = 0, + .flags = 0}); any_array_push(nodes_material_utilities, normal_node_def); any_map_set(parser_material_node_vectors, "NORMAL", normal_node_vector); diff --git a/paint/sources/material_nodes/object_info_node.c b/paint/sources/material_nodes/object_info_node.c index 5b877465..4d3121f0 100644 --- a/paint/sources/material_nodes/object_info_node.c +++ b/paint/sources/material_nodes/object_info_node.c @@ -26,62 +26,60 @@ char *object_info_node_value(ui_node_t *node, ui_node_socket_t *socket) { void object_info_node_init() { - object_info_node_def = - GC_ALLOC_INIT(ui_node_t, {.id = 0, - .name = _tr("Object Info"), - .type = "OBJECT_INFO", - .x = 0, - .y = 0, - .color = 0xffb34f5a, - .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("Location"), - .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("Object Index"), - .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("Material Index"), - .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("Random"), - .type = "VALUE", - .color = 0xffa1a1a1, - .default_value = f32_array_create_x(0.0), - .min = 0.0, - .max = 1.0, - .precision = 100, - .display = 0}), - }, - 4), - .buttons = any_array_create_from_raw((void *[]){}, 0), - .width = 0, - .flags = 0}); - gc_root(object_info_node_def); + ui_node_t *object_info_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, + .name = _tr("Object Info"), + .type = "OBJECT_INFO", + .x = 0, + .y = 0, + .color = 0xffb34f5a, + .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("Location"), + .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("Object Index"), + .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("Material Index"), + .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("Random"), + .type = "VALUE", + .color = 0xffa1a1a1, + .default_value = f32_array_create_x(0.0), + .min = 0.0, + .max = 1.0, + .precision = 100, + .display = 0}), + }, + 4), + .buttons = any_array_create_from_raw((void *[]){}, 0), + .width = 0, + .flags = 0}); any_array_push(nodes_material_input, object_info_node_def); any_map_set(parser_material_node_vectors, "OBJECT_INFO", object_info_node_vector); diff --git a/paint/sources/material_nodes/picker_node.c b/paint/sources/material_nodes/picker_node.c index 4996ce26..b353f712 100644 --- a/paint/sources/material_nodes/picker_node.c +++ b/paint/sources/material_nodes/picker_node.c @@ -43,111 +43,110 @@ char *picker_node_value(ui_node_t *node, ui_node_socket_t *socket) { void picker_node_init() { - picker_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, - .name = _tr("Picker"), - .type = "PICKER", // extension - .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("Base Color"), - .type = "RGBA", - .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("Opacity"), - .type = "VALUE", - .color = 0xffa1a1a1, - .default_value = f32_array_create_x(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("Occlusion"), - .type = "VALUE", - .color = 0xffa1a1a1, - .default_value = f32_array_create_x(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("Roughness"), - .type = "VALUE", - .color = 0xffa1a1a1, - .default_value = f32_array_create_x(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("Metallic"), - .type = "VALUE", - .color = 0xffa1a1a1, - .default_value = f32_array_create_x(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("Normal Map"), - .type = "VECTOR", - .color = -10238109, - .default_value = f32_array_create_xyz(0.5, 0.5, 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("Emission"), - .type = "VALUE", - .color = 0xffa1a1a1, - .default_value = f32_array_create_x(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("Height"), - .type = "VALUE", - .color = 0xffa1a1a1, - .default_value = f32_array_create_x(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("Subsurface"), - .type = "VALUE", - .color = 0xffa1a1a1, - .default_value = f32_array_create_x(1.0), - .min = 0.0, - .max = 1.0, - .precision = 100, - .display = 0}), - }, - 9), - .buttons = any_array_create_from_raw((void *[]){}, 0), - .width = 0, - .flags = 0}); - gc_root(picker_node_def); + ui_node_t *picker_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, + .name = _tr("Picker"), + .type = "PICKER", // extension + .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("Base Color"), + .type = "RGBA", + .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("Opacity"), + .type = "VALUE", + .color = 0xffa1a1a1, + .default_value = f32_array_create_x(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("Occlusion"), + .type = "VALUE", + .color = 0xffa1a1a1, + .default_value = f32_array_create_x(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("Roughness"), + .type = "VALUE", + .color = 0xffa1a1a1, + .default_value = f32_array_create_x(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("Metallic"), + .type = "VALUE", + .color = 0xffa1a1a1, + .default_value = f32_array_create_x(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("Normal Map"), + .type = "VECTOR", + .color = -10238109, + .default_value = f32_array_create_xyz(0.5, 0.5, 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("Emission"), + .type = "VALUE", + .color = 0xffa1a1a1, + .default_value = f32_array_create_x(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("Height"), + .type = "VALUE", + .color = 0xffa1a1a1, + .default_value = f32_array_create_x(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("Subsurface"), + .type = "VALUE", + .color = 0xffa1a1a1, + .default_value = f32_array_create_x(1.0), + .min = 0.0, + .max = 1.0, + .precision = 100, + .display = 0}), + }, + 9), + .buttons = any_array_create_from_raw((void *[]){}, 0), + .width = 0, + .flags = 0}); any_array_push(nodes_material_input, picker_node_def); any_map_set(parser_material_node_vectors, "PICKER", picker_node_vector); diff --git a/paint/sources/material_nodes/quantize_node.c b/paint/sources/material_nodes/quantize_node.c index 5eb17b3e..dcab2c6f 100644 --- a/paint/sources/material_nodes/quantize_node.c +++ b/paint/sources/material_nodes/quantize_node.c @@ -9,54 +9,54 @@ char *quantize_node_vector(ui_node_t *node, ui_node_socket_t *socket) { void quantize_node_init() { - quantize_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, - .name = _tr("Quantize"), - .type = "QUANTIZE", // extension - .x = 0, - .y = 0, - .color = 0xff448c6d, - .inputs = any_array_create_from_raw( - (void *[]){ - GC_ALLOC_INIT(ui_node_socket_t, {.id = 0, - .node_id = 0, - .name = _tr("Strength"), - .type = "VALUE", - .color = 0xffa1a1a1, - .default_value = f32_array_create_x(0.1), - .min = 0.0, - .max = 1.0, - .precision = 100, - .display = 0}), - GC_ALLOC_INIT(ui_node_socket_t, {.id = 0, - .node_id = 0, - .name = _tr("Color"), - .type = "RGBA", - .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}), - }, - 2), - .outputs = any_array_create_from_raw( - (void *[]){ - GC_ALLOC_INIT(ui_node_socket_t, {.id = 0, - .node_id = 0, - .name = _tr("Color"), - .type = "RGBA", - .color = 0xffc7c729, - .default_value = f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0), - .min = 0.0, - .max = 1.0, - .precision = 100, - .display = 0}), - }, - 1), - .buttons = any_array_create_from_raw((void *[]){}, 0), - .width = 0, - .flags = 0}); - gc_root(quantize_node_def); + ui_node_t *quantize_node_def = + GC_ALLOC_INIT(ui_node_t, {.id = 0, + .name = _tr("Quantize"), + .type = "QUANTIZE", // extension + .x = 0, + .y = 0, + .color = 0xff448c6d, + .inputs = any_array_create_from_raw( + (void *[]){ + GC_ALLOC_INIT(ui_node_socket_t, {.id = 0, + .node_id = 0, + .name = _tr("Strength"), + .type = "VALUE", + .color = 0xffa1a1a1, + .default_value = f32_array_create_x(0.1), + .min = 0.0, + .max = 1.0, + .precision = 100, + .display = 0}), + GC_ALLOC_INIT(ui_node_socket_t, {.id = 0, + .node_id = 0, + .name = _tr("Color"), + .type = "RGBA", + .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}), + }, + 2), + .outputs = any_array_create_from_raw( + (void *[]){ + GC_ALLOC_INIT(ui_node_socket_t, {.id = 0, + .node_id = 0, + .name = _tr("Color"), + .type = "RGBA", + .color = 0xffc7c729, + .default_value = f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0), + .min = 0.0, + .max = 1.0, + .precision = 100, + .display = 0}), + }, + 1), + .buttons = any_array_create_from_raw((void *[]){}, 0), + .width = 0, + .flags = 0}); any_array_push(nodes_material_color, quantize_node_def); any_map_set(parser_material_node_vectors, "QUANTIZE", quantize_node_vector); diff --git a/paint/sources/material_nodes/replace_color_node.c b/paint/sources/material_nodes/replace_color_node.c index cc117744..329ce798 100644 --- a/paint/sources/material_nodes/replace_color_node.c +++ b/paint/sources/material_nodes/replace_color_node.c @@ -13,7 +13,7 @@ char *replace_color_node_vector(ui_node_t *node, ui_node_socket_t *socket) { void replace_color_node_init() { - replace_color_node_def = + ui_node_t *replace_color_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, .name = _tr("Replace Color"), .type = "REPLACECOL", // extension @@ -73,7 +73,6 @@ void replace_color_node_init() { }, 1), .buttons = any_array_create_from_raw((void *[]){}, 0)}); - gc_root(replace_color_node_def); any_array_push(nodes_material_color, replace_color_node_def); any_map_set(parser_material_node_vectors, "REPLACECOL", replace_color_node_vector); diff --git a/paint/sources/material_nodes/rgb_curves_node.c b/paint/sources/material_nodes/rgb_curves_node.c index b867d753..70cb6d6a 100644 --- a/paint/sources/material_nodes/rgb_curves_node.c +++ b/paint/sources/material_nodes/rgb_curves_node.c @@ -140,66 +140,66 @@ void nodes_material_rgb_curves_button(i32 node_id) { void rgb_curves_node_init() { - rgb_curves_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, - .name = _tr("RGB Curves"), - .type = "CURVE_RGB", - .x = 0, - .y = 0, - .color = 0xff448c6d, - .inputs = any_array_create_from_raw( - (void *[]){ - GC_ALLOC_INIT(ui_node_socket_t, {.id = 0, - .node_id = 0, - .name = _tr("Fac"), - .type = "VALUE", - .color = 0xffa1a1a1, - .default_value = f32_array_create_x(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("Color"), - .type = "RGBA", - .color = 0xffc7c729, - .default_value = f32_array_create_xyzw(1.0, 1.0, 1.0, 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("Color"), - .type = "RGBA", - .color = 0xffc7c729, - .default_value = f32_array_create_xyzw(1.0, 1.0, 1.0, 1.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 = "nodes_material_rgb_curves_button", - .type = "CUSTOM", - .output = 0, - .default_value = f32_array_create(128 + 4), - .data = NULL, - .min = 0.0, - .max = 1.0, - .precision = 100, - .height = 7.2}), - }, - 1), - .width = 0, - .flags = 0}); - gc_root(rgb_curves_node_def); + ui_node_t *rgb_curves_node_def = + GC_ALLOC_INIT(ui_node_t, {.id = 0, + .name = _tr("RGB Curves"), + .type = "CURVE_RGB", + .x = 0, + .y = 0, + .color = 0xff448c6d, + .inputs = any_array_create_from_raw( + (void *[]){ + GC_ALLOC_INIT(ui_node_socket_t, {.id = 0, + .node_id = 0, + .name = _tr("Fac"), + .type = "VALUE", + .color = 0xffa1a1a1, + .default_value = f32_array_create_x(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("Color"), + .type = "RGBA", + .color = 0xffc7c729, + .default_value = f32_array_create_xyzw(1.0, 1.0, 1.0, 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("Color"), + .type = "RGBA", + .color = 0xffc7c729, + .default_value = f32_array_create_xyzw(1.0, 1.0, 1.0, 1.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 = "nodes_material_rgb_curves_button", + .type = "CUSTOM", + .output = 0, + .default_value = f32_array_create(128 + 4), + .data = NULL, + .min = 0.0, + .max = 1.0, + .precision = 100, + .height = 7.2}), + }, + 1), + .width = 0, + .flags = 0}); any_array_push(nodes_material_color, rgb_curves_node_def); any_map_set(parser_material_node_vectors, "CURVE_RGB", rgb_curves_node_vector); diff --git a/paint/sources/material_nodes/rgb_node.c b/paint/sources/material_nodes/rgb_node.c index 3c13b7b8..67efb3cc 100644 --- a/paint/sources/material_nodes/rgb_node.c +++ b/paint/sources/material_nodes/rgb_node.c @@ -7,43 +7,43 @@ char *rgb_node_vector(ui_node_t *node, ui_node_socket_t *socket) { void rgb_node_init() { - rgb_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, - .name = _tr("Color"), - .type = "RGB", - .x = 0, - .y = 0, - .color = 0xffb34f5a, - .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("Color"), - .type = "RGBA", - .color = 0xffc7c729, - .default_value = f32_array_create_xyzw(0.5, 0.5, 0.5, 1.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("RGBA"), - .type = "RGBA", - .output = 0, - .default_value = f32_array_create_x(0), - .data = NULL, - .min = 0.0, - .max = 1.0, - .precision = 100, - .height = 0}), - }, - 1), - .width = 0, - .flags = 0}); - gc_root(rgb_node_def); + ui_node_t *rgb_node_def = + GC_ALLOC_INIT(ui_node_t, {.id = 0, + .name = _tr("Color"), + .type = "RGB", + .x = 0, + .y = 0, + .color = 0xffb34f5a, + .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("Color"), + .type = "RGBA", + .color = 0xffc7c729, + .default_value = f32_array_create_xyzw(0.5, 0.5, 0.5, 1.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("RGBA"), + .type = "RGBA", + .output = 0, + .default_value = f32_array_create_x(0), + .data = NULL, + .min = 0.0, + .max = 1.0, + .precision = 100, + .height = 0}), + }, + 1), + .width = 0, + .flags = 0}); any_array_push(nodes_material_input, rgb_node_def); any_map_set(parser_material_node_vectors, "RGB", rgb_node_vector); diff --git a/paint/sources/material_nodes/rgb_to_bw_node.c b/paint/sources/material_nodes/rgb_to_bw_node.c index 98e7ac1c..7674bed7 100644 --- a/paint/sources/material_nodes/rgb_to_bw_node.c +++ b/paint/sources/material_nodes/rgb_to_bw_node.c @@ -8,44 +8,44 @@ char *rgb_to_bw_node_value(ui_node_t *node, ui_node_socket_t *socket) { void rgb_to_bw_node_init() { - rgb_to_bw_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, - .name = _tr("RGB to BW"), - .type = "RGBTOBW", - .x = 0, - .y = 0, - .color = 0xff62676d, - .inputs = any_array_create_from_raw( - (void *[]){ - GC_ALLOC_INIT(ui_node_socket_t, {.id = 0, - .node_id = 0, - .name = _tr("Color"), - .type = "RGBA", - .color = 0xffc7c729, - .default_value = f32_array_create_xyzw(0.5, 0.5, 0.5, 1.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("Val"), - .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 *[]){}, 0), - .width = 0, - .flags = 0}); - gc_root(rgb_to_bw_node_def); + ui_node_t *rgb_to_bw_node_def = + GC_ALLOC_INIT(ui_node_t, {.id = 0, + .name = _tr("RGB to BW"), + .type = "RGBTOBW", + .x = 0, + .y = 0, + .color = 0xff62676d, + .inputs = any_array_create_from_raw( + (void *[]){ + GC_ALLOC_INIT(ui_node_socket_t, {.id = 0, + .node_id = 0, + .name = _tr("Color"), + .type = "RGBA", + .color = 0xffc7c729, + .default_value = f32_array_create_xyzw(0.5, 0.5, 0.5, 1.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("Val"), + .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 *[]){}, 0), + .width = 0, + .flags = 0}); any_array_push(nodes_material_color, rgb_to_bw_node_def); any_map_set(parser_material_node_values, "RGBTOBW", rgb_to_bw_node_value); diff --git a/paint/sources/material_nodes/script_node.c b/paint/sources/material_nodes/script_node.c index 3c40f2c0..c1e11a72 100644 --- a/paint/sources/material_nodes/script_node.c +++ b/paint/sources/material_nodes/script_node.c @@ -36,52 +36,51 @@ void script_node_button(i32 node_id) { void script_node_init() { - script_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, - .name = _tr("Script"), - .type = "SCRIPT_CPU", // extension - .x = 0, - .y = 0, - .color = 0xffb34f5a, - .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("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 *[]){ - GC_ALLOC_INIT(ui_node_button_t, {.name = " ", - .type = "STRING", - .output = -1, - .default_value = f32_array_create_x(0), // "", - .data = NULL, - .min = 0.0, - .max = 1.0, - .precision = 100, - .height = 0}), - GC_ALLOC_INIT(ui_node_button_t, {.name = "script_node_button", - .type = "CUSTOM", - .output = -1, - .default_value = f32_array_create_x(0), - .data = NULL, - .min = 0.0, - .max = 1.0, - .precision = 100, - .height = 1}), - }, - 2), - .width = 0, - .flags = 0}); - gc_root(script_node_def); + ui_node_t *script_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, + .name = _tr("Script"), + .type = "SCRIPT_CPU", // extension + .x = 0, + .y = 0, + .color = 0xffb34f5a, + .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("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 *[]){ + GC_ALLOC_INIT(ui_node_button_t, {.name = " ", + .type = "STRING", + .output = -1, + .default_value = f32_array_create_x(0), // "", + .data = NULL, + .min = 0.0, + .max = 1.0, + .precision = 100, + .height = 0}), + GC_ALLOC_INIT(ui_node_button_t, {.name = "script_node_button", + .type = "CUSTOM", + .output = -1, + .default_value = f32_array_create_x(0), + .data = NULL, + .min = 0.0, + .max = 1.0, + .precision = 100, + .height = 1}), + }, + 2), + .width = 0, + .flags = 0}); any_array_push(nodes_material_input, script_node_def); any_map_set(parser_material_node_values, "SCRIPT_CPU", script_node_value); diff --git a/paint/sources/material_nodes/separate_color_node.c b/paint/sources/material_nodes/separate_color_node.c index 99d9fc0d..3bfef2b1 100644 --- a/paint/sources/material_nodes/separate_color_node.c +++ b/paint/sources/material_nodes/separate_color_node.c @@ -16,7 +16,7 @@ char *separate_color_node_value(ui_node_t *node, ui_node_socket_t *socket) { void separate_color_node_init() { - separate_color_node_def = + ui_node_t *separate_color_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, .name = _tr("Separate Color"), .type = "SEPARATE_COLOR", @@ -74,7 +74,6 @@ void separate_color_node_init() { .buttons = any_array_create_from_raw((void *[]){}, 0), .width = 0, .flags = 0}); - gc_root(separate_color_node_def); any_array_push(nodes_material_color, separate_color_node_def); any_map_set(parser_material_node_values, "SEPARATE_COLOR", separate_color_node_value); diff --git a/paint/sources/material_nodes/separate_xyz_node.c b/paint/sources/material_nodes/separate_xyz_node.c index 37a3939a..377b1b62 100644 --- a/paint/sources/material_nodes/separate_xyz_node.c +++ b/paint/sources/material_nodes/separate_xyz_node.c @@ -16,65 +16,63 @@ char *separate_xyz_node_value(ui_node_t *node, ui_node_socket_t *socket) { void separate_xyz_node_init() { - separate_xyz_node_def = - GC_ALLOC_INIT(ui_node_t, {.id = 0, - .name = _tr("Separate XYZ"), - .type = "SEPXYZ", - .x = 0, - .y = 0, - .color = 0xff62676d, - .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_root(separate_xyz_node_def); + ui_node_t *separate_xyz_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, + .name = _tr("Separate XYZ"), + .type = "SEPXYZ", + .x = 0, + .y = 0, + .color = 0xff62676d, + .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}); any_array_push(nodes_material_utilities, separate_xyz_node_def); any_map_set(parser_material_node_values, "SEPXYZ", separate_xyz_node_value); diff --git a/paint/sources/material_nodes/shader_node.c b/paint/sources/material_nodes/shader_node.c index 9994d07f..f2d217df 100644 --- a/paint/sources/material_nodes/shader_node.c +++ b/paint/sources/material_nodes/shader_node.c @@ -3,49 +3,48 @@ char *shader_node_value(ui_node_t *node, ui_node_socket_t *socket) { buffer_t *shader = node->buttons->buffer[0]->default_value; - char *str = sys_buffer_to_string(shader); + char *str = sys_buffer_to_string(shader); return string_equals(str, "") ? "0.0" : str; } void shader_node_init() { - shader_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, - .name = _tr("Shader"), - .type = "SHADER_GPU", // extension - .x = 0, - .y = 0, - .color = 0xffb34f5a, - .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("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 *[]){ - GC_ALLOC_INIT(ui_node_button_t, {.name = " ", - .type = "STRING", - .output = -1, - .default_value = f32_array_create_x(0), // "", - .data = NULL, - .min = 0.0, - .max = 1.0, - .precision = 100, - .height = 0}), - }, - 1), - .width = 0, - .flags = 0}); - gc_root(shader_node_def); + ui_node_t *shader_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, + .name = _tr("Shader"), + .type = "SHADER_GPU", // extension + .x = 0, + .y = 0, + .color = 0xffb34f5a, + .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("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 *[]){ + GC_ALLOC_INIT(ui_node_button_t, {.name = " ", + .type = "STRING", + .output = -1, + .default_value = f32_array_create_x(0), // "", + .data = NULL, + .min = 0.0, + .max = 1.0, + .precision = 100, + .height = 0}), + }, + 1), + .width = 0, + .flags = 0}); any_array_push(nodes_material_input, shader_node_def); any_map_set(parser_material_node_values, "SHADER_GPU", shader_node_value); diff --git a/paint/sources/material_nodes/text_texture_node.c b/paint/sources/material_nodes/text_texture_node.c index db111c5b..b8db1a6a 100644 --- a/paint/sources/material_nodes/text_texture_node.c +++ b/paint/sources/material_nodes/text_texture_node.c @@ -44,7 +44,7 @@ char *text_texture_node_value(ui_node_t *node, ui_node_socket_t *socket) { void text_texture_node_init() { - text_texture_node_def = + ui_node_t *text_texture_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, .name = _tr("Text Texture"), .type = "TEX_TEXT", // extension @@ -104,7 +104,6 @@ void text_texture_node_init() { 1), .width = 0, .flags = 0}); - gc_root(text_texture_node_def); any_array_push(nodes_material_texture, text_texture_node_def); any_map_set(parser_material_node_vectors, "TEX_TEXT", text_texture_node_vector); diff --git a/paint/sources/material_nodes/texture_coordinate_node.c b/paint/sources/material_nodes/texture_coordinate_node.c index 841e8e68..0e87fa1b 100644 --- a/paint/sources/material_nodes/texture_coordinate_node.c +++ b/paint/sources/material_nodes/texture_coordinate_node.c @@ -31,7 +31,7 @@ char *texture_coordinate_node_vector(ui_node_t *node, ui_node_socket_t *socket) void texture_coordinate_node_init() { - texture_coordinate_node_def = + ui_node_t *texture_coordinate_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, .name = _tr("Texture Coordinate"), .type = "TEX_COORD", @@ -104,7 +104,6 @@ void texture_coordinate_node_init() { }, 6), .buttons = any_array_create_from_raw((void *[]){}, 0)}); - gc_root(texture_coordinate_node_def); any_array_push(nodes_material_input, texture_coordinate_node_def); any_map_set(parser_material_node_vectors, "TEX_COORD", texture_coordinate_node_vector); diff --git a/paint/sources/material_nodes/uv_map_node.c b/paint/sources/material_nodes/uv_map_node.c index 67f8b778..0dc8a137 100644 --- a/paint/sources/material_nodes/uv_map_node.c +++ b/paint/sources/material_nodes/uv_map_node.c @@ -17,44 +17,43 @@ char *uv_map_node_vector(ui_node_t *node, ui_node_socket_t *socket) { void uv_map_node_init() { - char *uv_map_data = string("%s\n%s", "uv0", "uv1"); - uv_map_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, - .name = _tr("UV Map"), - .type = "UVMAP", - .x = 0, - .y = 0, - .color = 0xffb34f5a, - .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("UV"), - .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 *[]){ - GC_ALLOC_INIT(ui_node_button_t, {.name = _tr("UV Map"), - .type = "ENUM", - .output = -1, - .default_value = f32_array_create_x(0), - .data = u8_array_create_from_string(uv_map_data), - .min = 0.0, - .max = 1.0, - .precision = 100, - .height = 0}), - }, - 1), - .width = 0, - .flags = 0}); - gc_root(uv_map_node_def); + char *uv_map_data = string("%s\n%s", "uv0", "uv1"); + ui_node_t *uv_map_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, + .name = _tr("UV Map"), + .type = "UVMAP", + .x = 0, + .y = 0, + .color = 0xffb34f5a, + .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("UV"), + .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 *[]){ + GC_ALLOC_INIT(ui_node_button_t, {.name = _tr("UV Map"), + .type = "ENUM", + .output = -1, + .default_value = f32_array_create_x(0), + .data = u8_array_create_from_string(uv_map_data), + .min = 0.0, + .max = 1.0, + .precision = 100, + .height = 0}), + }, + 1), + .width = 0, + .flags = 0}); any_array_push(nodes_material_input, uv_map_node_def); any_map_set(parser_material_node_vectors, "UVMAP", uv_map_node_vector); diff --git a/paint/sources/material_nodes/value_node.c b/paint/sources/material_nodes/value_node.c index b5280b2b..a10e8054 100644 --- a/paint/sources/material_nodes/value_node.c +++ b/paint/sources/material_nodes/value_node.c @@ -7,43 +7,43 @@ char *value_node_value(ui_node_t *node, ui_node_socket_t *socket) { void value_node_init() { - value_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, - .name = _tr("Value"), - .type = "VALUE", - .x = 0, - .y = 0, - .color = 0xffb34f5a, - .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("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("Value"), - .type = "VALUE", - .output = 0, - .default_value = f32_array_create_x(0), - .data = NULL, - .min = 0.0, - .max = 10.0, - .precision = 100, - .height = 0}), - }, - 1), - .width = 0, - .flags = 0}); - gc_root(value_node_def); + ui_node_t *value_node_def = + GC_ALLOC_INIT(ui_node_t, {.id = 0, + .name = _tr("Value"), + .type = "VALUE", + .x = 0, + .y = 0, + .color = 0xffb34f5a, + .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("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("Value"), + .type = "VALUE", + .output = 0, + .default_value = f32_array_create_x(0), + .data = NULL, + .min = 0.0, + .max = 10.0, + .precision = 100, + .height = 0}), + }, + 1), + .width = 0, + .flags = 0}); any_array_push(nodes_material_input, value_node_def); any_map_set(parser_material_node_values, "VALUE", value_node_value); diff --git a/paint/sources/material_nodes/vector_curves_node.c b/paint/sources/material_nodes/vector_curves_node.c index dec2d388..7897b86d 100644 --- a/paint/sources/material_nodes/vector_curves_node.c +++ b/paint/sources/material_nodes/vector_curves_node.c @@ -222,66 +222,66 @@ void nodes_material_vector_curves_button(i32 node_id) { void vector_curves_node_init() { - vector_curves_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, - .name = _tr("Vector Curves"), - .type = "CURVE_VEC", - .x = 0, - .y = 0, - .color = 0xff522c99, - .inputs = any_array_create_from_raw( - (void *[]){ - GC_ALLOC_INIT(ui_node_socket_t, {.id = 0, - .node_id = 0, - .name = _tr("Factor"), - .type = "VALUE", - .color = 0xffa1a1a1, - .default_value = f32_array_create_x(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("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}), - }, - 1), - .buttons = any_array_create_from_raw( - (void *[]){ - GC_ALLOC_INIT(ui_node_button_t, {.name = "nodes_material_vector_curves_button", - .type = "CUSTOM", - .output = 0, - .default_value = f32_array_create(96 + 3), - .data = NULL, - .min = 0.0, - .max = 1.0, - .precision = 100, - .height = 7.2}), - }, - 1), - .width = 0, - .flags = 0}); - gc_root(vector_curves_node_def); + ui_node_t *vector_curves_node_def = + GC_ALLOC_INIT(ui_node_t, {.id = 0, + .name = _tr("Vector Curves"), + .type = "CURVE_VEC", + .x = 0, + .y = 0, + .color = 0xff522c99, + .inputs = any_array_create_from_raw( + (void *[]){ + GC_ALLOC_INIT(ui_node_socket_t, {.id = 0, + .node_id = 0, + .name = _tr("Factor"), + .type = "VALUE", + .color = 0xffa1a1a1, + .default_value = f32_array_create_x(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("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}), + }, + 1), + .buttons = any_array_create_from_raw( + (void *[]){ + GC_ALLOC_INIT(ui_node_button_t, {.name = "nodes_material_vector_curves_button", + .type = "CUSTOM", + .output = 0, + .default_value = f32_array_create(96 + 3), + .data = NULL, + .min = 0.0, + .max = 1.0, + .precision = 100, + .height = 7.2}), + }, + 1), + .width = 0, + .flags = 0}); any_array_push(nodes_material_utilities, vector_curves_node_def); any_map_set(parser_material_node_vectors, "CURVE_VEC", vector_curves_node_vector); diff --git a/paint/sources/material_nodes/vector_math2_node.c b/paint/sources/material_nodes/vector_math2_node.c index 762e7c5f..765eb13a 100644 --- a/paint/sources/material_nodes/vector_math2_node.c +++ b/paint/sources/material_nodes/vector_math2_node.c @@ -115,11 +115,11 @@ char *vector_math2_node_value(ui_node_t *node, ui_node_socket_t *socket) { void vector_math2_node_init() { char *vector_math_operation_data = - string("%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s", _tr("Add"), _tr("Subtract"), _tr("Multiply"), - _tr("Divide"), _tr("Average"), _tr("Cross Product"), _tr("Project"), _tr("Reflect"), _tr("Dot Product"), _tr("Distance"), _tr("Length"), - _tr("Scale"), _tr("Normalize"), _tr("Absolute"), _tr("Power"), _tr("Sign"), _tr("Minimum"), _tr("Maximum"), _tr("Floor"), _tr("Ceil"), - _tr("Fraction"), _tr("Modulo"), _tr("Snap"), _tr("Sine"), _tr("Cosine"), _tr("Tangent")); - vector_math2_node_def = + string("%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s", _tr("Add"), _tr("Subtract"), + _tr("Multiply"), _tr("Divide"), _tr("Average"), _tr("Cross Product"), _tr("Project"), _tr("Reflect"), _tr("Dot Product"), _tr("Distance"), + _tr("Length"), _tr("Scale"), _tr("Normalize"), _tr("Absolute"), _tr("Power"), _tr("Sign"), _tr("Minimum"), _tr("Maximum"), _tr("Floor"), + _tr("Ceil"), _tr("Fraction"), _tr("Modulo"), _tr("Snap"), _tr("Sine"), _tr("Cosine"), _tr("Tangent")); + ui_node_t *vector_math2_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, .name = _tr("Vector Math"), .type = "VECT_MATH", @@ -189,7 +189,6 @@ void vector_math2_node_init() { 1), .width = 0, .flags = 0}); - gc_root(vector_math2_node_def); any_array_push(nodes_material_utilities, vector_math2_node_def); any_map_set(parser_material_node_vectors, "VECT_MATH", vector_math2_node_vector); diff --git a/paint/sources/material_nodes/vector_rotate_node.c b/paint/sources/material_nodes/vector_rotate_node.c index 4492d4d9..d456396e 100644 --- a/paint/sources/material_nodes/vector_rotate_node.c +++ b/paint/sources/material_nodes/vector_rotate_node.c @@ -20,7 +20,7 @@ char *vector_rotate_node_vector(ui_node_t *node, ui_node_socket_t *socket) { void vector_rotate_node_init() { - vector_rotate_node_def = + ui_node_t *vector_rotate_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, .name = _tr("Vector Rotate"), .type = "VECT_ROTATE", @@ -88,7 +88,6 @@ void vector_rotate_node_init() { .buttons = any_array_create_from_raw((void *[]){}, 0), .width = 0, .flags = 0}); - gc_root(vector_rotate_node_def); any_array_push(nodes_material_utilities, vector_rotate_node_def); any_map_set(parser_material_node_vectors, "VECT_ROTATE", vector_rotate_node_vector); diff --git a/paint/sources/material_nodes/vector_transform_node.c b/paint/sources/material_nodes/vector_transform_node.c index 9c729e3f..d0c1ef77 100644 --- a/paint/sources/material_nodes/vector_transform_node.c +++ b/paint/sources/material_nodes/vector_transform_node.c @@ -34,7 +34,7 @@ void vector_transform_node_init() { char *type_data = string("%s\n%s\n%s", _tr("Vector"), _tr("Point"), _tr("Normal")); char *space_data = string("%s\n%s\n%s", _tr("World"), _tr("Object"), _tr("Camera")); - vector_transform_node_def = + ui_node_t *vector_transform_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, .name = _tr("Vector Transform"), .type = "VECT_TRANSFORM", @@ -102,7 +102,6 @@ void vector_transform_node_init() { 3), .width = 0, .flags = 0}); - gc_root(vector_transform_node_def); any_array_push(nodes_material_utilities, vector_transform_node_def); any_map_set(parser_material_node_vectors, "VECT_TRANSFORM", vector_transform_node_vector); diff --git a/paint/sources/material_nodes/voronoi_texture_node.c b/paint/sources/material_nodes/voronoi_texture_node.c index 87a4ade4..78450b91 100644 --- a/paint/sources/material_nodes/voronoi_texture_node.c +++ b/paint/sources/material_nodes/voronoi_texture_node.c @@ -304,9 +304,9 @@ char *voronoi_texture_node_value(ui_node_t *node, ui_node_socket_t *socket) { void voronoi_texture_node_init() { - char *voronoi_dimensions_data = string("%s\n%s", _tr("2D"), _tr("3D")); - char *voronoi_feature_data = string("%s\n%s", _tr("F1"), _tr("F2")); - voronoi_texture_node_def = + char *voronoi_dimensions_data = string("%s\n%s", _tr("2D"), _tr("3D")); + char *voronoi_feature_data = string("%s\n%s", _tr("F1"), _tr("F2")); + ui_node_t *voronoi_texture_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, .name = _tr("Voronoi Texture"), .type = "TEX_VORONOI", @@ -444,7 +444,6 @@ void voronoi_texture_node_init() { 3), .width = 0, .flags = 0}); - gc_root(voronoi_texture_node_def); any_array_push(nodes_material_texture, voronoi_texture_node_def); any_map_set(parser_material_node_vectors, "TEX_VORONOI", voronoi_texture_node_vector); diff --git a/paint/sources/material_nodes/warp_node.c b/paint/sources/material_nodes/warp_node.c index a67a4406..c4e10959 100644 --- a/paint/sources/material_nodes/warp_node.c +++ b/paint/sources/material_nodes/warp_node.c @@ -19,64 +19,63 @@ char *warp_node_vector(ui_node_t *node, ui_node_socket_t *socket) { void warp_node_init() { - warp_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, - .name = _tr("Warp"), - .type = "DIRECT_WARP", // extension - .x = 0, - .y = 0, - .color = 0xff448c6d, - .inputs = any_array_create_from_raw( - (void *[]){ - GC_ALLOC_INIT(ui_node_socket_t, {.id = 0, - .node_id = 0, - .name = _tr("Color"), - .type = "RGBA", - .color = 0xffc7c729, - .default_value = f32_array_create_xyzw(0.8, 0.8, 0.8, 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("Angle"), - .type = "VALUE", - .color = 0xffa1a1a1, - .default_value = f32_array_create_x(0.0), - .min = 0.0, - .max = 360.0, - .precision = 100, - .display = 0}), - GC_ALLOC_INIT(ui_node_socket_t, {.id = 0, - .node_id = 0, - .name = _tr("Mask"), - .type = "VALUE", - .color = 0xffa1a1a1, - .default_value = f32_array_create_x(0.5), - .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("Color"), - .type = "RGBA", - .color = 0xffc7c729, - .default_value = f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0), - .min = 0.0, - .max = 1.0, - .precision = 100, - .display = 0}), - }, - 1), - .buttons = any_array_create_from_raw((void *[]){}, 0), - .width = 0, - .flags = 0}); - gc_root(warp_node_def); + ui_node_t *warp_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, + .name = _tr("Warp"), + .type = "DIRECT_WARP", // extension + .x = 0, + .y = 0, + .color = 0xff448c6d, + .inputs = any_array_create_from_raw( + (void *[]){ + GC_ALLOC_INIT(ui_node_socket_t, {.id = 0, + .node_id = 0, + .name = _tr("Color"), + .type = "RGBA", + .color = 0xffc7c729, + .default_value = f32_array_create_xyzw(0.8, 0.8, 0.8, 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("Angle"), + .type = "VALUE", + .color = 0xffa1a1a1, + .default_value = f32_array_create_x(0.0), + .min = 0.0, + .max = 360.0, + .precision = 100, + .display = 0}), + GC_ALLOC_INIT(ui_node_socket_t, {.id = 0, + .node_id = 0, + .name = _tr("Mask"), + .type = "VALUE", + .color = 0xffa1a1a1, + .default_value = f32_array_create_x(0.5), + .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("Color"), + .type = "RGBA", + .color = 0xffc7c729, + .default_value = f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0), + .min = 0.0, + .max = 1.0, + .precision = 100, + .display = 0}), + }, + 1), + .buttons = any_array_create_from_raw((void *[]){}, 0), + .width = 0, + .flags = 0}); any_array_push(nodes_material_color, warp_node_def); any_map_set(parser_material_node_vectors, "DIRECT_WARP", warp_node_vector); diff --git a/paint/sources/material_nodes/wave_texture_node.c b/paint/sources/material_nodes/wave_texture_node.c index ff40867b..5d026efe 100644 --- a/paint/sources/material_nodes/wave_texture_node.c +++ b/paint/sources/material_nodes/wave_texture_node.c @@ -83,7 +83,7 @@ void wave_texture_node_init() { char *wave_direction_data = string("%s\n%s\n%s\n%s", _tr("X"), _tr("Y"), _tr("Z"), _tr("Diagonal")); char *wave_profile_data = string("%s\n%s\n%s", _tr("Sine"), _tr("Saw"), _tr("Triangle")); - wave_texture_node_def = + ui_node_t *wave_texture_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, .name = _tr("Wave Texture"), .type = "TEX_WAVE", @@ -211,7 +211,6 @@ void wave_texture_node_init() { 3), .width = 0, .flags = 0}); - gc_root(wave_texture_node_def); any_array_push(nodes_material_texture, wave_texture_node_def); any_map_set(parser_material_node_vectors, "TEX_WAVE", wave_texture_node_vector); diff --git a/paint/sources/material_nodes/wireframe_node.c b/paint/sources/material_nodes/wireframe_node.c index ebcb0116..a3a8d465 100644 --- a/paint/sources/material_nodes/wireframe_node.c +++ b/paint/sources/material_nodes/wireframe_node.c @@ -10,56 +10,56 @@ char *wireframe_node_value(ui_node_t *node, ui_node_socket_t *socket) { void wireframe_node_init() { - wireframe_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, - .name = _tr("Wireframe"), - .type = "WIREFRAME", - .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("Size"), - .type = "VALUE", - .color = 0xffa1a1a1, - .default_value = f32_array_create_x(0.01), - .min = 0.0, - .max = 0.1, - .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("Factor"), - .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("Pixel Size"), - .type = "BOOL", - .output = 0, - .default_value = f32_array_create_x(0), - .data = NULL, - .min = 0.0, - .max = 1.0, - .precision = 100, - .height = 0}), - }, - 1), - .width = 0, - .flags = 0}); - gc_root(wireframe_node_def); + ui_node_t *wireframe_node_def = + GC_ALLOC_INIT(ui_node_t, {.id = 0, + .name = _tr("Wireframe"), + .type = "WIREFRAME", + .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("Size"), + .type = "VALUE", + .color = 0xffa1a1a1, + .default_value = f32_array_create_x(0.01), + .min = 0.0, + .max = 0.1, + .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("Factor"), + .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("Pixel Size"), + .type = "BOOL", + .output = 0, + .default_value = f32_array_create_x(0), + .data = NULL, + .min = 0.0, + .max = 1.0, + .precision = 100, + .height = 0}), + }, + 1), + .width = 0, + .flags = 0}); any_array_push(nodes_material_input, wireframe_node_def); any_map_set(parser_material_node_values, "WIREFRAME", wireframe_node_value); diff --git a/paint/sources/neural_nodes/edit_image_node.c b/paint/sources/neural_nodes/edit_image_node.c index 5a24404a..07a1448a 100644 --- a/paint/sources/neural_nodes/edit_image_node.c +++ b/paint/sources/neural_nodes/edit_image_node.c @@ -77,56 +77,56 @@ void edit_image_node_button(i32 node_id) { void edit_image_node_init() { - edit_image_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, - .name = _tr("Edit Image"), - .type = "NEURAL_EDIT_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("Color"), - .type = "RGBA", - .color = 0xffc7c729, - .default_value = f32_array_create_xyzw(1.0, 1.0, 1.0, 1.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 = "RGBA", - .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}), - }, - 1), - .buttons = any_array_create_from_raw( - (void *[]){ - GC_ALLOC_INIT(ui_node_button_t, {.name = "edit_image_node_button", - .type = "CUSTOM", - .output = -1, - .default_value = f32_array_create_x(0), - .data = NULL, - .min = 0.0, - .max = 1.0, - .precision = 100, - .height = 0}), - }, - 1), - .width = 0, - .flags = 0}); - gc_root(edit_image_node_def); + ui_node_t *edit_image_node_def = + GC_ALLOC_INIT(ui_node_t, {.id = 0, + .name = _tr("Edit Image"), + .type = "NEURAL_EDIT_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("Color"), + .type = "RGBA", + .color = 0xffc7c729, + .default_value = f32_array_create_xyzw(1.0, 1.0, 1.0, 1.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 = "RGBA", + .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}), + }, + 1), + .buttons = any_array_create_from_raw( + (void *[]){ + GC_ALLOC_INIT(ui_node_button_t, {.name = "edit_image_node_button", + .type = "CUSTOM", + .output = -1, + .default_value = f32_array_create_x(0), + .data = NULL, + .min = 0.0, + .max = 1.0, + .precision = 100, + .height = 0}), + }, + 1), + .width = 0, + .flags = 0}); any_array_push(nodes_material_neural, edit_image_node_def); any_map_set(parser_material_node_vectors, "NEURAL_EDIT_IMAGE", neural_node_vector); diff --git a/paint/sources/neural_nodes/image_to_3d_mesh_node.c b/paint/sources/neural_nodes/image_to_3d_mesh_node.c index acd3de88..2f99ea79 100644 --- a/paint/sources/neural_nodes/image_to_3d_mesh_node.c +++ b/paint/sources/neural_nodes/image_to_3d_mesh_node.c @@ -33,7 +33,7 @@ void image_to_3d_mesh_node_button(i32 node_id) { ui_node_t *node = ui_get_node(canvas->nodes, node_id); char *node_name = parser_material_node_name(node, NULL); ui_handle_t *h = ui_handle(node_name); - string_array_t *models = any_array_create_from_raw( + string_array_t *models = any_array_create_from_raw( (void *[]){ "Hunyuan3D", }, @@ -52,7 +52,7 @@ void image_to_3d_mesh_node_button(i32 node_id) { #endif iron_write_png(string("%s%sinput.png", dir, PATH_SEP), input_buf, input->width, input->height, 0); - dir = string_copy(string_replace_all(dir, "\\", "/")); + dir = string_copy(string_replace_all(dir, "\\", "/")); string_array_t *argv = any_array_create_from_raw( (void *[]){ string("%s/Hunyuan3D_win64/python/python.exe", dir), @@ -76,7 +76,7 @@ void image_to_3d_mesh_node_button(i32 node_id) { void image_to_3d_mesh_node_init() { - image_to_3d_mesh_node_def = + ui_node_t *image_to_3d_mesh_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, .name = _tr("Image to 3D Mesh"), .type = "NEURAL_IMAGE_TO_3D_MESH", @@ -126,7 +126,6 @@ void image_to_3d_mesh_node_init() { 1), .width = 0, .flags = 0}); - gc_root(image_to_3d_mesh_node_def); any_array_push(nodes_material_neural, image_to_3d_mesh_node_def); any_map_set(parser_material_node_values, "NEURAL_IMAGE_TO_3D_MESH", neural_node_value); diff --git a/paint/sources/neural_nodes/image_to_depth_node.c b/paint/sources/neural_nodes/image_to_depth_node.c index 1ec6fccc..a9cc4cb0 100644 --- a/paint/sources/neural_nodes/image_to_depth_node.c +++ b/paint/sources/neural_nodes/image_to_depth_node.c @@ -6,7 +6,7 @@ void image_to_depth_node_button(i32 node_id) { ui_node_t *node = ui_get_node(canvas->nodes, node_id); char *node_name = parser_material_node_name(node, NULL); ui_handle_t *h = ui_handle(node_name); - string_array_t *models = any_array_create_from_raw( + string_array_t *models = any_array_create_from_raw( (void *[]){ "Marigold", }, @@ -57,7 +57,7 @@ void image_to_depth_node_button(i32 node_id) { void image_to_depth_node_init() { - image_to_depth_node_def = + ui_node_t *image_to_depth_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, .name = _tr("Image to Depth"), .type = "NEURAL_IMAGE_TO_DEPTH", @@ -107,7 +107,6 @@ void image_to_depth_node_init() { 1), .width = 0, .flags = 0}); - gc_root(image_to_depth_node_def); any_array_push(nodes_material_neural, image_to_depth_node_def); any_map_set(parser_material_node_values, "NEURAL_IMAGE_TO_DEPTH", neural_node_value); diff --git a/paint/sources/neural_nodes/image_to_normal_map_node.c b/paint/sources/neural_nodes/image_to_normal_map_node.c index 71b3618d..2c6332c6 100644 --- a/paint/sources/neural_nodes/image_to_normal_map_node.c +++ b/paint/sources/neural_nodes/image_to_normal_map_node.c @@ -6,7 +6,7 @@ void image_to_normal_map_node_button(i32 node_id) { ui_node_t *node = ui_get_node(canvas->nodes, node_id); char *node_name = parser_material_node_name(node, NULL); ui_handle_t *h = ui_handle(node_name); - string_array_t *models = any_array_create_from_raw( + string_array_t *models = any_array_create_from_raw( (void *[]){ "Marigold", }, @@ -57,7 +57,7 @@ void image_to_normal_map_node_button(i32 node_id) { void image_to_normal_map_node_init() { - image_to_normal_map_node_def = + ui_node_t *image_to_normal_map_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, .name = _tr("Image to Normal Map"), .type = "NEURAL_IMAGE_TO_NORMAL_MAP", @@ -107,7 +107,6 @@ void image_to_normal_map_node_init() { 1), .width = 0, .flags = 0}); - gc_root(image_to_normal_map_node_def); any_array_push(nodes_material_neural, image_to_normal_map_node_def); any_map_set(parser_material_node_vectors, "NEURAL_IMAGE_TO_NORMAL_MAP", neural_node_vector); diff --git a/paint/sources/neural_nodes/image_to_pbr_node.c b/paint/sources/neural_nodes/image_to_pbr_node.c index ea640352..45a957a2 100644 --- a/paint/sources/neural_nodes/image_to_pbr_node.c +++ b/paint/sources/neural_nodes/image_to_pbr_node.c @@ -1,6 +1,13 @@ #include "../global.h" +gpu_texture_t *image_to_pbr_node_result_base = NULL; +gpu_texture_t *image_to_pbr_node_result_normal = NULL; +gpu_texture_t *image_to_pbr_node_result_occlusion = NULL; +gpu_texture_t *image_to_pbr_node_result_height = NULL; +gpu_texture_t *image_to_pbr_node_result_roughness = NULL; +gpu_texture_t *image_to_pbr_node_result_metallic = NULL; + char *image_to_pbr_node_vector(ui_node_t *node, ui_node_socket_t *socket) { gpu_texture_t *result = NULL; if (socket == node->outputs->buffer[0]) { // base color @@ -60,7 +67,7 @@ void image_to_pbr_node_check_result(void (*done)(gpu_texture_t *)) { } void image_to_pbr_node_run_sd(char *model, char *prompt, void (*done)(gpu_texture_t *)) { - char *dir = neural_node_dir(); + char *dir = neural_node_dir(); string_array_t *argv = any_array_create_from_raw( (void *[]){ string("%s/%s", dir, neural_node_sd_bin()), @@ -165,7 +172,7 @@ void image_to_pbr_node_button(i32 node_id) { ui_node_t *node = ui_get_node(canvas->nodes, node_id); char *node_name = parser_material_node_name(node, NULL); ui_handle_t *h = ui_handle(node_name); - string_array_t *models = any_array_create_from_raw( + string_array_t *models = any_array_create_from_raw( (void *[]){ "Marigold", }, @@ -191,7 +198,7 @@ void image_to_pbr_node_button(i32 node_id) { void image_to_pbr_node_init() { - image_to_pbr_node_def = + ui_node_t *image_to_pbr_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, .name = _tr("Image to PBR"), .type = "NEURAL_IMAGE_TO_PBR", @@ -291,7 +298,6 @@ void image_to_pbr_node_init() { 1), .width = 0, .flags = 0}); - gc_root(image_to_pbr_node_def); any_array_push(nodes_material_neural, image_to_pbr_node_def); any_map_set(parser_material_node_vectors, "NEURAL_IMAGE_TO_PBR", image_to_pbr_node_vector); diff --git a/paint/sources/neural_nodes/inpaint_image_node.c b/paint/sources/neural_nodes/inpaint_image_node.c index a84256fa..a86f155d 100644 --- a/paint/sources/neural_nodes/inpaint_image_node.c +++ b/paint/sources/neural_nodes/inpaint_image_node.c @@ -114,7 +114,7 @@ void inpaint_image_node_button(i32 node_id) { ui_node_t *node = ui_get_node(canvas->nodes, node_id); char *node_name = parser_material_node_name(node, NULL); ui_handle_t *h = ui_handle(node_name); - string_array_t *models = any_array_create_from_raw( + string_array_t *models = any_array_create_from_raw( (void *[]){ "Stable Diffusion", "Qwen Image Edit", @@ -131,66 +131,66 @@ void inpaint_image_node_button(i32 node_id) { void inpaint_image_node_init() { - inpaint_image_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, - .name = _tr("Inpaint Image"), - .type = "NEURAL_INPAINT_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("Color"), - .type = "RGBA", - .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("Mask"), - .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("Color"), - .type = "RGBA", - .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}), - }, - 1), - .buttons = any_array_create_from_raw( - (void *[]){ - GC_ALLOC_INIT(ui_node_button_t, {.name = "inpaint_image_node_button", - .type = "CUSTOM", - .output = -1, - .default_value = f32_array_create_x(0), - .data = NULL, - .min = 0.0, - .max = 1.0, - .precision = 100, - .height = 2}), - }, - 1), - .width = 0, - .flags = 0}); - gc_root(inpaint_image_node_def); + ui_node_t *inpaint_image_node_def = + GC_ALLOC_INIT(ui_node_t, {.id = 0, + .name = _tr("Inpaint Image"), + .type = "NEURAL_INPAINT_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("Color"), + .type = "RGBA", + .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("Mask"), + .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("Color"), + .type = "RGBA", + .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}), + }, + 1), + .buttons = any_array_create_from_raw( + (void *[]){ + GC_ALLOC_INIT(ui_node_button_t, {.name = "inpaint_image_node_button", + .type = "CUSTOM", + .output = -1, + .default_value = f32_array_create_x(0), + .data = NULL, + .min = 0.0, + .max = 1.0, + .precision = 100, + .height = 2}), + }, + 1), + .width = 0, + .flags = 0}); any_array_push(nodes_material_neural, inpaint_image_node_def); any_map_set(parser_material_node_vectors, "NEURAL_INPAINT_IMAGE", neural_node_vector); diff --git a/paint/sources/neural_nodes/outpaint_image_node.c b/paint/sources/neural_nodes/outpaint_image_node.c index a8d014c7..cdcb59a2 100644 --- a/paint/sources/neural_nodes/outpaint_image_node.c +++ b/paint/sources/neural_nodes/outpaint_image_node.c @@ -112,7 +112,7 @@ void outpaint_image_node_button(i32 node_id) { ui_node_t *node = ui_get_node(canvas->nodes, node_id); char *node_name = parser_material_node_name(node, NULL); ui_handle_t *h = ui_handle(node_name); - string_array_t *models = any_array_create_from_raw( + string_array_t *models = any_array_create_from_raw( (void *[]){ "Stable Diffusion", "Qwen Image Edit", @@ -129,7 +129,7 @@ void outpaint_image_node_button(i32 node_id) { void outpaint_image_node_init() { - outpaint_image_node_def = + ui_node_t *outpaint_image_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, .name = _tr("Outpaint Image"), .type = "NEURAL_OUTPAINT_IMAGE", @@ -179,7 +179,6 @@ void outpaint_image_node_init() { 1), .width = 0, .flags = 0}); - gc_root(outpaint_image_node_def); any_array_push(nodes_material_neural, outpaint_image_node_def); any_map_set(parser_material_node_vectors, "NEURAL_OUTPAINT_IMAGE", neural_node_vector); diff --git a/paint/sources/neural_nodes/text_to_image_node.c b/paint/sources/neural_nodes/text_to_image_node.c index 44f1de66..8bd322e5 100644 --- a/paint/sources/neural_nodes/text_to_image_node.c +++ b/paint/sources/neural_nodes/text_to_image_node.c @@ -131,9 +131,9 @@ string_array_t *text_to_image_node_wan_args(char *dir, char *prompt) { } void text_to_image_node_button(i32 node_id) { - ui_node_t *node = ui_get_node(ui_nodes_get_canvas(true)->nodes, node_id); - char *node_name = parser_material_node_name(node, NULL); - ui_handle_t *h = ui_handle(node_name); + ui_node_t *node = ui_get_node(ui_nodes_get_canvas(true)->nodes, node_id); + char *node_name = parser_material_node_name(node, NULL); + ui_handle_t *h = ui_handle(node_name); string_array_t *models = any_array_create_from_raw( (void *[]){ "Stable Diffusion", @@ -178,52 +178,52 @@ void text_to_image_node_button(i32 node_id) { void text_to_image_node_init() { - text_to_image_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, - .name = _tr("Text to Image"), - .type = "NEURAL_TEXT_TO_IMAGE", - .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("Color"), - .type = "RGBA", - .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}), - }, - 1), - .buttons = any_array_create_from_raw( - (void *[]){ - GC_ALLOC_INIT(ui_node_button_t, {.name = "text_to_image_node_button", - .type = "CUSTOM", - .output = -1, - .default_value = f32_array_create_x(0), - .data = NULL, - .min = 0.0, - .max = 1.0, - .precision = 100, - .height = 1}), - GC_ALLOC_INIT(ui_node_button_t, {.name = _tr("Tiled"), - .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}); - gc_root(text_to_image_node_def); + ui_node_t *text_to_image_node_def = + GC_ALLOC_INIT(ui_node_t, {.id = 0, + .name = _tr("Text to Image"), + .type = "NEURAL_TEXT_TO_IMAGE", + .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("Color"), + .type = "RGBA", + .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}), + }, + 1), + .buttons = any_array_create_from_raw( + (void *[]){ + GC_ALLOC_INIT(ui_node_button_t, {.name = "text_to_image_node_button", + .type = "CUSTOM", + .output = -1, + .default_value = f32_array_create_x(0), + .data = NULL, + .min = 0.0, + .max = 1.0, + .precision = 100, + .height = 1}), + GC_ALLOC_INIT(ui_node_button_t, {.name = _tr("Tiled"), + .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}); any_array_push(nodes_material_neural, text_to_image_node_def); any_map_set(parser_material_node_vectors, "NEURAL_TEXT_TO_IMAGE", neural_node_vector); diff --git a/paint/sources/neural_nodes/tile_image_node.c b/paint/sources/neural_nodes/tile_image_node.c index c113eb24..a2b7b753 100644 --- a/paint/sources/neural_nodes/tile_image_node.c +++ b/paint/sources/neural_nodes/tile_image_node.c @@ -112,7 +112,7 @@ void tile_image_node_button(i32 node_id) { ui_node_t *node = ui_get_node(canvas->nodes, node_id); char *node_name = parser_material_node_name(node, NULL); ui_handle_t *h = ui_handle(node_name); - string_array_t *models = any_array_create_from_raw( + string_array_t *models = any_array_create_from_raw( (void *[]){ "Stable Diffusion", "Qwen Image Edit", @@ -129,56 +129,56 @@ void tile_image_node_button(i32 node_id) { void tile_image_node_init() { - tile_image_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, - .name = _tr("Tile Image"), - .type = "NEURAL_TILE_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("Color"), - .type = "RGBA", - .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}), - }, - 1), - .outputs = any_array_create_from_raw( - (void *[]){ - GC_ALLOC_INIT(ui_node_socket_t, {.id = 0, - .node_id = 0, - .name = _tr("Color"), - .type = "RGBA", - .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}), - }, - 1), - .buttons = any_array_create_from_raw( - (void *[]){ - GC_ALLOC_INIT(ui_node_button_t, {.name = "tile_image_node_button", - .type = "CUSTOM", - .output = -1, - .default_value = f32_array_create_x(0), - .data = NULL, - .min = 0.0, - .max = 1.0, - .precision = 100, - .height = 2}), - }, - 1), - .width = 0, - .flags = 0}); - gc_root(tile_image_node_def); + ui_node_t *tile_image_node_def = + GC_ALLOC_INIT(ui_node_t, {.id = 0, + .name = _tr("Tile Image"), + .type = "NEURAL_TILE_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("Color"), + .type = "RGBA", + .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}), + }, + 1), + .outputs = any_array_create_from_raw( + (void *[]){ + GC_ALLOC_INIT(ui_node_socket_t, {.id = 0, + .node_id = 0, + .name = _tr("Color"), + .type = "RGBA", + .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}), + }, + 1), + .buttons = any_array_create_from_raw( + (void *[]){ + GC_ALLOC_INIT(ui_node_button_t, {.name = "tile_image_node_button", + .type = "CUSTOM", + .output = -1, + .default_value = f32_array_create_x(0), + .data = NULL, + .min = 0.0, + .max = 1.0, + .precision = 100, + .height = 2}), + }, + 1), + .width = 0, + .flags = 0}); any_array_push(nodes_material_neural, tile_image_node_def); any_map_set(parser_material_node_vectors, "NEURAL_TILE_IMAGE", neural_node_vector); diff --git a/paint/sources/neural_nodes/upscale_image_node.c b/paint/sources/neural_nodes/upscale_image_node.c index 6432bb8d..a409cd7b 100644 --- a/paint/sources/neural_nodes/upscale_image_node.c +++ b/paint/sources/neural_nodes/upscale_image_node.c @@ -6,7 +6,7 @@ void upscale_image_node_button(i32 node_id) { ui_node_t *node = ui_get_node(canvas->nodes, node_id); char *node_name = parser_material_node_name(node, NULL); ui_handle_t *h = ui_handle(node_name); - string_array_t *models = any_array_create_from_raw( + string_array_t *models = any_array_create_from_raw( (void *[]){ "Real-ESRGAN", }, @@ -47,56 +47,56 @@ void upscale_image_node_button(i32 node_id) { void upscale_image_node_init() { - upscale_image_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, - .name = _tr("Upscale Image"), - .type = "NEURAL_UPSCALE_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("Color"), - .type = "RGBA", - .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}), - }, - 1), - .outputs = any_array_create_from_raw( - (void *[]){ - GC_ALLOC_INIT(ui_node_socket_t, {.id = 0, - .node_id = 0, - .name = _tr("Color"), - .type = "RGBA", - .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}), - }, - 1), - .buttons = any_array_create_from_raw( - (void *[]){ - GC_ALLOC_INIT(ui_node_button_t, {.name = "upscale_image_node_button", - .type = "CUSTOM", - .output = -1, - .default_value = f32_array_create_x(0), - .data = NULL, - .min = 0.0, - .max = 1.0, - .precision = 100, - .height = 2}), - }, - 1), - .width = 0, - .flags = 0}); - gc_root(upscale_image_node_def); + ui_node_t *upscale_image_node_def = + GC_ALLOC_INIT(ui_node_t, {.id = 0, + .name = _tr("Upscale Image"), + .type = "NEURAL_UPSCALE_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("Color"), + .type = "RGBA", + .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}), + }, + 1), + .outputs = any_array_create_from_raw( + (void *[]){ + GC_ALLOC_INIT(ui_node_socket_t, {.id = 0, + .node_id = 0, + .name = _tr("Color"), + .type = "RGBA", + .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}), + }, + 1), + .buttons = any_array_create_from_raw( + (void *[]){ + GC_ALLOC_INIT(ui_node_button_t, {.name = "upscale_image_node_button", + .type = "CUSTOM", + .output = -1, + .default_value = f32_array_create_x(0), + .data = NULL, + .min = 0.0, + .max = 1.0, + .precision = 100, + .height = 2}), + }, + 1), + .width = 0, + .flags = 0}); any_array_push(nodes_material_neural, upscale_image_node_def); any_map_set(parser_material_node_vectors, "NEURAL_UPSCALE_IMAGE", neural_node_vector); diff --git a/paint/sources/neural_nodes/vary_image_node.c b/paint/sources/neural_nodes/vary_image_node.c index da49b7db..3f7a1372 100644 --- a/paint/sources/neural_nodes/vary_image_node.c +++ b/paint/sources/neural_nodes/vary_image_node.c @@ -110,7 +110,7 @@ void vary_image_node_button(i32 node_id) { ui_node_t *node = ui_get_node(canvas->nodes, node_id); char *node_name = parser_material_node_name(node, NULL); ui_handle_t *h = ui_handle(node_name); - string_array_t *models = any_array_create_from_raw( + string_array_t *models = any_array_create_from_raw( (void *[]){ "Stable Diffusion", "Qwen Image Edit", @@ -127,56 +127,56 @@ void vary_image_node_button(i32 node_id) { void vary_image_node_init() { - vary_image_node_def = GC_ALLOC_INIT(ui_node_t, {.id = 0, - .name = _tr("Vary Image"), - .type = "NEURAL_VARY_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("Color"), - .type = "RGBA", - .color = 0xffc7c729, - .default_value = f32_array_create_xyzw(1.0, 1.0, 1.0, 1.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 = "RGBA", - .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}), - }, - 1), - .buttons = any_array_create_from_raw( - (void *[]){ - GC_ALLOC_INIT(ui_node_button_t, {.name = "vary_image_node_button", - .type = "CUSTOM", - .output = -1, - .default_value = f32_array_create_x(0), - .data = NULL, - .min = 0.0, - .max = 1.0, - .precision = 100, - .height = 0}), - }, - 1), - .width = 0, - .flags = 0}); - gc_root(vary_image_node_def); + ui_node_t *vary_image_node_def = + GC_ALLOC_INIT(ui_node_t, {.id = 0, + .name = _tr("Vary Image"), + .type = "NEURAL_VARY_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("Color"), + .type = "RGBA", + .color = 0xffc7c729, + .default_value = f32_array_create_xyzw(1.0, 1.0, 1.0, 1.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 = "RGBA", + .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}), + }, + 1), + .buttons = any_array_create_from_raw( + (void *[]){ + GC_ALLOC_INIT(ui_node_button_t, {.name = "vary_image_node_button", + .type = "CUSTOM", + .output = -1, + .default_value = f32_array_create_x(0), + .data = NULL, + .min = 0.0, + .max = 1.0, + .precision = 100, + .height = 0}), + }, + 1), + .width = 0, + .flags = 0}); any_array_push(nodes_material_neural, vary_image_node_def); any_map_set(parser_material_node_vectors, "NEURAL_VARY_IMAGE", neural_node_vector); diff --git a/paint/sources/nodes_brush.c b/paint/sources/nodes_brush.c index 3f4e6b41..ede5d476 100644 --- a/paint/sources/nodes_brush.c +++ b/paint/sources/nodes_brush.c @@ -1,6 +1,8 @@ #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(); @@ -25,6 +27,526 @@ void nodes_brush_list_init() { 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 *[]){ diff --git a/paint/sources/parser_logic.c b/paint/sources/parser_logic.c index ec52b506..a974dbff 100644 --- a/paint/sources/parser_logic.c +++ b/paint/sources/parser_logic.c @@ -1,6 +1,11 @@ #include "global.h" +ui_node_t_array_t *parser_logic_nodes; +ui_node_link_t_array_t *parser_logic_links; +string_array_t *parser_logic_parsed_nodes = NULL; +any_map_t *parser_logic_node_map; + ui_node_t *parser_logic_get_node(i32 id) { for (i32 i = 0; i < parser_logic_nodes->length; ++i) { ui_node_t *n = parser_logic_nodes->buffer[i]; diff --git a/paint/sources/parser_material.c b/paint/sources/parser_material.c index bc2642f6..841f5913 100644 --- a/paint/sources/parser_material.c +++ b/paint/sources/parser_material.c @@ -1,6 +1,11 @@ #include "global.h" +bool parser_material_cotangent_frame_written; +bool parser_material_parse_surface = true; +bool parser_material_parse_opacity = true; +bool parser_material_arm_export_tangents = true; + ui_node_t *parser_material_get_node(i32 id) { for (i32 i = 0; i < parser_material_nodes->length; ++i) { ui_node_t *n = parser_material_nodes->buffer[i]; @@ -423,7 +428,7 @@ char *parser_material_parse_vector(ui_node_t *node, ui_node_socket_t *socket) { return parser_material_parse_group_input(node, socket); } else if (any_map_get(parser_material_custom_nodes, node->type) != NULL) { - void *cb = any_map_get(parser_material_custom_nodes, node->type); + void *cb = any_map_get(parser_material_custom_nodes, node->type); minic_val_t args[2] = {minic_val_ptr(node), minic_val_ptr(socket->name)}; return minic_call_fn(cb, args, 2).p; } @@ -462,7 +467,7 @@ char *parser_material_parse_value(ui_node_t *node, ui_node_socket_t *socket) { return parser_material_parse_group_input(node, socket); } else if (any_map_get(parser_material_custom_nodes, node->type) != NULL) { - void *cb = any_map_get(parser_material_custom_nodes, node->type); + void *cb = any_map_get(parser_material_custom_nodes, node->type); minic_val_t args[2] = {minic_val_ptr(node), minic_val_ptr(socket->name)}; return minic_call_fn(cb, args, 2).p; } @@ -591,7 +596,7 @@ bind_tex_t *parser_material_make_bind_tex(char *tex_name, char *file) { } char *u8_array_string_at(u8_array_t *a, i32 i) { - char *s = u8_array_to_string(a); + char *s = u8_array_to_string(a); string_array_t *ss = string_split(s, "\n"); return ss->buffer[i]; } diff --git a/paint/sources/physics_sim.c b/paint/sources/physics_sim.c index 053a7484..3d5e8835 100644 --- a/paint/sources/physics_sim.c +++ b/paint/sources/physics_sim.c @@ -1,6 +1,9 @@ #include "global.h" +mat4_box_t_array_t *sim_transforms; +bool sim_initialized = false; + void sim_init() { if (sim_initialized) { return; diff --git a/paint/sources/plugin.c b/paint/sources/plugin.c index 99aebb77..9c158212 100644 --- a/paint/sources/plugin.c +++ b/paint/sources/plugin.c @@ -1,6 +1,8 @@ #include "global.h" +char *_plugin_name; + plugin_t *plugin_create() { plugin_t *p = GC_ALLOC_INIT(plugin_t, {0}); p->name = string_copy(_plugin_name); @@ -17,7 +19,7 @@ void plugin_start(char *plugin) { data_delete_blob(string("plugins/%s", plugin)); // Store context on the plugin so callbacks can use it and it can be freed on stop plugin_t *p = any_map_get(plugin_map, plugin); - p->ctx = ctx; + p->ctx = ctx; } void plugin_stop(char *plugin) { diff --git a/paint/sources/project.c b/paint/sources/project.c index a1aad03d..d1df37ec 100644 --- a/paint/sources/project.c +++ b/paint/sources/project.c @@ -1,6 +1,22 @@ #include "global.h" +bool _project_save_and_quit; +bool _project_import_mesh_replace_existing; +void (*_project_import_mesh_done)(void); +char *_project_import_mesh_box_path; +bool _project_import_mesh_box_replace_existing; +bool _project_import_mesh_box_clear_layers; +void (*_project_import_mesh_box_done)(void); +raw_mesh_t *_project_unwrap_mesh_box_mesh; +void (*_project_unwrap_mesh_box_done)(raw_mesh_t *); +bool _project_unwrap_mesh_box_skip_ui; +bool _project_import_asset_hdr_as_envmap; +bool _project_import_swatches_replace_existing; +asset_t *_project_reimport_texture_asset; +scene_t *_project_scene_mesh_gc; +i32 _project_unwrap_by = 0; + void project_open_on_file_picked(char *path) { if (!ends_with(path, ".arm")) { console_error(strings_arm_file_expected()); @@ -455,10 +471,10 @@ void project_import_mesh_box_draw() { if (ends_with(to_lower_case(path), ".fbx") || ends_with(to_lower_case(path), ".gltf") || ends_with(to_lower_case(path), ".glb")) { ui_row2(); - bool b = ui_check(ui_handle(__ID__), tr("Apply Skinning"), ""); - ui->enabled = b; + bool b = ui_check(ui_handle(__ID__), tr("Apply Skinning"), ""); + ui->enabled = b; plugins_skinning_frame = ui_slider(ui_handle(__ID__), tr("Frame"), 1, 99, false, 1, true, UI_ALIGN_RIGHT, true); - ui->enabled = true; + ui->enabled = true; if (!b) { plugins_skinning_frame = -1; } @@ -552,7 +568,7 @@ void project_unwrap_mesh_box_draw() { void (*done)(raw_mesh_t *) = _project_unwrap_mesh_box_done; string_array_t *unwrap_plugins = project_get_unwrap_plugins(); - _project_unwrap_by = ui_combo(ui_handle(__ID__), unwrap_plugins, tr("Plugin"), true, UI_ALIGN_LEFT, true); + _project_unwrap_by = ui_combo(ui_handle(__ID__), unwrap_plugins, tr("Plugin"), true, UI_ALIGN_LEFT, true); ui_row2(); if (ui_icon_button(tr("Cancel"), ICON_CLOSE, UI_ALIGN_CENTER)) { @@ -695,7 +711,7 @@ bool project_is_atlas_object(mesh_object_t *p) { mesh_object_t_array_t *project_get_atlas_objects(i32 object_mask) { string_array_t *atlases = project_get_used_atlases(); - i32 i = object_mask - project_paint_objects->length - 1; + i32 i = object_mask - project_paint_objects->length - 1; if (atlases == NULL || i >= atlases->length) { return project_paint_objects; } diff --git a/paint/sources/render_path_base.c b/paint/sources/render_path_base.c index 257470ca..ada80bbb 100644 --- a/paint/sources/render_path_base.c +++ b/paint/sources/render_path_base.c @@ -1,6 +1,11 @@ #include "global.h" +f32 render_path_base_super_sample = 1.0; +f32 render_path_base_last_x = -1.0; +f32 render_path_base_last_y = -1.0; +render_target_t_array_t *render_path_base_bloom_mipmaps; + void render_path_base_init() { pipes_init(); const_data_create_screen_aligned_data(); @@ -10,7 +15,7 @@ void render_path_base_init() { void render_path_base_apply_config() { if (render_path_base_super_sample != config_raw->rp_supersample) { render_path_base_super_sample = config_raw->rp_supersample; - string_array_t *keys = map_keys(render_path_render_targets); + string_array_t *keys = map_keys(render_path_render_targets); for (i32 i = 0; i < keys->length; ++i) { render_target_t *rt = any_map_get(render_path_render_targets, keys->buffer[i]); if (rt->width == 0) { @@ -419,8 +424,8 @@ void render_path_base_draw_gbuffer() { if (i == make_mesh_layer_pass_count - 1) { render_path_set_target(string("gbuffer2%s", ping), NULL, NULL, GPU_CLEAR_COLOR, 0xff000000, 0.0); } - char *g1ping = string("gbuffer1%s", ping); - char *g2ping = string("gbuffer2%s", ping); + char *g1ping = string("gbuffer1%s", ping); + char *g2ping = string("gbuffer2%s", ping); string_array_t *additional = any_array_create_from_raw( (void *[]){ g1ping, @@ -443,8 +448,8 @@ void render_path_base_draw_gbuffer() { bool hide = operator_shortcut(any_map_get(config_keymap, "stencil_hide"), SHORTCUT_TYPE_DOWN) || keyboard_down("control"); bool is_decal = base_is_decal_layer(); if (is_decal && !hide) { - line_draw_color = 0xff000000; - line_draw_strength = 0.002; + line_draw_color = 0xff000000; + line_draw_strength = 0.002; string_array_t *additional = any_array_create_from_raw( (void *[]){ "gbuffer1", diff --git a/paint/sources/render_path_paint.c b/paint/sources/render_path_paint.c index d7b8bf9e..7fe8188e 100644 --- a/paint/sources/render_path_paint.c +++ b/paint/sources/render_path_paint.c @@ -1,6 +1,23 @@ #include "global.h" +bool render_path_paint_dilated = true; +mesh_object_t *render_path_paint_painto = NULL; +mesh_object_t *render_path_paint_planeo = NULL; +u8_array_t *render_path_paint_visibles = NULL; +bool render_path_paint_merged_object_visible = false; +f32 render_path_paint_saved_fov = 0.0; +bool render_path_paint_baking = false; +render_target_t *_render_path_paint_texpaint; +render_target_t *_render_path_paint_texpaint_nor; +render_target_t *_render_path_paint_texpaint_pack; +render_target_t *_render_path_paint_texpaint_undo; +render_target_t *_render_path_paint_texpaint_nor_undo; +render_target_t *_render_path_paint_texpaint_pack_undo; +f32 render_path_paint_last_x = -1.0; +f32 render_path_paint_last_y = -1.0; +bake_type_t _render_path_paint_bake_type; + void render_path_paint_init() { { diff --git a/paint/sources/render_path_raytrace.c b/paint/sources/render_path_raytrace.c index c6321737..d731b40e 100644 --- a/paint/sources/render_path_raytrace.c +++ b/paint/sources/render_path_raytrace.c @@ -1,6 +1,11 @@ #include "global.h" +f32 render_path_raytrace_uv_scale = 1.0; +mat4_t render_path_raytrace_transform; +gpu_buffer_t *render_path_raytrace_vb; +gpu_buffer_t *render_path_raytrace_ib; + void render_path_raytrace_init() {} void render_path_raytrace_commands(bool use_live_layer) { diff --git a/paint/sources/render_path_raytrace_bake.c b/paint/sources/render_path_raytrace_bake.c index 8473a684..d62aea06 100644 --- a/paint/sources/render_path_raytrace_bake.c +++ b/paint/sources/render_path_raytrace_bake.c @@ -1,6 +1,12 @@ #include "global.h" +f32 render_path_raytrace_bake_rays_timer = 0.0; +i32 render_path_raytrace_bake_rays_counter = 0; +gpu_texture_t *render_path_raytrace_bake_last_layer = NULL; +i32 render_path_raytrace_bake_last_bake_type = 0; +i32 render_path_raytrace_bake_last_bake_type2 = 0; + void render_path_raytrace_bake_commands_parse_paint_material(void (*parse_paint_material)(bool)) { parse_paint_material(true); } diff --git a/paint/sources/slot_brush.c b/paint/sources/slot_brush.c index 0cf8e755..d613e0ab 100644 --- a/paint/sources/slot_brush.c +++ b/paint/sources/slot_brush.c @@ -1,6 +1,8 @@ #include "global.h" +buffer_t *slot_brush_default_canvas = NULL; + slot_brush_t *slot_brush_create(ui_node_canvas_t *c) { slot_brush_t *raw = GC_ALLOC_INIT(slot_brush_t, {0}); raw->nodes = ui_nodes_create(); diff --git a/paint/sources/slot_layer.c b/paint/sources/slot_layer.c index 485f0458..2cecc036 100644 --- a/paint/sources/slot_layer.c +++ b/paint/sources/slot_layer.c @@ -1,6 +1,20 @@ #include "global.h" +#if defined(IRON_ANDROID) || defined(IRON_IOS) +i32 layers_max_layers = 18; +#else +i32 layers_max_layers = 255; +#endif + +uv_type_t _layers_uv_type; +mat4_t _layers_decal_mat; +i32 _layers_position; +i32 _layers_base_color; +f32 _layers_occlusion; +f32 _layers_roughness; +f32 _layers_metallic; + slot_layer_t *slot_layer_create(char *ext, layer_slot_type_t type, slot_layer_t *parent) { slot_layer_t *raw = GC_ALLOC_INIT(slot_layer_t, {0}); raw->id = 0; diff --git a/paint/sources/slot_material.c b/paint/sources/slot_material.c index 7c6684eb..a5999bde 100644 --- a/paint/sources/slot_material.c +++ b/paint/sources/slot_material.c @@ -1,6 +1,8 @@ #include "global.h" +buffer_t *slot_material_default_canvas = NULL; + slot_material_t *slot_material_create(material_data_t *m, ui_node_canvas_t *c) { slot_material_t *raw = GC_ALLOC_INIT(slot_material_t, {0}); raw->nodes = ui_nodes_create(); diff --git a/paint/sources/tab_browser.c b/paint/sources/tab_browser.c index 54dff9c2..45866128 100644 --- a/paint/sources/tab_browser.c +++ b/paint/sources/tab_browser.c @@ -1,6 +1,11 @@ #include "global.h" +bool tab_browser_known = false; +char *tab_browser_last_path = ""; +char *_tab_browser_draw_file; +char *_tab_browser_draw_b; + void tab_browser_show_directory(char *directory) { tab_browser_hpath->text = string_copy(directory); tab_browser_hsearch->text = ""; diff --git a/paint/sources/tab_brushes.c b/paint/sources/tab_brushes.c index 4a164628..4388f113 100644 --- a/paint/sources/tab_brushes.c +++ b/paint/sources/tab_brushes.c @@ -1,7 +1,9 @@ #include "global.h" -void tab_brushes_draw_make_brush_preview(void * _) { +i32 _tab_brushes_draw_i; + +void tab_brushes_draw_make_brush_preview(void *_) { i32 i = _tab_brushes_draw_i; slot_brush_t *_brush = context_raw->brush; context_raw->brush = project_brushes->buffer[i]; @@ -10,11 +12,11 @@ void tab_brushes_draw_make_brush_preview(void * _) { context_raw->brush = _brush; } -void tab_brushes_draw_duplicate(void * _) { +void tab_brushes_draw_duplicate(void *_) { i32 i = _tab_brushes_draw_i; context_raw->brush = slot_brush_create(NULL); any_array_push(project_brushes, context_raw->brush); - void * cloned = util_clone_canvas(project_brushes->buffer[i]->canvas); + void *cloned = util_clone_canvas(project_brushes->buffer[i]->canvas); context_raw->brush->canvas = cloned; context_set_brush(context_raw->brush); util_render_make_brush_preview(); @@ -117,7 +119,7 @@ void tab_brushes_draw(ui_handle_t *htab) { ui_fill(w + 1, -2, 2, w + 4, ui->ops->theme->HIGHLIGHT_COL); } - f32 uix = ui->_x; + f32 uix = ui->_x; // let uiy: f32 = ui._y; i32 tile = UI_SCALE() > 1 ? 100 : 50; ui_state_t state = project_brushes->buffer[i]->preview_ready ? ui_image(img, 0xffffffff, -1.0) diff --git a/paint/sources/tab_fonts.c b/paint/sources/tab_fonts.c index 61cc945e..71745650 100644 --- a/paint/sources/tab_fonts.c +++ b/paint/sources/tab_fonts.c @@ -1,7 +1,9 @@ #include "global.h" -void tab_fonts_draw_make_font_preview(void * _) { +i32 _tab_fonts_draw_i; + +void tab_fonts_draw_make_font_preview(void *_) { i32 i = _tab_fonts_draw_i; slot_font_t *_font = context_raw->font; context_raw->font = project_fonts->buffer[i]; @@ -28,12 +30,12 @@ void tab_fonts_draw_context_menu_draw() { } } -void tab_fonts_draw_context_menu(void * _) { +void tab_fonts_draw_context_menu(void *_) { context_select_font(_tab_fonts_draw_i); ui_menu_draw(&tab_fonts_draw_context_menu_draw, -1, -1); } -void tab_fonts_draw_select_font(void * _) { +void tab_fonts_draw_select_font(void *_) { i32 i = _tab_fonts_draw_i; context_select_font(i); } diff --git a/paint/sources/tab_layers.c b/paint/sources/tab_layers.c index 9f40a0e2..c6f8715b 100644 --- a/paint/sources/tab_layers.c +++ b/paint/sources/tab_layers.c @@ -1,6 +1,11 @@ #include "global.h" +i32 tab_layers_layer_name_edit = -1; +bool tab_layers_show_context_menu = false; +slot_layer_t *tab_layers_l; +bool tab_layers_mini; + void tab_layers_button_2d_view() { if (ui_button(tr("2D View"), UI_ALIGN_CENTER, "")) { ui_base_show_2d_view(VIEW_2D_TYPE_LAYER); @@ -265,8 +270,8 @@ ui_handle_t *tab_layers_combo_object(slot_layer_t *l, bool label) { } ui_handle_t *tab_layers_combo_blending(slot_layer_t *l, bool label) { - ui_handle_t *blending_handle = ui_nest(ui_handle(__ID__), l->id); - blending_handle->i = l->blending; + ui_handle_t *blending_handle = ui_nest(ui_handle(__ID__), l->id); + blending_handle->i = l->blending; string_array_t *blending_combo = any_array_create_from_raw( (void *[]){ tr("Mix"), @@ -722,8 +727,8 @@ void tab_layers_draw_layer_context_menu_draw() { } ui_menu_align(); - ui_handle_t *huv = ui_handle(__ID__); - huv->i = l->uv_map; + ui_handle_t *huv = ui_handle(__ID__); + huv->i = l->uv_map; string_array_t *aruv = any_array_create_from_raw( (void *[]){ "uv0", @@ -788,8 +793,8 @@ void tab_layers_draw_layer_context_menu_draw() { } ui_menu_align(); - ui_handle_t *uv_type_handle = ui_nest(ui_handle(__ID__), l->id); - uv_type_handle->i = l->uv_type; + ui_handle_t *uv_type_handle = ui_nest(ui_handle(__ID__), l->id); + uv_type_handle->i = l->uv_type; string_array_t *uv_type_items = any_array_create_from_raw( (void *[]){ tr("UV Map"), @@ -856,7 +861,7 @@ void tab_layers_draw_layer_context_menu_draw() { } if (base_handle->changed || opac_handle->changed || nor_handle->changed || nor_blend_handle->changed || occ_handle->changed || rough_handle->changed || - met_handle->changed || height_handle->changed || height_blend_handle->changed || emis_handle->changed || subs_handle->changed) { + met_handle->changed || height_handle->changed || height_blend_handle->changed || emis_handle->changed || subs_handle->changed) { make_material_parse_mesh_material(); ui_menu_keep_open = true; } @@ -1180,7 +1185,7 @@ i32_map_t *tab_layers_init_layer_map() { } i32_imap_t *tab_layers_fill_layer_map(i32_map_t *map) { - i32_imap_t *res = any_map_create(); + i32_imap_t *res = any_map_create(); string_array_t *keys = map_keys(map); for (i32 i = 0; i < keys->length; ++i) { char *l = keys->buffer[i]; diff --git a/paint/sources/tab_materials.c b/paint/sources/tab_materials.c index c50f8bf6..2bbc1fe0 100644 --- a/paint/sources/tab_materials.c +++ b/paint/sources/tab_materials.c @@ -1,6 +1,8 @@ #include "global.h" +i32 _tab_materials_draw_slots; + void tab_materials_button_nodes() { if (ui_button(tr("Nodes"), UI_ALIGN_CENTER, "")) { ui_base_show_material_nodes(); diff --git a/paint/sources/tab_meshes.c b/paint/sources/tab_meshes.c index 1d2bbdf6..11e5f6b5 100644 --- a/paint/sources/tab_meshes.c +++ b/paint/sources/tab_meshes.c @@ -1,6 +1,8 @@ #include "global.h" +i32 _tab_meshes_draw_i; + void tab_meshes_draw_properties(mesh_object_t *o) { context_raw->selected_object = o->base; ui_handle_t *h = ui_handle(__ID__); @@ -137,8 +139,8 @@ void tab_meshes_draw_properties(mesh_object_t *o) { } } - physics_body_t *pb = any_imap_get(physics_body_object_map, context_raw->selected_object->uid); - ui_handle_t *hshape = ui_handle(__ID__); + physics_body_t *pb = any_imap_get(physics_body_object_map, context_raw->selected_object->uid); + ui_handle_t *hshape = ui_handle(__ID__); string_array_t *shape_combo = any_array_create_from_raw( (void *[]){ tr("None"), diff --git a/paint/sources/tab_scene.c b/paint/sources/tab_scene.c index b15df921..6278bc7a 100644 --- a/paint/sources/tab_scene.c +++ b/paint/sources/tab_scene.c @@ -1,6 +1,8 @@ #include "global.h" +i32 tab_scene_line_counter = 0; + void tab_scene_select_object(mesh_object_t *mo) { if (mo == NULL) { return; diff --git a/paint/sources/tab_scripts.c b/paint/sources/tab_scripts.c index 60a57ae7..0ac82d13 100644 --- a/paint/sources/tab_scripts.c +++ b/paint/sources/tab_scripts.c @@ -1,6 +1,8 @@ #include "global.h" +ui_text_coloring_t *tab_scripts_text_coloring = NULL; + void tab_scripts_draw_export(char *path) { char *str = tab_scripts_hscript->text; char *f = ui_files_filename; diff --git a/paint/sources/tab_swatches.c b/paint/sources/tab_swatches.c index 8d974b15..7050516d 100644 --- a/paint/sources/tab_swatches.c +++ b/paint/sources/tab_swatches.c @@ -1,6 +1,10 @@ #include "global.h" +gpu_texture_t *_tab_swatches_empty; +i32 tab_swatches_drag_pos = -1; +i32 _tab_swatches_draw_i; + gpu_texture_t *tab_swatches_empty_get() { if (_tab_swatches_empty == NULL) { u8_array_t *b = u8_array_create(4); @@ -69,9 +73,9 @@ void tab_swatches_draw_edit_menu() { context_raw->swatch->base = ui_color_wheel(h, false, -1, 11 * ui->ops->theme->ELEMENT_H * UI_SCALE(), true, &tab_swatches_draw_color_picker, NULL); - ui_handle_t *hopacity = ui_handle(__ID__); - hopacity->f = context_raw->swatch->opacity; - context_raw->swatch->opacity = ui_slider(hopacity, "Opacity", 0, 1, true, 100.0, true, UI_ALIGN_RIGHT, true); + ui_handle_t *hopacity = ui_handle(__ID__); + hopacity->f = context_raw->swatch->opacity; + context_raw->swatch->opacity = ui_slider(hopacity, "Opacity", 0, 1, true, 100.0, true, UI_ALIGN_RIGHT, true); if (config_raw->workflow == WORKFLOW_PBR) { ui_handle_t *hocclusion = ui_handle(__ID__); diff --git a/paint/sources/tab_textures.c b/paint/sources/tab_textures.c index 7b30d823..b7ef1082 100644 --- a/paint/sources/tab_textures.c +++ b/paint/sources/tab_textures.c @@ -1,6 +1,12 @@ #include "global.h" +gpu_texture_t *_tab_textures_draw_img; +char *_tab_textures_draw_path; +asset_t *_tab_textures_draw_asset; +i32 _tab_textures_draw_i; +bool _tab_textures_draw_is_packed; + void tab_textures_draw_set_as_envmap(void *_) { import_envmap_run(_tab_textures_draw_asset->file, _tab_textures_draw_img); } @@ -249,11 +255,11 @@ void tab_textures_draw(ui_handle_t *htab) { if (is_packed) { tooltip = string("%s %s", tooltip, tr("(packed)")); } - #ifdef WITH_BC7 +#ifdef WITH_BC7 if (img->format == GPU_TEXTURE_FORMAT_RGBA32_BC7) { tooltip = string("%s %s", tooltip, tr("(compressed)")); } - #endif +#endif ui_tooltip(tooltip); } diff --git a/paint/sources/translator.c b/paint/sources/translator.c index 126d9675..9b267e33 100644 --- a/paint/sources/translator.c +++ b/paint/sources/translator.c @@ -1,6 +1,15 @@ #include "global.h" +// The font index is a value specific to font_cjk.ttc +i32_map_t *translator_cjk_font_indices = NULL; +char *translator_last_locale = "en"; +char *_translator_load_translations_cjk_font_path; +char *_translator_load_translations_cjk_font_disk_path; +bool _translator_init_font_cjk; +char *_translator_init_font_font_path; +f32 _translator_init_font_font_scale; + // Mark strings as localizable in order to be parsed by the extract_locale script // The string will not be translated to the currently selected locale though char *_tr(char *s) { @@ -155,7 +164,7 @@ void translator_load_translations(char *new_locale) { translator_extended_glyphs(); // Push additional char codes contained in translation file - bool cjk = false; + bool cjk = false; string_array_t *keys = map_keys(translator_translations); for (i32 i = 0; i < keys->length; ++i) { char *s = any_map_get(translator_translations, keys->buffer[i]); diff --git a/paint/sources/types.h b/paint/sources/types.h index 1503c58a..91109468 100644 --- a/paint/sources/types.h +++ b/paint/sources/types.h @@ -64,11 +64,6 @@ typedef struct slot_font { char *file; } slot_font_t; -typedef struct version { - char *sha; - char *date; -} version_t; - typedef struct config { char *version; char *sha; // Commit id @@ -171,22 +166,6 @@ typedef struct slot_material { bool paint_subs; } slot_material_t; -typedef struct import_texture_data { - char *path; - struct gpu_texture *image; -} import_texture_data_t; - -typedef struct draw_cloud_icon_data { - char *f; - struct gpu_texture *image; -} draw_cloud_icon_data_t; - -typedef struct ui_files_make_icon { - struct gpu_texture *image; - char *shandle; - i32 w; -} ui_files_make_icon_t; - typedef struct tab_draw { void (*f)(struct ui_handle *); } tab_draw_t; @@ -478,11 +457,6 @@ typedef struct history_step { i32 canvas_type; } history_step_t; -typedef struct update_info { - i32 version; - char *version_name; -} update_info_t; - typedef struct logic_node { struct logic_node_input_t_array *inputs; struct logic_node_t_array *outputs; @@ -741,23 +715,12 @@ typedef struct neural_node_model_t_array { int capacity; } neural_node_model_t_array_t; -typedef struct material_data_t_array { - material_data_t **buffer; - int length; - int capacity; -} material_data_t_array_t; - -typedef struct world_data_t_array { - world_data_t **buffer; - int length; - int capacity; -} world_data_t_array_t; - typedef struct buffer_t_array { buffer_t **buffer; int length; int capacity; } buffer_t_array_t; + typedef struct slot_material_t_array { slot_material_t **buffer; int length; @@ -812,24 +775,12 @@ typedef struct slot_font_t_array { int capacity; } slot_font_t_array_t; -typedef struct ui_coloring_t_array { - ui_coloring_t **buffer; - int length; - int capacity; -} ui_coloring_t_array_t; - typedef struct slot_layer_t_array { slot_layer_t **buffer; int length; int capacity; } slot_layer_t_array_t; -typedef struct swatch_color_t_array { - swatch_color_t **buffer; - int length; - int capacity; -} swatch_color_t_array_t; - typedef struct gpu_texture_t_array { gpu_texture_t **buffer; int length; @@ -872,12 +823,6 @@ typedef struct ui_node_button_t_array { int capacity; } ui_node_button_t_array_t; -typedef struct tilesheet_action_t_array { - tilesheet_action_t **buffer; - int length; - int capacity; -} tilesheet_action_t_array_t; - typedef struct logic_node_input_t_array { logic_node_input_t **buffer; int length; @@ -896,12 +841,6 @@ typedef struct vec4_box_t_array { int capacity; } vec4_box_t_array_t; -typedef struct u32_array_t_array { - u32_array_t **buffer; - int length; - int capacity; -} u32_array_t_array_t; - typedef struct tab_draw_array_t_array { tab_draw_array_t **buffer; int length; @@ -926,12 +865,6 @@ typedef struct render_target_t_array { int capacity; } render_target_t_array_t; -typedef struct camera_data_t_array { - camera_data_t **buffer; - int length; - int capacity; -} camera_data_t_array_t; - typedef struct ui_node_link_t_array { ui_node_link_t **buffer; int length; @@ -962,30 +895,12 @@ typedef struct export_preset_texture_t_array { int capacity; } export_preset_texture_t_array_t; -typedef struct camera_object_t_array { - camera_object_t **buffer; - int length; - int capacity; -} camera_object_t_array_t; - -typedef struct frustum_plane_t_array { - frustum_plane_t **buffer; - int length; - int capacity; -} frustum_plane_t_array_t; - typedef struct layer_data_t_array { layer_data_t **buffer; int length; int capacity; } layer_data_t_array_t; -typedef struct tilesheet_data_t_array { - tilesheet_data_t **buffer; - int length; - int capacity; -} tilesheet_data_t_array_t; - typedef struct ui_node_t_array { ui_node_t **buffer; int length; @@ -997,3 +912,9 @@ typedef struct packed_asset_t_array { int length; int capacity; } packed_asset_t_array_t; + +typedef struct swatch_color_t_array { + swatch_color_t **buffer; + int length; + int capacity; +} swatch_color_t_array_t; diff --git a/paint/sources/ui_box.c b/paint/sources/ui_box.c index 79848cf7..a2e8cac2 100644 --- a/paint/sources/ui_box.c +++ b/paint/sources/ui_box.c @@ -1,6 +1,15 @@ #include "global.h" +bool ui_box_draggable = true; +char *ui_box_title = ""; +char *ui_box_text = ""; +void (*ui_box_commands)(void) = NULL; +void (*ui_box_modal_on_hide)(void) = NULL; +i32 ui_box_draws = 0; +bool ui_box_copyable = false; +f32 ui_box_tween_alpha = 0.0; + void ui_box_init() { ui_box_hwnd->redraws = 2; ui_box_hwnd->drag_x = 0; @@ -45,11 +54,11 @@ void ui_box_render() { if (config_raw->touch_ui) { // Darken bg draw_begin(NULL, false, 0); - #if defined(IRON_ANDROID) || defined(IRON_IOS) +#if defined(IRON_ANDROID) || defined(IRON_IOS) draw_set_color(color_from_floats(0, 0, 0, ui_box_tween_alpha)); - #else +#else draw_set_color(color_from_floats(0, 0, 0, 0.5)); - #endif +#endif draw_filled_rect(0, 0, iron_window_width(), iron_window_height()); draw_end(); } @@ -82,7 +91,7 @@ void ui_box_render() { } ui_end_element(); - #if defined(IRON_WINDOWS) || defined(IRON_LINUX) || defined(IRON_MACOS) +#if defined(IRON_WINDOWS) || defined(IRON_LINUX) || defined(IRON_MACOS) if (ui_box_copyable) { ui_row3(); } @@ -95,7 +104,7 @@ void ui_box_render() { 2); ui_row(row); } - #else +#else f32_array_t *row = f32_array_create_from_raw( (f32[]){ 2 / 3.0, @@ -103,15 +112,15 @@ void ui_box_render() { }, 2); ui_row(row); - #endif +#endif ui_end_element(); - #if defined(IRON_WINDOWS) || defined(IRON_LINUX) || defined(IRON_MACOS) +#if defined(IRON_WINDOWS) || defined(IRON_LINUX) || defined(IRON_MACOS) if (ui_box_copyable && ui_icon_button(tr("Copy"), ICON_COPY, UI_ALIGN_CENTER)) { iron_copy_to_clipboard(ui_box_text); } - #endif +#endif if (ui_icon_button(tr("OK"), ICON_CHECK, UI_ALIGN_CENTER)) { ui_box_hide(); } @@ -180,9 +189,9 @@ void ui_box_show_message(char *title, char *text, bool copyable) { ui_box_commands = NULL; ui_box_copyable = copyable; ui_box_draggable = true; - #if defined(IRON_ANDROID) || defined(IRON_IOS) +#if defined(IRON_ANDROID) || defined(IRON_IOS) ui_box_tween_in(); - #endif +#endif } void ui_box_show_custom(void (*commands)(void), i32 mw, i32 mh, void (*on_hide)(void), bool draggable, char *title) { @@ -199,15 +208,15 @@ void ui_box_show_custom(void (*commands)(void), i32 mw, i32 mh, void (*on_hide)( gc_unroot(ui_box_title); ui_box_title = string_copy(title); gc_root(ui_box_title); - #if defined(IRON_ANDROID) || defined(IRON_IOS) +#if defined(IRON_ANDROID) || defined(IRON_IOS) ui_box_tween_in(); - #endif +#endif } void ui_box_hide() { - #if defined(IRON_ANDROID) || defined(IRON_IOS) +#if defined(IRON_ANDROID) || defined(IRON_IOS) ui_box_tween_out(); - #else +#else ui_box_hide_internal(); - #endif +#endif } diff --git a/paint/sources/ui_files.c b/paint/sources/ui_files.c index ab0beb58..b0ea577a 100644 --- a/paint/sources/ui_files.c +++ b/paint/sources/ui_files.c @@ -1,6 +1,26 @@ #include "global.h" +typedef struct draw_cloud_icon_data { + char *f; + struct gpu_texture *image; +} draw_cloud_icon_data_t; + +typedef struct ui_files_make_icon { + struct gpu_texture *image; + char *shandle; + i32 w; +} ui_files_make_icon_t; + +char *ui_files_last_search = ""; +string_array_t *ui_files_files = NULL; +any_map_t *ui_files_icon_map = NULL; +any_map_t *ui_files_icon_file_map = NULL; +i32 ui_files_selected = -1; +bool ui_files_show_extensions = false; +bool ui_files_offline = false; +ui_handle_t *_ui_files_file_browser_handle; + void ui_files_release_keys() { // File dialog may prevent firing key up events keyboard_up_listener(KEY_CODE_SHIFT); @@ -141,6 +161,34 @@ static void ui_files_clear_icon_map(void) { ui_files_icon_file_map = NULL; } +void ui_files_make_icon(ui_files_make_icon_t *args) { + i32 w = args->w; + gpu_texture_t *image = args->image; + i32 sw = image->width > image->height ? w : math_floor(1.0 * image->width / (float)image->height * w); + i32 sh = image->width > image->height ? math_floor(1.0 * image->height / (float)image->width * w) : w; + gpu_texture_t *icon = gpu_create_render_target(sw, sh, GPU_TEXTURE_FORMAT_RGBA32); + draw_begin(icon, true, 0xffffffff); + draw_set_pipeline(pipes_copy_rgb); + draw_scaled_image(image, 0, 0, sw, sh); + draw_set_pipeline(NULL); + draw_end(); + any_map_set(ui_files_icon_map, args->shandle, icon); + ui_base_hwnds->buffer[TAB_AREA_STATUS]->redraws = 3; + + bool found = false; + for (i32 i = 0; i < project_assets->length; ++i) { + asset_t *a = project_assets->buffer[i]; + if (string_equals(a->file, args->shandle)) { + found = true; + break; + } + } + + if (!found) { + data_delete_image(args->shandle); // The big image is not needed anymore + } +} + char *ui_files_file_browser(ui_handle_t *handle, bool drag_files, char *search, bool refresh, void (*context_menu)(char *)) { gpu_texture_t *icons = resource_get("icons.k"); rect_t *folder = resource_tile50(icons, ICON_FOLDER_FULL); @@ -505,34 +553,6 @@ char *ui_files_file_browser(ui_handle_t *handle, bool drag_files, char *search, return handle->text; } -void ui_files_make_icon(ui_files_make_icon_t *args) { - i32 w = args->w; - gpu_texture_t *image = args->image; - i32 sw = image->width > image->height ? w : math_floor(1.0 * image->width / (float)image->height * w); - i32 sh = image->width > image->height ? math_floor(1.0 * image->height / (float)image->width * w) : w; - gpu_texture_t *icon = gpu_create_render_target(sw, sh, GPU_TEXTURE_FORMAT_RGBA32); - draw_begin(icon, true, 0xffffffff); - draw_set_pipeline(pipes_copy_rgb); - draw_scaled_image(image, 0, 0, sw, sh); - draw_set_pipeline(NULL); - draw_end(); - any_map_set(ui_files_icon_map, args->shandle, icon); - ui_base_hwnds->buffer[TAB_AREA_STATUS]->redraws = 3; - - bool found = false; - for (i32 i = 0; i < project_assets->length; ++i) { - asset_t *a = project_assets->buffer[i]; - if (string_equals(a->file, args->shandle)) { - found = true; - break; - } - } - - if (!found) { - data_delete_image(args->shandle); // The big image is not needed anymore - } -} - void ui_files_go_up(ui_handle_t *handle) { handle->text = string_copy(substring(handle->text, 0, string_last_index_of(handle->text, PATH_SEP))); // Drive root diff --git a/paint/sources/ui_header.c b/paint/sources/ui_header.c index fb8385a9..b28797b3 100644 --- a/paint/sources/ui_header.c +++ b/paint/sources/ui_header.c @@ -1,6 +1,8 @@ #include "global.h" +ui_handle_t *_ui_header_draw_tool_properties_h; + void ui_header_init() { ui_header_handle->layout = UI_LAYOUT_HORIZONTAL; } @@ -402,9 +404,10 @@ void ui_header_draw_tool_properties() { any_map_set(vars, "brush_radius", any_map_get(config_keymap, "brush_radius")); any_map_set(vars, "brush_radius_decrease", any_map_get(config_keymap, "brush_radius_decrease")); any_map_set(vars, "brush_radius_increase", any_map_get(config_keymap, "brush_radius_increase")); - ui_tooltip(vtr("Hold {brush_radius} and move mouse to the left or press {brush_radius_decrease} to decrease the radius\nHold {brush_radius} " - "and move mouse to the right or press {brush_radius_increase} to increase the radius", - vars)); + ui_tooltip( + vtr("Hold {brush_radius} and move mouse to the left or press {brush_radius_decrease} to decrease the radius\nHold {brush_radius} " + "and move mouse to the right or press {brush_radius_increase} to increase the radius", + vars)); } } else { @@ -414,9 +417,10 @@ void ui_header_draw_tool_properties() { any_map_set(vars, "brush_radius", any_map_get(config_keymap, "brush_radius")); any_map_set(vars, "brush_radius_decrease", any_map_get(config_keymap, "brush_radius_decrease")); any_map_set(vars, "brush_radius_increase", any_map_get(config_keymap, "brush_radius_increase")); - ui_tooltip(vtr("Hold {brush_radius} and move mouse to the left or press {brush_radius_decrease} to decrease the radius\nHold {brush_radius} " - "and move mouse to the right or press {brush_radius_increase} to increase the radius", - vars)); + ui_tooltip( + vtr("Hold {brush_radius} and move mouse to the left or press {brush_radius_decrease} to decrease the radius\nHold {brush_radius} " + "and move mouse to the right or press {brush_radius_increase} to increase the radius", + vars)); } } } @@ -460,8 +464,8 @@ void ui_header_draw_tool_properties() { any_map_t *vars = any_map_create(); any_map_set(vars, "brush_opacity", any_map_get(config_keymap, "brush_opacity")); ui_tooltip(vtr("Hold {brush_opacity} and move mouse to the left to decrease the opacity\nHold {brush_opacity} and move mouse to the right to " - "increase the opacity", - vars)); + "increase the opacity", + vars)); } if (context_raw->tool == TOOL_TYPE_BRUSH || context_raw->tool == TOOL_TYPE_ERASER || context_raw->tool == TOOL_TYPE_CLONE || decal_mask) { @@ -506,7 +510,7 @@ void ui_header_draw_tool_properties() { } if (context_raw->tool == TOOL_TYPE_BRUSH || context_raw->tool == TOOL_TYPE_FILL) { - ui_handle_t *paint_handle = ui_handle(__ID__); + ui_handle_t *paint_handle = ui_handle(__ID__); string_array_t *texcoord_combo = any_array_create_from_raw( (void *[]){ tr("UV Map"), diff --git a/paint/sources/ui_menu.c b/paint/sources/ui_menu.c index aaa1294b..438702fb 100644 --- a/paint/sources/ui_menu.c +++ b/paint/sources/ui_menu.c @@ -1,6 +1,12 @@ #include "global.h" +bool ui_menu_hide_flag = false; +i32 ui_menu_sub_x = 0; +i32 ui_menu_sub_y = 0; +ui_handle_t *ui_menu_sub_handle = NULL; +char *_ui_menu_render_msg; + void ui_menu_hide() { ui_menu_show = false; base_redraw_ui(); diff --git a/paint/sources/ui_menubar.c b/paint/sources/ui_menubar.c index b4f3c837..f6ecbb08 100644 --- a/paint/sources/ui_menubar.c +++ b/paint/sources/ui_menubar.c @@ -1,6 +1,23 @@ #include "global.h" +typedef enum { + MENUBAR_CATEGORY_FILE = 0, + MENUBAR_CATEGORY_EDIT = 1, + MENUBAR_CATEGORY_VIEWPORT = 2, + MENUBAR_CATEGORY_MODE = 3, + MENUBAR_CATEGORY_CAMERA = 4, + MENUBAR_CATEGORY_WORKSPACE = 5, + MENUBAR_CATEGORY_HELP = 6, +} menubar_category_t; + +typedef struct update_info { + i32 version; + char *version_name; +} update_info_t; + +i32 ui_menubar_category = 0; + void ui_menubar_init() { ui_menubar_hwnd->layout = UI_LAYOUT_HORIZONTAL; ui_menubar_menu_handle->layout = UI_LAYOUT_HORIZONTAL; @@ -480,7 +497,7 @@ void ui_menubar_draw_category_items() { else if (ui_menubar_category == MENUBAR_CATEGORY_MODE) { ui_handle_t *mode_handle = ui_handle(__ID__); mode_handle->i = context_raw->viewport_mode; - string_array_t *modes = any_array_create_from_raw( + string_array_t *modes = any_array_create_from_raw( (void *[]){ tr("Lit"), tr("Base Color"), @@ -635,8 +652,8 @@ void ui_menubar_draw_category_items() { ui_menu_align(); ui_menu_label(tr("Pivot"), any_map_get(config_keymap, "view_pivot_center")); ui_menu_align(); - ui_handle_t *camera_pivot_handle = ui_handle(__ID__); - camera_pivot_handle->i = context_raw->camera_pivot; + ui_handle_t *camera_pivot_handle = ui_handle(__ID__); + camera_pivot_handle->i = context_raw->camera_pivot; string_array_t *pivot_center_items = any_array_create_from_raw( (void *[]){ tr("Cursor"), @@ -649,8 +666,8 @@ void ui_menubar_draw_category_items() { ui_menu_align(); ui_menu_label(tr("Mode"), NULL); ui_menu_align(); - ui_handle_t *camera_controls_handle = ui_handle(__ID__); - camera_controls_handle->i = context_raw->camera_controls; + ui_handle_t *camera_controls_handle = ui_handle(__ID__); + camera_controls_handle->i = context_raw->camera_controls; string_array_t *camera_controls_items = any_array_create_from_raw( (void *[]){ tr("Orbit"), @@ -757,7 +774,7 @@ void ui_menubar_draw_category_items() { else if (ui_menubar_category == MENUBAR_CATEGORY_WORKSPACE) { ui_handle_t *workspace_handle = ui_handle(__ID__); workspace_handle->i = config_raw->workspace; - string_array_t *modes = any_array_create_from_raw( + string_array_t *modes = any_array_create_from_raw( (void *[]){ tr("Paint 3D"), tr("Paint 2D"), @@ -785,8 +802,8 @@ void ui_menubar_draw_category_items() { ui_menu_align(); ui_menu_label(tr("Workflow"), NULL); ui_menu_align(); - ui_handle_t *workflow_handle = ui_handle(__ID__); - workflow_handle->i = config_raw->workflow; + ui_handle_t *workflow_handle = ui_handle(__ID__); + workflow_handle->i = config_raw->workflow; string_array_t *workflow_items = any_array_create_from_raw( (void *[]){ tr("PBR"), diff --git a/paint/sources/ui_nodes.c b/paint/sources/ui_nodes.c index 7b48c69c..e794d90c 100644 --- a/paint/sources/ui_nodes.c +++ b/paint/sources/ui_nodes.c @@ -1,6 +1,36 @@ #include "global.h" +bool ui_nodes_show_menu = false; +bool ui_nodes_show_menu_first = true; +bool ui_nodes_hide_menu = false; +i32 ui_nodes_menu_category = 0; +f32 ui_nodes_popup_x = 0.0; +f32 ui_nodes_popup_y = 0.0; +i32 ui_nodes_node_search_x; +i32 ui_nodes_node_search_y; +bool ui_nodes_uichanged_last = false; +bool ui_nodes_recompile_mat = false; // Mat preview +bool ui_nodes_recompile_mat_final = false; +ui_node_t *ui_nodes_node_search_spawn = NULL; +i32 ui_nodes_node_search_offset = 0; +ui_node_canvas_t *ui_nodes_last_canvas = NULL; +i32 ui_nodes_last_node_selected_id = -1; +bool ui_nodes_release_link = false; +bool ui_nodes_is_node_menu_op = false; +gpu_texture_t *ui_nodes_grid = NULL; +bool ui_nodes_controls_down = false; +slot_material_t_array_t *ui_nodes_tabs = NULL; +ui_node_link_t *_ui_nodes_on_link_drag_link_drag; +ui_node_t *_ui_nodes_on_link_drag_node; +ui_node_socket_t *_ui_nodes_on_socket_released_socket; +ui_node_t *_ui_nodes_on_socket_released_node; +ui_node_t *_ui_nodes_on_canvas_released_selected; +bool _ui_nodes_node_search_first; +void (*_ui_nodes_node_search_done)(void); +ui_node_t *ui_nodes_node_changed = NULL; +void (*_ui_nodes_render_tmp)(i32); + void ui_viewnodes_on_node_remove(ui_node_t *n) { gpu_texture_t *img = any_imap_get(context_raw->node_preview_map, n->id); if (img != NULL) { @@ -187,13 +217,13 @@ void ui_viewnodes_on_link_drag(i32 link_drag_id, bool is_new_link) { void ui_viewnodes_on_socket_released_group_edit_box() { ui_node_socket_t *socket = _ui_nodes_on_socket_released_socket; ui_node_t *node = _ui_nodes_on_socket_released_node; - string_array_t *type_combo = any_array_create_from_raw( - (void *[]){ - tr("Color"), - tr("Vector"), - tr("Value"), - }, - 3); + string_array_t *type_combo = any_array_create_from_raw( + (void *[]){ + tr("Color"), + tr("Vector"), + tr("Value"), + }, + 3); i32 type = ui_combo(_ui_nodes_htype, type_combo, tr("Type"), true, UI_ALIGN_LEFT, true); if (_ui_nodes_htype->changed) { _ui_nodes_hname->text = type == 0 ? tr("Color") : type == 1 ? tr("Vector") : tr("Value"); @@ -527,8 +557,8 @@ ui_canvas_control_t *ui_nodes_get_canvas_control(bool controls_down, bool is_nod return cc; } - bool pan = ui->input_down_r || operator_shortcut(any_map_get(config_keymap, "action_pan"), SHORTCUT_TYPE_DOWN); - f32 zoom_delta = operator_shortcut(any_map_get(config_keymap, "action_zoom"), SHORTCUT_TYPE_DOWN) ? ui_nodes_get_zoom_delta() / 100.0 : 0.0; + bool pan = ui->input_down_r || operator_shortcut(any_map_get(config_keymap, "action_pan"), SHORTCUT_TYPE_DOWN); + f32 zoom_delta = operator_shortcut(any_map_get(config_keymap, "action_zoom"), SHORTCUT_TYPE_DOWN) ? ui_nodes_get_zoom_delta() / 100.0 : 0.0; ui_canvas_control_t *control = GC_ALLOC_INIT(ui_canvas_control_t, {.pan_x = pan ? ui->input_dx : 0.0, .pan_y = pan ? ui->input_dy : 0.0, .zoom = ui->input_wheel_delta != 0.0 ? -ui->input_wheel_delta / 10 : zoom_delta, @@ -537,7 +567,7 @@ ui_canvas_control_t *ui_nodes_get_canvas_control(bool controls_down, bool is_nod if (is_node_view && ui->input_x < ui->_window_x) { control->pan_x = 0.0; control->pan_y = 0.0; - control->zoom = 0.0; + control->zoom = 0.0; } if (ui->combo_selected_handle != NULL) { @@ -878,7 +908,7 @@ void ui_nodes_draw_menubar() { bool _SHADOWS = ui->ops->theme->SHADOWS; ui->ops->theme->BUTTON_COL = ui->ops->theme->WINDOW_BG_COL; ui->ops->theme->SHADOWS = false; - string_array_t *cats = ui_nodes_canvas_type == CANVAS_TYPE_MATERIAL ? nodes_material_categories : nodes_brush_categories; + string_array_t *cats = ui_nodes_canvas_type == CANVAS_TYPE_MATERIAL ? nodes_material_categories : nodes_brush_categories; for (i32 i = 0; i < cats->length; ++i) { if ((ui_menubar_button(tr(cats->buffer[i]))) || (ui->is_hovered && ui_nodes_show_menu)) { ui_nodes_show_menu = true; @@ -1083,7 +1113,7 @@ void ui_nodes_render(void *_) { } if (has_script_node) { ui_nodes_last_node_selected_id = -1; - ui_view2d_hwnd->redraws = 2; + ui_view2d_hwnd->redraws = 2; iron_delay_idle_sleep(); } } diff --git a/paint/sources/ui_sidebar.c b/paint/sources/ui_sidebar.c index 2f058109..287b838c 100644 --- a/paint/sources/ui_sidebar.c +++ b/paint/sources/ui_sidebar.c @@ -1,6 +1,9 @@ #include "global.h" +i32 ui_sidebar_tabx = 0; +i32 ui_sidebar_last_tab = 0; + void ui_sidebar_render_ui() { // Expand button diff --git a/paint/sources/ui_statusbar.c b/paint/sources/ui_statusbar.c index 40785627..77e2e475 100644 --- a/paint/sources/ui_statusbar.c +++ b/paint/sources/ui_statusbar.c @@ -1,6 +1,8 @@ #include "global.h" +i32 ui_statusbar_last_tab = 0; + void ui_statusbar_init() {} i32 ui_statusbar_width() { diff --git a/paint/sources/ui_toolbar.c b/paint/sources/ui_toolbar.c index a39f32f1..3caa1a55 100644 --- a/paint/sources/ui_toolbar.c +++ b/paint/sources/ui_toolbar.c @@ -1,6 +1,9 @@ #include "global.h" +i32 ui_toolbar_last_tool = 0; +i32 _ui_toolbar_i; + void ui_toolbar_init() {} void ui_toolbar_draw_tool_select_tool(void *_) { diff --git a/paint/sources/ui_view2d.c b/paint/sources/ui_view2d.c index 7d81e3ec..37b5e37d 100644 --- a/paint/sources/ui_view2d.c +++ b/paint/sources/ui_view2d.c @@ -1,6 +1,19 @@ #include "global.h" +bool ui_view2d_text_input_hover = false; +bool ui_view2d_uvmap_show = false; +paint_tex_t ui_view2d_tex_type = PAINT_TEX_BASE; +view_2d_layer_mode_t ui_view2d_layer_mode = VIEW_2D_LAYER_MODE_SELECTED; +bool ui_view2d_controls_down = false; +gpu_texture_t *_ui_view2d_render_tex; +f32 _ui_view2d_render_x; +f32 _ui_view2d_render_y; +f32 _ui_view2d_render_tw; +f32 _ui_view2d_render_th; +gpu_texture_t *ui_view2d_grid = NULL; +bool ui_view2d_layer_touched = false; + void ui_view2d_init() { ui_view2d_pipe = gpu_create_pipeline(); gc_root(ui_view2d_pipe); @@ -277,10 +290,10 @@ void ui_view2d_render(void *_) { asset_t *asset = context_raw->texture; if (asset != NULL) { string_array_t *asset_names = project_asset_names; - i32 i = string_array_index_of(asset_names, asset->name); - h->text = string_copy(asset->name); - asset->name = string_copy(ui_text_input(h, "", UI_ALIGN_LEFT, true, false)); - asset_names->buffer[i] = asset->name; + i32 i = string_array_index_of(asset_names, asset->name); + h->text = string_copy(asset->name); + asset->name = string_copy(ui_text_input(h, "", UI_ALIGN_LEFT, true, false)); + asset_names->buffer[i] = asset->name; } } else if (ui_view2d_type == VIEW_2D_TYPE_NODE) { diff --git a/paint/sources/util_mesh.c b/paint/sources/util_mesh.c index 9d15fb69..ee24abf5 100644 --- a/paint/sources/util_mesh.c +++ b/paint/sources/util_mesh.c @@ -1,6 +1,9 @@ #include "global.h" +i16_array_t *util_mesh_va0; +i32_array_t *util_mesh_quantized; + void util_mesh_remove_merged() { if (context_raw->merged_object != NULL) { mesh_data_delete(context_raw->merged_object->data); @@ -424,8 +427,7 @@ void util_mesh_equirect_unwrap(raw_mesh_t *mesh) { mesh->texa = i16_array_create(verts * 2); vec4_t n = vec4_create(0.0, 0.0, 0.0, 1.0); for (i32 i = 0; i < verts; ++i) { - n = vec4_create(mesh->posa->buffer[i * 4] / 32767.0, mesh->posa->buffer[i * 4 + 1] / 32767.0, mesh->posa->buffer[i * 4 + 2] / 32767.0, - 1.0); + n = vec4_create(mesh->posa->buffer[i * 4] / 32767.0, mesh->posa->buffer[i * 4 + 1] / 32767.0, mesh->posa->buffer[i * 4 + 2] / 32767.0, 1.0); n = vec4_norm(n); // Sphere projection // mesh.texa[i * 2 ] = math_atan2(n.x, n.y) / (math_pi() * 2) + 0.5; diff --git a/paint/sources/util_render.c b/paint/sources/util_render.c index 956b09fd..e34d5a5e 100644 --- a/paint/sources/util_render.c +++ b/paint/sources/util_render.c @@ -1,6 +1,9 @@ #include "global.h" +gpu_buffer_t *util_render_screen_aligned_full_vb = NULL; +gpu_buffer_t *util_render_screen_aligned_full_ib = NULL; + void util_render_make_material_preview() { context_raw->material_preview = true; diff --git a/paint/sources/util_uv.c b/paint/sources/util_uv.c index a3759606..a01a004c 100644 --- a/paint/sources/util_uv.c +++ b/paint/sources/util_uv.c @@ -1,6 +1,9 @@ #include "global.h" +buffer_t *util_uv_dilate_bytes = NULL; +gpu_pipeline_t *util_uv_pipe_dilate = NULL; + void util_uv_cache_uv_map() { if (util_uv_uvmap != NULL && (util_uv_uvmap->width != config_get_texture_res_x() || util_uv_uvmap->height != config_get_texture_res_y())) { gpu_delete_texture(util_uv_uvmap); @@ -26,8 +29,8 @@ void util_uv_cache_uv_map() { mesh_object_t *merged = mask > 0 ? project_paint_objects->buffer[mask - 1] : context_raw->merged_object; mesh_data_t *mesh = (context_raw->layer_filter == 0 && merged != NULL) ? merged->data : context_raw->paint_object->data; - i16_array_t *texa = mesh->vertex_arrays->buffer[2]->values; - u32_array_t *inda = mesh->index_array; + i16_array_t *texa = mesh->vertex_arrays->buffer[2]->values; + u32_array_t *inda = mesh->index_array; draw_begin(util_uv_uvmap, true, 0x00000000); draw_set_color(0xffffffff); f32 strength = res_x > 2048 ? 2.0 : 1.0; @@ -116,9 +119,9 @@ void util_uv_cache_dilate_map() { gpu_vertex_struct_add(vs, "pos", GPU_VERTEX_DATA_I16_4X_NORM); gpu_vertex_struct_add(vs, "nor", GPU_VERTEX_DATA_I16_2X_NORM); gpu_vertex_struct_add(vs, "tex", GPU_VERTEX_DATA_I16_2X_NORM); - util_uv_pipe_dilate->input_layout = vs; - util_uv_pipe_dilate->depth_write = false; - util_uv_pipe_dilate->depth_mode = GPU_COMPARE_MODE_ALWAYS; + util_uv_pipe_dilate->input_layout = vs; + util_uv_pipe_dilate->depth_write = false; + util_uv_pipe_dilate->depth_mode = GPU_COMPARE_MODE_ALWAYS; util_uv_pipe_dilate->color_attachment[0] = GPU_TEXTURE_FORMAT_R8; gpu_pipeline_compile(util_uv_pipe_dilate); // dilate_tex_unpack = getConstantLocation(pipeDilate, "tex_unpack");