• Website
  • Search
  • Member List
  • Help
  • Old Forum
  • Social Media
    •   @Wings3dOfficial
    •   @Wings3dOfficial
    •   Wings3dOfficial
    •   Wings3dOfficial
  • Register
  • Login
  • Website
  • Search
  • Member List
  • Help
  • Old Forum
  • Register
  • Login
Wings 3D Development Forum Wings 3D Design & Development v
« Previous 1 … 6 7 8 9 10 11 Next »
Want to finalize a new wings_we:build for colors.

 
  • 0 Vote(s) - 0 Average
Want to finalize a new wings_we:build for colors.

micheus
Offline

Forum's Admin and Support | Bug fixer
Posts: 3,676
Threads: 183
Joined: Jun 2012
#2
10-22-2014, 08:53 PM
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_vaConfusedet_vertex_color_1. maybe you could test it.
[Image: tw.png] @MicheusVieira [Image: yt.png] @MicheusVieira [Image: da.png] Micheuss [Image: ig.png] micheus4wings3d
* Wings3D Team stands for: Björn and Dan
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)



Messages In This Thread
Want to finalize a new wings_we:build for colors. - by ggaliens - 10-22-2014, 05:29 PM
RE: Want to finalize a new wings_we:build for colors. - by micheus - 10-22-2014, 08:53 PM
RE: Want to finalize a new wings_we:build for colors. - by ggaliens - 10-22-2014, 11:25 PM
RE: Want to finalize a new wings_we:build for colors. - by micheus - 10-22-2014, 11:43 PM
RE: Want to finalize a new wings_we:build for colors. - by micheus - 10-25-2014, 07:24 AM
RE: Want to finalize a new wings_we:build for colors. - by ggaliens - 10-26-2014, 12:27 AM
RE: Want to finalize a new wings_we:build for colors. - by ggaliens - 10-27-2014, 02:29 PM
RE: Want to finalize a new wings_we:build for colors. - by micheus - 10-27-2014, 04:08 PM
RE: Want to finalize a new wings_we:build for colors. - by ggaliens - 10-27-2014, 05:59 PM
RE: Want to finalize a new wings_we:build for colors. - by micheus - 10-27-2014, 11:22 PM

  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Designed by D&D - Powered by MyBB

Linear Mode
Threaded Mode