diff --git a/paint/sources/base.c b/paint/sources/base.c index b3c57f44..1f92a661 100644 --- a/paint/sources/base.c +++ b/paint/sources/base.c @@ -976,7 +976,7 @@ void ui_base_update_ui() { g_context->clone_delta_y = (g_context->clone_start_y - my) / (float)sys_h(); g_context->clone_start_x = -1; } - else if (g_context->tool == TOOL_TYPE_FILL && g_context->fill_type_handle->i == FILL_TYPE_UV_ISLAND) { + else if (g_context->tool == TOOL_TYPE_FILL && g_context->fill_type == FILL_TYPE_UV_ISLAND) { util_uv_uvislandmap_cached = false; } } @@ -1171,7 +1171,6 @@ void ui_base_update(void *_) { g_context->brush_opacity += mouse_movement_x / 500.0; g_context->brush_opacity = math_max(0.0, math_min(1.0, g_context->brush_opacity)); g_context->brush_opacity = math_round(g_context->brush_opacity * 100) / 100.0; - g_context->brush_opacity_handle->f = g_context->brush_opacity; } else if (operator_shortcut(any_map_get(config_keymap, "brush_angle"), SHORTCUT_TYPE_DOWN)) { g_context->brush_angle += mouse_movement_x / 5.0; @@ -1179,15 +1178,13 @@ void ui_base_update(void *_) { g_context->brush_angle = i % 360; if (g_context->brush_angle < 0) g_context->brush_angle += 360; - g_context->brush_angle_handle->f = g_context->brush_angle; make_material_parse_paint_material(true); } else if (decal_mask && operator_shortcut(string("%s+%s", any_map_get(config_keymap, "decal_mask"), any_map_get(config_keymap, "brush_radius")), SHORTCUT_TYPE_DOWN)) { g_context->brush_decal_mask_radius += mouse_movement_x / 150.0; - g_context->brush_decal_mask_radius = math_max(0.01, math_min(4.0, g_context->brush_decal_mask_radius)); - g_context->brush_decal_mask_radius = math_round(g_context->brush_decal_mask_radius * 100) / 100.0; - g_context->brush_decal_mask_radius_handle->f = g_context->brush_decal_mask_radius; + g_context->brush_decal_mask_radius = math_max(0.01, math_min(4.0, g_context->brush_decal_mask_radius)); + g_context->brush_decal_mask_radius = math_round(g_context->brush_decal_mask_radius * 100) / 100.0; } else { g_context->brush_radius += mouse_movement_x / 150.0; @@ -1295,16 +1292,14 @@ void ui_base_update(void *_) { if (operator_shortcut(string("%s+%s", any_map_get(config_keymap, "decal_mask"), any_map_get(config_keymap, "brush_radius_decrease")), SHORTCUT_TYPE_REPEAT)) { g_context->brush_decal_mask_radius -= ui_base_get_radius_increment(); - g_context->brush_decal_mask_radius = math_max(math_round(g_context->brush_decal_mask_radius * 100) / 100.0, 0.01); - g_context->brush_decal_mask_radius_handle->f = g_context->brush_decal_mask_radius; - ui_header_handle->redraws = 2; + g_context->brush_decal_mask_radius = math_max(math_round(g_context->brush_decal_mask_radius * 100) / 100.0, 0.01); + ui_header_handle->redraws = 2; } else if (operator_shortcut(string("%s+%s", any_map_get(config_keymap, "decal_mask"), any_map_get(config_keymap, "brush_radius_increase")), SHORTCUT_TYPE_REPEAT)) { g_context->brush_decal_mask_radius += ui_base_get_radius_increment(); - g_context->brush_decal_mask_radius = math_round(g_context->brush_decal_mask_radius * 100) / 100.0; - g_context->brush_decal_mask_radius_handle->f = g_context->brush_decal_mask_radius; - ui_header_handle->redraws = 2; + g_context->brush_decal_mask_radius = math_round(g_context->brush_decal_mask_radius * 100) / 100.0; + ui_header_handle->redraws = 2; } } } @@ -1335,8 +1330,7 @@ void ui_base_update(void *_) { viewport_set_view(0, 0, -1, math_pi(), 0, math_pi()); } else if (operator_shortcut(any_map_get(config_keymap, "view_camera_type"), SHORTCUT_TYPE_STARTED)) { - g_context->camera_type = g_context->camera_type == CAMERA_TYPE_PERSPECTIVE ? CAMERA_TYPE_ORTHOGRAPHIC : CAMERA_TYPE_PERSPECTIVE; - g_context->cam_handle->i = g_context->camera_type; + g_context->camera_type = g_context->camera_type == CAMERA_TYPE_PERSPECTIVE ? CAMERA_TYPE_ORTHOGRAPHIC : CAMERA_TYPE_PERSPECTIVE; viewport_update_camera_type(g_context->camera_type); } else if (operator_shortcut(any_map_get(config_keymap, "view_orbit_left"), SHORTCUT_TYPE_REPEAT)) { @@ -1549,7 +1543,7 @@ void ui_base_update(void *_) { g_context->layer_preview_dirty = true; } -#ifdef arm_physics +#ifdef WITH_PHYSICS if (!particle_just_fired) { for (i32 i = 0; i < 32; ++i) { if (g_context->particles[i].timer == NULL) { diff --git a/paint/sources/context.c b/paint/sources/context.c index f57f6ec4..6883e8a8 100644 --- a/paint/sources/context.c +++ b/paint/sources/context.c @@ -1,196 +1,175 @@ #include "global.h" -context_t *context_create() { - context_t *c = GC_ALLOC_INIT(context_t, {0}); - c->merged_object_is_atlas = false; // Only objects referenced by atlas are merged - c->ddirty = 0; // depth - c->pdirty = 0; // paint - c->rdirty = 0; // render - c->brush_blend_dirty = true; - c->split_view = false; - c->view_index = -1; - c->view_index_last = -1; - c->picked_color = project_make_swatch(0xffffffff); - c->envmap_loaded = false; - c->show_envmap = false; - c->show_envmap_handle = ui_handle_create(); - c->show_envmap_blur = false; - c->show_envmap_blur_handle = ui_handle_create(); - c->show_envmap_spheres = false; - c->show_envmap_spheres_handle = ui_handle_create(); - c->capturing_screenshot = false; - c->capture_background = false; - c->envmap_angle = 0.0; - c->light_angle = 0.0; - c->cull_backfaces = true; - c->texture_filter = true; - c->format_type = TEXTURE_LDR_FORMAT_PNG; - c->format_quality = 100.0; - c->layers_destination = EXPORT_DESTINATION_DISK; - c->split_by = SPLIT_TYPE_OBJECT; - c->select_time = 0.0; - c->viewport_mode = g_config->viewport_mode; - c->hscale_was_changed = false; - c->export_mesh_format = MESH_FORMAT_OBJ; - c->export_mesh_index = 0; - c->pack_assets_on_export = true; - c->pack_assets_on_save = false; - c->paint_vec = (vec4_t){0.0, 0.0, 0.0, 1.0}; - c->last_paint_x = -1.0; - c->last_paint_y = -1.0; - c->foreground_event = false; - c->painted = 0; - c->brush_time = 0.0; - c->clone_start_x = -1.0; - c->clone_start_y = -1.0; - c->clone_delta_x = 0.0; - c->clone_delta_y = 0.0; - c->show_compass = true; - c->last_paint_vec_x = -1.0; - c->last_paint_vec_y = -1.0; - c->prev_paint_vec_x = -1.0; - c->prev_paint_vec_y = -1.0; - c->frame = 0; - c->paint2d_view = false; - c->brush_locked = false; - c->camera_type = CAMERA_TYPE_PERSPECTIVE; - c->cam_handle = ui_handle_create(); - c->fov_handle = ui_handle_create(); - c->texture_export_path = ""; - c->last_status_position = 0; - c->camera_pivot = CAMERA_PIVOT_CURSOR; - c->camera_controls = CAMERA_CONTROLS_ORBIT; - c->pen_painting_only = false; // Reject painting with finger when using pen - c->layer_preview_dirty = true; - c->layers_preview_dirty = false; - c->node_preview_name = ""; - c->node_preview_socket_map = any_map_create(); - c->node_preview_map = any_map_create(); - c->selected_node_preview = true; - c->colorid_picked = false; - c->material_preview = false; // Drawing material previews - c->saved_camera = mat4_identity(); - c->materialid_picked = 0; - c->uvx_picked = 0.0; - c->uvy_picked = 0.0; - c->picker_select_material = false; - c->picker_mask_handle = ui_handle_create(); - c->pick_pos_nor_tex = false; - c->pick_object_id = false; - c->posx_picked = 0.0; - c->posy_picked = 0.0; - c->posz_picked = 0.0; - c->norx_picked = 0.0; - c->nory_picked = 0.0; - c->norz_picked = 0.0; - c->draw_wireframe = false; - c->wireframe_handle = ui_handle_create(); - c->draw_texels = false; - c->texels_handle = ui_handle_create(); - c->colorid_handle = ui_handle_create(); - c->layers_export = EXPORT_MODE_VISIBLE; - c->decal_preview = false; - c->decal_x = 0.0; - c->decal_y = 0.0; - // c.cache_draws = false; - c->write_icon_on_export = false; - c->particle_hit_x = 0.0; - c->particle_hit_y = 0.0; - c->particle_hit_z = 0.0; - c->last_particle_hit_x = 0.0; - c->last_particle_hit_y = 0.0; - c->last_particle_hit_z = 0.0; - c->particle_friction = 0.1; - c->particle_bounciness = 0.0; - c->particle_gravity_x = 0.0; - c->particle_gravity_y = 0.0; - c->particle_gravity_z = -9.81; - c->particle_lifetime = 5.0; - c->particle_mass = 1.0; - c->particle_random = 0.1; - c->particle_spawn_distance = 0.3; - c->layer_filter = 0; - c->gizmo_started = false; - c->gizmo_offset = 0.0; - c->gizmo_drag = 0.0; - c->gizmo_drag_last = 0.0; - c->translate_x = false; - c->translate_y = false; - c->translate_z = false; - c->scale_x = false; - c->scale_y = false; - c->scale_z = false; - c->rotate_x = false; - c->rotate_y = false; - c->rotate_z = false; - c->brush_nodes_radius = 1.0; - c->brush_nodes_opacity = 1.0; - c->brush_nodes_uses_random = false; - c->brush_mask_image_is_alpha = false; - c->brush_stencil_image_is_alpha = false; - c->brush_stencil_x = 0.02; - c->brush_stencil_y = 0.02; - c->brush_stencil_scale = 0.9; - c->brush_stencil_scaling = false; - c->brush_stencil_angle = 0.0; - c->brush_stencil_rotating = false; - c->brush_nodes_scale = 1.0; - c->brush_nodes_angle = 0.0; - c->brush_nodes_hardness = 1.0; - c->brush_directional = false; - c->brush_scale_x = 1.0; - c->brush_decal_mask_radius = 0.5; - c->brush_decal_mask_radius_handle = ui_handle_create(); - c->brush_decal_mask_radius_handle->f = 0.5; - c->brush_scale_x_handle = ui_handle_create(); - c->brush_scale_x_handle->f = 1.0; - c->brush_blending = BLEND_TYPE_MIX; - c->brush_opacity = 1.0; - c->brush_opacity_handle = ui_handle_create(); - c->brush_opacity_handle->f = 1.0; - c->brush_scale = 1.0; - c->brush_angle = 0.0; - c->brush_angle_handle = ui_handle_create(); - c->brush_angle_handle->f = 0.0; - c->brush_lazy_radius = 0.0; - c->brush_lazy_step = 0.0; - c->brush_lazy_x = 0.0; - c->brush_lazy_y = 0.0; - c->brush_paint = UV_TYPE_UVMAP; - c->brush_angle_reject_dot = 0.5; - c->bake_type = BAKE_TYPE_CURVATURE; - c->bake_axis = BAKE_AXIS_XYZ; - c->bake_up_axis = BAKE_UP_AXIS_Z; - c->bake_samples = 128; - c->bake_ao_strength = 1.0; - c->bake_ao_radius = 1.0; - c->bake_ao_offset = 1.0; - c->bake_curv_strength = 1.0; - c->bake_curv_radius = 1.0; - c->bake_curv_offset = 0.0; - c->bake_curv_smooth = 1; - c->bake_high_poly = 0; - c->xray = false; - c->sym_x = false; - c->sym_y = false; - c->sym_z = false; - c->fill_type_handle = ui_handle_create(); - c->blur_type_handle = ui_handle_create(); - c->blur_type = BLUR_TYPE_BLUR; - c->paint2d = false; - c->maximized_sidebar_width = 0; - c->drag_dest = 0; - return c; -} - void context_init() { - g_context = context_create(); + g_context = GC_ALLOC_INIT(context_t, {0}); gc_root(g_context); - g_context->tool = TOOL_TYPE_BRUSH; - g_context->color_picker_previous_tool = TOOL_TYPE_BRUSH; - g_context->brush_radius = 0.5; - g_context->brush_hardness = 1.0; + + g_context->merged_object_is_atlas = false; // Only objects referenced by atlas are merged + g_context->ddirty = 0; // depth + g_context->pdirty = 0; // paint + g_context->rdirty = 0; // render + g_context->brush_blend_dirty = true; + g_context->split_view = false; + g_context->view_index = -1; + g_context->view_index_last = -1; + g_context->picked_color = project_make_swatch(0xffffffff); + g_context->envmap_loaded = false; + g_context->show_envmap = false; + g_context->show_envmap_blur = false; + g_context->show_envmap_spheres = false; + g_context->capturing_screenshot = false; + g_context->capture_background = false; + g_context->envmap_angle = 0.0; + g_context->light_angle = 0.0; + g_context->cull_backfaces = true; + g_context->texture_filter = true; + g_context->format_type = TEXTURE_LDR_FORMAT_PNG; + g_context->format_quality = 100.0; + g_context->layers_destination = EXPORT_DESTINATION_DISK; + g_context->split_by = SPLIT_TYPE_OBJECT; + g_context->select_time = 0.0; + g_context->viewport_mode = g_config->viewport_mode; + g_context->hscale_was_changed = false; + g_context->export_mesh_format = MESH_FORMAT_OBJ; + g_context->export_mesh_index = 0; + g_context->pack_assets_on_export = true; + g_context->pack_assets_on_save = false; + g_context->paint_vec = (vec4_t){0.0, 0.0, 0.0, 1.0}; + g_context->last_paint_x = -1.0; + g_context->last_paint_y = -1.0; + g_context->foreground_event = false; + g_context->painted = 0; + g_context->brush_time = 0.0; + g_context->clone_start_x = -1.0; + g_context->clone_start_y = -1.0; + g_context->clone_delta_x = 0.0; + g_context->clone_delta_y = 0.0; + g_context->show_compass = true; + g_context->last_paint_vec_x = -1.0; + g_context->last_paint_vec_y = -1.0; + g_context->prev_paint_vec_x = -1.0; + g_context->prev_paint_vec_y = -1.0; + g_context->frame = 0; + g_context->paint2d_view = false; + g_context->brush_locked = false; + g_context->camera_type = CAMERA_TYPE_PERSPECTIVE; + g_context->texture_export_path = ""; + g_context->last_status_position = 0; + g_context->camera_pivot = CAMERA_PIVOT_CURSOR; + g_context->camera_controls = CAMERA_CONTROLS_ORBIT; + g_context->pen_painting_only = false; // Reject painting with finger when using pen + g_context->layer_preview_dirty = true; + g_context->layers_preview_dirty = false; + g_context->node_preview_name = ""; + g_context->node_preview_socket_map = any_map_create(); + g_context->node_preview_map = any_map_create(); + g_context->selected_node_preview = true; + g_context->material_preview = false; // Drawing material previews + g_context->saved_camera = mat4_identity(); + g_context->materialid_picked = 0; + g_context->uvx_picked = 0.0; + g_context->uvy_picked = 0.0; + g_context->picker_select_material = false; + g_context->picker_mask = 0; + g_context->pick_pos_nor_tex = false; + g_context->pick_object_id = false; + g_context->posx_picked = 0.0; + g_context->posy_picked = 0.0; + g_context->posz_picked = 0.0; + g_context->norx_picked = 0.0; + g_context->nory_picked = 0.0; + g_context->norz_picked = 0.0; + g_context->draw_wireframe = false; + g_context->draw_texels = false; + g_context->colorid = 0; + g_context->colorid_picked = false; + g_context->layers_export = EXPORT_MODE_VISIBLE; + g_context->decal_preview = false; + g_context->decal_x = 0.0; + g_context->decal_y = 0.0; + g_context->write_icon_on_export = false; + g_context->particle_hit_x = 0.0; + g_context->particle_hit_y = 0.0; + g_context->particle_hit_z = 0.0; + g_context->last_particle_hit_x = 0.0; + g_context->last_particle_hit_y = 0.0; + g_context->last_particle_hit_z = 0.0; + g_context->particle_friction = 0.1; + g_context->particle_bounciness = 0.0; + g_context->particle_gravity_x = 0.0; + g_context->particle_gravity_y = 0.0; + g_context->particle_gravity_z = -9.81; + g_context->particle_lifetime = 5.0; + g_context->particle_mass = 1.0; + g_context->particle_random = 0.1; + g_context->particle_spawn_distance = 0.3; + g_context->layer_filter = 0; + g_context->gizmo_started = false; + g_context->gizmo_offset = 0.0; + g_context->gizmo_drag = 0.0; + g_context->gizmo_drag_last = 0.0; + g_context->translate_x = false; + g_context->translate_y = false; + g_context->translate_z = false; + g_context->scale_x = false; + g_context->scale_y = false; + g_context->scale_z = false; + g_context->rotate_x = false; + g_context->rotate_y = false; + g_context->rotate_z = false; + g_context->brush_nodes_radius = 1.0; + g_context->brush_nodes_opacity = 1.0; + g_context->brush_nodes_uses_random = false; + g_context->brush_mask_image_is_alpha = false; + g_context->brush_stencil_image_is_alpha = false; + g_context->brush_stencil_x = 0.02; + g_context->brush_stencil_y = 0.02; + g_context->brush_stencil_scale = 0.9; + g_context->brush_stencil_scaling = false; + g_context->brush_stencil_angle = 0.0; + g_context->brush_stencil_rotating = false; + g_context->brush_nodes_scale = 1.0; + g_context->brush_nodes_angle = 0.0; + g_context->brush_nodes_hardness = 1.0; + g_context->brush_directional = false; + g_context->brush_scale_x = 1.0; + g_context->brush_decal_mask_radius = 0.5; + g_context->brush_blending = BLEND_TYPE_MIX; + g_context->brush_opacity = 1.0; + g_context->brush_scale = 1.0; + g_context->brush_angle = 0.0; + g_context->brush_lazy_radius = 0.0; + g_context->brush_lazy_step = 0.0; + g_context->brush_lazy_x = 0.0; + g_context->brush_lazy_y = 0.0; + g_context->brush_paint = UV_TYPE_UVMAP; + g_context->brush_angle_reject_dot = 0.5; + g_context->bake_type = BAKE_TYPE_CURVATURE; + g_context->bake_axis = BAKE_AXIS_XYZ; + g_context->bake_up_axis = BAKE_UP_AXIS_Z; + g_context->bake_samples = 128; + g_context->bake_ao_strength = 1.0; + g_context->bake_ao_radius = 1.0; + g_context->bake_ao_offset = 1.0; + g_context->bake_curv_strength = 1.0; + g_context->bake_curv_radius = 1.0; + g_context->bake_curv_offset = 0.0; + g_context->bake_curv_smooth = 1; + g_context->bake_high_poly = 0; + g_context->xray = false; + g_context->sym_x = false; + g_context->sym_y = false; + g_context->sym_z = false; + g_context->fill_type = FILL_TYPE_OBJECT; + g_context->blur_type = BLUR_TYPE_BLUR; + g_context->paint2d = false; + g_context->maximized_sidebar_width = 0; + g_context->drag_dest = 0; + g_context->tool = TOOL_TYPE_BRUSH; + g_context->color_picker_previous_tool = TOOL_TYPE_BRUSH; + g_context->brush_radius = 0.5; + g_context->brush_hardness = 1.0; } bool context_use_deferred() { @@ -384,15 +363,6 @@ bool context_in_materials() { return string_equals(tab, tr("Materials")); } -bool context_in_2d_view(view_2d_type_t type) { - return ui_view2d_show && ui_view2d_type == type && mouse_x > ui_view2d_wx && mouse_x < ui_view2d_wx + ui_view2d_ww && mouse_y > ui_view2d_wy && - mouse_y < ui_view2d_wy + ui_view2d_wh; -} - -bool context_in_nodes() { - return ui_nodes_show && mouse_x > ui_nodes_wx && mouse_x < ui_nodes_wx + ui_nodes_ww && mouse_y > ui_nodes_wy && mouse_y < ui_nodes_wy + ui_nodes_wh; -} - bool context_in_swatches() { char *tab = ui_hovered_tab_name(); return string_equals(tab, tr("Swatches")); @@ -418,6 +388,15 @@ bool context_in_browser() { return string_equals(tab, tr("Browser")); } +bool context_in_2d_view(view_2d_type_t type) { + return ui_view2d_show && ui_view2d_type == type && mouse_x > ui_view2d_wx && mouse_x < ui_view2d_wx + ui_view2d_ww && mouse_y > ui_view2d_wy && + mouse_y < ui_view2d_wy + ui_view2d_wh; +} + +bool context_in_nodes() { + return ui_nodes_show && mouse_x > ui_nodes_wx && mouse_x < ui_nodes_wx + ui_nodes_ww && mouse_y > ui_nodes_wy && mouse_y < ui_nodes_wy + ui_nodes_wh; +} + bool context_is_decal() { return g_context->tool == TOOL_TYPE_DECAL || g_context->tool == TOOL_TYPE_TEXT; } @@ -534,7 +513,3 @@ bool context_enable_import_plugin(char *file) { } return false; } - -void context_set_swatch(swatch_color_t *s) { - g_context->swatch = s; -} diff --git a/paint/sources/functions.h b/paint/sources/functions.h index a7d9b1e9..f9b29fd1 100644 --- a/paint/sources/functions.h +++ b/paint/sources/functions.h @@ -238,7 +238,6 @@ void context_update_envmap(); void context_set_viewport_shader(void *viewport_shader); void context_set_render_path(); bool context_enable_import_plugin(char *file); -void context_set_swatch(swatch_color_t *s); void node_shader_add_out(node_shader_t *raw, char *s); void node_shader_add_constant(node_shader_t *raw, char *s, char *link); void node_shader_add_texture(node_shader_t *raw, char *name, char *link); @@ -260,8 +259,6 @@ void ui_toolbar_render_ui(); void export_arm_run_mesh(char *path, mesh_object_t_array_t *paint_objects); void export_arm_run_project(); void export_arm_run_material(char *path); -buffer_t *export_arm_bgra_swap(buffer_t *buffer); -buffer_t *export_arm_bgra64_swap(buffer_t *buffer); void export_arm_run_brush(char *path); void export_arm_pack_assets(project_t *raw, asset_t_array_t *assets); void export_arm_run_swatches(char *path); @@ -698,56 +695,56 @@ void nodes_material_group_input_button(i32 node_id); void nodes_material_group_output_button(i32 node_id); void nodes_material_sync_sockets(ui_node_t *node); i32 nodes_material_get_socket_color(char *type); -ui_node_socket_t *nodes_material_create_socket(ui_nodes_t *nodes, ui_node_t *node, char *name, char *type, ui_node_canvas_t *canvas, f32 min, f32 max, - void *default_value); -void brick_texture_node_init(); -void rgb_node_init(); -void rgb_to_bw_node_init(); -void attribute_node_init(); -void shader_node_init(); -void save_image_node_init(); -void save_image_node_run(ui_node_t *node, gpu_texture_t *result); -void repeat_node_init(); -void neural_node_load_result(ui_node_t *node); -void text_to_image_node_run(ui_node_t *node, void (*callback)(ui_node_t *)); -void upscale_image_node_init(); -void image_to_pbr_node_init(); -void inpaint_image_node_init(); -void text_to_image_node_init(); -void texture_mesh_node_init(); -void text_to_text_node_clear(); -void text_to_text_node_run(char *prompt, void (*done)(char *)); -void outpaint_image_node_init(); -char *neural_node_vector(ui_node_t *node, ui_node_socket_t *socket); -char *neural_node_value(ui_node_t *node, ui_node_socket_t *socket); -ui_node_t *neural_from_node(ui_node_socket_t *inp, i32 socket); -bool neural_node_button(ui_node_t *node, char *model); -void neural_node_check_result(ui_node_t *node); -char *neural_node_sd_bin(); -char *neural_node_dir(); -void neural_node_download_models(string_array_t *models); -void neural_node_models_init(); -void edit_image_node_init(); -void tile_image_node_init(); -void image_to_3d_mesh_node_init(); -void image_to_3d_mesh_node_button(i32 node_id); -void vary_image_node_init(); -void image_to_normal_map_node_init(); -void image_to_depth_node_init(); -tex_image_node_t *tex_image_node_create(ui_node_t *raw, f32_array_t *args); -random_node_t *random_node_create(ui_node_t *raw, f32_array_t *args); -boolean_node_t *boolean_node_create(ui_node_t *raw, f32_array_t *args); -input_node_t *input_node_create(ui_node_t *raw, f32_array_t *args); -math_node_t *math_node_create(ui_node_t *raw, f32_array_t *args); -vector_node_t *vector_node_create(ui_node_t *raw, f32_array_t *args); -color_node_t *color_node_create(ui_node_t *raw, f32_array_t *args); -string_node_t *string_node_create(ui_node_t *raw, f32_array_t *args); -null_node_t *null_node_create(ui_node_t *raw, f32_array_t *args); -time_node_t *time_node_create(ui_node_t *raw, f32_array_t *args); -vector_math_node_t *vector_math_node_create(ui_node_t *raw, f32_array_t *args); -float_node_t *float_node_create(ui_node_t *raw, f32_array_t *args); -integer_node_t *integer_node_create(ui_node_t *raw, f32_array_t *args); -separate_vector_node_t *separate_vector_node_create(ui_node_t *raw, f32_array_t *args); -brush_output_node_t *brush_output_node_create(ui_node_t *raw, f32_array_t *args); -void brush_output_node_parse_inputs(); -void edit_uvmap_update(); +ui_node_socket_t *nodes_material_create_socket(ui_nodes_t *nodes, ui_node_t *node, char *name, char *type, ui_node_canvas_t *canvas, f32 min, f32 max, + void *default_value); +void brick_texture_node_init(); +void rgb_node_init(); +void rgb_to_bw_node_init(); +void attribute_node_init(); +void shader_node_init(); +void save_image_node_init(); +void save_image_node_run(ui_node_t *node, gpu_texture_t *result); +void repeat_node_init(); +void neural_node_load_result(ui_node_t *node); +void text_to_image_node_run(ui_node_t *node, void (*callback)(ui_node_t *)); +void upscale_image_node_init(); +void image_to_pbr_node_init(); +void inpaint_image_node_init(); +void text_to_image_node_init(); +void texture_mesh_node_init(); +void text_to_text_node_clear(); +void text_to_text_node_run(char *prompt, void (*done)(char *)); +void outpaint_image_node_init(); +char *neural_node_vector(ui_node_t *node, ui_node_socket_t *socket); +char *neural_node_value(ui_node_t *node, ui_node_socket_t *socket); +ui_node_t *neural_from_node(ui_node_socket_t *inp, i32 socket); +bool neural_node_button(ui_node_t *node, char *model); +void neural_node_check_result(ui_node_t *node); +char *neural_node_sd_bin(); +char *neural_node_dir(); +void neural_node_download_models(string_array_t *models); +void neural_node_models_init(); +void edit_image_node_init(); +void tile_image_node_init(); +void image_to_3d_mesh_node_init(); +void image_to_3d_mesh_node_button(i32 node_id); +void vary_image_node_init(); +void image_to_normal_map_node_init(); +void image_to_depth_node_init(); +void *tex_image_node_create(ui_node_t *raw, f32_array_t *args); +void *random_node_create(ui_node_t *raw, f32_array_t *args); +void *boolean_node_create(ui_node_t *raw, f32_array_t *args); +void *input_node_create(ui_node_t *raw, f32_array_t *args); +void *math_node_create(ui_node_t *raw, f32_array_t *args); +void *vector_node_create(ui_node_t *raw, f32_array_t *args); +void *color_node_create(ui_node_t *raw, f32_array_t *args); +void *string_node_create(ui_node_t *raw, f32_array_t *args); +void *null_node_create(ui_node_t *raw, f32_array_t *args); +void *time_node_create(ui_node_t *raw, f32_array_t *args); +void *vector_math_node_create(ui_node_t *raw, f32_array_t *args); +void *float_node_create(ui_node_t *raw, f32_array_t *args); +void *integer_node_create(ui_node_t *raw, f32_array_t *args); +void *separate_vector_node_create(ui_node_t *raw, f32_array_t *args); +void *brush_output_node_create(ui_node_t *raw, f32_array_t *args); +void brush_output_node_parse_inputs(); +void edit_uvmap_update(); diff --git a/paint/sources/io/export_arm.c b/paint/sources/io/export_arm.c index f3378104..72a6ac53 100644 --- a/paint/sources/io/export_arm.c +++ b/paint/sources/io/export_arm.c @@ -95,21 +95,6 @@ string_array_t *export_arm_fonts_to_files(char *project_path, slot_font_t_array_ return font_files; } -f32_array_t *export_arm_vec3f32(vec4_t v) { - f32_array_t *res = f32_array_create(3); - res->buffer[0] = v.x; - res->buffer[1] = v.y; - res->buffer[2] = v.z; - return res; -} - -buffer_t *export_arm_rgba64_to_rgba32(buffer_t *buffer) { - for (i32 i = 0; i < buffer->length / 2.0; ++i) { - buffer->buffer[i] = half_to_u8_fast(buffer_get_u16(buffer, i * 2)); - } - return buffer; -} - void export_arm_run_project() { tab_timeline_prepare_save(); @@ -251,7 +236,7 @@ void export_arm_run_project() { g_project->envmap_angle = g_context->envmap_angle; g_project->envmap_blur = g_context->show_envmap_blur; g_project->camera_world = mat4_to_f32_array(scene_camera->base->transform->local); - g_project->camera_origin = export_arm_vec3f32(camera_origins[0]); + g_project->camera_origin = vec3_to_f32_array(camera_origins[0]); g_project->camera_fov = scene_camera->data->fov; // g_project.mesh_datas = md; // TODO: fix GC ref @@ -394,7 +379,7 @@ void export_arm_run_material(char *path) { } #ifdef IRON_BGRA - buffer_t *buf = lz4_encode(export_arm_bgra64_swap(gpu_get_texture_pixels(m->image))); + buffer_t *buf = lz4_encode(buffer_bgra64_swap(gpu_get_texture_pixels(m->image))); #else buffer_t *buf = lz4_encode(gpu_get_texture_pixels(m->image)); #endif @@ -428,9 +413,9 @@ void export_arm_run_material(char *path) { .packed_assets = packed_assets}); if (g_context->write_icon_on_export) { // Separate icon files - buffer_t *buf = export_arm_rgba64_to_rgba32(gpu_get_texture_pixels(m->image)); + buffer_t *buf = buffer_half_to_u8(gpu_get_texture_pixels(m->image)); #ifdef IRON_BGRA - buf = export_arm_bgra_swap(buf); + buf = buffer_bgra_swap(buf); #endif iron_write_png(string("%s_icon.png", substring(path, 0, string_length(path) - 4)), buf, m->image->width, m->image->height, 0); iron_write_jpg(string("%s_icon.jpg", substring(path, 0, string_length(path) - 4)), buf, m->image->width, m->image->height, 0, 50); @@ -444,27 +429,6 @@ void export_arm_run_material(char *path) { iron_file_save_bytes(path, buffer, buffer->length + 1); } -buffer_t *export_arm_bgra_swap(buffer_t *buffer) { - for (i32 i = 0; i < math_floor((buffer->length) / 4.0); ++i) { - i32 r = buffer->buffer[i * 4]; - buffer->buffer[i * 4] = buffer->buffer[i * 4 + 2]; - buffer->buffer[i * 4 + 2] = r; - } - return buffer; -} - -buffer_t *export_arm_bgra64_swap(buffer_t *buffer) { - for (i32 i = 0; i < math_floor((buffer->length) / 8.0); ++i) { - i32 r_low = buffer->buffer[i * 8 + 4]; - i32 r_high = buffer->buffer[i * 8 + 5]; - buffer->buffer[i * 8 + 4] = buffer->buffer[i * 8 + 0]; - buffer->buffer[i * 8 + 5] = buffer->buffer[i * 8 + 1]; - buffer->buffer[i * 8] = r_low; - buffer->buffer[i * 8 + 1] = r_high; - } - return buffer; -} - void export_arm_run_brush(char *path) { if (!ends_with(path, ".arm")) { path = string("%s.arm", path); @@ -486,7 +450,7 @@ void export_arm_run_brush(char *path) { } #ifdef IRON_BGRA - buffer_t *buf = lz4_encode(export_arm_bgra_swap(gpu_get_texture_pixels(b->image))); + buffer_t *buf = lz4_encode(buffer_bgra_swap(gpu_get_texture_pixels(b->image))); #else buffer_t *buf = lz4_encode(gpu_get_texture_pixels(b->image)); #endif @@ -503,7 +467,7 @@ void export_arm_run_brush(char *path) { if (g_context->write_icon_on_export) { // Separate icon files buffer_t *buf = gpu_get_texture_pixels(b->image); #ifdef IRON_BGRA - buf = export_arm_bgra_swap(buf); + buf = buffer_bgra_swap(buf); #endif iron_write_png(string("%s_icon.png", substring(path, 0, string_length(path) - 4)), buf, b->image->width, b->image->height, 0); iron_write_jpg(string("%s_icon.jpg", substring(path, 0, string_length(path) - 4)), buf, b->image->width, b->image->height, 0, 50); diff --git a/paint/sources/io/export_exr.c b/paint/sources/io/export_exr.c index 9f77f450..06a4f8c3 100644 --- a/paint/sources/io/export_exr.c +++ b/paint/sources/io/export_exr.c @@ -5,19 +5,19 @@ // 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); +static i32 _export_exr_width; +static i32 _export_exr_stride; +static u8_array_t *_export_exr_out; +static buffer_t *_export_exr_src_view; +static void (*_export_exr_write_line)(i32); -void export_exr_write_string(u8_array_t *out, char *str) { +static 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)); } } -void export_exr_write_line16(i32 byte_pos) { +static void export_exr_write_line16(i32 byte_pos) { for (i32 x = 0; x < _export_exr_width; ++x) { u8_array_push(_export_exr_out, buffer_get_u8(_export_exr_src_view, byte_pos)); u8_array_push(_export_exr_out, buffer_get_u8(_export_exr_src_view, byte_pos + 1)); @@ -25,7 +25,7 @@ void export_exr_write_line16(i32 byte_pos) { } } -void export_exr_write_line32(i32 byte_pos) { +static void export_exr_write_line32(i32 byte_pos) { for (i32 x = 0; x < _export_exr_width; ++x) { u8_array_push(_export_exr_out, buffer_get_u8(_export_exr_src_view, byte_pos)); u8_array_push(_export_exr_out, buffer_get_u8(_export_exr_src_view, byte_pos + 1)); @@ -35,13 +35,13 @@ void export_exr_write_line32(i32 byte_pos) { } } -void export_exr_write_bgr(i32 off, i32 pos, i32 byte_size) { +static void export_exr_write_bgr(i32 off, i32 pos, i32 byte_size) { _export_exr_write_line(pos + byte_size * 2); _export_exr_write_line(pos + byte_size); _export_exr_write_line(pos); } -void export_exr_write_single(i32 off, i32 pos, i32 byte_size) { +static void export_exr_write_single(i32 off, i32 pos, i32 byte_size) { _export_exr_write_line(pos + off * byte_size); _export_exr_write_line(pos + off * byte_size); _export_exr_write_line(pos + off * byte_size); diff --git a/paint/sources/io/export_obj.c b/paint/sources/io/export_obj.c index 3a3573c6..013b41c1 100644 --- a/paint/sources/io/export_obj.c +++ b/paint/sources/io/export_obj.c @@ -1,7 +1,7 @@ #include "../global.h" -void export_obj_write_string(u8_array_t *out, char *str) { +static void export_obj_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)); } diff --git a/paint/sources/io/export_player.c b/paint/sources/io/export_player.c index cf7885de..2359309d 100644 --- a/paint/sources/io/export_player.c +++ b/paint/sources/io/export_player.c @@ -110,7 +110,7 @@ static void export_player_run_on_download(char *url, buffer_t *ab) {} void export_player_run(char *path) { #ifndef NDEBUG - console_error(tr("Not available in debug build")); + console_error(tr("Not available in debug build")); // Requires --embed return; #endif diff --git a/paint/sources/io/export_texture.c b/paint/sources/io/export_texture.c index 1f938fad..74e0cc47 100644 --- a/paint/sources/io/export_texture.c +++ b/paint/sources/io/export_texture.c @@ -1,9 +1,9 @@ #include "../global.h" -f32 export_texture_gamma = 1.0 / 2.2; +static f32 export_texture_gamma = 1.0 / 2.2; -void export_texture_write_texture(char *file, buffer_t *pixels, i32 type, i32 off) { +static 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(); i32 bits_handle = base_bits_handle->i; @@ -28,7 +28,7 @@ void export_texture_write_texture(char *file, buffer_t *pixels, i32 type, i32 of if (g_context->layers_destination == EXPORT_DESTINATION_PACK_INTO_PROJECT) { #ifdef IRON_BGRA if (format == 2) { // RGB1 - export_arm_bgra_swap(pixels); + buffer_bgra_swap(pixels); } #endif gpu_texture_t *image = gpu_create_texture_from_bytes(pixels, res_x, res_y, GPU_TEXTURE_FORMAT_RGBA32); @@ -64,19 +64,17 @@ void export_texture_write_texture(char *file, buffer_t *pixels, i32 type, i32 of } } -void export_texture_to_srgb(buffer_t *to, i32 to_channel) { +static void export_texture_to_srgb(buffer_t *to, i32 to_channel) { for (i32 i = 0; i < math_floor((to->length) / 4.0); ++i) { buffer_set_u8(to, i * 4 + to_channel, math_floor(math_pow(buffer_get_u8(to, i * 4 + to_channel) / 255.0, export_texture_gamma) * 255)); } } -#ifdef IRON_BGRA -i32 _export_texture_channel_bgra_swap(i32 c) { +static i32 _export_texture_channel_bgra_swap(i32 c) { return c == 0 ? 2 : c == 2 ? 0 : c; } -#endif -void export_texture_copy_channel(buffer_t *from, i32 from_channel, buffer_t *to, i32 to_channel, bool linear) { +static void export_texture_copy_channel(buffer_t *from, i32 from_channel, buffer_t *to, i32 to_channel, bool linear) { #ifdef IRON_BGRA from_channel = _export_texture_channel_bgra_swap(from_channel); #endif @@ -88,7 +86,7 @@ void export_texture_copy_channel(buffer_t *from, i32 from_channel, buffer_t *to, } } -void export_texture_copy_channel_inv(buffer_t *from, i32 from_channel, buffer_t *to, i32 to_channel, bool linear) { +static void export_texture_copy_channel_inv(buffer_t *from, i32 from_channel, buffer_t *to, i32 to_channel, bool linear) { #ifdef IRON_BGRA from_channel = _export_texture_channel_bgra_swap(from_channel); #endif @@ -100,7 +98,7 @@ void export_texture_copy_channel_inv(buffer_t *from, i32 from_channel, buffer_t } } -void export_texture_extract_channel(buffer_t *from, i32 from_channel, buffer_t *to, i32 to_channel, i32 step, i32 mask, bool linear) { +static void export_texture_extract_channel(buffer_t *from, i32 from_channel, buffer_t *to, i32 to_channel, i32 step, i32 mask, bool linear) { #ifdef IRON_BGRA from_channel = _export_texture_channel_bgra_swap(from_channel); #endif @@ -112,8 +110,8 @@ void export_texture_extract_channel(buffer_t *from, i32 from_channel, buffer_t * } } -void export_texture_compute_diff_spec_channel(buffer_t *from_albedo, buffer_t *from_pack, i32 albedo_channel, buffer_t *to, i32 to_channel, bool linear, - bool is_specular) { +static void export_texture_compute_diff_spec_channel(buffer_t *from_albedo, buffer_t *from_pack, i32 albedo_channel, buffer_t *to, i32 to_channel, bool linear, + bool is_specular) { #ifdef IRON_BGRA albedo_channel = _export_texture_channel_bgra_swap(albedo_channel); to_channel = _export_texture_channel_bgra_swap(to_channel); @@ -138,7 +136,7 @@ void export_texture_compute_diff_spec_channel(buffer_t *from_albedo, buffer_t *f } } -void export_texture_set_channel(i32 value, buffer_t *to, i32 to_channel, bool linear) { +static void export_texture_set_channel(i32 value, buffer_t *to, i32 to_channel, bool linear) { for (i32 i = 0; i < math_floor((to->length) / 4.0); ++i) { buffer_set_u8(to, i * 4 + to_channel, value); } @@ -147,8 +145,7 @@ void export_texture_set_channel(i32 value, buffer_t *to, i32 to_channel, bool li } } -void export_texture_run_layers(char *path, slot_layer_t_array_t *layers, char *object_name, bool bake_material) { - +static void export_texture_run_layers(char *path, slot_layer_t_array_t *layers, char *object_name, bool bake_material) { i32 texture_size_x = config_get_texture_res_x(); i32 texture_size_y = config_get_texture_res_y(); #if defined(IRON_ANDROID) || defined(IRON_IOS) @@ -448,7 +445,7 @@ void export_texture_run_layers(char *path, slot_layer_t_array_t *layers, char *o // texpaint_pack->pixels = NULL; } -void export_texture_run_bake_material(char *path) { +static void export_texture_run_bake_material(char *path) { if (render_path_paint_live_layer == NULL) { gc_unroot(render_path_paint_live_layer); render_path_paint_live_layer = slot_layer_create("_live", LAYER_SLOT_TYPE_LAYER, NULL); diff --git a/paint/sources/nodes_brush/boolean_node.c b/paint/sources/nodes_brush/boolean_node.c index 0e8b96ca..85837d01 100644 --- a/paint/sources/nodes_brush/boolean_node.c +++ b/paint/sources/nodes_brush/boolean_node.c @@ -1,6 +1,11 @@ #include "../global.h" +typedef struct boolean_node { + struct logic_node *base; + bool value; +} boolean_node_t; + logic_node_value_t *boolean_node_get(boolean_node_t *self, i32 from) { if (self->base->inputs->length > 0) { return logic_node_input_get(self->base->inputs->buffer[0]); @@ -20,7 +25,7 @@ void boolean_node_set(boolean_node_t *self, f32_array_t *value) { } } -boolean_node_t *boolean_node_create(ui_node_t *raw, f32_array_t *args) { +void *boolean_node_create(ui_node_t *raw, f32_array_t *args) { boolean_node_t *n = GC_ALLOC_INIT(boolean_node_t, {0}); n->base = logic_node_create(n); n->base->get = boolean_node_get; diff --git a/paint/sources/nodes_brush/brush_output_node.c b/paint/sources/nodes_brush/brush_output_node.c index 92157d5a..ae5ccaf9 100644 --- a/paint/sources/nodes_brush/brush_output_node.c +++ b/paint/sources/nodes_brush/brush_output_node.c @@ -1,6 +1,11 @@ #include "../global.h" +typedef struct brush_output_node { + struct logic_node *base; + struct ui_node *raw; +} brush_output_node_t; + static brush_output_node_t *brush_output_node_inst; void brush_output_node_parse_inputs() { @@ -185,7 +190,7 @@ void brush_output_node_run() { } } -brush_output_node_t *brush_output_node_create(ui_node_t *raw, f32_array_t *args) { +void *brush_output_node_create(ui_node_t *raw, f32_array_t *args) { brush_output_node_t *n = GC_ALLOC_INIT(brush_output_node_t, {0}); n->base = logic_node_create(n); n->raw = raw; diff --git a/paint/sources/nodes_brush/color_node.c b/paint/sources/nodes_brush/color_node.c index 42b5ebb1..f05428ad 100644 --- a/paint/sources/nodes_brush/color_node.c +++ b/paint/sources/nodes_brush/color_node.c @@ -1,6 +1,12 @@ #include "../global.h" +typedef struct color_node { + struct logic_node *base; + vec4_t value; + struct gpu_texture *image; +} color_node_t; + logic_node_value_t *color_node_get(color_node_t *self, i32 from) { if (self->base->inputs->length > 0) { return logic_node_input_get(self->base->inputs->buffer[0]); @@ -39,7 +45,7 @@ void color_node_set(color_node_t *self, f32_array_t *value) { } } -color_node_t *color_node_create(ui_node_t *raw, f32_array_t *args) { +void *color_node_create(ui_node_t *raw, f32_array_t *args) { f32 r = args == NULL ? 0.8 : args->buffer[0]; f32 g = args == NULL ? 0.8 : args->buffer[1]; f32 b = args == NULL ? 0.8 : args->buffer[2]; diff --git a/paint/sources/nodes_brush/float_node.c b/paint/sources/nodes_brush/float_node.c index d05c29db..3140c91c 100644 --- a/paint/sources/nodes_brush/float_node.c +++ b/paint/sources/nodes_brush/float_node.c @@ -36,7 +36,7 @@ void float_node_set(float_node_t *self, f32_array_t *value) { } } -float_node_t *float_node_create(ui_node_t *raw, f32_array_t *args) { +void *float_node_create(ui_node_t *raw, f32_array_t *args) { float_node_t *n = GC_ALLOC_INIT(float_node_t, {0}); n->base = logic_node_create(n); n->base->get = float_node_get; diff --git a/paint/sources/nodes_brush/input_node.c b/paint/sources/nodes_brush/input_node.c index 0dd009ca..908ae5d6 100644 --- a/paint/sources/nodes_brush/input_node.c +++ b/paint/sources/nodes_brush/input_node.c @@ -1,6 +1,10 @@ #include "../global.h" +typedef struct input_node { + struct logic_node *base; +} input_node_t; + f32 input_node_start_x = 0.0; f32 input_node_start_y = 0.0; // Brush ruler @@ -187,7 +191,7 @@ logic_node_value_t *input_node_get(input_node_t *self, i32 from) { return v; } -input_node_t *input_node_create(ui_node_t *raw, f32_array_t *args) { +void *input_node_create(ui_node_t *raw, f32_array_t *args) { float_node_t *n = GC_ALLOC_INIT(float_node_t, {0}); n->base = logic_node_create(n); n->base->get = input_node_get; diff --git a/paint/sources/nodes_brush/integer_node.c b/paint/sources/nodes_brush/integer_node.c index 80321a1b..cd6f1e74 100644 --- a/paint/sources/nodes_brush/integer_node.c +++ b/paint/sources/nodes_brush/integer_node.c @@ -1,6 +1,11 @@ #include "../global.h" +typedef struct integer_node { + struct logic_node *base; + i32 value; +} integer_node_t; + logic_node_value_t *integer_node_get(integer_node_t *self, i32 from) { if (self->base->inputs->length > 0) { return logic_node_input_get(self->base->inputs->buffer[0]); @@ -20,7 +25,7 @@ void integer_node_set(integer_node_t *self, f32_array_t *value) { } } -integer_node_t *integer_node_create(ui_node_t *raw, f32_array_t *args) { +void *integer_node_create(ui_node_t *raw, f32_array_t *args) { float_node_t *n = GC_ALLOC_INIT(float_node_t, {0}); n->base = logic_node_create(n); n->base->get = integer_node_get; diff --git a/paint/sources/nodes_brush/math_node.c b/paint/sources/nodes_brush/math_node.c index 24ef415b..eb4dd07b 100644 --- a/paint/sources/nodes_brush/math_node.c +++ b/paint/sources/nodes_brush/math_node.c @@ -1,6 +1,12 @@ #include "../global.h" +typedef struct math_node { + struct logic_node *base; + char *operation; + bool use_clamp; +} math_node_t; + logic_node_value_t *math_node_get(math_node_t *self, i32 from) { f32 v1 = logic_node_input_get(self->base->inputs->buffer[0])->_f32; f32 v2 = logic_node_input_get(self->base->inputs->buffer[1])->_f32; @@ -120,7 +126,7 @@ logic_node_value_t *math_node_get(math_node_t *self, i32 from) { return v; } -math_node_t *math_node_create(ui_node_t *raw, f32_array_t *args) { +void *math_node_create(ui_node_t *raw, f32_array_t *args) { math_node_t *n = GC_ALLOC_INIT(math_node_t, {0}); n->base = logic_node_create(n); n->base->get = math_node_get; diff --git a/paint/sources/nodes_brush/null_node.c b/paint/sources/nodes_brush/null_node.c index a8a08622..0fd8ed52 100644 --- a/paint/sources/nodes_brush/null_node.c +++ b/paint/sources/nodes_brush/null_node.c @@ -1,11 +1,15 @@ #include "../global.h" +typedef struct null_node { + struct logic_node *base; +} null_node_t; + logic_node_value_t *null_node_get(null_node_t *self, i32 from) { return NULL; } -null_node_t *null_node_create(ui_node_t *raw, f32_array_t *args) { +void *null_node_create(ui_node_t *raw, f32_array_t *args) { null_node_t *n = GC_ALLOC_INIT(null_node_t, {0}); n->base = logic_node_create(n); n->base->get = float_node_get; diff --git a/paint/sources/nodes_brush/random_node.c b/paint/sources/nodes_brush/random_node.c index bb5b7aa3..3e4b4e0c 100644 --- a/paint/sources/nodes_brush/random_node.c +++ b/paint/sources/nodes_brush/random_node.c @@ -1,6 +1,10 @@ #include "../global.h" +typedef struct random_node { + struct logic_node *base; +} random_node_t; + i32 random_node_a; i32 random_node_b; i32 random_node_c; @@ -51,7 +55,7 @@ logic_node_value_t *random_node_get(random_node_t *self, i32 from) { return v; } -random_node_t *random_node_create(ui_node_t *raw, f32_array_t *args) { +void *random_node_create(ui_node_t *raw, f32_array_t *args) { random_node_t *n = GC_ALLOC_INIT(random_node_t, {0}); n->base = logic_node_create(n); n->base->get = random_node_get; diff --git a/paint/sources/nodes_brush/separate_vector_node.c b/paint/sources/nodes_brush/separate_vector_node.c index 7f1f9945..d8acb0c0 100644 --- a/paint/sources/nodes_brush/separate_vector_node.c +++ b/paint/sources/nodes_brush/separate_vector_node.c @@ -1,6 +1,10 @@ #include "../global.h" +typedef struct separate_vector_node { + struct logic_node *base; +} separate_vector_node_t; + logic_node_value_t *separate_vector_node_get(separate_vector_node_t *self, i32 from) { vec4_t vector = logic_node_input_get(self->base->inputs->buffer[0])->_vec4; if (from == 0) { @@ -17,7 +21,7 @@ logic_node_value_t *separate_vector_node_get(separate_vector_node_t *self, i32 f } } -separate_vector_node_t *separate_vector_node_create(ui_node_t *raw, f32_array_t *args) { +void *separate_vector_node_create(ui_node_t *raw, f32_array_t *args) { separate_vector_node_t *n = GC_ALLOC_INIT(separate_vector_node_t, {0}); n->base = logic_node_create(n); n->base->get = separate_vector_node_get; diff --git a/paint/sources/nodes_brush/string_node.c b/paint/sources/nodes_brush/string_node.c index ab17f25c..46b42e9d 100644 --- a/paint/sources/nodes_brush/string_node.c +++ b/paint/sources/nodes_brush/string_node.c @@ -1,6 +1,11 @@ #include "../global.h" +typedef struct string_node { + struct logic_node *base; + char *value; +} string_node_t; + logic_node_value_t *string_node_get(string_node_t *self, i32 from) { if (self->base->inputs->length > 0) { return logic_node_input_get(self->base->inputs->buffer[0]); @@ -20,7 +25,7 @@ void string_node_set(string_node_t *self, void *value) { } } -string_node_t *string_node_create(ui_node_t *raw, f32_array_t *args) { +void *string_node_create(ui_node_t *raw, f32_array_t *args) { string_node_t *n = GC_ALLOC_INIT(string_node_t, {0}); n->base = logic_node_create(n); n->base->get = string_node_get; diff --git a/paint/sources/nodes_brush/tex_image_node.c b/paint/sources/nodes_brush/tex_image_node.c index 0d815072..11b6d8b4 100644 --- a/paint/sources/nodes_brush/tex_image_node.c +++ b/paint/sources/nodes_brush/tex_image_node.c @@ -1,6 +1,11 @@ #include "../global.h" +typedef struct tex_image_node { + struct logic_node *base; + struct ui_node *raw; +} tex_image_node_t; + logic_node_value_t *tex_image_node_get(tex_image_node_t *self, i32 from) { string_array_t *ar = ui_nodes_enum_texts(self->raw->type); i32 i = self->raw->buttons->buffer[0]->default_value->buffer[0]; @@ -16,7 +21,7 @@ logic_node_value_t *tex_image_node_get(tex_image_node_t *self, i32 from) { } } -tex_image_node_t *tex_image_node_create(ui_node_t *raw, f32_array_t *args) { +void *tex_image_node_create(ui_node_t *raw, f32_array_t *args) { tex_image_node_t *n = GC_ALLOC_INIT(tex_image_node_t, {0}); n->base = logic_node_create(n); n->base->get = tex_image_node_get; diff --git a/paint/sources/nodes_brush/time_node.c b/paint/sources/nodes_brush/time_node.c index 22c6ba4b..1f083a87 100644 --- a/paint/sources/nodes_brush/time_node.c +++ b/paint/sources/nodes_brush/time_node.c @@ -1,6 +1,10 @@ #include "../global.h" +typedef struct time_node { + struct logic_node *base; +} time_node_t; + logic_node_value_t *time_node_get(time_node_t *self, i32 from) { if (from == 0) { logic_node_value_t *v = GC_ALLOC_INIT(logic_node_value_t, {._f32 = sys_time()}); @@ -16,7 +20,7 @@ logic_node_value_t *time_node_get(time_node_t *self, i32 from) { } } -time_node_t *time_node_create(ui_node_t *raw, f32_array_t *args) { +void *time_node_create(ui_node_t *raw, f32_array_t *args) { time_node_t *n = GC_ALLOC_INIT(time_node_t, {0}); n->base = logic_node_create(n); n->base->get = time_node_get; diff --git a/paint/sources/nodes_brush/vector_math_node.c b/paint/sources/nodes_brush/vector_math_node.c index a0c66dc4..aa6b543f 100644 --- a/paint/sources/nodes_brush/vector_math_node.c +++ b/paint/sources/nodes_brush/vector_math_node.c @@ -1,6 +1,12 @@ #include "../global.h" +typedef struct vector_math_node { + struct logic_node *base; + char *operation; + vec4_t v; +} vector_math_node_t; + logic_node_value_t *vector_math_node_get(vector_math_node_t *self, i32 from) { vec4_t v1 = logic_node_input_get(self->base->inputs->buffer[0])->_vec4; vec4_t v2 = logic_node_input_get(self->base->inputs->buffer[1])->_vec4; @@ -128,7 +134,7 @@ logic_node_value_t *vector_math_node_get(vector_math_node_t *self, i32 from) { } } -vector_math_node_t *vector_math_node_create(ui_node_t *raw, f32_array_t *args) { +void *vector_math_node_create(ui_node_t *raw, f32_array_t *args) { vector_math_node_t *n = GC_ALLOC_INIT(vector_math_node_t, {0}); n->base = logic_node_create(n); n->base->get = vector_math_node_get; diff --git a/paint/sources/nodes_brush/vector_node.c b/paint/sources/nodes_brush/vector_node.c index 4448ffef..8dc46e4a 100644 --- a/paint/sources/nodes_brush/vector_node.c +++ b/paint/sources/nodes_brush/vector_node.c @@ -1,6 +1,12 @@ #include "../global.h" +typedef struct vector_node { + struct logic_node *base; + vec4_t value; + struct gpu_texture *image; +} vector_node_t; + logic_node_value_t *vector_node_get(vector_node_t *self, i32 from) { f32 x = logic_node_input_get(self->base->inputs->buffer[0])->_f32; f32 y = logic_node_input_get(self->base->inputs->buffer[1])->_f32; @@ -37,7 +43,7 @@ void vector_node_set(vector_node_t *self, f32_array_t *value) { logic_node_input_set(self->base->inputs->buffer[2], f32_array_create_x(value->buffer[2])); } -vector_node_t *vector_node_create(ui_node_t *raw, f32_array_t *args) { +void *vector_node_create(ui_node_t *raw, f32_array_t *args) { vector_node_t *n = GC_ALLOC_INIT(vector_node_t, {0}); n->base = logic_node_create(n); n->base->get = vector_node_get; diff --git a/paint/sources/nodes_neural/edit_image_node.c b/paint/sources/nodes_neural/edit_image_node.c index 562b7857..9503c72f 100644 --- a/paint/sources/nodes_neural/edit_image_node.c +++ b/paint/sources/nodes_neural/edit_image_node.c @@ -93,7 +93,7 @@ void edit_image_node_button(i32 node_id) { gpu_texture_t *input = ui_nodes_get_node_preview_image(from_node); if (input != NULL) { #ifdef IRON_BGRA - buffer_t *input_buf = export_arm_bgra_swap(gpu_get_texture_pixels(input)); // Vulkan non-rt textures need a flip + buffer_t *input_buf = buffer_bgra_swap(gpu_get_texture_pixels(input)); // Vulkan non-rt textures need a flip #else buffer_t *input_buf = gpu_get_texture_pixels(input); #endif diff --git a/paint/sources/nodes_neural/image_to_3d_mesh_node.c b/paint/sources/nodes_neural/image_to_3d_mesh_node.c index 55433e7e..dc13a0db 100644 --- a/paint/sources/nodes_neural/image_to_3d_mesh_node.c +++ b/paint/sources/nodes_neural/image_to_3d_mesh_node.c @@ -46,7 +46,7 @@ void image_to_3d_mesh_node_button(i32 node_id) { char *dir = neural_node_dir(); #ifdef IRON_BGRA - buffer_t *input_buf = image_to_3d_mesh_node_remove_background(export_arm_bgra_swap(gpu_get_texture_pixels(input))); + buffer_t *input_buf = image_to_3d_mesh_node_remove_background(buffer_bgra_swap(gpu_get_texture_pixels(input))); #else buffer_t *input_buf = image_to_3d_mesh_node_remove_background(gpu_get_texture_pixels(input)); #endif diff --git a/paint/sources/nodes_neural/image_to_depth_node.c b/paint/sources/nodes_neural/image_to_depth_node.c index a9cc4cb0..3f823cae 100644 --- a/paint/sources/nodes_neural/image_to_depth_node.c +++ b/paint/sources/nodes_neural/image_to_depth_node.c @@ -19,7 +19,7 @@ void image_to_depth_node_button(i32 node_id) { char *dir = neural_node_dir(); #ifdef IRON_BGRA - buffer_t *input_buf = export_arm_bgra_swap(gpu_get_texture_pixels(input)); // Vulkan non-rt textures need a flip + buffer_t *input_buf = buffer_bgra_swap(gpu_get_texture_pixels(input)); // Vulkan non-rt textures need a flip #else buffer_t *input_buf = gpu_get_texture_pixels(input); #endif diff --git a/paint/sources/nodes_neural/image_to_normal_map_node.c b/paint/sources/nodes_neural/image_to_normal_map_node.c index 2c6332c6..bf4def2f 100644 --- a/paint/sources/nodes_neural/image_to_normal_map_node.c +++ b/paint/sources/nodes_neural/image_to_normal_map_node.c @@ -19,7 +19,7 @@ void image_to_normal_map_node_button(i32 node_id) { char *dir = neural_node_dir(); #ifdef IRON_BGRA - buffer_t *input_buf = export_arm_bgra_swap(gpu_get_texture_pixels(input)); // Vulkan non-rt textures need a flip + buffer_t *input_buf = buffer_bgra_swap(gpu_get_texture_pixels(input)); // Vulkan non-rt textures need a flip #else buffer_t *input_buf = gpu_get_texture_pixels(input); #endif diff --git a/paint/sources/nodes_neural/image_to_pbr_node.c b/paint/sources/nodes_neural/image_to_pbr_node.c index 45a957a2..52cd3ea3 100644 --- a/paint/sources/nodes_neural/image_to_pbr_node.c +++ b/paint/sources/nodes_neural/image_to_pbr_node.c @@ -185,7 +185,7 @@ void image_to_pbr_node_button(i32 node_id) { char *dir = neural_node_dir(); #ifdef IRON_BGRA - buffer_t *input_buf = export_arm_bgra_swap(gpu_get_texture_pixels(input)); // Vulkan non-rt textures need a flip + buffer_t *input_buf = buffer_bgra_swap(gpu_get_texture_pixels(input)); // Vulkan non-rt textures need a flip #else buffer_t *input_buf = gpu_get_texture_pixels(input); #endif diff --git a/paint/sources/nodes_neural/inpaint_image_node.c b/paint/sources/nodes_neural/inpaint_image_node.c index a86f155d..ad6c23be 100644 --- a/paint/sources/nodes_neural/inpaint_image_node.c +++ b/paint/sources/nodes_neural/inpaint_image_node.c @@ -20,7 +20,7 @@ void inpaint_image_node_button_on_next_frame(ui_node_t *node) { char *dir = neural_node_dir(); if (model == 0) { #ifdef IRON_BGRA - buffer_t *input_buf = export_arm_bgra_swap(gpu_get_texture_pixels(input)); // Vulkan non-rt textures need a flip + buffer_t *input_buf = buffer_bgra_swap(gpu_get_texture_pixels(input)); // Vulkan non-rt textures need a flip #else buffer_t *input_buf = gpu_get_texture_pixels(input); #endif diff --git a/paint/sources/nodes_neural/outpaint_image_node.c b/paint/sources/nodes_neural/outpaint_image_node.c index cdcb59a2..1e7f02b6 100644 --- a/paint/sources/nodes_neural/outpaint_image_node.c +++ b/paint/sources/nodes_neural/outpaint_image_node.c @@ -27,7 +27,7 @@ void outpaint_image_node_button_on_next_frame(ui_node_t *node) { draw_end(); // #ifdef IRON_BGRA - // let input_buf: buffer_t = export_arm_bgra_swap(gpu_get_texture_pixels(input)); // Vulkan non-rt textures need a flip + // let input_buf: buffer_t = buffer_bgra_swap(gpu_get_texture_pixels(input)); // Vulkan non-rt textures need a flip // #else // let input_buf: buffer_t = gpu_get_texture_pixels(input); // #endif diff --git a/paint/sources/nodes_neural/save_image_node.c b/paint/sources/nodes_neural/save_image_node.c index 48475feb..524a3150 100644 --- a/paint/sources/nodes_neural/save_image_node.c +++ b/paint/sources/nodes_neural/save_image_node.c @@ -14,7 +14,7 @@ void save_image_node_run(ui_node_t *node, gpu_texture_t *result) { } while (iron_file_exists(file)); #ifdef IRON_BGRA - buffer_t *buf = export_arm_bgra_swap(gpu_get_texture_pixels(result)); + buffer_t *buf = buffer_bgra_swap(gpu_get_texture_pixels(result)); #else buffer_t *buf = gpu_get_texture_pixels(result); #endif diff --git a/paint/sources/nodes_neural/texture_mesh_node.c b/paint/sources/nodes_neural/texture_mesh_node.c index 2e7cf18a..9a2d1dd9 100644 --- a/paint/sources/nodes_neural/texture_mesh_node.c +++ b/paint/sources/nodes_neural/texture_mesh_node.c @@ -14,7 +14,6 @@ static i32 texture_mesh_node_model = 0; static void texture_mesh_node_run_sd(ui_node_t *node); static void texture_mesh_node_project(ui_node_t *node); -buffer_t *export_arm_rgba64_to_rgba32(buffer_t *buffer); static void texture_mesh_node_set_view(i32 view) { f32 h = math_pi() / 2.0; @@ -50,7 +49,7 @@ static void texture_mesh_node_grab_view(i32 view_idx) { render_target_t *rt = any_map_get(render_path_render_targets, "last"); gpu_texture_t *tex = rt->_image; - iron_write_png(string("%s%sinput_%d.png", dir, PATH_SEP, view_idx), export_arm_rgba64_to_rgba32(gpu_get_texture_pixels(tex)), tex->width, tex->height, 0); + iron_write_png(string("%s%sinput_%d.png", dir, PATH_SEP, view_idx), buffer_half_to_u8(gpu_get_texture_pixels(tex)), tex->width, tex->height, 0); } static void texture_mesh_node_capture(void *_) { diff --git a/paint/sources/nodes_neural/upscale_image_node.c b/paint/sources/nodes_neural/upscale_image_node.c index a409cd7b..29ae98c2 100644 --- a/paint/sources/nodes_neural/upscale_image_node.c +++ b/paint/sources/nodes_neural/upscale_image_node.c @@ -17,7 +17,7 @@ void upscale_image_node_button(i32 node_id) { gpu_texture_t *input = ui_nodes_get_node_preview_image(from_node); if (input != NULL) { #ifdef IRON_BGRA - buffer_t *input_buf = export_arm_bgra_swap(gpu_get_texture_pixels(input)); // Vulkan non-rt textures need a flip + buffer_t *input_buf = buffer_bgra_swap(gpu_get_texture_pixels(input)); // Vulkan non-rt textures need a flip #else buffer_t *input_buf = gpu_get_texture_pixels(input); #endif diff --git a/paint/sources/nodes_neural/vary_image_node.c b/paint/sources/nodes_neural/vary_image_node.c index 3f7a1372..9bdc0768 100644 --- a/paint/sources/nodes_neural/vary_image_node.c +++ b/paint/sources/nodes_neural/vary_image_node.c @@ -11,7 +11,7 @@ void vary_image_node_button_on_next_frame(ui_node_t *node) { draw_end(); #ifdef IRON_BGRA - buffer_t *input_buf = export_arm_bgra_swap(gpu_get_texture_pixels(input)); // Vulkan non-rt textures need a flip + buffer_t *input_buf = buffer_bgra_swap(gpu_get_texture_pixels(input)); // Vulkan non-rt textures need a flip #else buffer_t *input_buf = gpu_get_texture_pixels(input); #endif diff --git a/paint/sources/physics_body.c b/paint/sources/physics_body.c index 7fb42d9a..99a285ce 100644 --- a/paint/sources/physics_body.c +++ b/paint/sources/physics_body.c @@ -1,5 +1,5 @@ -#ifdef arm_physics +#ifdef WITH_PHYSICS #include "../libs/asim.h" #include "global.h" diff --git a/paint/sources/physics_sim.c b/paint/sources/physics_sim.c index 1f637c04..7fd772f3 100644 --- a/paint/sources/physics_sim.c +++ b/paint/sources/physics_sim.c @@ -39,7 +39,7 @@ void sim_update() { render_target_t *rt = any_map_get(render_path_render_targets, "last"); buffer_t *pixels = gpu_get_texture_pixels(rt->_image); #ifdef IRON_BGRA - export_arm_bgra_swap(pixels); + buffer_bgra_swap(pixels); #endif // iron_mp4_encode(pixels); } diff --git a/paint/sources/physics_world.c b/paint/sources/physics_world.c index 279eec94..27a06bfd 100644 --- a/paint/sources/physics_world.c +++ b/paint/sources/physics_world.c @@ -1,5 +1,5 @@ -#ifdef arm_physics +#ifdef WITH_PHYSICS #include "../libs/asim.h" #include "global.h" diff --git a/paint/sources/project.c b/paint/sources/project.c index 734df327..15001ff5 100644 --- a/paint/sources/project.c +++ b/paint/sources/project.c @@ -108,10 +108,8 @@ void project_new_box_draw() { project_fetch_default_meshes(); ui_handle_t *h_project_type = ui_handle(__ID__); - if (h_project_type->init) { - h_project_type->i = g_context->project_type; - } - g_context->project_type = ui_combo(h_project_type, project_mesh_list, tr("Template"), true, UI_ALIGN_LEFT, true); + h_project_type->i = g_context->project_type; + g_context->project_type = ui_combo(h_project_type, project_mesh_list, tr("Template"), true, UI_ALIGN_LEFT, true); ui_end_element(); ui_row2(); if (ui_icon_button(tr("Cancel"), ICON_CLOSE, UI_ALIGN_CENTER)) { @@ -248,9 +246,9 @@ void project_new(bool reset_layers) { } any_array_push(project_materials, slot_material_create(m, NULL)); - g_context->picker_mask_handle->i = PICKER_MASK_NONE; - g_context->material = project_materials->buffer[0]; - ui_nodes_hwnd->redraws = 2; + g_context->picker_mask = PICKER_MASK_NONE; + g_context->material = project_materials->buffer[0]; + ui_nodes_hwnd->redraws = 2; gc_unroot(ui_nodes_group_stack); ui_nodes_group_stack = any_array_create_from_raw((void *[]){}, 0); gc_root(ui_nodes_group_stack); @@ -332,14 +330,14 @@ void project_set_default_envmap() { g_context->envmap_loaded = false; scene_world->_->envmap = g_context->empty_envmap; scene_world->envmap = "World_radiance.k"; - g_context->show_envmap_handle->b = g_context->show_envmap = false; - scene_world->_->radiance = g_context->default_radiance; - scene_world->_->radiance_mipmaps = g_context->default_radiance_mipmaps; - scene_world->_->irradiance = g_context->default_irradiance; - scene_world->strength = 2.0; - g_context->envmap_angle = 0.0; - g_context->show_envmap_blur = false; - g_project->envmap = NULL; + g_context->show_envmap = false; + scene_world->_->radiance = g_context->default_radiance; + scene_world->_->radiance_mipmaps = g_context->default_radiance_mipmaps; + scene_world->_->irradiance = g_context->default_irradiance; + scene_world->strength = 2.0; + g_context->envmap_angle = 0.0; + g_context->show_envmap_blur = false; + g_project->envmap = NULL; } void project_import_material_on_file_picked(char *path) { diff --git a/paint/sources/render/make_paint.c b/paint/sources/render/make_paint.c index d109d58f..4e5ec886 100644 --- a/paint/sources/render/make_paint.c +++ b/paint/sources/render/make_paint.c @@ -177,8 +177,8 @@ node_shader_context_t *make_paint_run(material_t *data, material_context_t *matc return con_paint; } - bool face_fill = g_context->tool == TOOL_TYPE_FILL && g_context->fill_type_handle->i == FILL_TYPE_FACE; - bool uv_island_fill = g_context->tool == TOOL_TYPE_FILL && g_context->fill_type_handle->i == FILL_TYPE_UV_ISLAND; + bool face_fill = g_context->tool == TOOL_TYPE_FILL && g_context->fill_type == FILL_TYPE_FACE; + bool uv_island_fill = g_context->tool == TOOL_TYPE_FILL && g_context->fill_type == FILL_TYPE_UV_ISLAND; bool decal = context_is_decal(); if (g_context->layer->uv_map == 1) { @@ -258,7 +258,7 @@ node_shader_context_t *make_paint_run(material_t *data, material_context_t *matc } else { // Fill, Bake node_shader_write_frag(kong, "var dist: float = 0.0;"); - bool angle_fill = g_context->tool == TOOL_TYPE_FILL && g_context->fill_type_handle->i == FILL_TYPE_ANGLE; + bool angle_fill = g_context->tool == TOOL_TYPE_FILL && g_context->fill_type == FILL_TYPE_ANGLE; if (angle_fill) { node_shader_add_function(kong, str_octahedron_wrap); node_shader_add_texture(kong, "gbuffer0", NULL); @@ -293,7 +293,7 @@ node_shader_context_t *make_paint_run(material_t *data, material_context_t *matc } } - if (g_context->picker_mask_handle->i == PICKER_MASK_MATERIAL) { + if (g_context->picker_mask == PICKER_MASK_MATERIAL) { make_discard_material_id(kong); } @@ -482,7 +482,7 @@ node_shader_context_t *make_paint_run(material_t *data, material_context_t *matc node_shader_write_frag(kong, "var sample_undo: float4 = sample_lod(texpaint_undo, sampler_linear, sample_tc, 0.0);"); f32 matid = g_context->material->id / 255.0; - if (g_context->picker_mask_handle->i == PICKER_MASK_MATERIAL) { + if (g_context->picker_mask == PICKER_MASK_MATERIAL) { matid = g_context->materialid_picked / 255.0; // Keep existing material id in place when mask is set } char *matid_string = parser_material_vec1(matid * 3.0); diff --git a/paint/sources/render/render_path_paint.c b/paint/sources/render/render_path_paint.c index 1cb6777b..37471edd 100644 --- a/paint/sources/render/render_path_paint.c +++ b/paint/sources/render/render_path_paint.c @@ -387,7 +387,7 @@ void render_path_paint_commands_paint(bool dilation) { bool is_mask = slot_layer_is_mask(g_context->layer); // Read texcoords from gbuffer - bool read_tc = (g_context->tool == TOOL_TYPE_FILL && g_context->fill_type_handle->i == FILL_TYPE_FACE) || g_context->tool == TOOL_TYPE_CLONE || + bool read_tc = (g_context->tool == TOOL_TYPE_FILL && g_context->fill_type == FILL_TYPE_FACE) || g_context->tool == TOOL_TYPE_CLONE || g_context->tool == TOOL_TYPE_BLUR; if (g_context->tool == TOOL_TYPE_PARTICLE) { diff --git a/paint/sources/slot_layer.c b/paint/sources/slot_layer.c index def3f110..7d791e61 100644 --- a/paint/sources/slot_layer.c +++ b/paint/sources/slot_layer.c @@ -1093,7 +1093,7 @@ void layers_update_fill_layers() { slot_layer_t *_layer = g_context->layer; tool_type_t _tool = g_context->tool; - i32 _fill_type = g_context->fill_type_handle->i; + i32 _fill_type = g_context->fill_type; gpu_texture_t *current = NULL; if (g_context->tool == TOOL_TYPE_MATERIAL) { @@ -1108,8 +1108,8 @@ void layers_update_fill_layers() { if (in_use) draw_end(); - g_context->tool = TOOL_TYPE_FILL; - g_context->fill_type_handle->i = FILL_TYPE_OBJECT; + g_context->tool = TOOL_TYPE_FILL; + g_context->fill_type = FILL_TYPE_OBJECT; render_path_paint_set_plane_mesh(); make_material_parse_paint_material(false); g_context->pdirty = 1; @@ -1117,10 +1117,10 @@ void layers_update_fill_layers() { render_path_paint_commands_paint(false); render_path_paint_dilate(true, true); render_path_paint_use_live_layer(false); - g_context->tool = _tool; - g_context->fill_type_handle->i = _fill_type; - g_context->pdirty = 0; - g_context->rdirty = 2; + g_context->tool = _tool; + g_context->fill_type = _fill_type; + g_context->pdirty = 0; + g_context->rdirty = 2; render_path_paint_restore_plane_mesh(); make_material_parse_paint_material(true); ui_view2d_hwnd->redraws = 2; @@ -1150,9 +1150,9 @@ void layers_update_fill_layers() { bool in_use = gpu_in_use; if (in_use) draw_end(); - g_context->pdirty = 1; - g_context->tool = TOOL_TYPE_FILL; - g_context->fill_type_handle->i = FILL_TYPE_OBJECT; + g_context->pdirty = 1; + g_context->tool = TOOL_TYPE_FILL; + g_context->fill_type = FILL_TYPE_OBJECT; if (has_fill_layer) { bool first = true; @@ -1207,8 +1207,8 @@ void layers_update_fill_layers() { draw_begin(current, false, 0); g_context->layer = _layer; layers_set_object_mask(); - g_context->tool = _tool; - g_context->fill_type_handle->i = _fill_type; + g_context->tool = _tool; + g_context->fill_type = _fill_type; make_material_parse_paint_material(false); } } @@ -1239,11 +1239,11 @@ void layers_update_fill_layer(bool parse_paint) { if (in_use) draw_end(); - tool_type_t _tool = g_context->tool; - i32 _fill_type = g_context->fill_type_handle->i; - g_context->tool = TOOL_TYPE_FILL; - g_context->fill_type_handle->i = FILL_TYPE_OBJECT; - g_context->pdirty = 1; + tool_type_t _tool = g_context->tool; + i32 _fill_type = g_context->fill_type; + g_context->tool = TOOL_TYPE_FILL; + g_context->fill_type = FILL_TYPE_OBJECT; + g_context->pdirty = 1; if (g_context->layer->texpaint_sculpt != NULL) { i32 tid = g_context->layer->id; @@ -1266,9 +1266,9 @@ void layers_update_fill_layer(bool parse_paint) { render_path_paint_dilate(true, true); } - g_context->rdirty = 2; - g_context->tool = _tool; - g_context->fill_type_handle->i = _fill_type; + g_context->rdirty = 2; + g_context->tool = _tool; + g_context->fill_type = _fill_type; if (in_use) draw_begin(current, false, 0); } diff --git a/paint/sources/types.h b/paint/sources/types.h index 9f6b00b4..470d13a9 100644 --- a/paint/sources/types.h +++ b/paint/sources/types.h @@ -200,11 +200,8 @@ typedef struct context { struct gpu_texture *preview_envmap; bool envmap_loaded; bool show_envmap; - struct ui_handle *show_envmap_handle; bool show_envmap_blur; - struct ui_handle *show_envmap_blur_handle; bool show_envmap_spheres; - struct ui_handle *show_envmap_spheres_handle; bool capturing_screenshot; bool capture_background; f32 envmap_angle; @@ -244,8 +241,6 @@ typedef struct context { bool paint2d_view; bool brush_locked; camera_type_t camera_type; - struct ui_handle *cam_handle; - struct ui_handle *fov_handle; char *texture_export_path; i32 last_status_position; camera_pivot_t camera_pivot; @@ -275,7 +270,7 @@ typedef struct context { f32 uvx_picked; f32 uvy_picked; bool picker_select_material; - struct ui_handle *picker_mask_handle; + i32 picker_mask; bool pick_pos_nor_tex; bool pick_object_id; f32 posx_picked; @@ -285,10 +280,8 @@ typedef struct context { f32 nory_picked; f32 norz_picked; bool draw_wireframe; - struct ui_handle *wireframe_handle; bool draw_texels; - struct ui_handle *texels_handle; - struct ui_handle *colorid_handle; + i32 colorid; export_mode_t layers_export; struct gpu_texture *decal_image; bool decal_preview; @@ -350,14 +343,10 @@ typedef struct context { f32 brush_radius; f32 brush_scale_x; f32 brush_decal_mask_radius; - struct ui_handle *brush_decal_mask_radius_handle; - struct ui_handle *brush_scale_x_handle; blend_type_t brush_blending; f32 brush_opacity; - struct ui_handle *brush_opacity_handle; f32 brush_scale; f32 brush_angle; - struct ui_handle *brush_angle_handle; f32 brush_hardness; f32 brush_lazy_radius; f32 brush_lazy_step; @@ -381,8 +370,7 @@ typedef struct context { bool sym_x; bool sym_y; bool sym_z; - struct ui_handle *fill_type_handle; - struct ui_handle *blur_type_handle; + i32 fill_type; i32 blur_type; bool paint2d; i32 maximized_sidebar_width; @@ -532,7 +520,7 @@ typedef struct node_group { struct ui_node_canvas *canvas; } node_group_t; -typedef struct project_format { +typedef struct project { char *version; struct string_array *assets; // texture_assets bool is_bgra; // Swapped red and blue channels for layer textures @@ -703,81 +691,12 @@ typedef struct neural_node_model { char *license; } neural_node_model_t; -typedef struct tex_image_node { - struct logic_node *base; - struct ui_node *raw; -} tex_image_node_t; - -typedef struct random_node { - struct logic_node *base; -} random_node_t; - -typedef struct boolean_node { - struct logic_node *base; - bool value; -} boolean_node_t; - -typedef struct input_node { - struct logic_node *base; -} input_node_t; - -typedef struct math_node { - struct logic_node *base; - char *operation; - bool use_clamp; -} math_node_t; - -typedef struct vector_node { - struct logic_node *base; - vec4_t value; - struct gpu_texture *image; -} vector_node_t; - -typedef struct color_node { - struct logic_node *base; - vec4_t value; - struct gpu_texture *image; -} color_node_t; - -typedef struct string_node { - struct logic_node *base; - char *value; -} string_node_t; - -typedef struct null_node { - struct logic_node *base; -} null_node_t; - -typedef struct time_node { - struct logic_node *base; -} time_node_t; - -typedef struct vector_math_node { - struct logic_node *base; - char *operation; - vec4_t v; -} vector_math_node_t; - typedef struct float_node { struct logic_node *base; f32 value; struct gpu_texture *image; } float_node_t; -typedef struct integer_node { - struct logic_node *base; - i32 value; -} integer_node_t; - -typedef struct separate_vector_node { - struct logic_node *base; -} separate_vector_node_t; - -typedef struct brush_output_node { - struct logic_node *base; - struct ui_node *raw; -} brush_output_node_t; - typedef struct node_group_t_array { node_group_t **buffer; int length; @@ -862,16 +781,13 @@ typedef struct gpu_texture_t_array { int capacity; } gpu_texture_t_array_t; -#ifdef arm_physics - +#ifdef WITH_PHYSICS #include "../libs/asim.h" - typedef struct physics_pair_t_array { physics_pair_t **buffer; int length; int capacity; } physics_pair_t_array_t; - #endif typedef struct ui_node_socket_t_array { diff --git a/paint/sources/ui/box_export.c b/paint/sources/ui/box_export.c index 3de39e5a..7619cf34 100644 --- a/paint/sources/ui/box_export.c +++ b/paint/sources/ui/box_export.c @@ -80,10 +80,8 @@ void box_export_tab_export_textures(char *title, bool bake_material) { ui_row2(); if (base_bits_handle->i == TEXTURE_BITS_BITS8) { - ui_handle_t *h = ui_handle(__ID__); - if (h->init) { - h->i = g_context->format_type; - } + ui_handle_t *h = ui_handle(__ID__); + h->i = g_context->format_type; string_array_t *format_combo = any_array_create_from_raw( (void *[]){ "png", @@ -93,10 +91,8 @@ void box_export_tab_export_textures(char *title, bool bake_material) { g_context->format_type = ui_combo(h, format_combo, tr("Format"), true, UI_ALIGN_LEFT, true); } else { - ui_handle_t *h = ui_handle(__ID__); - if (h->init) { - h->i = g_context->format_type; - } + ui_handle_t *h = ui_handle(__ID__); + h->i = g_context->format_type; string_array_t *format_combo = any_array_create_from_raw( (void *[]){ "exr", @@ -107,10 +103,8 @@ void box_export_tab_export_textures(char *title, bool bake_material) { ui->enabled = g_context->format_type == TEXTURE_LDR_FORMAT_JPG && base_bits_handle->i == TEXTURE_BITS_BITS8; - ui_handle_t *h_quality = ui_handle(__ID__); - if (h_quality->init) { - h_quality->f = g_context->format_quality; - } + ui_handle_t *h_quality = ui_handle(__ID__); + h_quality->f = g_context->format_quality; g_context->format_quality = ui_slider(h_quality, tr("Quality"), 0.0, 100.0, true, 1, true, UI_ALIGN_RIGHT, true); ui->enabled = true; @@ -458,10 +452,8 @@ void box_export_tab_export_mesh(ui_handle_t *htab) { ui_row2(); - ui_handle_t *h_export_mesh_format = ui_handle(__ID__); - if (h_export_mesh_format->init) { - h_export_mesh_format->i = g_context->export_mesh_format; - } + ui_handle_t *h_export_mesh_format = ui_handle(__ID__); + h_export_mesh_format->i = g_context->export_mesh_format; string_array_t *export_mesh_format_combo = any_array_create_from_raw( (void *[]){ "obj", diff --git a/paint/sources/ui/box_preferences.c b/paint/sources/ui/box_preferences.c index 116e59b3..06d4bae6 100644 --- a/paint/sources/ui/box_preferences.c +++ b/paint/sources/ui/box_preferences.c @@ -1114,9 +1114,6 @@ void box_preferences_plugins_tab() { g_config->plugins = any_array_create_from_raw((void *[]){}, 0); } ui_handle_t *h = ui_handle(__ID__); - if (h->init) { - h->b = false; - } for (i32 i = 0; i < box_preferences_files_plugin->length; ++i) { char *f = box_preferences_files_plugin->buffer[i]; bool is_c = ends_with(f, ".c"); diff --git a/paint/sources/ui/tab_browser.c b/paint/sources/ui/tab_browser.c index fb9a07c5..cb8fa4ec 100644 --- a/paint/sources/ui/tab_browser.c +++ b/paint/sources/ui/tab_browser.c @@ -35,9 +35,9 @@ void tab_browser_draw_set_as_color_id_map_on_next_frame(void *_) { } if (asset_index != -1) { - g_context->colorid_handle->i = asset_index; - g_context->colorid_picked = false; - ui_toolbar_handle->redraws = 1; + g_context->colorid = asset_index; + g_context->colorid_picked = false; + ui_toolbar_handle->redraws = 1; if (g_context->tool == TOOL_TYPE_COLORID) { ui_header_handle->redraws = 2; g_context->ddirty = 2; diff --git a/paint/sources/ui/tab_materials.c b/paint/sources/ui/tab_materials.c index 43c135c9..20df5ce4 100644 --- a/paint/sources/ui/tab_materials.c +++ b/paint/sources/ui/tab_materials.c @@ -110,50 +110,24 @@ void tab_materials_draw_slots_menu() { context_select_material(i); } - ui_handle_t *base_handle = ui_nest(ui_handle(__ID__), m->id); - if (base_handle->init) { - base_handle->b = m->paint_base; - } - - ui_handle_t *opac_handle = ui_nest(ui_handle(__ID__), m->id); - if (opac_handle->init) { - opac_handle->b = m->paint_opac; - } - - ui_handle_t *nor_handle = ui_nest(ui_handle(__ID__), m->id); - if (nor_handle->init) { - nor_handle->b = m->paint_nor; - } - - ui_handle_t *occ_handle = ui_nest(ui_handle(__ID__), m->id); - if (occ_handle->init) { - occ_handle->b = m->paint_occ; - } - - ui_handle_t *rough_handle = ui_nest(ui_handle(__ID__), m->id); - if (rough_handle->init) { - rough_handle->b = m->paint_rough; - } - - ui_handle_t *met_handle = ui_nest(ui_handle(__ID__), m->id); - if (met_handle->init) { - met_handle->b = m->paint_met; - } - + ui_handle_t *base_handle = ui_nest(ui_handle(__ID__), m->id); + ui_handle_t *opac_handle = ui_nest(ui_handle(__ID__), m->id); + ui_handle_t *nor_handle = ui_nest(ui_handle(__ID__), m->id); + ui_handle_t *occ_handle = ui_nest(ui_handle(__ID__), m->id); + ui_handle_t *rough_handle = ui_nest(ui_handle(__ID__), m->id); + ui_handle_t *met_handle = ui_nest(ui_handle(__ID__), m->id); ui_handle_t *height_handle = ui_nest(ui_handle(__ID__), m->id); - if (height_handle->init) { - height_handle->b = m->paint_height; - } - - ui_handle_t *emis_handle = ui_nest(ui_handle(__ID__), m->id); - if (emis_handle->init) { - emis_handle->b = m->paint_emis; - } - - ui_handle_t *subs_handle = ui_nest(ui_handle(__ID__), m->id); - if (subs_handle->init) { - subs_handle->b = m->paint_subs; - } + ui_handle_t *emis_handle = ui_nest(ui_handle(__ID__), m->id); + ui_handle_t *subs_handle = ui_nest(ui_handle(__ID__), m->id); + base_handle->b = m->paint_base; + opac_handle->b = m->paint_opac; + nor_handle->b = m->paint_nor; + occ_handle->b = m->paint_occ; + rough_handle->b = m->paint_rough; + met_handle->b = m->paint_met; + height_handle->b = m->paint_height; + emis_handle->b = m->paint_emis; + subs_handle->b = m->paint_subs; ui_menu_separator(); ui_menu_align(); diff --git a/paint/sources/ui/tab_swatches.c b/paint/sources/ui/tab_swatches.c index b78073db..3f58afd4 100644 --- a/paint/sources/ui/tab_swatches.c +++ b/paint/sources/ui/tab_swatches.c @@ -21,7 +21,7 @@ gpu_texture_t *tab_swatches_empty_get() { void tab_swatches_delete_swatch(swatch_color_t *swatch) { i32 i = array_index_of(g_project->swatches, swatch); - context_set_swatch(g_project->swatches->buffer[i == g_project->swatches->length - 1 ? i - 1 : i + 1]); + g_context->swatch = g_project->swatches->buffer[i == g_project->swatches->length - 1 ? i - 1 : i + 1]; array_splice(g_project->swatches, i, 1); ui_base_hwnds->buffer[TAB_AREA_STATUS]->redraws = 2; } @@ -30,7 +30,7 @@ void tab_swatches_draw_menu() { i32 i = _tab_swatches_draw_i; if (ui_menu_button(tr("Duplicate"), "ctrl+d", ICON_DUPLICATE)) { - context_set_swatch(project_clone_swatch(g_context->swatch)); + g_context->swatch = project_clone_swatch(g_context->swatch); any_array_push(g_project->swatches, g_context->swatch); } #if defined(IRON_WINDOWS) || defined(IRON_LINUX) || defined(IRON_MACOS) @@ -96,7 +96,7 @@ void tab_swatches_draw_edit_menu() { ui_menu_keep_open = true; } if (ui->input_released) { - context_set_swatch(g_context->swatch); // Trigger material preview update + g_context->swatch = g_context->swatch; // Trigger material preview update g_context->picked_color = util_clone_swatch_color(g_context->swatch); ui_header_handle->redraws = 2; } @@ -105,7 +105,7 @@ void tab_swatches_draw_edit_menu() { void tab_swatches_draw_import() { if (ui_menu_button(tr("Replace Existing"), "", ICON_NONE)) { project_import_swatches(true); - context_set_swatch(g_project->swatches->buffer[0]); + g_context->swatch = g_project->swatches->buffer[0]; } if (ui_menu_button(tr("Append"), "", ICON_NONE)) { project_import_swatches(false); @@ -128,7 +128,7 @@ void tab_swatches_draw(ui_handle_t *htab) { ui_row(row); if (ui_icon_button(tr("New"), ICON_PLUS, UI_ALIGN_CENTER)) { - context_set_swatch(project_make_swatch(0xffffffff)); + g_context->swatch = project_make_swatch(0xffffffff); any_array_push(g_project->swatches, g_context->swatch); } if (ui->is_hovered) { @@ -150,7 +150,7 @@ void tab_swatches_draw(ui_handle_t *htab) { } if (ui_icon_button(tr("Clear"), ICON_ERASE, UI_ALIGN_CENTER)) { - context_set_swatch(project_make_swatch(0xffffffff)); + g_context->swatch = project_make_swatch(0xffffffff); g_project->swatches = any_array_create_from_raw( (void *[]){ g_context->swatch, @@ -160,7 +160,7 @@ void tab_swatches_draw(ui_handle_t *htab) { if (ui_icon_button(tr("Restore"), ICON_REPLAY, UI_ALIGN_CENTER)) { project_set_default_swatches(); - context_set_swatch(g_project->swatches->buffer[0]); + g_context->swatch = g_project->swatches->buffer[0]; } if (ui->is_hovered) { ui_tooltip(tr("Restore default swatches")); @@ -213,7 +213,7 @@ void tab_swatches_draw(ui_handle_t *htab) { ui_state_t state = ui_image(tab_swatches_empty_get(), g_project->swatches->buffer[i]->base, slotw); if (state == UI_STATE_STARTED) { - context_set_swatch(g_project->swatches->buffer[i]); + g_context->swatch = g_project->swatches->buffer[i]; base_drag_off_x = -(mouse_x - uix - ui->_window_x); base_drag_off_y = -(mouse_y - uiy - ui->_window_y + 1); gc_unroot(base_drag_swatch); @@ -237,7 +237,7 @@ void tab_swatches_draw(ui_handle_t *htab) { g_context->select_time = sys_time(); } if (ui->is_hovered && ui->input_released_r) { - context_set_swatch(g_project->swatches->buffer[i]); + g_context->swatch = g_project->swatches->buffer[i]; _tab_swatches_draw_i = i; @@ -271,19 +271,19 @@ void tab_swatches_draw(ui_handle_t *htab) { tab_swatches_delete_swatch(g_context->swatch); } if (in_focus && ui->is_ctrl_down && ui->is_key_pressed && ui->key_code == KEY_CODE_D) { - context_set_swatch(project_clone_swatch(g_context->swatch)); + g_context->swatch = project_clone_swatch(g_context->swatch); any_array_push(g_project->swatches, g_context->swatch); } if (in_focus) { i32 i = array_index_of(g_project->swatches, g_context->swatch); if (ui->is_key_pressed && ui->key_code == KEY_CODE_UP) { if (i > 0) { - context_set_swatch(g_project->swatches->buffer[i - 1]); + g_context->swatch = g_project->swatches->buffer[i - 1]; } } if (ui->is_key_pressed && ui->key_code == KEY_CODE_DOWN) { if (i < g_project->swatches->length - 1) { - context_set_swatch(g_project->swatches->buffer[i + 1]); + g_context->swatch = g_project->swatches->buffer[i + 1]; } } } diff --git a/paint/sources/ui/tab_textures.c b/paint/sources/ui/tab_textures.c index d8eb9916..fe6c04a7 100644 --- a/paint/sources/ui/tab_textures.c +++ b/paint/sources/ui/tab_textures.c @@ -79,7 +79,7 @@ void tab_textures_delete_texture(asset_t *asset) { } ui_base_hwnds->buffer[TAB_AREA_STATUS]->redraws = 2; - if (g_context->tool == TOOL_TYPE_COLORID && index == g_context->colorid_handle->i) { + if (g_context->tool == TOOL_TYPE_COLORID && index == g_context->colorid) { ui_header_handle->redraws = 2; g_context->ddirty = 2; g_context->colorid_picked = false; @@ -134,9 +134,9 @@ void tab_textures_draw_context_menu() { sys_notify_on_next_frame(&tab_textures_draw_set_as_envmap, NULL); } if (ui_menu_button(tr("Set as Color ID Map"), "", ICON_COLOR_ID)) { - g_context->colorid_handle->i = _tab_textures_draw_i; - g_context->colorid_picked = false; - ui_toolbar_handle->redraws = 1; + g_context->colorid = _tab_textures_draw_i; + g_context->colorid_picked = false; + ui_toolbar_handle->redraws = 1; if (g_context->tool == TOOL_TYPE_COLORID) { ui_header_handle->redraws = 2; g_context->ddirty = 2; @@ -396,14 +396,14 @@ void tab_textures_accept_asset_drop(asset_t *asset) { for (i32 i = 0; i < project_brushes->length; ++i) { tab_textures_remap_node_indices(project_brushes->buffer[i]->canvas->nodes, asset_pos, new_pos); } - if (g_context->colorid_handle->i == asset_pos) { - g_context->colorid_handle->i = new_pos; + if (g_context->colorid == asset_pos) { + g_context->colorid = new_pos; } - else if (new_pos > asset_pos && g_context->colorid_handle->i > asset_pos && g_context->colorid_handle->i <= new_pos) { - g_context->colorid_handle->i--; + else if (new_pos > asset_pos && g_context->colorid > asset_pos && g_context->colorid <= new_pos) { + g_context->colorid--; } - else if (new_pos < asset_pos && g_context->colorid_handle->i >= new_pos && g_context->colorid_handle->i < asset_pos) { - g_context->colorid_handle->i++; + else if (new_pos < asset_pos && g_context->colorid >= new_pos && g_context->colorid < asset_pos) { + g_context->colorid++; } } } diff --git a/paint/sources/ui/ui_files.c b/paint/sources/ui/ui_files.c index ecd9a01a..b566f177 100644 --- a/paint/sources/ui/ui_files.c +++ b/paint/sources/ui/ui_files.c @@ -409,7 +409,7 @@ char *ui_files_file_browser(ui_handle_t *handle, bool drag_files, char *search, if (raw->material_icons != NULL) { buffer_t *bytes_icon = raw->material_icons->buffer[0]; #ifdef IRON_BGRA - buffer_t *buf = export_arm_bgra64_swap(lz4_decode(bytes_icon, 256 * 256 * 8)); + buffer_t *buf = buffer_bgra64_swap(lz4_decode(bytes_icon, 256 * 256 * 8)); #else buffer_t *buf = lz4_decode(bytes_icon, 256 * 256 * 8); #endif diff --git a/paint/sources/ui/ui_header.c b/paint/sources/ui/ui_header.c index f80930be..e7599a7a 100644 --- a/paint/sources/ui/ui_header.c +++ b/paint/sources/ui/ui_header.c @@ -38,70 +38,52 @@ void ui_header_render_ui() { } void ui_header_particle_menu_draw() { - ui_handle_t *hlifetime = ui_handle(__ID__); - if (hlifetime->init) { - hlifetime->f = g_context->particle_lifetime; - } + ui_handle_t *hlifetime = ui_handle(__ID__); + hlifetime->f = g_context->particle_lifetime; g_context->particle_lifetime = ui_slider(hlifetime, tr("Lifetime"), 0.0, 10.0, true, 1.0, true, UI_ALIGN_RIGHT, true); - ui_handle_t *hspawn_distance = ui_handle(__ID__); - if (hspawn_distance->init) { - hspawn_distance->f = g_context->particle_spawn_distance; - } + ui_handle_t *hspawn_distance = ui_handle(__ID__); + hspawn_distance->f = g_context->particle_spawn_distance; g_context->particle_spawn_distance = ui_slider(hspawn_distance, tr("Distance"), 0.0, 1.0, true, 100.0, true, UI_ALIGN_RIGHT, true); - ui_handle_t *hmass = ui_handle(__ID__); - if (hmass->init) { - hmass->f = g_context->particle_mass; - } + ui_handle_t *hmass = ui_handle(__ID__); + hmass->f = g_context->particle_mass; g_context->particle_mass = ui_slider(hmass, tr("Mass"), 0.0, 3.0, true, 100.0, true, UI_ALIGN_RIGHT, true); - ui_handle_t *hrandom = ui_handle(__ID__); - if (hrandom->init) { - hrandom->f = g_context->particle_random; - } + ui_handle_t *hrandom = ui_handle(__ID__); + hrandom->f = g_context->particle_random; g_context->particle_random = ui_slider(hrandom, tr("Random"), 0.0, 1.0, true, 100.0, true, UI_ALIGN_RIGHT, true); - ui_handle_t *hfriction = ui_handle(__ID__); - if (hfriction->init) { - hfriction->f = g_context->particle_friction; - } + ui_handle_t *hfriction = ui_handle(__ID__); + hfriction->f = g_context->particle_friction; g_context->particle_friction = ui_slider(hfriction, tr("Friction"), 0.0, 1.0, true, 100.0, true, UI_ALIGN_RIGHT, true); if (hfriction->changed) { asim_set_friction(g_context->particle_friction); } - ui_handle_t *hbounciness = ui_handle(__ID__); - if (hbounciness->init) { - hbounciness->f = g_context->particle_bounciness; - } + ui_handle_t *hbounciness = ui_handle(__ID__); + hbounciness->f = g_context->particle_bounciness; g_context->particle_bounciness = ui_slider(hbounciness, tr("Bounce"), 0.0, 1.0, true, 100.0, true, UI_ALIGN_RIGHT, true); if (hbounciness->changed) { asim_set_bounciness(g_context->particle_bounciness); } - ui_handle_t *hgravx = ui_handle(__ID__); - if (hgravx->init) { - hgravx->f = g_context->particle_gravity_x; - } + ui_handle_t *hgravx = ui_handle(__ID__); + hgravx->f = g_context->particle_gravity_x; g_context->particle_gravity_x = ui_slider(hgravx, tr("Gravity X"), -10.0, 10.0, true, 100.0, true, UI_ALIGN_RIGHT, true); if (hgravx->changed) { asim_set_gravity(g_context->particle_gravity_x, g_context->particle_gravity_y, g_context->particle_gravity_z); } - ui_handle_t *hgravy = ui_handle(__ID__); - if (hgravy->init) { - hgravy->f = g_context->particle_gravity_y; - } + ui_handle_t *hgravy = ui_handle(__ID__); + hgravy->f = g_context->particle_gravity_y; g_context->particle_gravity_y = ui_slider(hgravy, tr("Gravity Y"), -10.0, 10.0, true, 100.0, true, UI_ALIGN_RIGHT, true); if (hgravy->changed) { asim_set_gravity(g_context->particle_gravity_x, g_context->particle_gravity_y, g_context->particle_gravity_z); } - ui_handle_t *hgravz = ui_handle(__ID__); - if (hgravz->init) { - hgravz->f = g_context->particle_gravity_z; - } + ui_handle_t *hgravz = ui_handle(__ID__); + hgravz->f = g_context->particle_gravity_z; g_context->particle_gravity_z = ui_slider(hgravz, tr("Gravity Z"), -10.0, 10.0, true, 100.0, true, UI_ALIGN_RIGHT, true); if (hgravz->changed) { asim_set_gravity(g_context->particle_gravity_x, g_context->particle_gravity_y, g_context->particle_gravity_z); @@ -143,7 +125,7 @@ void ui_header_draw_tool_properties_to_mask(slot_layer_t *m) { gpu_set_pipeline(pipes_colorid_to_mask); render_target_t *rt = any_map_get(render_path_render_targets, "texpaint_colorid"); gpu_set_texture(pipes_texpaint_colorid, rt->_image); - gpu_set_texture(pipes_tex_colorid, project_get_image(project_assets->buffer[g_context->colorid_handle->i])); + gpu_set_texture(pipes_tex_colorid, project_get_image(project_assets->buffer[g_context->colorid])); gpu_set_vertex_buffer(const_data_screen_aligned_vb); gpu_set_index_buffer(const_data_screen_aligned_ib); gpu_draw(); @@ -157,12 +139,12 @@ void ui_header_draw_tool_properties_to_mask(slot_layer_t *m) { void ui_header_draw_tool_properties_import(char *path) { import_asset_run(path, -1.0, -1.0, true, false, NULL); - g_context->colorid_handle->i = project_asset_names->length - 1; + g_context->colorid = project_asset_names->length - 1; for (i32 i = 0; i < project_assets->length; ++i) { asset_t *a = project_assets->buffer[i]; // Already imported if (string_equals(a->file, path)) { - g_context->colorid_handle->i = array_index_of(project_assets, a); + g_context->colorid = array_index_of(project_assets, a); } } g_context->ddirty = 2; @@ -186,18 +168,20 @@ void ui_header_draw_tool_properties() { ui->enabled = true; ui_text(tr("Color ID Map"), UI_ALIGN_LEFT, 0x00000000); if (project_asset_names->length > 0) { - i32 cid = ui_combo(g_context->colorid_handle, base_combo_enum_texts("TEX_IMAGE"), tr("Color ID"), false, UI_ALIGN_LEFT, true); - if (g_context->colorid_handle == ui->combo_selected_handle) { + ui_handle_t *colorid_handle = ui_handle(__ID__); + colorid_handle->i = g_context->colorid; + g_context->colorid = ui_combo(colorid_handle, base_combo_enum_texts("TEX_IMAGE"), tr("Color ID"), false, UI_ALIGN_LEFT, true); + if (colorid_handle == ui->combo_selected_handle) { ui->combo_selected_images = base_combo_enum_images("TEX_IMAGE"); } - if (g_context->colorid_handle->changed) { + if (colorid_handle->changed) { g_context->ddirty = 2; g_context->colorid_picked = false; ui_toolbar_handle->redraws = 1; } - ui_image(project_get_image(project_assets->buffer[cid]), 0xffffffff, -1.0); + ui_image(project_get_image(project_assets->buffer[g_context->colorid]), 0xffffffff, -1.0); if (ui->is_hovered) { - ui_tooltip_image(project_get_image(project_assets->buffer[cid]), 256); + ui_tooltip_image(project_get_image(project_assets->buffer[g_context->colorid]), 256); } } if (ui_icon_button(tr("Import"), ICON_FOLDER_OPEN, UI_ALIGN_CENTER)) { @@ -244,7 +228,7 @@ void ui_header_draw_tool_properties() { } if (ui_icon_button(tr("Add Swatch"), ICON_PLUS, UI_ALIGN_CENTER)) { swatch_color_t *new_swatch = project_clone_swatch(g_context->picked_color); - context_set_swatch(new_swatch); + g_context->swatch = new_swatch; any_array_push(g_project->swatches, new_swatch); ui_base_hwnds->buffer[2]->redraws = 1; } @@ -290,10 +274,8 @@ void ui_header_draw_tool_properties() { hopac->f = g_context->picked_color->opacity; g_context->picked_color->opacity = ui_slider(hopac, tr("Opacity"), 0.0, 1.0, true, 100.0, true, UI_ALIGN_RIGHT, true); - ui_handle_t *h_select_mat = ui_handle(__ID__); - if (h_select_mat->init) { - h_select_mat->b = g_context->picker_select_material; - } + ui_handle_t *h_select_mat = ui_handle(__ID__); + h_select_mat->b = g_context->picker_select_material; g_context->picker_select_material = ui_check(h_select_mat, tr("Select Material"), ""); string_array_t *picker_mask_combo = any_array_create_from_raw( @@ -302,8 +284,11 @@ void ui_header_draw_tool_properties() { tr("Material"), }, 2); - ui_combo(g_context->picker_mask_handle, picker_mask_combo, tr("Mask"), true, UI_ALIGN_LEFT, true); - if (g_context->picker_mask_handle->changed) { + + ui_handle_t *picker_mask_handle = ui_handle(__ID__); + picker_mask_handle->i = g_context->picker_mask; + g_context->picker_mask = ui_combo(picker_mask_handle, picker_mask_combo, tr("Mask"), true, UI_ALIGN_LEFT, true); + if (picker_mask_handle->changed) { make_material_parse_paint_material(true); } } @@ -313,8 +298,10 @@ void ui_header_draw_tool_properties() { bool decal_mask = context_is_decal_mask(); if (g_context->tool != TOOL_TYPE_FILL) { if (decal_mask) { + ui_handle_t *brush_decal_mask_radius_handle = ui_handle(__ID__); + brush_decal_mask_radius_handle->f = g_context->brush_decal_mask_radius; g_context->brush_decal_mask_radius = - ui_slider(g_context->brush_decal_mask_radius_handle, tr("Radius"), 0.01, 2.0, true, 100.0, true, UI_ALIGN_RIGHT, true); + ui_slider(brush_decal_mask_radius_handle, tr("Radius"), 0.01, 2.0, true, 100.0, true, UI_ALIGN_RIGHT, true); if (ui->is_hovered) { any_map_t *vars = any_map_create(); any_map_set(vars, "brush_radius", any_map_get(config_keymap, "brush_radius")); @@ -344,16 +331,16 @@ void ui_header_draw_tool_properties() { } if (g_context->tool == TOOL_TYPE_DECAL || g_context->tool == TOOL_TYPE_TEXT) { - g_context->brush_scale_x = ui_slider(g_context->brush_scale_x_handle, tr("Scale X"), 0.01, 2.0, true, 100.0, true, UI_ALIGN_RIGHT, true); + ui_handle_t *brush_scale_x_handle = ui_handle(__ID__); + brush_scale_x_handle->f = g_context->brush_scale_x; + g_context->brush_scale_x = ui_slider(brush_scale_x_handle, tr("Scale X"), 0.01, 2.0, true, 100.0, true, UI_ALIGN_RIGHT, true); } if (g_context->tool == TOOL_TYPE_BRUSH || g_context->tool == TOOL_TYPE_FILL || g_context->tool == TOOL_TYPE_DECAL || g_context->tool == TOOL_TYPE_TEXT) { ui_handle_t *brush_scale_handle = ui_handle(__ID__); - if (brush_scale_handle->init) { - brush_scale_handle->f = g_context->brush_scale; - } - g_context->brush_scale = ui_slider(brush_scale_handle, tr("UV Scale"), 0.01, 5.0, true, 100.0, true, UI_ALIGN_RIGHT, true); + brush_scale_handle->f = g_context->brush_scale; + g_context->brush_scale = ui_slider(brush_scale_handle, tr("UV Scale"), 0.01, 5.0, true, 100.0, true, UI_ALIGN_RIGHT, true); if (brush_scale_handle->changed) { if (g_context->tool == TOOL_TYPE_DECAL || g_context->tool == TOOL_TYPE_TEXT) { gpu_texture_t *current = _draw_current; @@ -363,7 +350,9 @@ void ui_header_draw_tool_properties() { } } - g_context->brush_angle = ui_slider(g_context->brush_angle_handle, tr("Angle"), 0.0, 360.0, true, 1, true, UI_ALIGN_RIGHT, true); + ui_handle_t *brush_angle_handle = ui_handle(__ID__); + brush_angle_handle->f = g_context->brush_angle; + g_context->brush_angle = ui_slider(brush_angle_handle, tr("Angle"), 0.0, 360.0, true, 1, true, UI_ALIGN_RIGHT, true); if (ui->is_hovered) { any_map_t *vars = any_map_create(); any_map_set(vars, "brush_angle", any_map_get(config_keymap, "brush_angle")); @@ -372,12 +361,14 @@ void ui_header_draw_tool_properties() { vars)); } - if (g_context->brush_angle_handle->changed) { + if (brush_angle_handle->changed) { make_material_parse_paint_material(true); } } - g_context->brush_opacity = ui_slider(g_context->brush_opacity_handle, tr("Opacity"), 0.0, 1.0, true, 100.0, true, UI_ALIGN_RIGHT, true); + ui_handle_t *brush_opacity_handle = ui_handle(__ID__); + brush_opacity_handle->f = g_context->brush_opacity; + g_context->brush_opacity = ui_slider(brush_opacity_handle, tr("Opacity"), 0.0, 1.0, true, 100.0, true, UI_ALIGN_RIGHT, true); if (ui->is_hovered) { any_map_t *vars = any_map_create(); any_map_set(vars, "brush_opacity", any_map_get(config_keymap, "brush_opacity")); @@ -388,18 +379,14 @@ void ui_header_draw_tool_properties() { if (g_context->tool == TOOL_TYPE_BRUSH || g_context->tool == TOOL_TYPE_ERASER || g_context->tool == TOOL_TYPE_CLONE || decal_mask || g_context->tool == TOOL_TYPE_PARTICLE) { - ui_handle_t *h = ui_handle(__ID__); - if (h->init) { - h->f = g_context->brush_hardness; - } + ui_handle_t *h = ui_handle(__ID__); + h->f = g_context->brush_hardness; g_context->brush_hardness = ui_slider(h, tr("Hardness"), 0.0, 1.0, true, 100.0, true, UI_ALIGN_RIGHT, true); } if (g_context->tool != TOOL_TYPE_ERASER) { - ui_handle_t *brush_blending_handle = ui_handle(__ID__); - if (brush_blending_handle->init) { - brush_blending_handle->f = g_context->brush_blending; - } + ui_handle_t *brush_blending_handle = ui_handle(__ID__); + brush_blending_handle->i = g_context->brush_blending; string_array_t *brush_blending_combo = any_array_create_from_raw( (void *[]){ tr("Mix"), @@ -474,8 +461,10 @@ void ui_header_draw_tool_properties() { tr("Smudge"), }, 2); - g_context->blur_type = ui_combo(g_context->blur_type_handle, blur_type_combo, tr("Blur Type"), false, UI_ALIGN_LEFT, true); - if (g_context->blur_type_handle->changed) { + ui_handle_t *blur_type_handle = ui_handle(__ID__); + blur_type_handle->i = g_context->blur_type; + g_context->blur_type = ui_combo(blur_type_handle, blur_type_combo, tr("Blur Type"), false, UI_ALIGN_LEFT, true); + if (blur_type_handle->changed) { make_material_parse_paint_material(true); } } @@ -489,15 +478,17 @@ void ui_header_draw_tool_properties() { tr("UV Island"), }, 4); - ui_combo(g_context->fill_type_handle, fill_mode_combo, tr("Fill Mode"), false, UI_ALIGN_LEFT, true); - if (g_context->fill_type_handle->changed) { - if (g_context->fill_type_handle->i == FILL_TYPE_FACE) { + ui_handle_t *fill_type_handle = ui_handle(__ID__); + fill_type_handle->i = g_context->fill_type; + g_context->fill_type = ui_combo(fill_type_handle, fill_mode_combo, tr("Fill Mode"), false, UI_ALIGN_LEFT, true); + if (fill_type_handle->changed) { + if (g_context->fill_type == FILL_TYPE_FACE) { gpu_texture_t *current = _draw_current; draw_end(); // cache_uv_map(); util_uv_cache_triangle_map(); draw_begin(current, false, 0); - // wireframe_handle.b = draw_wireframe = true; + // draw_wireframe = true; } make_material_parse_paint_material(true); make_material_parse_mesh_material(); @@ -513,28 +504,15 @@ void ui_header_draw_tool_properties() { ui->_w = math_floor((touch_header ? 54 : 60) * sc); ui_handle_t *xray_handle = ui_handle(__ID__); - if (xray_handle->init) { - xray_handle->b = g_context->xray; - } - g_context->xray = ui_check(xray_handle, tr("X-Ray"), ""); + xray_handle->b = g_context->xray; + g_context->xray = ui_check(xray_handle, tr("X-Ray"), ""); if (xray_handle->changed) { make_material_parse_paint_material(true); } ui_handle_t *sym_x_handle = ui_handle(__ID__); - if (sym_x_handle->init) { - sym_x_handle->b = false; - } - ui_handle_t *sym_y_handle = ui_handle(__ID__); - if (sym_y_handle->init) { - sym_y_handle->b = false; - } - ui_handle_t *sym_z_handle = ui_handle(__ID__); - if (sym_z_handle->init) { - sym_z_handle->b = false; - } if (g_config->layout->buffer[LAYOUT_SIZE_HEADER] == 1) { if (g_config->touch_ui) { diff --git a/paint/sources/ui/ui_menubar.c b/paint/sources/ui/ui_menubar.c index 1ff98d84..b70b9e80 100644 --- a/paint/sources/ui/ui_menubar.c +++ b/paint/sources/ui/ui_menubar.c @@ -441,34 +441,30 @@ void ui_menubar_draw_category_items() { } ui_handle_t *split_view_handle = ui_handle(__ID__); - if (split_view_handle->init) { - split_view_handle->b = g_context->split_view; - } - g_context->split_view = ui_check(split_view_handle, string(" %s", tr("Split View")), ""); + split_view_handle->b = g_context->split_view; + g_context->split_view = ui_check(split_view_handle, string(" %s", tr("Split View")), ""); if (split_view_handle->changed) { base_resize(); } - ui_handle_t *cull_handle = ui_handle(__ID__); - if (cull_handle->init) { - cull_handle->b = g_context->cull_backfaces; - } + ui_handle_t *cull_handle = ui_handle(__ID__); + cull_handle->b = g_context->cull_backfaces; g_context->cull_backfaces = ui_check(cull_handle, string(" %s", tr("Cull Backfaces")), ""); if (cull_handle->changed) { make_material_parse_mesh_material(); } ui_handle_t *filter_handle = ui_handle(__ID__); - if (filter_handle->init) { - filter_handle->b = g_context->texture_filter; - } - g_context->texture_filter = ui_check(filter_handle, string(" %s", tr("Filter Textures")), ""); + filter_handle->b = g_context->texture_filter; + g_context->texture_filter = ui_check(filter_handle, string(" %s", tr("Filter Textures")), ""); if (filter_handle->changed) { gpu_use_linear_sampling(g_context->texture_filter); } - g_context->draw_wireframe = ui_check(g_context->wireframe_handle, string(" %s", tr("Wireframe")), ""); - if (g_context->wireframe_handle->changed) { + ui_handle_t *wireframe_handle = ui_handle(__ID__); + wireframe_handle->b = g_context->draw_wireframe; + g_context->draw_wireframe = ui_check(wireframe_handle, string(" %s", tr("Wireframe")), ""); + if (wireframe_handle->changed) { gpu_texture_t *current = _draw_current; draw_end(); util_uv_cache_uv_map(); @@ -476,37 +472,40 @@ void ui_menubar_draw_category_items() { make_material_parse_mesh_material(); } - g_context->draw_texels = ui_check(g_context->texels_handle, string(" %s", tr("Texels")), ""); - if (g_context->texels_handle->changed) { + ui_handle_t *texels_handle = ui_handle(__ID__); + texels_handle->b = g_context->draw_texels; + g_context->draw_texels = ui_check(texels_handle, string(" %s", tr("Texels")), ""); + if (texels_handle->changed) { make_material_parse_mesh_material(); } ui_handle_t *compass_handle = ui_handle(__ID__); - if (compass_handle->init) { - compass_handle->b = g_context->show_compass; - } - g_context->show_compass = ui_check(compass_handle, string(" %s", tr("Compass")), ""); + compass_handle->b = g_context->show_compass; + g_context->show_compass = ui_check(compass_handle, string(" %s", tr("Compass")), ""); if (compass_handle->changed) { g_context->ddirty = 2; } - g_context->show_envmap_handle->b = g_context->show_envmap; - g_context->show_envmap = ui_check(g_context->show_envmap_handle, string(" %s", tr("Envmap")), ""); - if (g_context->show_envmap_handle->changed) { + ui_handle_t *show_envmap_handle = ui_handle(__ID__); + show_envmap_handle->b = g_context->show_envmap; + g_context->show_envmap = ui_check(show_envmap_handle, string(" %s", tr("Envmap")), ""); + if (show_envmap_handle->changed) { context_load_envmap(); g_context->ddirty = 2; } - g_context->show_envmap_blur_handle->b = g_context->show_envmap_blur; - g_context->show_envmap_blur = ui_check(g_context->show_envmap_blur_handle, string(" %s", tr("Blur Envmap")), ""); - if (g_context->show_envmap_blur_handle->changed) { + ui_handle_t *show_envmap_blur_handle = ui_handle(__ID__); + show_envmap_blur_handle->b = g_context->show_envmap_blur; + g_context->show_envmap_blur = ui_check(show_envmap_blur_handle, string(" %s", tr("Blur Envmap")), ""); + if (show_envmap_blur_handle->changed) { g_context->ddirty = 2; } if (g_config->experimental) { - g_context->show_envmap_spheres_handle->b = g_context->show_envmap_spheres; - g_context->show_envmap_spheres = ui_check(g_context->show_envmap_spheres_handle, string(" %s", tr("Envmap Spheres")), ""); - if (g_context->show_envmap_spheres_handle->changed) { + ui_handle_t *show_envmap_spheres_handle = ui_handle(__ID__); + show_envmap_spheres_handle->b = g_context->show_envmap_spheres; + g_context->show_envmap_spheres = ui_check(show_envmap_spheres_handle, string(" %s", tr("Envmap Spheres")), ""); + if (show_envmap_spheres_handle->changed) { g_context->ddirty = 2; } } @@ -653,11 +652,11 @@ void ui_menubar_draw_category_items() { viewport_zoom(-0.2); } - camera_object_t *cam = scene_camera; - g_context->fov_handle->f = math_floor(cam->data->fov * 100) / 100.0; ui_menu_align(); - cam->data->fov = ui_slider(g_context->fov_handle, tr("FoV"), 0.3, 1.4, true, 100.0, true, UI_ALIGN_RIGHT, true); - if (g_context->fov_handle->changed) { + ui_handle_t *fov_handle = ui_handle(__ID__); + fov_handle->f = math_floor(scene_camera->data->fov * 100) / 100.0; + scene_camera->data->fov = ui_slider(fov_handle, tr("FoV"), 0.3, 1.4, true, 100.0, true, UI_ALIGN_RIGHT, true); + if (fov_handle->changed) { viewport_update_camera_type(g_context->camera_type); } @@ -714,8 +713,10 @@ void ui_menubar_draw_category_items() { tr("Orthographic"), }, 2); - g_context->camera_type = ui_inline_radio(g_context->cam_handle, camera_type_items, UI_ALIGN_LEFT); - if (g_context->cam_handle->changed) { + ui_handle_t *cam_handle = ui_handle(__ID__); + cam_handle->i = g_context->camera_type; + g_context->camera_type = ui_inline_radio(cam_handle, camera_type_items, UI_ALIGN_LEFT); + if (cam_handle->changed) { viewport_update_camera_type(g_context->camera_type); } diff --git a/paint/sources/ui/ui_nodes.c b/paint/sources/ui/ui_nodes.c index f56e7214..c622df1f 100644 --- a/paint/sources/ui/ui_nodes.c +++ b/paint/sources/ui/ui_nodes.c @@ -388,7 +388,7 @@ void ui_viewnodes_on_canvas_context_menu() { if (ui_menu_button(tr("Add Swatch"), "", ICON_PALETTE)) { f32_array_t *color = selected->outputs->buffer[0]->default_value; swatch_color_t *new_swatch = project_make_swatch(color_from_floats(color->buffer[0], color->buffer[1], color->buffer[2], color->buffer[3])); - context_set_swatch(new_swatch); + g_context->swatch = new_swatch; any_array_push(g_project->swatches, new_swatch); ui_base_hwnds->buffer[TAB_AREA_STATUS]->redraws = 1; } diff --git a/paint/sources/ui/ui_view2d.c b/paint/sources/ui/ui_view2d.c index bdb38752..8a2265e2 100644 --- a/paint/sources/ui/ui_view2d.c +++ b/paint/sources/ui/ui_view2d.c @@ -405,10 +405,8 @@ void ui_view2d_render(void *_) { ui->_w = ew; if (ui_view2d_type == VIEW_2D_TYPE_LAYER) { - ui_handle_t *h_layer_mode = ui_handle(__ID__); - if (h_layer_mode->init) { - h_layer_mode->i = ui_view2d_layer_mode; - } + ui_handle_t *h_layer_mode = ui_handle(__ID__); + h_layer_mode->i = ui_view2d_layer_mode; string_array_t *layer_mode_combo = any_array_create_from_raw( (void *[]){ tr("Visible"), @@ -420,10 +418,8 @@ void ui_view2d_render(void *_) { ui->_y = 2 + start_y; if (!slot_layer_is_mask(g_context->layer)) { - ui_handle_t *h_tex_type = ui_handle(__ID__); - if (h_tex_type->init) { - h_tex_type->i = ui_view2d_tex_type; - } + ui_handle_t *h_tex_type = ui_handle(__ID__); + h_tex_type->i = ui_view2d_tex_type; string_array_t *tex_type_combo = any_array_create_from_raw( (void *[]){ tr("Base Color"), diff --git a/paint/sources/uniforms.c b/paint/sources/uniforms.c index dcb0f6a9..8b16fd68 100644 --- a/paint/sources/uniforms.c +++ b/paint/sources/uniforms.c @@ -337,7 +337,7 @@ gpu_texture_t *uniforms_ext_tex_link(object_t *object, material_data_t *mat, cha return rt->_image; } else { - return project_get_image(project_assets->buffer[g_context->colorid_handle->i]); + return project_get_image(project_assets->buffer[g_context->colorid]); } } else if (string_equals(link, "_textexttool")) { // Opacity map for text diff --git a/paint/sources/viewport.c b/paint/sources/viewport.c index d861bc10..979cceaf 100644 --- a/paint/sources/viewport.c +++ b/paint/sources/viewport.c @@ -28,7 +28,7 @@ void viewport_reset() { cam->base->transform->local = mat4_from_f32_array(o->transform, 0); transform_decompose(cam->base->transform); cam->data->fov = g_config->camera_fov; - g_context->cam_handle->i = 0; + g_context->camera_type = 0; cam->data->ortho = NULL; camera_object_build_proj(cam, -1.0); g_context->ddirty = 2; @@ -151,7 +151,7 @@ void viewport_capture_video_update(void *_) { render_target_t *rt = any_map_get(render_path_render_targets, "last"); buffer_t *pixels = gpu_get_texture_pixels(rt->_image); #ifdef IRON_BGRA - export_arm_bgra_swap(pixels); + buffer_bgra_swap(pixels); #endif iron_mp4_encode(pixels); }