From ec998e7f2eae4bed2a55e35588c739bf0944efeb Mon Sep 17 00:00:00 2001 From: micheus Date: Mon, 22 Dec 2025 18:42:49 -0300 Subject: [PATCH 1/2] AutoUV Segmenting was rewritten the AutoUV state When a user opened multiple AutoUV Segmenting windows, each window kept its state (#st{}) frozen at the moment it was created. After completing the segmentation process in one window and activating the AutoUV Editor, if the user switched to another segmenting window, the Geometry window would show that the previously segmented object had lost its segmentation. Note: - Fixed an issue with multiple AutoUV Segmenting window erasing the previous segmentation. Thanks to Arclite. --- plugins_src/autouv/auv_seg_ui.erl | 5 +++++ plugins_src/autouv/wpc_autouv.erl | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/plugins_src/autouv/auv_seg_ui.erl b/plugins_src/autouv/auv_seg_ui.erl index fe9e4410e..c579865a0 100644 --- a/plugins_src/autouv/auv_seg_ui.erl +++ b/plugins_src/autouv/auv_seg_ui.erl @@ -205,6 +205,11 @@ seg_event_5(Ev, #seg{st=St0}=Ss) -> seg_event_6({new_state,St}, Ss) -> get_seg_event(Ss#seg{st=St}); +seg_event_6({new_orig_state,{Id,#st{shapes=Shp1,mat=TMat}}}, #seg{orig_st=#st{shapes=Shp0}=St}=Ss) -> + We = gb_trees:get(Id,Shp1), + Shp = gb_trees:enter(Id,We,Shp0), + get_seg_event(Ss#seg{orig_st=St#st{shapes=Shp,mat=TMat}}); + seg_event_6({action,{view,Cmd}}, #seg{st=St0}=Ss) -> case Cmd of aim -> diff --git a/plugins_src/autouv/wpc_autouv.erl b/plugins_src/autouv/wpc_autouv.erl index 92be1e414..e6fb0bb52 100644 --- a/plugins_src/autouv/wpc_autouv.erl +++ b/plugins_src/autouv/wpc_autouv.erl @@ -283,6 +283,7 @@ init_show_maps(Charts0, Fs, #we{name=WeName,id=Id}, GeomSt0) -> case wings_wm:is_window(EditWin) of true -> wings_wm:send(EditWin, {add_faces,Fs,GeomSt}), + update_all_seg_ui(all, Id, GeomSt), wings_wm:send(geom, {new_state,GeomSt}); false -> %% we are going to ensure to open the AutoUV window in the same @@ -293,6 +294,7 @@ init_show_maps(Charts0, Fs, #we{name=WeName,id=Id}, GeomSt0) -> Pos = wxWindow:clientToScreen(SegWin,X0,Y0), Win = create_window({edit,Fs}, EditWin, Id, GeomSt), wxWindow:move(Win,Pos), + update_all_seg_ui(SegWin, Id, GeomSt), wings_wm:send(geom, {new_state,GeomSt}) end, GeomSt. @@ -481,6 +483,7 @@ update_selected_uvcoords(#st{bb=Uvs}=St) -> We = update_uvs(Charts, We0), Shs = gb_trees:update(Id, We, Shs0), GeomSt = GeomSt0#st{shapes=Shs}, + update_all_seg_ui(all, Id, GeomSt), wings_wm:send(geom, {new_state,GeomSt}), clear_temp_sel(St#st{bb=Uvs#uvstate{st=GeomSt}}). @@ -2829,3 +2832,20 @@ camera_reset() -> distance=Dist, pan_x=0.0,pan_y=0.0, along_axis=none}). + +%% When multiple 'AutoUV Segmenting' windows are open, this function ensures that all of them +%% keep their #ss.orig_st field updated with the latest UV state. This prevents the field from +%% being overridden when concluding a new segmentation, which previously caused users to lose +%% the work they had already done in an active 'AutoUV Edit' window. +update_all_seg_ui(SegWin, Id, St) -> + All = wings_wm:windows(), + Filter = fun(Name) when Name =:= SegWin -> false; + ({autouv,{segment,_}}) -> true; + (_) -> false + end, + case lists:filter(Filter, All) of + [] -> + ok; + SegAuv0 -> + [wings_wm:send(Name,{new_orig_state,{Id,St}}) || Name <- SegAuv0] + end. From 7085b0bbfae93c30e5690e022383ad842c16b5fa Mon Sep 17 00:00:00 2001 From: micheus Date: Wed, 29 Apr 2026 17:46:51 -0300 Subject: [PATCH 2/2] - Fixed wrong parameter passed to update_all_seg_ui/3 as pointed by @dgud. --- plugins_src/autouv/wpc_autouv.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins_src/autouv/wpc_autouv.erl b/plugins_src/autouv/wpc_autouv.erl index e6fb0bb52..cf5842fe7 100644 --- a/plugins_src/autouv/wpc_autouv.erl +++ b/plugins_src/autouv/wpc_autouv.erl @@ -294,7 +294,7 @@ init_show_maps(Charts0, Fs, #we{name=WeName,id=Id}, GeomSt0) -> Pos = wxWindow:clientToScreen(SegWin,X0,Y0), Win = create_window({edit,Fs}, EditWin, Id, GeomSt), wxWindow:move(Win,Pos), - update_all_seg_ui(SegWin, Id, GeomSt), + update_all_seg_ui(wings_wm:wx2win(SegWin), Id, GeomSt), wings_wm:send(geom, {new_state,GeomSt}) end, GeomSt.