diff --git a/plugins_src/autouv/Makefile b/plugins_src/autouv/Makefile index d0f5c52e..c808e2bc 100644 --- a/plugins_src/autouv/Makefile +++ b/plugins_src/autouv/Makefile @@ -44,7 +44,7 @@ TARGET_FILES= $(MODULES:%=$(EBIN)/%.beam) # ---------------------------------------------------- # FLAGS # ---------------------------------------------------- -ERL_COMPILE_FLAGS += +nowarn_match_float_zero -Werror -pa $(WINGS_INTL) -I $(WINGS_TOP) $(TYPE_FLAGS) +debug_info +ERL_COMPILE_FLAGS += -Werror -pa $(WINGS_INTL) -I $(WINGS_TOP) $(TYPE_FLAGS) +debug_info # ---------------------------------------------------- # Targets diff --git a/plugins_src/autouv/auv_mapping.erl b/plugins_src/autouv/auv_mapping.erl index 7d41a02a..95e49064 100644 --- a/plugins_src/autouv/auv_mapping.erl +++ b/plugins_src/autouv/auv_mapping.erl @@ -439,7 +439,7 @@ split_pinned([], _, Indx, PosL) -> {reverse(Indx), reverse(PosL)}. scaleVs(VUVs,Scale) -> - [{Id, {X*Scale,Y*Scale,0.0}} || {Id,{X,Y,0.0}} <- VUVs]. + [{Id, {X*Scale,Y*Scale,0.0}} || {Id,{X,Y,_}} <- VUVs]. find_pinned({Circumference, BorderEdges}, We) -> Vs = [array:get(V1, We#we.vp) || #be{vs=V1} <- BorderEdges], @@ -489,7 +489,7 @@ chart_normal(Fs,We = #we{es=Etab}) -> CalcNormal = fun(Face,Area) -> face_normal(Face,Area,We) end, N0 = foldl(CalcNormal, e3d_vec:zero(), Fs), case e3d_vec:norm(N0) of - {0.0,0.0,0.0} -> %% Bad normal Fallback1 + {+0.0,+0.0,+0.0} -> %% Bad normal Fallback1 %% BE = auv_util:outer_edges(Fs,We,false), [{_,BE}|_] = auv_placement:group_edge_loops(Fs,We), EdgeNormals = @@ -500,7 +500,7 @@ chart_normal(Fs,We = #we{es=Etab}) -> end, N1 = foldl(EdgeNormals, e3d_vec:zero(), BE), case e3d_vec:norm(N1) of - {0.0,0.0,0.0} -> %% Bad normal Fallback2 + {+0.0,+0.0,+0.0} -> %% Bad normal Fallback2 NewFs = decrease_chart(Fs,BE), chart_normal(NewFs, We); N -> e3d_vec:neg(N) @@ -603,11 +603,11 @@ lsq_init_fs([F|Fs],P,We = #we{vp=Vtab},Ds0,N,Re0,Im0) -> array:get(C0,Vtab)), %% Raimos old solution. SqrtDT0 = try math:sqrt(abs((X2-X1)*(Y3-Y1)-(Y2-Y1)*(X3-X1))) - catch _:_ -> 0.000001 - end, - SqrtDT = if SqrtDT0 =:= 0.0 -> 1.0; % this can happen e.g. in a bevel/extrude without offset - true -> SqrtDT0 - end, + catch _:_ -> 0.000001 + end, + SqrtDT = if SqrtDT0 < ?EPSILON -> 1.0; % this can happen e.g. in a bevel/extrude without offset + true -> SqrtDT0 + end, W1re = X3-X2, W1im = Y3-Y2, W2re = X1-X3, W2im = Y1-Y3, W3re = X2-X1, W3im = Y2-Y1, diff --git a/plugins_src/autouv/auv_matrix.erl b/plugins_src/autouv/auv_matrix.erl index c8dec45c..07804b82 100644 --- a/plugins_src/autouv/auv_matrix.erl +++ b/plugins_src/autouv/auv_matrix.erl @@ -453,7 +453,7 @@ reduce_sort([Row | A], C) -> reduce_presort(Z, []) -> {Z, infinity, []}; -reduce_presort(Z, [0.0 | Row]) -> +reduce_presort(Z, [+0.0 | Row]) -> reduce_presort(Z+1, Row); reduce_presort(Z, [V | _] = Row) when is_float(V) -> {Z, 1.0/abs(V), Row}; @@ -518,7 +518,7 @@ backsubst_rev_z(Z, Za, _, _, _) when Za > Z -> {error, not_reduced}; backsubst_rev_z(_, _, [_], _, _) -> {error, not_reduced}; -backsubst_rev_z(Z, Za, [0.0 | RowA], A, C) -> +backsubst_rev_z(Z, Za, [+0.0 | RowA], A, C) -> backsubst_rev_z(Z, Za+1, RowA, A, C); backsubst_rev_z(Z, Za, [Va | _] = RowA, A, C) when is_float(Va) -> if Z == Za -> @@ -692,7 +692,7 @@ vec_sq([_ | A], S) -> %% Push value; zeros or float -push_v(0.0, C) -> +push_v(+0.0, C) -> case C of [Z | R] when is_integer(Z) -> [Z+1 | R]; diff --git a/plugins_src/autouv/auv_texture.erl b/plugins_src/autouv/auv_texture.erl index c652eda7..56f52e56 100644 --- a/plugins_src/autouv/auv_texture.erl +++ b/plugins_src/autouv/auv_texture.erl @@ -1277,7 +1277,7 @@ build_tangents([], _, Bin) -> Bin. add_tangents1([V|Vs], Ts, H0, N, Prev, Bin0) -> case array:get(V, Ts) of - {{0.0, 0.0, 0.0}, BiT} -> + {{+0.0, +0.0, +0.0}, BiT} -> {Tan = {X,Y,Z}, H} = get_tangent(Prev, BiT, H0, N), Bin = <>, add_tangents1(Vs, Ts, H, N, Tan, Bin); @@ -1294,7 +1294,7 @@ add_tangents1([V|Vs], Ts, H0, N, Prev, Bin0) -> end; add_tangents1([], _, _, _, _, Bin) -> Bin. -get_tangent(undefined, {0.0,0.0,0.0}, H0, N) -> +get_tangent(undefined, {+0.0,+0.0,+0.0}, H0, N) -> H = if H0 =:= 0 -> -1; true -> H0 end, {cross_axis(N), H}; get_tangent(undefined, BiT, 0, N) -> diff --git a/plugins_src/autouv/wpc_autouv.erl b/plugins_src/autouv/wpc_autouv.erl index 9acdc611..fc8bd519 100644 --- a/plugins_src/autouv/wpc_autouv.erl +++ b/plugins_src/autouv/wpc_autouv.erl @@ -1333,9 +1333,9 @@ make_proportional([Link0|R],We = #we{vp=Vtab1}, [LinkObj0|RObj], WeObj = #we{vp= {Xd,Yd,_} = e3d_vec:sub(array:get(Ve,Vtab1), array:get(Vs,Vtab1)), ELen = e3d_vec:len({Xd,Yd,0.0}), - Dir = if (ELen =:= 0.0) -> none; - true -> e3d_vec:norm({Xd,Yd,0.0}) - end, + Dir = if abs(ELen) < ?EPSILON -> none; + true -> e3d_vec:norm({Xd,Yd,0.0}) + end, {Len+ELen,[{E,Dir}|Acc]} end,{0.0,[]},Link), EsLen = validate_dir(EsLen0,[]), @@ -1357,8 +1357,8 @@ make_proportional([Link0|R],We = #we{vp=Vtab1}, [LinkObj0|RObj], WeObj = #we{vp= Vtab0 = lists:foldr(fun({{E,Ve,Vs},Dir0}, Acc) -> EObjLen = proplists:get_value(E,EsObjLen), - if LinkObjLen =/= 0.0 -> Prc = EObjLen/LinkObjLen; - true -> Prc = 1.0 + if abs(LinkObjLen) > ?EPSILON -> Prc = EObjLen/LinkObjLen; + true -> Prc = 1.0 end, ELen = Prc*LinkLen, Dir = e3d_vec:mul(Dir0,ELen), @@ -1377,25 +1377,25 @@ make_proportional([Link0|R],We = #we{vp=Vtab1}, [LinkObj0|RObj], WeObj = #we{vp= D1 = e3d_vec:len(Vec1), %% making the new loop arrangement fit in the old BB length and alignment - if D1 =/= 0.0 -> Scl = round((D0/D1)*100.0)/100.0; - true -> Scl = 1.0 + if abs(D1) > ?EPSILON -> Scl = round((D0/D1)*100.0)/100.0; + true -> Scl = 1.0 end, {_,_,RotSide} = e3d_vec:norm(e3d_vec:cross(Vec1,Vec0)), Rot = round(e3d_vec:degrees(Vec1,Vec0)*10.0)/10.0*RotSide, MToOri = e3d_mat:translate(e3d_vec:neg(Mid1)), - if (Rot=/=0.0) or (Scl=/=1.0) -> - %% preparing transform matrices - MRot = e3d_mat:rotate(Rot,wings_util:make_vector(z)), - MScl = e3d_mat:scale({Scl,Scl,1.0}), - MToDst = e3d_mat:translate(Mid0), - M2 = e3d_mat:mul(MScl,MToOri), - M1 = e3d_mat:mul(MRot,M2), - M0 = e3d_mat:mul(MToDst,M1); - true -> - MToDst = e3d_mat:translate(Mid0), - M0 = e3d_mat:mul(MToDst,MToOri) + if abs(Rot) > ?EPSILON orelse (Scl=/=1.0) -> + %% preparing transform matrices + MRot = e3d_mat:rotate(Rot,wings_util:make_vector(z)), + MScl = e3d_mat:scale({Scl,Scl,1.0}), + MToDst = e3d_mat:translate(Mid0), + M2 = e3d_mat:mul(MScl,MToOri), + M1 = e3d_mat:mul(MRot,M2), + M0 = e3d_mat:mul(MToDst,M1); + true -> + MToDst = e3d_mat:translate(Mid0), + M0 = e3d_mat:mul(MToDst,MToOri) end, - + Vtab = lists:foldr(fun(V, Acc) -> Pos = e3d_mat:mul_point(M0,array:get(V,Acc)), @@ -1647,7 +1647,7 @@ displace_charts([{_,{Id1,_,_},{Id2,_,_}}|Eds], Moved, Sh) -> C2 = wings_vertex:center(gb_trees:get(Id2,Sh)), Disp0 = e3d_vec:mul(e3d_vec:norm(e3d_vec:sub(C1,C2)),?EPSILON), Move = case Disp0 of - {0.0,0.0,0.0} -> {0.0,?EPSILON,0.0}; + {+0.0,+0.0,_} -> {0.0,?EPSILON,0.0}; Disp -> Disp end, Vpos= [{V,e3d_vec:add(Pos,Move)} || diff --git a/plugins_src/commands/Makefile b/plugins_src/commands/Makefile index 93d60b09..6e1516bc 100644 --- a/plugins_src/commands/Makefile +++ b/plugins_src/commands/Makefile @@ -71,7 +71,7 @@ TARGET_FILES= $(MODULES:%=$(EBIN)/%.beam) # ---------------------------------------------------- # FLAGS # ---------------------------------------------------- -ERL_COMPILE_FLAGS += -pa $(WINGS_INTL) +nowarn_match_float_zero -Werror -I $(WINGS_TOP) $(TYPE_FLAGS) +debug_info +ERL_COMPILE_FLAGS += -pa $(WINGS_INTL) -Werror -I $(WINGS_TOP) $(TYPE_FLAGS) +debug_info # ---------------------------------------------------- # Targets diff --git a/plugins_src/commands/wpc_absolute_scale.erl b/plugins_src/commands/wpc_absolute_scale.erl index 2e4e2c4f..6a8a42fc 100644 --- a/plugins_src/commands/wpc_absolute_scale.erl +++ b/plugins_src/commands/wpc_absolute_scale.erl @@ -133,7 +133,7 @@ getSuggestedCenter([{AX1,AY1,AZ1},{AX2,AY2,AZ2}], getC(AY1,AY2,BY1,BY2), getC(AZ1,AZ2,BZ1,BZ2)}. -getC(A1, A2, B1, B2) when A1 =/= A2, B1 =/= B2, ((A1 - A2)-(B1 - B2))=/=0.0 -> +getC(A1, A2, B1, B2) when A1 =/= A2, B1 =/= B2, abs((A1 - A2)-(B1 - B2)) > ?EPSILON -> (B1*A2-B2*A1)/((A2-A1) - (B2-B1)); getC(A1, A2, _, _) -> (A1+A2)/2. diff --git a/plugins_src/commands/wpc_align_to_axis.erl b/plugins_src/commands/wpc_align_to_axis.erl index 54177c76..b3a2c9b0 100644 --- a/plugins_src/commands/wpc_align_to_axis.erl +++ b/plugins_src/commands/wpc_align_to_axis.erl @@ -264,9 +264,9 @@ trunc_axis(x, {_,Y,Z}) -> {0.0,Y,Z}; trunc_axis(y, {X,_,Z}) -> {X,0.0,Z}; trunc_axis(z, {X,Y,_}) -> {X,Y,0.0}. -translate_axis(x, {0.0,_Y,_Z}) -> {-1.0,0.0,0.0}; +translate_axis(x, {+0.0,_Y,_Z}) -> {-1.0,0.0,0.0}; translate_axis(x, {X,_Y,_Z}) -> {-1.0*(X/abs(X)),0.0,0.0}; -translate_axis(y, {_X,0.0,_Z}) -> {0.0,1.0,0.0}; +translate_axis(y, {_X,+0.0,_Z}) -> {0.0,1.0,0.0}; translate_axis(y, {_X,Y,_Z}) -> {0.0,Y/abs(Y),0.0}; -translate_axis(z, {_X,_Y,0.0}) -> {0.0,0.0,1.0}; +translate_axis(z, {_X,_Y,+0.0}) -> {0.0,0.0,1.0}; translate_axis(z, {_X,_Y,Z}) -> {0.0,0.0,Z/abs(Z)}. diff --git a/plugins_src/commands/wpc_arc_intersect.erl b/plugins_src/commands/wpc_arc_intersect.erl index af4c642c..8459e003 100644 --- a/plugins_src/commands/wpc_arc_intersect.erl +++ b/plugins_src/commands/wpc_arc_intersect.erl @@ -234,10 +234,10 @@ arc_intersect_fun(Axis,Center,Deg,VsInf0,{_,R}=Magnet0,State0) -> end. -arc_intersect(_Axis,_Center,_Deg,Vpos,_State,0.0) -> +arc_intersect(_Axis,_Center,_Deg,Vpos,_State, +0.0) -> Vpos; -arc_intersect(Axis,Center,Deg,Vpos,_State,Percent) when Deg =:= 0.0; Deg =:= 180.0 -> +arc_intersect(Axis,Center,Deg,Vpos,_State,Percent) when Deg =:= +0.0; Deg =:= 180.0 -> Rotate = 180.0 * Percent, rotate(Vpos,Axis,Center,Rotate); diff --git a/plugins_src/commands/wpc_bend.erl b/plugins_src/commands/wpc_bend.erl index f483ceaf..cfc63705 100644 --- a/plugins_src/commands/wpc_bend.erl +++ b/plugins_src/commands/wpc_bend.erl @@ -256,7 +256,7 @@ bend_setup_clamps(#bend_data{rodCenter=RC, rodNormal=RN}=BD, bend_verts(BendData, St) -> case BendData#bend_data.rodLength of - 0.0 -> + +0.0 -> wpa:error_msg(?__(1,"Configuration does not result in bending")); _ -> %% FIXME @@ -288,9 +288,9 @@ bend_verts(BendData, Vs0, We) -> %% The return value is the new position. {X,Y,Z} %% -bend_vertex(Pos, _, #bend_data{rodLength = 0.0}) -> +bend_vertex(Pos, _, #bend_data{rodLength = +0.0}) -> Pos; -bend_vertex(Pos, 0.0, #bend_data{dragMode = fixed_length}) -> +bend_vertex(Pos, +0.0, #bend_data{dragMode = fixed_length}) -> Pos; bend_vertex(Pos, Angle, #bend_data{dragMode = DragMode, rodCenter = RC, diff --git a/plugins_src/commands/wpc_circularise.erl b/plugins_src/commands/wpc_circularise.erl index 559841ec..a62b774d 100644 --- a/plugins_src/commands/wpc_circularise.erl +++ b/plugins_src/commands/wpc_circularise.erl @@ -538,7 +538,7 @@ get_radius([], Center, _, _, RayLen0, NearestVert, Pos, LastPos, FirstPos, AtInd false -> {Pos, math:sqrt(NearestVert), Index} end; -get_radius([Vert|Vs], Center, Plane, Vtab, 0.0, 0.0, _Pos, _LastPos, _FirstPos, AtIndex, _Index) -> +get_radius([Vert|Vs], Center, Plane, Vtab, +0.0, +0.0, _Pos, _LastPos, _FirstPos, AtIndex, _Index) -> Pos = array:get(Vert, Vtab), RayPos = intersect_vec_plane(Pos, Center, Plane), Dist = len_sqrt(e3d_vec:sub(RayPos, Center)), @@ -713,9 +713,9 @@ make_circular_fun(Data, State) -> end. %%%% Arc Main Functions -arc(Vpos, _Index, _Data, _State, 0.0, 0.0) -> Vpos; +arc(Vpos, _Index, _Data, _State, +0.0, +0.0) -> Vpos; arc(Vpos, Index, {CwNorm, _, Opp, Plane0, Pos, Hinge, NumVs}, - {Flatten,Orientation,_}, Percent, 0.0) -> + {Flatten,Orientation,_}, Percent, +0.0) -> Segment = (Opp * 2) / NumVs, ChordNorm = e3d_vec:norm(e3d_vec:sub(Hinge, Pos)), Plane = reverse_norm(CwNorm,Plane0,Orientation), @@ -764,7 +764,7 @@ arc(Vpos, Index, {CwNorm, Cross0, Opp, Plane0, Pos, Hinge, NumVs}, % % % % % % % % % % % % % % % % % % % % -arc_center(Vpos, _, _, _, _, _, _, _, 0.0) -> Vpos; +arc_center(Vpos, _, _, _, _, _, _, _, +0.0) -> Vpos; arc_center(Vpos, Angle, Index, NumVs, Pos, Center, Plane, {Flatten,AxisMode,AngleMode}, Percent) -> DegIncrement = acute_obtuse(AngleMode, Angle, NumVs), RotationAmount = rotation_amount(AxisMode, DegIncrement, Index), @@ -782,7 +782,7 @@ rotation_amount(reverse, Deg, Index) -> -Deg * Index. %%%% Closed Loop. Calculate the final position of each vertex (NewPos). %%%% Measure the distance between NewPos and the Center (Factor). Move the %%%% vertex towards the NewPos by a distance of the drag Dist * Factor. -make_circular(_Center, _Ray, _Nearest, _Axis, _Deg, Vpos, _State, 0.0, 0.0) -> Vpos; +make_circular(_Center, _Ray, _Nearest, _Axis, _Deg, Vpos, _State, +0.0, +0.0) -> Vpos; make_circular(Center, Ray, Nearest, Plane, Deg, Vpos, {Flatten,_,Mode}, Percent, Dia) -> Pos0 = static_pos(Mode, Center, Ray, Nearest, Dia), Pos1 = rotate(Pos0, Plane, Center, Deg), @@ -822,7 +822,7 @@ intersect_vec_plane(PosA, PosB, PlaneNorm) -> Intersection = e3d_vec:dot(e3d_vec:sub(PosB, PosA), PlaneNorm), e3d_vec:add(PosA, e3d_vec:mul(PlaneNorm, Intersection)). -reverse_norm({0.0,0.0,0.0}, Norm, reverse) -> e3d_vec:neg(Norm); +reverse_norm({+0.0,+0.0,+0.0}, Norm, reverse) -> e3d_vec:neg(Norm); reverse_norm(_, Norm, _) -> Norm. %%%% Selection errors diff --git a/plugins_src/commands/wpc_constraints.erl b/plugins_src/commands/wpc_constraints.erl index 1ead6c0f..d13b133a 100644 --- a/plugins_src/commands/wpc_constraints.erl +++ b/plugins_src/commands/wpc_constraints.erl @@ -515,9 +515,9 @@ check_selection(sub_angle,none,none,#st{sel=[{_Id0,Sel0},{_Id1,Sel1}]}=St,OrigSt OrigA = measure_angle(normal,OrigSt), Angle = measure_angle(normal,St), A0 = abs(Angle - OrigA), - A1 = case A0 of - 0.0 -> 180.0; - _ -> A0 + A1 = case A0 < ?EPSILON of + true -> 180.0; + false -> A0 end, Str = [?__(11," Original Angle ~s"),?DEGREE,?__(12,"\n Current Angle ~s"), ?DEGREE,?__(13,"\n Difference ~s"),?DEGREE], @@ -534,9 +534,9 @@ check_selection(sub_angle,none,none,#st{sel=[{_Id,Sel}]}=St,OrigSt) -> OrigA = wings_util:nice_float(Angle), CurrA = wings_util:nice_float(CAngle), A0 = abs(Angle - CAngle), - A1 = case A0 of - 0.0 -> 180.0; - _ -> A0 + A1 = case A0 < ?EPSILON of + true -> 180.0; + false -> A0 end, A2 = wings_util:nice_float(A1), Str1 = [wings_util:format(?__(16," Angle ~s"),[OrigA]),?DEGREE], diff --git a/plugins_src/commands/wpc_corner.erl b/plugins_src/commands/wpc_corner.erl index 42f1866b..d2f0f318 100644 --- a/plugins_src/commands/wpc_corner.erl +++ b/plugins_src/commands/wpc_corner.erl @@ -231,7 +231,7 @@ corner_error() -> corner_tension_fun(VD) -> fun - ([0.0], A) -> + ([+0.0], A) -> lists:foldl(fun ({V,Vpos,_Rad,_Vec}, VsAcc) -> [{V,Vpos}|VsAcc]; diff --git a/plugins_src/commands/wpc_flow_connect.erl b/plugins_src/commands/wpc_flow_connect.erl index 2eb80f0a..bb00344f 100644 --- a/plugins_src/commands/wpc_flow_connect.erl +++ b/plugins_src/commands/wpc_flow_connect.erl @@ -266,9 +266,9 @@ get_result(Deg, Len, false) -> opposite(Deg, Adjacent, Divider) -> D0 = (180 - Deg)/Divider, - case D0 of - 0.0 -> 0.0; - _ -> + case abs(D0) < ?EPSILON of + true -> 0.0; + false -> Radians = math:pi()/(180/D0), Adjacent * math:tan(Radians) end. @@ -276,12 +276,12 @@ opposite(Deg, Adjacent, Divider) -> intersect_vec_plane(PosA, PosB, Plane, Vec) -> %% Return point where Vec through PosA intersects with Plane at PosB case e3d_vec:dot(Vec,Plane) of - 0.0 -> - Intersection = e3d_vec:dot(e3d_vec:sub(PosB, PosA), Plane), - e3d_vec:add(PosB, e3d_vec:mul(Plane, Intersection)); - Dot -> - Intersection = e3d_vec:dot(e3d_vec:sub(PosB, PosA), Plane) / Dot, - e3d_vec:add(PosA, e3d_vec:mul(Vec, Intersection)) + Dot when abs(Dot) < ?EPSILON -> + Intersection = e3d_vec:dot(e3d_vec:sub(PosB, PosA), Plane), + e3d_vec:add(PosB, e3d_vec:mul(Plane, Intersection)); + Dot -> + Intersection = e3d_vec:dot(e3d_vec:sub(PosB, PosA), Plane) / Dot, + e3d_vec:add(PosA, e3d_vec:mul(Vec, Intersection)) end. %% Drag option cut diff --git a/plugins_src/commands/wpc_greebles.erl b/plugins_src/commands/wpc_greebles.erl index 889f0b26..81a0794d 100644 --- a/plugins_src/commands/wpc_greebles.erl +++ b/plugins_src/commands/wpc_greebles.erl @@ -170,11 +170,11 @@ inset(Fs, InsetP, BumpP, State, #we{vp=Vp0}=We) -> end, Vp0, FacesData), We#we{vp=Vp}. -inset_faces(_,{Vpos,_},0.0) -> Vpos; +inset_faces(_,{Vpos,_},+0.0) -> Vpos; inset_faces(SFDist,{Vpos,Dir},Percent) -> e3d_vec:add(Vpos, e3d_vec:mul(Dir, SFDist * Percent)). -bump(Vpos,_,0.0) -> Vpos; +bump(Vpos,_,+0.0) -> Vpos; bump(Vpos,FNorm,Bump)-> e3d_vec:add(Vpos, e3d_vec:mul(FNorm,Bump)). diff --git a/plugins_src/commands/wpc_inset.erl b/plugins_src/commands/wpc_inset.erl index e1c2ec1c..a5f57f9e 100644 --- a/plugins_src/commands/wpc_inset.erl +++ b/plugins_src/commands/wpc_inset.erl @@ -834,26 +834,26 @@ inset_faces_fun(InsetData,State) -> end,A,VData) end. -inset_regions(Vpos,_,_,_,0.0) -> +inset_regions(Vpos,_,_,_,+0.0) -> Vpos; inset_regions(Vpos,_Dir,EDir,{_,along_edges,_},Dist) -> e3d_vec:add(Vpos,e3d_vec:mul(EDir,Dist)); inset_regions(Vpos,Dir,_EDir,{_,average,_},Dist) -> e3d_vec:add(Vpos,e3d_vec:mul(Dir,Dist)). -offset_regions(Vpos,_,0.0) -> +offset_regions(Vpos,_,+0.0) -> Vpos; offset_regions(Vpos,Vec,Dist) -> e3d_vec:add(Vpos,e3d_vec:mul(Vec,Dist)). -bump_regions(Vpos,_,_,_,0.0) -> +bump_regions(Vpos,_,_,_,+0.0) -> Vpos; bump_regions(Vpos,LoopNormal,_,{_,_,loop},Bump) -> e3d_vec:add(Vpos,e3d_vec:mul(LoopNormal,Bump)); bump_regions(Vpos,_,VNorm,{_,_,faces},Bump) -> e3d_vec:add(Vpos,e3d_vec:mul(VNorm,Bump)). -inset_faces(_,_,{Vpos,_},_,0.0) -> +inset_faces(_,_,{Vpos,_},_,+0.0) -> Vpos; inset_faces(SDist,_,{Vpos,Dir},{_,_,relative,_,per_obj},Percent) -> e3d_vec:add(Vpos, e3d_vec:mul(Dir, SDist * Percent)); @@ -864,7 +864,7 @@ inset_faces(_,_,{Vpos,Dir},{_,along_edges,absolute,_,_},Dist) -> inset_faces(_,_,{Vpos,Dir},{_,average,absolute,_,_},Dist) -> e3d_vec:add(Vpos, e3d_vec:mul(Dir, Dist)). -bump(Vpos,_,0.0) -> +bump(Vpos,_,+0.0) -> Vpos; bump(Vpos,FNorm,Bump)-> e3d_vec:add(Vpos, e3d_vec:mul(FNorm,Bump)). diff --git a/plugins_src/commands/wpc_move_planar.erl b/plugins_src/commands/wpc_move_planar.erl index a3d5e35a..490af405 100644 --- a/plugins_src/commands/wpc_move_planar.erl +++ b/plugins_src/commands/wpc_move_planar.erl @@ -190,7 +190,7 @@ planar_fun(VsPos,Axis) -> end. %%%% Planar -planar(Vpos,_Axis,0.0,0.0) -> +planar(Vpos,_Axis,+0.0,+0.0) -> Vpos; planar(Vpos,{X,Y,Z},Dx,Dy) when abs(Y)<1.0e-9 andalso abs(Z)<1.0e-9 -> %% X {Px,Py,Pz} = Vpos, diff --git a/plugins_src/commands/wpc_numeric_camera.erl b/plugins_src/commands/wpc_numeric_camera.erl index b74d7243..5d2aec8b 100644 --- a/plugins_src/commands/wpc_numeric_camera.erl +++ b/plugins_src/commands/wpc_numeric_camera.erl @@ -84,24 +84,24 @@ preview_fun(Qs, OrigView, St) -> end). camera_position({OldView,[CamX,CamY,CamZ, FX,FY,FZ]}, St) -> - AzF = case CamX of - 0.0 -> 1.0; - _ -> -CamX/abs(CamX) - end, - Y2 = case {CamX,CamZ} of - {0.0,0.0} -> {0.0,0.0,1.0}; - _ -> e3d_vec:sub({CamX,0.0,CamZ}, {FX,0.0,FZ}) - end, + AzF = case abs(CamX) < ?EPSILON of + true -> 1.0; + false -> -CamX/abs(CamX) + end, + Y2 = case abs(CamX) < ?EPSILON andalso abs(CamZ) < ?EPSILON of + true -> {0.0,0.0,1.0}; + false -> e3d_vec:sub({CamX,0.0,CamZ}, {FX,0.0,FZ}) + end, Az = AzF * e3d_vec:degrees(Y2, {0.0,0.0,1.0}), - ElF = case CamY of - 0.0 -> 1.0; - _ -> CamY/abs(CamY) - end, + ElF = case abs(CamY) < ?EPSILON of + true -> 1.0; + false -> CamY/abs(CamY) + end, Dist = e3d_vec:sub({CamX,CamY,CamZ}, {FX,FY,FZ}), El = ElF * e3d_vec:degrees(Dist,Y2), D = e3d_vec:len(Dist), NewView = OldView#view{origin={FX,FY,FZ},distance=D,azimuth=Az,elevation=El, - pan_x=0.0,pan_y=0.0}, + pan_x=0.0,pan_y=0.0}, Window = wings_wm:this(), wings_wm:set_prop(Window, current_view, NewView), St. diff --git a/plugins_src/commands/wpc_plane_cut.erl b/plugins_src/commands/wpc_plane_cut.erl index f918d0f1..f1ef447e 100644 --- a/plugins_src/commands/wpc_plane_cut.erl +++ b/plugins_src/commands/wpc_plane_cut.erl @@ -407,7 +407,7 @@ get_point_positions(Pos0, Dist, Axis, N) -> %%% Body mode %%% -intersects({1.0,0.0,0.0}=Plane, {X,_,_}=CutPoint, #we{es=Etab,vp=Vtab}) -> +intersects({1.0,+0.0,+0.0}=Plane, {X,_,_}=CutPoint, #we{es=Etab,vp=Vtab}) -> array:sparse_foldl(fun (Edge, #edge{vs=Va,ve=Vb}, EdgesToCut1) -> {Xa,_,_} = PosA = array:get(Va, Vtab), @@ -424,7 +424,7 @@ intersects({1.0,0.0,0.0}=Plane, {X,_,_}=CutPoint, #we{es=Etab,vp=Vtab}) -> false -> EdgesToCut1 end end, [], Etab); -intersects({0.0,1.0,0.0}=Plane, {_,Y,_}=CutPoint, #we{es=Etab,vp=Vtab}) -> +intersects({+0.0,1.0,+0.0}=Plane, {_,Y,_}=CutPoint, #we{es=Etab,vp=Vtab}) -> array:sparse_foldl(fun (Edge, #edge{vs=Va,ve=Vb}, EdgesToCut1) -> {_,Ya,_} = PosA = array:get(Va, Vtab), @@ -441,7 +441,7 @@ intersects({0.0,1.0,0.0}=Plane, {_,Y,_}=CutPoint, #we{es=Etab,vp=Vtab}) -> false -> EdgesToCut1 end end, [], Etab); -intersects({0.0,0.0,1.0}=Plane, {_,_,Z}=CutPoint, #we{es=Etab,vp=Vtab}) -> +intersects({+0.0,+0.0,1.0}=Plane, {_,_,Z}=CutPoint, #we{es=Etab,vp=Vtab}) -> array:sparse_foldl(fun (Edge, #edge{vs=Va,ve=Vb}, EdgesToCut1) -> {_,_,Za} = PosA = array:get(Va, Vtab), @@ -481,7 +481,7 @@ intersects(Plane, CutPoint, #we{es=Etab,vp=Vtab}) -> %%% Face mode %%% -intersects(Faces, {1.0,0.0,0.0}=Plane, {X,_,_}=CutPoint, #we{es=Etab,vp=Vtab}=We0) -> +intersects(Faces, {1.0,+0.0,+0.0}=Plane, {X,_,_}=CutPoint, #we{es=Etab,vp=Vtab}=We0) -> Edges = wings_face:to_edges(Faces, We0), EdgePos2Cut = foldl(fun(Edge, EdgesToCut1) -> #edge{vs=Va,ve=Vb} = array:get(Edge, Etab), @@ -500,7 +500,7 @@ intersects(Faces, {1.0,0.0,0.0}=Plane, {X,_,_}=CutPoint, #we{es=Etab,vp=Vtab}=We end end, [], Edges), cut_intersecting_edges(Faces, Plane, EdgePos2Cut, We0); -intersects(Faces, {0.0,1.0,0.0}=Plane, {_,Y,_}=CutPoint, #we{es=Etab,vp=Vtab}=We0) -> +intersects(Faces, {+0.0,1.0,+0.0}=Plane, {_,Y,_}=CutPoint, #we{es=Etab,vp=Vtab}=We0) -> Edges = wings_face:to_edges(Faces, We0), EdgePos2Cut = foldl(fun(Edge, EdgesToCut1) -> #edge{vs=Va,ve=Vb} = array:get(Edge, Etab), @@ -519,7 +519,7 @@ intersects(Faces, {0.0,1.0,0.0}=Plane, {_,Y,_}=CutPoint, #we{es=Etab,vp=Vtab}=We end end, [], Edges), cut_intersecting_edges(Faces, Plane, EdgePos2Cut, We0); -intersects(Faces, {0.0,0.0,1.0}=Plane, {_,_,Z}=CutPoint, #we{es=Etab,vp=Vtab}=We0) -> +intersects(Faces, {+0.0,+0.0,1.0}=Plane, {_,_,Z}=CutPoint, #we{es=Etab,vp=Vtab}=We0) -> Edges = wings_face:to_edges(Faces, We0), EdgePos2Cut = foldl(fun(Edge, EdgesToCut1) -> #edge{vs=Va,ve=Vb} = array:get(Edge, Etab), @@ -649,7 +649,7 @@ cut_edges(Es, We0) -> intersect_vec_plane(PosA, PosB, Plane, EdgeVec) -> %% Return point where Vector through PosA intersects with plane at PosB case e3d_vec:dot(EdgeVec,Plane) of - 0.0 -> + Dot when abs(Dot) < ?EPSILON -> Intersection = e3d_vec:dot(e3d_vec:sub(PosB, PosA), Plane), e3d_vec:add(PosB, e3d_vec:mul(Plane, Intersection)); Dot -> diff --git a/plugins_src/commands/wpc_rotate_unconstrained.erl b/plugins_src/commands/wpc_rotate_unconstrained.erl index 39ec2f5f..6ae3edc3 100644 --- a/plugins_src/commands/wpc_rotate_unconstrained.erl +++ b/plugins_src/commands/wpc_rotate_unconstrained.erl @@ -181,7 +181,7 @@ rotate_fun(CamX,CamY,Center,VsInf0,{_,R}=Magnet0,State0) -> % mag %%%% ROTATIONS %%%% (matrix or vector operations) -rotate(Vpos,_CamX,_CamY,_Center,_, 0.0,0.0) -> +rotate(Vpos,_CamX,_CamY,_Center,_, +0.0,+0.0) -> Vpos; rotate(Vpos,CamX,CamY,{Cx,Cy,Cz},_,Dx, Dy) -> % vertex rotation diff --git a/plugins_src/commands/wpc_sculpt.erl b/plugins_src/commands/wpc_sculpt.erl index 616bfb05..5a6b307f 100644 --- a/plugins_src/commands/wpc_sculpt.erl +++ b/plugins_src/commands/wpc_sculpt.erl @@ -671,7 +671,7 @@ constraint_check({X1,Y1,Z1}=OrigPos, {X2,Y2,Z2}=NewPos) -> intersect_vec_plane(PosA, PosB, Plane, Vec) -> %% Return point where Vec through PosA intersects with Plane at PosB case e3d_vec:dot(Vec,Plane) of - 0.0 -> + Dot when abs(Dot) < ?EPSILON -> Intersection = e3d_vec:dot(e3d_vec:sub(PosB, PosA), Plane), e3d_vec:add(PosB, e3d_vec:mul(Plane, Intersection)); Dot -> diff --git a/plugins_src/commands/wpc_shear.erl b/plugins_src/commands/wpc_shear.erl index ed7f52fd..cd8314bd 100644 --- a/plugins_src/commands/wpc_shear.erl +++ b/plugins_src/commands/wpc_shear.erl @@ -308,7 +308,7 @@ shear_verts_by_mode(ShearData,State,Data,VsPositions,Dist,Cf,A) -> end, A, VsPositions). %%%% Main Functions -relative_shear(_ShearData,Vpos, 0.0, _Cf, _Data) -> +relative_shear(_ShearData,Vpos, +0.0, _Cf, _Data) -> Vpos; relative_shear({Sf,Norm,DBbox,Dir,Anchor},Vpos,Dist,Cf,{GlidePlane,_Radial,Origin,_GlidePoint}) -> @@ -316,7 +316,7 @@ relative_shear({Sf,Norm,DBbox,Dir,Anchor},Vpos,Dist,Cf,{GlidePlane,_Radial,Origi {Dist1,Factor} = shear_dist_factor(Cf,Sf,Dir,Anchor,Dist,D), e3d_vec:add(Vpos, e3d_vec:mul(Norm, -Dist1 * DBbox * Factor)). -distance_shear(_ShearData,Vpos, 0.0, _Cf, _Data) -> +distance_shear(_ShearData,Vpos, +0.0, _Cf, _Data) -> Vpos; distance_shear({Sf,Norm,_DBbox,Dir,Anchor},Vpos,Dist,Cf,{GlidePlane,_Radial,Origin,_GlidePoint}) -> @@ -324,7 +324,7 @@ distance_shear({Sf,Norm,_DBbox,Dir,Anchor},Vpos,Dist,Cf,{GlidePlane,_Radial,Orig {Dist1,Factor} = shear_dist_factor(Cf,Sf,Dir,Anchor,Dist,D), e3d_vec:add(Vpos, e3d_vec:mul(Norm, -Dist1 * Factor)). -angle_shear(_ShearData,Vpos, 0.0, _Cf, _Data) -> +angle_shear(_ShearData,Vpos, +0.0, _Cf, _Data) -> Vpos; angle_shear({Sf,Norm,_DBbox,Dir,Anchor},Vpos,Dist,Cf,{GlidePlane,Radial,Origin,GlidePoint}) -> @@ -345,10 +345,10 @@ angle_shear({Sf,Norm,_DBbox,Dir,Anchor},Vpos,Dist,Cf,{GlidePlane,Radial,Origin,G Ln1 = e3d_vec:norm(Ln0), Dp1 = e3d_vec:dot(Ln1,Pn1), - Pos1 = case Dp1 of - 0.0 -> Vpos; - _ -> Int1 = e3d_vec:dot(e3d_vec:sub(GlidePoint,Pos),Pn1)/Dp1, - e3d_vec:add(Pos, e3d_vec:mul(Ln1, Int1)) + Pos1 = case abs(Dp1) < ?EPSILON of + true -> Vpos; + false -> Int1 = e3d_vec:dot(e3d_vec:sub(GlidePoint,Pos),Pn1)/Dp1, + e3d_vec:add(Pos, e3d_vec:mul(Ln1, Int1)) end, NewDist = dist_along_vector(GlidePoint,Pos1,Norm), diff --git a/plugins_src/commands/wpc_shift.erl b/plugins_src/commands/wpc_shift.erl index c893099e..1fd98c32 100644 --- a/plugins_src/commands/wpc_shift.erl +++ b/plugins_src/commands/wpc_shift.erl @@ -152,7 +152,7 @@ object_vector(CenterPoint, ObjCenter) -> %% The return value is the new position. {X,Y,Z} %% -shift_planar(Pos, 0.0, _) -> Pos; +shift_planar(Pos, +0.0, _) -> Pos; shift_planar(Pos, Dist, {Axis, Center}) -> V = e3d_vec:sub(Pos,Center), D = e3d_vec:dot(V,Axis), @@ -179,7 +179,7 @@ shift_planar(Pos, Dist, {object, Axis, V}) -> Pos end. -shift_cylindrical(Pos, 0.0, _) -> Pos; +shift_cylindrical(Pos, +0.0, _) -> Pos; shift_cylindrical(Pos, Dist, {Axis, Center}) -> V = e3d_vec:sub(Pos,Center), OffDist = e3d_vec:dot(V,Axis), @@ -192,7 +192,7 @@ shift_cylindrical(Pos, Dist, {object, Axis, V}) -> N = e3d_vec:norm(OffVec), e3d_vec:add([Pos, e3d_vec:mul(N, Dist)]). -shift_spherical(Pos, 0.0, _Center) -> Pos; +shift_spherical(Pos, +0.0, _Center) -> Pos; shift_spherical(Pos, Dist, {object, V}) -> N = e3d_vec:norm(V), e3d_vec:add([Pos, e3d_vec:mul(N, Dist)]); diff --git a/plugins_src/commands/wpc_sweep_extrude.erl b/plugins_src/commands/wpc_sweep_extrude.erl index ea9d848b..3fb8a8b0 100644 --- a/plugins_src/commands/wpc_sweep_extrude.erl +++ b/plugins_src/commands/wpc_sweep_extrude.erl @@ -211,7 +211,7 @@ average_face_norm(Fs0, We, Mir0, TouchingMir, Normals) -> case gb_sets:is_empty(Fs0) of true -> case e3d_vec:norm(e3d_vec:add(Normals)) of - {0.0,0.0,0.0} -> sweep_error(); + {+0.0,+0.0,+0.0} -> sweep_error(); Norm -> Norm end; false -> @@ -419,17 +419,17 @@ sweep(Type, Base, VsData, DragData, A) -> end,A,VsData). %%%% Main functions -extruded_face(_,Vpos,_,{0.0,0.0,0.0,0.0}) -> +extruded_face(_,Vpos,_,{+0.0,+0.0,+0.0,+0.0}) -> Vpos; -extruded_face(Type, Vpos,VData,{Angle,Dist,0.0,0.0}) -> +extruded_face(Type, Vpos,VData,{Angle,Dist,+0.0,+0.0}) -> out_and_side_to_side(Type, Vpos,VData,Angle,Dist); -extruded_face(Type, Vpos, {_,{_N,C}}=VData, {Angle,Dist,0.0,Scale}) -> +extruded_face(Type, Vpos, {_,{_N,C}}=VData, {Angle,Dist,+0.0,Scale}) -> ScPos = scale_extruded_section(Vpos,C,Scale), out_and_side_to_side(Type, ScPos, VData,Angle,Dist); -extruded_face(Type, Vpos, {{_,_,LNorm,_,_,_},{_,C}}=VData, {Angle,Dist,Rotate,0.0}) -> +extruded_face(Type, Vpos, {{_,_,LNorm,_,_,_},{_,C}}=VData, {Angle,Dist,Rotate,+0.0}) -> RPos = rotate(Vpos,LNorm,C,Rotate), out_and_side_to_side(Type, RPos,VData,Angle,Dist); @@ -464,7 +464,7 @@ scale_extruded_section(Vpos,Center,Scale) -> DistCntr = e3d_vec:len(ScaleVec0), e3d_vec:add(Vpos, e3d_vec:mul(ScaleVec, Scale*DistCntr)). -seed_face(_,Vpos,_,{0.0,_Dist,_Rotate,_Scale}) -> +seed_face(_,Vpos,_,{+0.0,_Dist,_Rotate,_Scale}) -> Vpos; seed_face(freeze_base,Vpos,_,_) -> Vpos; @@ -477,10 +477,10 @@ seed_face(_,Vpos,{{_,_,LoopNorm,_,_,Axis},{Norm,Center}},{Angle,_Dist,_Rotate,_S Pn0 = e3d_vec:sub(D,Vpos), Ln0 = e3d_vec:norm_sub(Vp,D), Dp = e3d_vec:dot(Ln0,Pn0), - case Dp of - 0.0 -> Vpos; - _ -> Int = e3d_vec:dot(e3d_vec:sub(Vpos,Vp),Pn0)/Dp, - e3d_vec:add(Vp, e3d_vec:mul(Ln0, Int)) + case abs(Dp) < ?EPSILON of + true -> Vpos; + false -> Int = e3d_vec:dot(e3d_vec:sub(Vpos,Vp),Pn0)/Dp, + e3d_vec:add(Vp, e3d_vec:mul(Ln0, Int)) end; false -> Vpos diff --git a/plugins_src/import_export/Makefile b/plugins_src/import_export/Makefile index b052ee8c..0eadd3bb 100644 --- a/plugins_src/import_export/Makefile +++ b/plugins_src/import_export/Makefile @@ -63,7 +63,7 @@ TARGET_FILES= $(MODULES:%=$(EBIN)/%.beam) # ---------------------------------------------------- # FLAGS # ---------------------------------------------------- -ERL_COMPILE_FLAGS += +nowarn_match_float_zero -Werror -pa $(WINGS_INTL) \ +ERL_COMPILE_FLAGS += -Werror -pa $(WINGS_INTL) \ -I $(WINGS_TOP) $(TYPE_FLAGS) +debug_info # ---------------------------------------------------- diff --git a/plugins_src/import_export/collada_import.erl b/plugins_src/import_export/collada_import.erl index a4717ef4..79b46c1f 100644 --- a/plugins_src/import_export/collada_import.erl +++ b/plugins_src/import_export/collada_import.erl @@ -833,12 +833,12 @@ renumber_face([#e3d_face{vs=Vs0, vc=Vc0, tx=Tx0, ns=Ns0}=F0|Fs], NVs, NVc, NTx, renumber_face([], _NVs, _NVc, _NTx, _NNs, Acc) -> Acc. -make_matrix({rotate, [_,_,_,0.0]}, M) -> +make_matrix({rotate, [_,_,_,+0.0]}, M) -> M; make_matrix({rotate, [X,Y,Z,Rad]}, M) -> Deg = Rad*180.0/math:pi(), e3d_mat:mul(e3d_mat:rotate(Deg, {X,Y,Z}), M); -make_matrix({translate, [0.0,0.0,0.0]}, M) -> +make_matrix({translate, [+0.0,+0.0,+0.0]}, M) -> M; make_matrix({translate, [X,Y,Z]}, M) -> e3d_mat:mul(e3d_mat:translate(X,Y,Z), M); diff --git a/plugins_src/import_export/wpc_gltf.erl b/plugins_src/import_export/wpc_gltf.erl index 22949387..2d8cff97 100644 --- a/plugins_src/import_export/wpc_gltf.erl +++ b/plugins_src/import_export/wpc_gltf.erl @@ -830,7 +830,7 @@ make_matrix(Key, Node) -> case Key of translation -> e3d_mat:translate(X,Y,Z); scale -> e3d_mat:scale(X,Y,Z); - rotation when T =:= [0.0] -> e3d_mat:identity(); + rotation when T =:= [+0.0] -> e3d_mat:identity(); rotation -> e3d_q:to_rotation_matrix({{X,Y,Z},hd(T)}) end end. diff --git a/plugins_src/import_export/wpc_hlines.erl b/plugins_src/import_export/wpc_hlines.erl index 53f69c48..d05a2b15 100755 --- a/plugins_src/import_export/wpc_hlines.erl +++ b/plugins_src/import_export/wpc_hlines.erl @@ -3071,7 +3071,7 @@ bspt__to_list(Bspt) -> sign(V) when V > 0.0 -> 1.0; sign(V) when V < 0.0 -> -1.0; -sign(V) when V =:= 0.0 -> 0.0. +sign(_V) -> 0.0. is_convex(FVCs, _Is_FF) when length(FVCs) =:= 3 -> true; is_convex([FVC1 | T], Is_FF) -> diff --git a/plugins_src/import_export/wpc_kerky.erl b/plugins_src/import_export/wpc_kerky.erl index 82456315..8e7e056b 100644 --- a/plugins_src/import_export/wpc_kerky.erl +++ b/plugins_src/import_export/wpc_kerky.erl @@ -1988,7 +1988,8 @@ all_zero([])-> true; all_zero([InVal | InList]) when is_list(InList)-> case InVal of - 0.0 -> all_zero(InList); + +0.0 -> all_zero(InList); + -0.0 -> all_zero(InList); 0 -> all_zero(InList); _ -> false end. diff --git a/plugins_src/import_export/wpc_pov.erl b/plugins_src/import_export/wpc_pov.erl index 76febab5..6ab80d62 100644 --- a/plugins_src/import_export/wpc_pov.erl +++ b/plugins_src/import_export/wpc_pov.erl @@ -548,8 +548,8 @@ export_camera(F, Attr, CorrectedFOV, Width, Height) -> io:format(F, "\t angle ~f\n", [Fov]), io:format(F, "\t sky <~f, ~f, ~f>\n", [Ux, Uy, Uz]), io:format(F, "\t look_at <~f, ~f, ~f>\n", [Px + Dx, Py + Dy, Pz + Dz]), - case proplists:get_value(aperture, Attr, 0.0) of - 0.0 -> ok; + case proplists:get_value(aperture, Attr, +0.0) of + +0.0 -> ok; _ -> io:format(F, "\t aperture ~f\n", [proplists:get_value(aperture, Attr, 0.0)]), io:format(F, "\t blur_samples ~p\n", [proplists:get_value(blur_samples, Attr, 1)]), @@ -873,8 +873,8 @@ export_gamma_macro(F, false) -> ambient_multiplier() -> {Ar, Ag, Ab} = get_pref(ambient, {0.0, 0.0, 0.0}), Ap0 = get_pref(ambient_power, 1.0), - case Ar * Ag * Ab * Ap0 of - 0.0 -> 1.0; + case abs(Ar * Ag * Ab * Ap0) < ?EPSILON of + true -> 1.0; _ -> {Apr, Apg, Apb} = {Ar * Ap0, Ag * Ap0, Ab * Ap0}, Ap1 = min(Apr, min(Apg, Apb)), @@ -1017,23 +1017,23 @@ export_finish(F, OpenGL, PovRay) -> {_H, _S, V} = wings_color:rgb_to_hsv(Sr, Sg, Sb), io:format(F, "\t\t specular ~f\n", [V]), io:format(F, "\t\t roughness ~f\n", [1.00001 - proplists:get_value(shininess, OpenGL, 1.0)]), - case proplists:get_value(finish_phong, PovRay, 0.0) of - 0.0 -> ok; + case proplists:get_value(finish_phong, PovRay, +0.0) of + +0.0 -> ok; Phong -> io:format(F, "\t\t phong ~f\n", [Phong]), io:format(F, "\t\t phong_size ~f\n", [proplists:get_value(finish_phong_size, PovRay, 40.0)]) end, - case proplists:get_value(finish_irid_amount, PovRay, 0.0) of - 0.0 -> ok; + case proplists:get_value(finish_irid_amount, PovRay, +0.0) of + +0.0 -> ok; Amount -> io:format(F, "\t\t irid { ~f\n", [Amount]), io:format(F, "\t\t\t thickness ~f\n", [proplists:get_value(finish_irid_thickness, PovRay, 0.2)]), io:format(F, "\t\t\t turbulence ~f\n", [proplists:get_value(finish_irid_turbulence, PovRay, 0.15)]), io:put_chars(F, "\t\t }\n") end, - SSLTMul = proplists:get_value(finish_sslt_multiplier, PovRay, 0.0), + SSLTMul = proplists:get_value(finish_sslt_multiplier, PovRay, +0.0), case {get_pref(sslt, false), SSLTMul} of - {_, 0.0} -> ok; + {_, +0.0} -> ok; {true, SSLTMul} -> {Tr, Tg, Tb} = proplists:get_value(finish_sslt_color, PovRay, {1.0, 1.0, 1.0}), io:put_chars(F, "\t\t subsurface { \n"), @@ -1751,7 +1751,7 @@ export_dialog(Op) -> _ -> ok end; aperture -> - wings_dialog:enable(pnl_blur, Value =/= 0.0, Store); + wings_dialog:enable(pnl_blur, abs(Value) > ?EPSILON, Store); _ -> ok end end, diff --git a/plugins_src/import_export/wpc_svg_path.erl b/plugins_src/import_export/wpc_svg_path.erl index f56ab928..11e93334 100644 --- a/plugins_src/import_export/wpc_svg_path.erl +++ b/plugins_src/import_export/wpc_svg_path.erl @@ -3426,7 +3426,7 @@ subst_str_to_bool(Str) -> end. arc_path(RX, RY, _Rotation, _LargeArcFlag, _SweepFlag, _P1, {X,Y}) - when abs(RX) =:= 0.0; abs(RY) =:= 0.0 -> + when abs(RX) < ?EPSILON; abs(RY) < ?EPSILON -> %% If rx = 0 or ry = 0, we just make a line [{X,Y}]; arc_path(RX, RY, Rotation, LargeArc, Sweep, P1, P2) -> @@ -3536,7 +3536,7 @@ get_radius_to_range_ratio({X1, Y1}, {X2, Y2}, {XR_1, YR_1}, Angle) -> -spec arc_path_cmd({float(), float()}, {float(),float()}, {float(),float()}, float(), boolean(), boolean()) -> any(). arc_path_cmd(ArcFromPoint, ArcToPoint, {XR_0,YR_0}, Angle_0, LargeArc, Sweep) - when is_float(YR_0), YR_0 =/= 0.0 -> + when is_float(YR_0), abs(YR_0) > ?EPSILON -> %% By making ellipses of the same radius and angle at the start and end point of %% the segment, we get two intersection points. At those two intersection points %% are the center of the two possible ellipses that can draw an arc for our arc path. diff --git a/plugins_src/import_export/wpc_wrl.erl b/plugins_src/import_export/wpc_wrl.erl index 429e34e1..020cc15d 100644 --- a/plugins_src/import_export/wpc_wrl.erl +++ b/plugins_src/import_export/wpc_wrl.erl @@ -321,7 +321,7 @@ def_material(Output, Name, Mat0, Dir) -> {Sr, Sg, Sb, _} = lookup(specular, Mat), Output(5, {tag_attr_vec3, "specularColor", {Sr, Sg, Sb}, true}), case (Ar+Ag+Ab)/3 of - 0.0 -> + Amb0 when abs(Amb0) < ?EPSILON -> Amb = 1.0, %% wrml needs a non zero value for ambient intensity O = 0.0; Amb0 -> diff --git a/plugins_src/import_export/wpc_yafaray.erl b/plugins_src/import_export/wpc_yafaray.erl index a36e79a2..ec4ae5a8 100644 --- a/plugins_src/import_export/wpc_yafaray.erl +++ b/plugins_src/import_export/wpc_yafaray.erl @@ -2362,16 +2362,16 @@ export_dialog_qs(Op, Attr) -> aperture -> {Value0,_} = f_stop_find(Value,ApertureList), wings_dialog:set_value(aperture_idx, Value0, Store), - wings_dialog:enable(bokeh_use_QMC, Value =/= 0.0, Store), - wings_dialog:enable(?KEY(pnl_dof_type), Value =/= 0.0, Store), - wings_dialog:enable(?KEY(pnl_dof_sliders), Value =/= 0.0, Store); + wings_dialog:enable(bokeh_use_QMC, Value =/= +0.0, Store), + wings_dialog:enable(?KEY(pnl_dof_type), Value =/= +0.0, Store), + wings_dialog:enable(?KEY(pnl_dof_sliders), Value =/= +0.0, Store); aperture_idx -> if ((Value =/= "") and (Value =/= Custom)) -> {_,Value0} = f_stop_find(Value,ApertureList), wings_dialog:set_value(aperture, Value0, Store); true -> ok end, - Enabled = wings_dialog:get_value(aperture, Store) =/= 0.0, + Enabled = wings_dialog:get_value(aperture, Store) =/= +0.0, wings_dialog:enable(bokeh_use_QMC, Enabled, Store), wings_dialog:enable(?KEY(pnl_dof_type), Enabled, Store), wings_dialog:enable(?KEY(pnl_dof_sliders), Enabled, Store); @@ -4297,36 +4297,36 @@ export_modulator(F, Texname0, Maps, {modulator,Ps}, _Opacity) when is_list(Ps) - TextureShaderType = case {Normal,TextureType,AlphaIntensity} of - {0.0,diffusetexture,off} -> " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " format_decimals(F) when is_float(F), F >= 0.0 -> format_decimals_1(F). -format_decimals_1(0.0) -> +format_decimals_1(+0.0) -> ".0"; format_decimals_1(F) when is_float(F) -> G = 10.0 * F, @@ -5990,7 +5990,7 @@ format_decimals_1(F) when is_float(F) -> D = G - float(I), [$.,(I+$0)|format_decimals_2(D)]. -format_decimals_2(0.0) -> +format_decimals_2(+0.0) -> []; format_decimals_2(F) when is_float(F) -> G = 100.0 * F, @@ -6002,7 +6002,7 @@ format_decimals_2(F) when is_float(F) -> [integer_to_list(I)|format_decimals_3(D)] end. -format_decimals_3(0.0) -> +format_decimals_3(+0.0) -> []; format_decimals_3(F) when is_float(F) -> G = 1000.0 * F, @@ -6016,7 +6016,7 @@ format_decimals_3(F) when is_float(F) -> [integer_to_list(I)|format_decimals_4(D)] end. -format_decimals_4(0.0) -> +format_decimals_4(+0.0) -> []; format_decimals_4(F) when is_float(F) -> G = 10000.0 * F, diff --git a/plugins_src/import_export/x3d_import.erl b/plugins_src/import_export/x3d_import.erl index 7df6a2b8..609ec9c1 100644 --- a/plugins_src/import_export/x3d_import.erl +++ b/plugins_src/import_export/x3d_import.erl @@ -3682,7 +3682,7 @@ mat_from_axises(Axises, Mat_0) -> % build_mat_from_axis(XAxis, {1.0, 0.0, 0.0}, % build_mat_from_axis(ZAxis, {0.0, 0.0, 1.0}, Mat_0))), Mat. -build_mat_from_axis({X,Y,Z}=_AxisV, _WasAxis, Mat_0) when X+Y+Z =:= 0.0 -> +build_mat_from_axis({X,Y,Z}=_AxisV, _WasAxis, Mat_0) when abs(X+Y+Z) < ?EPSILON -> Mat_0; build_mat_from_axis(AxisV, WasAxis, Mat_0) -> Mat = e3d_mat:mul(Mat_0, e3d_mat:rotate_s_to_t(WasAxis, AxisV)), @@ -3783,7 +3783,7 @@ scale_children([#shape_piece{geometry=Geometry}=Shape_0 | L], {XS, YS, ZS}, O) - }, scale_children(L, {XS, YS, ZS}, [Shape_1 | O]). -rotate_children(Shapes, {0.0, 0.0, 1.0, 0.0}) -> Shapes; +rotate_children(Shapes, {+0.0, +0.0, 1.0, +0.0}) -> Shapes; rotate_children(Shapes, {RA, RB, RC, RAng}) -> rotate_children(Shapes, {RA, RB, RC, RAng}, []). rotate_children([], _, O) -> @@ -3794,7 +3794,7 @@ rotate_children([#shape_piece{geometry=Geometry}=Shape_0 | L], {RA, RB, RC, RAng }, rotate_children(L, {RA, RB, RC, RAng}, [Shape_1 | O]). -translate_children(Shapes, {0.0, 0.0, 0.0}) -> Shapes; +translate_children(Shapes, {+0.0, +0.0, +0.0}) -> Shapes; translate_children(Shapes, {TX, TY, TZ}) -> translate_children(Shapes, {TX, TY, TZ}, []). translate_children([], _, O) -> @@ -3811,14 +3811,14 @@ scale_geometry({XS, YS, ZS}, #geometry{coords=Coords}=Geometry) -> coords=[{X*XS, Y*YS, Z*ZS} || {X, Y, Z} <- Coords] }. -rotate_geometry({0.0, 0.0, 1.0, 0.0}, Geometry) -> Geometry; +rotate_geometry({+0.0, +0.0, 1.0, +0.0}, Geometry) -> Geometry; rotate_geometry(RotateTup, #geometry{coords=Coords}=Geometry) -> Mat = rotate_mat(RotateTup), Geometry#geometry{ coords=[mul_point(Mat, {X, Y, Z}) || {X, Y, Z} <- Coords] }. -translate_geometry({0.0, 0.0, 0.0}, Geometry) -> Geometry; +translate_geometry({+0.0, +0.0, +0.0}, Geometry) -> Geometry; translate_geometry({TX, TY, TZ}, #geometry{coords=Coords}=Geometry) -> Geometry#geometry{ coords=[{X+TX, Y+TY, Z+TZ} || {X, Y, Z} <- Coords] diff --git a/plugins_src/primitives/Makefile b/plugins_src/primitives/Makefile index 1f4a7877..e488f88c 100644 --- a/plugins_src/primitives/Makefile +++ b/plugins_src/primitives/Makefile @@ -46,7 +46,7 @@ TARGET_FILES= $(MODULES:%=$(EBIN)/%.beam) # ---------------------------------------------------- # FLAGS # ---------------------------------------------------- -ERL_COMPILE_FLAGS += -Werror +nowarn_match_float_zero -I $(WINGS_TOP) \ +ERL_COMPILE_FLAGS += -Werror -I $(WINGS_TOP) \ $(TYPE_FLAGS) -pa $(WINGS_INTL) +debug_info # ---------------------------------------------------- diff --git a/plugins_src/primitives/wpc_oblong.erl b/plugins_src/primitives/wpc_oblong.erl index 0c5d78a6..2f80efd2 100644 --- a/plugins_src/primitives/wpc_oblong.erl +++ b/plugins_src/primitives/wpc_oblong.erl @@ -190,9 +190,9 @@ make_outer_contour(Width, Height0, Bevel0, HeightSec, BevelSec) -> end, BVs, lists:seq(trunc((HeightSec+1)/2),1,-1)); true -> YSeg = Height0/(HeightSec+1), - Vs = lists:foldl(fun(_I, [{0.0,Y,Z}|_]=Acc) -> - [{0.0,Y-YSeg,Z}|Acc] - end, [{0.0,YTop,ZRig}], lists:seq(1,trunc((HeightSec+1)/2))) + Vs = lists:foldl(fun(_I, [{+0.0,Y,Z}|_]=Acc) -> + [{+0.0,Y-YSeg,Z}|Acc] + end, [{+0.0,YTop,ZRig}], lists:seq(1,trunc((HeightSec+1)/2))) end, if (HeightSec rem 2) == 0 -> Vs1 = Vs; true ->