From 188bea513bd919aadfc4c62a949222bafae34d97 Mon Sep 17 00:00:00 2001 From: luboslenco Date: Thu, 7 May 2026 17:57:16 +0200 Subject: [PATCH] paint: cleanup --- paint/sources/base.c | 15 +++++++++------ paint/sources/compass.c | 2 +- paint/sources/context.c | 2 ++ paint/sources/functions.h | 1 - paint/sources/render_path_base.c | 4 ---- paint/sources/render_path_deferred.c | 2 +- paint/sources/render_path_forward.c | 2 +- paint/sources/render_path_raytrace.c | 2 +- paint/sources/types.h | 2 ++ paint/sources/ui_menubar.c | 23 ++++++++++++++++++----- paint/sources/viewport.c | 2 ++ 11 files changed, 37 insertions(+), 20 deletions(-) diff --git a/paint/sources/base.c b/paint/sources/base.c index 7fe22410..b5648b7b 100644 --- a/paint/sources/base.c +++ b/paint/sources/base.c @@ -1391,13 +1391,18 @@ void ui_base_update(void *_) { base_is_resizing = false; } - if (g_context->tool == TOOL_TYPE_PARTICLE && context_in_paint_area() && !g_context->paint2d) { + if (g_context->tool == TOOL_TYPE_PARTICLE) { util_particle_init_physics(); physics_world_t *world = physics_world_active; physics_world_update(world); - g_context->ddirty = 2; - g_context->rdirty = 2; - if (mouse_started("left")) { + + if (g_context->particle_timer != NULL) { + g_context->ddirty = 2; + g_context->rdirty = 2; + iron_delay_idle_sleep(); + } + + if (mouse_started("left") && context_in_paint_area() && !g_context->paint2d) { if (g_context->particle_timer != NULL) { tween_stop(g_context->particle_timer); tween_anim_t *timer = g_context->particle_timer; @@ -1429,7 +1434,6 @@ void ui_base_update(void *_) { } #ifdef arm_physics - physics_pair_t_array_t *pairs = physics_world_get_contact_pairs(world, g_context->paint_body); if (pairs != NULL) { for (i32 i = 0; i < pairs->length; ++i) { @@ -1444,7 +1448,6 @@ void ui_base_update(void *_) { break; // 1 pair for now } } - #endif } } diff --git a/paint/sources/compass.c b/paint/sources/compass.c index cbf622a3..2beb3a0f 100644 --- a/paint/sources/compass.c +++ b/paint/sources/compass.c @@ -8,7 +8,7 @@ object_t *_compass_hovered = NULL; object_t *_compass_hovered_last = NULL; void compass_render() { - if (!g_context->show_compass || g_config->workspace == WORKSPACE_PLAYER) { + if (!g_context->show_compass || g_config->workspace == WORKSPACE_PLAYER || g_context->capturing_screenshot) { return; } diff --git a/paint/sources/context.c b/paint/sources/context.c index 4dfc3398..5ac46e75 100644 --- a/paint/sources/context.c +++ b/paint/sources/context.c @@ -17,6 +17,8 @@ context_t *context_create() { c->show_envmap_handle = ui_handle_create(); c->show_envmap_blur = false; c->show_envmap_blur_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; diff --git a/paint/sources/functions.h b/paint/sources/functions.h index ebf1ee15..6765f04a 100644 --- a/paint/sources/functions.h +++ b/paint/sources/functions.h @@ -335,7 +335,6 @@ void ui_menu_sub_end(); void render_path_base_init(); void render_path_base_apply_config(); f32 render_path_base_get_super_sampling(); -void render_path_base_draw_compass(); void render_path_base_commands(void (*draw_commands)(void)); void render_path_base_draw_bloom(char *source, char *target); void render_path_base_init_ssao(); diff --git a/paint/sources/render_path_base.c b/paint/sources/render_path_base.c index e9dc69e4..fa407a14 100644 --- a/paint/sources/render_path_base.c +++ b/paint/sources/render_path_base.c @@ -30,10 +30,6 @@ f32 render_path_base_get_super_sampling() { return render_path_base_super_sample; } -void render_path_base_draw_compass() { - compass_render(); -} - void render_path_base_begin() { // Begin split if (g_context->split_view && !g_context->paint2d_view) { diff --git a/paint/sources/render_path_deferred.c b/paint/sources/render_path_deferred.c index 9a4b6cc4..fb7c3f45 100644 --- a/paint/sources/render_path_deferred.c +++ b/paint/sources/render_path_deferred.c @@ -115,7 +115,7 @@ void render_path_deferred_draw_deferred() { render_path_draw_shader("Scene/compositor_pass/compositor_pass"); render_path_set_target("gbuffer1", NULL, NULL, GPU_CLEAR_NONE, 0, 0.0); - render_path_base_draw_compass(); + compass_render(); render_path_draw_meshes("overlay"); render_path_base_draw_taa("gbuffer1", "buf"); } diff --git a/paint/sources/render_path_forward.c b/paint/sources/render_path_forward.c index 42ce564a..5a74c455 100644 --- a/paint/sources/render_path_forward.c +++ b/paint/sources/render_path_forward.c @@ -12,7 +12,7 @@ void render_path_forward_draw_forward() { render_path_draw_shader("Scene/compositor_pass/compositor_pass"); render_path_set_target("buf", NULL, NULL, GPU_CLEAR_NONE, 0, 0.0); - render_path_base_draw_compass(); + compass_render(); render_path_draw_meshes("overlay"); render_path_base_draw_taa("buf", "gbuffer1"); diff --git a/paint/sources/render_path_raytrace.c b/paint/sources/render_path_raytrace.c index eb15e8fd..4d0aad7a 100644 --- a/paint/sources/render_path_raytrace.c +++ b/paint/sources/render_path_raytrace.c @@ -196,7 +196,7 @@ void render_path_raytrace_draw(bool use_live_layer) { render_path_set_target("buf", NULL, NULL, GPU_CLEAR_NONE, 0, 0.0); render_path_draw_meshes("overlay"); render_path_set_target("buf", NULL, NULL, GPU_CLEAR_NONE, 0, 0.0); - render_path_base_draw_compass(); + compass_render(); render_path_set_target("last", NULL, NULL, GPU_CLEAR_NONE, 0, 0.0); render_path_bind_target("buf", "tex"); render_path_draw_shader("Scene/compositor_pass/compositor_pass"); diff --git a/paint/sources/types.h b/paint/sources/types.h index 898d4135..2b1129d6 100644 --- a/paint/sources/types.h +++ b/paint/sources/types.h @@ -191,6 +191,8 @@ typedef struct context { struct ui_handle *show_envmap_handle; bool show_envmap_blur; struct ui_handle *show_envmap_blur_handle; + bool capturing_screenshot; + bool capture_background; f32 envmap_angle; f32 light_angle; bool cull_backfaces; diff --git a/paint/sources/ui_menubar.c b/paint/sources/ui_menubar.c index 8f7f9da0..ea963032 100644 --- a/paint/sources/ui_menubar.c +++ b/paint/sources/ui_menubar.c @@ -17,6 +17,7 @@ typedef struct update_info { } update_info_t; i32 ui_menubar_category = 0; +int ui_menubar_capture_screenshot_frame = 0; void ui_menubar_init() { ui_menubar_hwnd->layout = UI_LAYOUT_HORIZONTAL; @@ -162,11 +163,15 @@ void ui_menubar_draw_category_items_on_check_for_updates_downloaded(char *url, b } } -void ui_menubar_draw_category_items_capture_screenshot(void *_) { - viewport_capture_screenshot(); +void ui_menubar_capture_screenshot(void *_) { + ui_menubar_capture_screenshot_frame++; + if (ui_menubar_capture_screenshot_frame == 2) { + viewport_capture_screenshot(); + sys_remove_update(ui_menubar_capture_screenshot); + } } -void ui_menubar_draw_category_items_import_envmap(char *path) { +void ui_menubar_import_envmap(char *path) { if (!ends_with(path, ".hdr")) { console_error(tr("Error: .hdr file expected")); return; @@ -279,7 +284,7 @@ void ui_menubar_draw_category_items() { project_import_asset(string_array_join(path_texture_formats(), ","), false); } if (ui_menu_button(tr("Envmap..."), "", ICON_LANDSCAPE)) { - ui_files_show("hdr", false, false, &ui_menubar_draw_category_items_import_envmap); + ui_files_show("hdr", false, false, &ui_menubar_import_envmap); } if (ui_menu_button(tr("Font..."), "", ICON_FONT)) { project_import_asset("ttf,ttc,otf", true); @@ -470,10 +475,18 @@ void ui_menubar_draw_category_items() { } if (ui_menu_button(tr("Capture Screenshot"), "", ICON_PHOTO)) { - sys_notify_on_next_frame(&ui_menubar_draw_category_items_capture_screenshot, NULL); + g_context->capturing_screenshot = true; + ui_menubar_capture_screenshot_frame = 0; + sys_notify_on_update(&ui_menubar_capture_screenshot, NULL); ui->changed = false; // Close menu } + // if (g_config->experimental) { + // ui_handle_t *h = ui_handle(__ID__); + // h->b = g_context->capture_background; + // g_context->capture_background = ui_check(h, tr("Capture Background"), ""); + // } + if (g_config->experimental && !viewport_recording && ui_menu_button(tr("Capture Video"), "", ICON_MOVIE)) { viewport_capture_video_begin(); ui->changed = false; // Close menu diff --git a/paint/sources/viewport.c b/paint/sources/viewport.c index e4f113f3..f4aa48ff 100644 --- a/paint/sources/viewport.c +++ b/paint/sources/viewport.c @@ -126,6 +126,8 @@ void viewport_capture_screenshot() { any_array_push(g_project->packed_assets, pa); any_map_set(data_cached_images, abs, screenshot); import_texture_run(abs, true); + g_context->capturing_screenshot = false; + g_context->ddirty = 2; } void viewport_capture_video_update(void *_) {