Skip to content

Commit

Permalink
- Applyed changes and fixed issues pointed by Dan;
Browse files Browse the repository at this point in the history
  • Loading branch information
Micheus committed Oct 14, 2024
1 parent 8188099 commit a262e3a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 38 deletions.
47 changes: 22 additions & 25 deletions plugins_src/autouv/auv_texture.erl
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,10 @@ draw_options(#st{bb=Uvs}=AuvSt0) ->
false -> atom_to_list(MatName0);
OldId ->
OldImg = wings_image:info(OldId),
case OldImg#e3d_image.name of
Name when is_list(Name) ->
case string:left(Name, 5) of
"auvBG" -> atom_to_list(MatName0);
_ -> Name
end;
Other -> Other
OldName = OldImg#e3d_image.name,
case string:prefix("auvBG", OldName) of
nomatch -> OldName;
_ -> atom_to_list(MatName0)
end
end,
catch wings_material:update_image(MatName0, diffuse, NewImg#e3d_image{name=TexName}, GeomSt0)
Expand Down Expand Up @@ -1136,24 +1133,24 @@ setup(#st{shapes=ShUV,selmode=SModeUV0,sel=SelUV0,bb=Uvs}=St, Reqs) ->
end,
SelForTile = lists:flatten([Get_mat_face(WeUV) || WeUV <- gb_trees:values(ShUV)]),
case SelForTile of
[_|_] ->
if (SelUV0==[]) ->
SModeUV = body,
SelUV = [{Id,gb_sets:singleton(0)} || {Id,_} <- SelForTile];
true ->
SelUV1 = [Sel || {IdSel,_}=Sel <- SelUV0, proplists:is_defined(IdSel,SelForTile)],
case SelUV1 of
[] ->
SModeUV = face,
SelUV = [{Id,gb_sets:from_list(Fs)} || {Id,Fs} <- SelForTile];
_ ->
SModeUV = SModeUV0,
SelUV = SelUV0
end
end,
setup_charts(St#st{selmode=SModeUV,sel=SelUV}, We, Reqs);
[] ->
setup_charts(St, We, Reqs)
[_|_] ->
if (SelUV0==[]) ->
SModeUV = body,
SelUV = [{Id,gb_sets:singleton(0)} || {Id,_} <- SelForTile];
true ->
SelUV1 = [Sel || {IdSel,_}=Sel <- SelUV0, proplists:is_defined(IdSel,SelForTile)],
case SelUV1 of
[] ->
SModeUV = face,
SelUV = [{Id,gb_sets:from_list(Fs)} || {Id,Fs} <- SelForTile];
_ ->
SModeUV = SModeUV0,
SelUV = SelUV0
end
end,
setup_charts(St#st{selmode=SModeUV,sel=SelUV}, We, Reqs);
[] ->
setup_charts(St, We, Reqs)
end;
none ->
setup_charts(St, We, Reqs)
Expand Down
20 changes: 7 additions & 13 deletions plugins_src/autouv/wpc_autouv.erl
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,8 @@ start_edit(Mode, We, St) ->
MatNames4 = sofs:to_external(MatNames3),
MatNames = [Mat || {Name,_}=Mat <- MatNames4, get_texture(Name, St) /= false],
case MatNames of
[{MatName,_}] ->
[{MatName,_}|_] ->
do_edit(MatName, Mode, We, St);
[MatFace|_] = MatNames when is_tuple(MatFace) ->
do_edit(MatNames, Mode, We, St);
_ ->
do_edit(none, Mode, We, St)
end.
Expand All @@ -250,11 +248,7 @@ do_edit(MatName0, Mode, We0, #st{mat=Materials,shapes=Shs0}=GeomSt0) ->
update_textureset_system(We0, ?MULTIPLE, TxSetInfo)
end;
_X ->
MatName =
case MatName0 of
[{MatName1,_}|_] -> MatName1;
_ -> MatName0
end,
MatName = MatName0,
update_textureset_system(We0, ?SINGLE, [])
end,
Shs = gb_trees:update(We#we.id, We, Shs0),
Expand Down Expand Up @@ -362,14 +356,14 @@ get_texture_set(OldTxSet, We, Materials) ->

get_texture_set([TxSetNaming, _OldTxSet], [MatInfo|_]=MatNames, We, Materials) when is_tuple(MatInfo) ->
TxSet =
lists:foldr(fun({MatName, Vs}, Acc) ->
lists:foldr(fun({MatName, Fs}, Acc) ->
VsPos =
gb_sets:fold(fun(Face, Acc0) when Face < 0 ->
Acc0;
(Face, Acc0) ->
UVPos = wings_va:face_attr(uv, Face, We),
[{U,V,0.0} || {U,V} <- UVPos]++Acc0
end, [], Vs),
end, [], Fs),
{U,V,_} = e3d_vec:average(VsPos),
TxId = get_texture_img(MatName, Materials),
gb_trees:enter({trunc(U),trunc(V)},#{mat=>MatName,bg_img=>TxId}, Acc)
Expand Down Expand Up @@ -1075,9 +1069,9 @@ handle_event_3({action,Ev}=Act, #st{selmode=AUVSel, bb=#uvstate{st=#st{selmode=G
{view,Cmd} when Cmd == frame ->
wings_view:command(Cmd,St),
get_event(St);
{view,Cmd} when Cmd == reset ->
camera_reset(),
get_event(St);
{view,Cmd} when Cmd == reset ->
camera_reset(),
get_event(St);
{edit, repeat} ->
repeat(command, St);
{edit, repeat_args} ->
Expand Down

0 comments on commit a262e3a

Please sign in to comment.