diff --git a/src/wings_we_build.erl b/src/wings_we_build.erl index 13624363..a0113979 100644 --- a/src/wings_we_build.erl +++ b/src/wings_we_build.erl @@ -508,7 +508,7 @@ find_hard_edges(Face, FlatNormal, SmoothNs0, EdgeNs, {He0, Possible0}, We) -> #edge{lf = Face, vs = V, ltsu = Next} -> {VNS, Next}; #edge{rf = Face, ve = V, rtsu = Next} -> {VNE, Next} end, - case e3d_vec:dist_sqr(VN, FlatNormal) < ?EPSILON of + try e3d_vec:dist_sqr(VN, FlatNormal) < ?EPSILON of true -> %% io:format("HE: V=~3w F=~3w Es: ~w ~w~n", [V, Face, Edge, Other]), {SmoothNs, [Edge, Other|He], Possible}; @@ -522,6 +522,10 @@ find_hard_edges(Face, FlatNormal, SmoothNs0, EdgeNs, {He0, Possible0}, We) -> %% io:format(" Calc: ~s Imp: ~s Face: ~s~n", [e3d_vec:format(SN), e3d_vec:format(VN), e3d_vec:format(FlatNormal)]), {SmoothNs, He, [V|Possible]} end + catch error:function_clause -> + %% Missing vertex normal, assume face-normal or smooth? + %% Currently we make it smooth + {SmoothNs, He, Possible} end end, {[], He, Poss} = wings_face:fold(Fun, {lists:reverse(SmoothNs0), He0, Possible0}, Face, We), @@ -548,11 +552,14 @@ find_he_from_vertex([], _, HeAcc, _) -> pick_edges({N1, Edge, NextFace}, Tree0, Acc) -> try gb_trees:take(NextFace, Tree0) of {{N2, _, _} = Next, Tree} -> - case e3d_vec:dist_sqr(N1,N2) < ?EPSILON of + try e3d_vec:dist_sqr(N1,N2) < ?EPSILON of true -> pick_edges(Next, Tree, Acc); false -> pick_edges(Next, Tree, [Edge|Acc]) + catch error:function_clause -> + %% Vertex normals assume smooth normal + pick_edges(Next, Tree, Acc) end - catch _:_ -> + catch _E:_R -> Acc end.