Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions plugins_src/autouv/auv_seg_ui.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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 ->
Expand Down
20 changes: 20 additions & 0 deletions plugins_src/autouv/wpc_autouv.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -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}}).

Expand Down Expand Up @@ -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.
Loading