diff --git a/paint/sources/functions.h b/paint/sources/functions.h index 74c933ac..e7ec6b63 100644 --- a/paint/sources/functions.h +++ b/paint/sources/functions.h @@ -131,6 +131,7 @@ void import_blend_mesh_run(char *path, bool replace_existin void tab_timeline_draw(ui_handle_t *htab); void tab_timeline_export(project_t *raw); void tab_timeline_import(project_t *raw); +void tab_timeline_reset(); void tab_timeline_prepare_save(); void tab_timeline_finish_save(); void tab_timeline_play(); diff --git a/paint/sources/io/import_mesh.c b/paint/sources/io/import_mesh.c index 012f3c17..82bbe5a7 100644 --- a/paint/sources/io/import_mesh.c +++ b/paint/sources/io/import_mesh.c @@ -197,6 +197,8 @@ void import_mesh_make_mesh(raw_mesh_t *mesh) { md->_->handle = string_copy(raw->name); any_map_set(data_cached_meshes, md->_->handle, md); + tab_timeline_reset(); + g_context->ddirty = 4; ui_base_hwnds->buffer[TAB_AREA_SIDEBAR0]->redraws = 2; diff --git a/paint/sources/project.c b/paint/sources/project.c index 256f4e74..9de4b5fa 100644 --- a/paint/sources/project.c +++ b/paint/sources/project.c @@ -290,6 +290,7 @@ void project_new(bool reset_layers) { g_context->picked_color = project_make_swatch(0xffffffff); g_context->color_picker_callback = NULL; history_reset(); + tab_timeline_reset(); make_material_parse_paint_material(true); make_material_parse_brush(); diff --git a/paint/sources/ui/tab_timeline.c b/paint/sources/ui/tab_timeline.c index a2a912da..a1aaf8f9 100644 --- a/paint/sources/ui/tab_timeline.c +++ b/paint/sources/ui/tab_timeline.c @@ -495,6 +495,29 @@ static void tab_timeline_init() { gc_root(tab_timeline_mesh_origins); } +void tab_timeline_reset() { + tab_timeline_init(); + + gc_unroot(tab_timeline_keyframes); + tab_timeline_keyframes = any_array_create_from_raw((void *[]){}, 0); + gc_root(tab_timeline_keyframes); + gc_unroot(tab_timeline_origins); + tab_timeline_origins = any_array_create_from_raw((void *[]){}, 0); + gc_root(tab_timeline_origins); + gc_unroot(tab_timeline_mesh_keyframes); + tab_timeline_mesh_keyframes = any_array_create_from_raw((void *[]){}, 0); + gc_root(tab_timeline_mesh_keyframes); + gc_unroot(tab_timeline_mesh_origins); + tab_timeline_mesh_origins = any_array_create_from_raw((void *[]){}, 0); + gc_root(tab_timeline_mesh_origins); + + tab_timeline_selected_frame = 0; + tab_timeline_selected_row = 0; + tab_timeline_last_frame = 0; + tab_timeline_playing = false; + tab_timeline_scroll = 0; +} + static i32 _tab_timeline_frame = 0; void tab_timeline_prepare_save() { @@ -576,26 +599,7 @@ static gpu_texture_t *tab_timeline_tex_from_buffer(buffer_t *buf, bool is_bgra) } void tab_timeline_import(project_t *raw) { - tab_timeline_init(); - - gc_unroot(tab_timeline_keyframes); - tab_timeline_keyframes = any_array_create_from_raw((void *[]){}, 0); - gc_root(tab_timeline_keyframes); - gc_unroot(tab_timeline_origins); - tab_timeline_origins = any_array_create_from_raw((void *[]){}, 0); - gc_root(tab_timeline_origins); - gc_unroot(tab_timeline_mesh_keyframes); - tab_timeline_mesh_keyframes = any_array_create_from_raw((void *[]){}, 0); - gc_root(tab_timeline_mesh_keyframes); - gc_unroot(tab_timeline_mesh_origins); - tab_timeline_mesh_origins = any_array_create_from_raw((void *[]){}, 0); - gc_root(tab_timeline_mesh_origins); - - tab_timeline_selected_frame = 0; - tab_timeline_selected_row = 0; - tab_timeline_last_frame = 0; - tab_timeline_playing = false; - tab_timeline_scroll = 0; + tab_timeline_reset(); if (raw->timeline_max_frames > 0) { tab_timeline_frame_rate = raw->timeline_frame_rate;