Skip to content

Commit ec998e7

Browse files
committed
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.
1 parent b3d2f8e commit ec998e7

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

plugins_src/autouv/auv_seg_ui.erl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,11 @@ seg_event_5(Ev, #seg{st=St0}=Ss) ->
205205
seg_event_6({new_state,St}, Ss) ->
206206
get_seg_event(Ss#seg{st=St});
207207

208+
seg_event_6({new_orig_state,{Id,#st{shapes=Shp1,mat=TMat}}}, #seg{orig_st=#st{shapes=Shp0}=St}=Ss) ->
209+
We = gb_trees:get(Id,Shp1),
210+
Shp = gb_trees:enter(Id,We,Shp0),
211+
get_seg_event(Ss#seg{orig_st=St#st{shapes=Shp,mat=TMat}});
212+
208213
seg_event_6({action,{view,Cmd}}, #seg{st=St0}=Ss) ->
209214
case Cmd of
210215
aim ->

plugins_src/autouv/wpc_autouv.erl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ init_show_maps(Charts0, Fs, #we{name=WeName,id=Id}, GeomSt0) ->
283283
case wings_wm:is_window(EditWin) of
284284
true ->
285285
wings_wm:send(EditWin, {add_faces,Fs,GeomSt}),
286+
update_all_seg_ui(all, Id, GeomSt),
286287
wings_wm:send(geom, {new_state,GeomSt});
287288
false ->
288289
%% 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) ->
293294
Pos = wxWindow:clientToScreen(SegWin,X0,Y0),
294295
Win = create_window({edit,Fs}, EditWin, Id, GeomSt),
295296
wxWindow:move(Win,Pos),
297+
update_all_seg_ui(SegWin, Id, GeomSt),
296298
wings_wm:send(geom, {new_state,GeomSt})
297299
end,
298300
GeomSt.
@@ -481,6 +483,7 @@ update_selected_uvcoords(#st{bb=Uvs}=St) ->
481483
We = update_uvs(Charts, We0),
482484
Shs = gb_trees:update(Id, We, Shs0),
483485
GeomSt = GeomSt0#st{shapes=Shs},
486+
update_all_seg_ui(all, Id, GeomSt),
484487
wings_wm:send(geom, {new_state,GeomSt}),
485488
clear_temp_sel(St#st{bb=Uvs#uvstate{st=GeomSt}}).
486489

@@ -2829,3 +2832,20 @@ camera_reset() ->
28292832
distance=Dist,
28302833
pan_x=0.0,pan_y=0.0,
28312834
along_axis=none}).
2835+
2836+
%% When multiple 'AutoUV Segmenting' windows are open, this function ensures that all of them
2837+
%% keep their #ss.orig_st field updated with the latest UV state. This prevents the field from
2838+
%% being overridden when concluding a new segmentation, which previously caused users to lose
2839+
%% the work they had already done in an active 'AutoUV Edit' window.
2840+
update_all_seg_ui(SegWin, Id, St) ->
2841+
All = wings_wm:windows(),
2842+
Filter = fun(Name) when Name =:= SegWin -> false;
2843+
({autouv,{segment,_}}) -> true;
2844+
(_) -> false
2845+
end,
2846+
case lists:filter(Filter, All) of
2847+
[] ->
2848+
ok;
2849+
SegAuv0 ->
2850+
[wings_wm:send(Name,{new_orig_state,{Id,St}}) || Name <- SegAuv0]
2851+
end.

0 commit comments

Comments
 (0)