Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 
Share Thread:
Reddit Facebook Twitter
Want to finalize a new wings_we:build for colors.
10-22-2014, 08:53 PM
Post: #2
RE: Want to finalize a new wings_we:build for colors.
considering you only need extract the vertex index from VPos, why not use array:fold instead of to convert the array to a lists which from the tuple element you want get the index?
Code:
...
MyAcc = fun(Vi, _Value, We) ->
    wings_va:set_vertex_color(gb_sets:singleton(Vi), lists:nth(Vi+1,Vc) , Acc)
end,

We1 = array:foldl(MyAcc, We, VPos)
...
Considering the use of the API by the wings3d itself I think that use wings_va is the right way to avoid problems with any change made to vertex color attribute.

If the implementation is made in a importer I think it's possible to improve it a little by removing a intermediate function call - the parameters are copied once less: (that makes sense?! Undecided)
Code:
...
    #we{vp=VPos} = We = wings_we_build:we(Fs, Vs, He),
    MyAcc = fun(Vi, _Value, #we{lv=Lva0,rv=Rva0} = We0) ->
        {Lva,Rva} = wings_vertex:fold(
                fun(Edge, _Face, Rec0, {Lv,Rv}) ->
                  case Rec0 of
                      #edge{vs=Vi} ->
                      {set_color(Edge, Color, Lv),Rv};
                      #edge{ve=Vi} ->
                      {Lv,set_color(Edge, Color, Rv)}
                  end,
                end, {Lva0,Rva0}, Vi, We),
        We0#we{lv=Lva,rv=Rva}
    end,
    We1 = array:foldl(MyAcc, We, VPos),
...
it came from wings_va:set_vertex_color_1. maybe you could test it.

@MicheusVieira MicheusVieira Micheuss micheus4wings3d
* Wings3D Team stands for: Björn and Dan
Reply


Messages In This Thread
RE: Want to finalize a new wings_we:build for colors. - micheus - 10-22-2014 08:53 PM

Forum Jump:


User(s) browsing this thread: 1 Guest(s)