- Home /
Grouping vertices?
Hey everyone. I have a model that, when in Max has only 1,002 vertices. When exported into Unity, it has 5,722. This is (from what I've researched) due to the vertices requiring multiple normal-facing directions to allow it to render hard edges and flat faces (exported intentionally without any smoothing groups).
Basically what I've written so far shoots a raycast from the mouse position to the mesh, and from the hit point, gathers the closest, say 80 verts. It then iterates through all the verts and grabs any that share the exact position of the chosen 80. All these verts are then stored in a different array and operated on.
What I'd like to know is if there is any way to group all shared vertices in something simple so I can simply reference them all at once? Ideally, something like a hash-table that stores multiple values per key. All I can think of so far is creating a 2D array to store their int position in the main vertices array, but that would still require iterating through the entire thing to find what group a vert belongs to. Any ideas?
I probably should have mentioned that I need 1,002 'containers' (one for each of the original vertices) to store the between 4 and 6 values each. I tried creating a list of lists to iterate through, however it gave the profiler a stroke using the List.Contains method so frequently. I avoided trying the old JS arrays since apparently they should be forgotten altogether. I also tried multidimensional arrays - [ , ], however each array needs to have a size between 4 and 6, so they need to be more like jagged arrays, which seem practically impossible to initialize in JS, at least the way I need them. The way it is currently set up works decently enough, it's just a little too CPU-heavy.
Answer by seth_slax · Sep 25, 2015 at 09:11 AM
So it seems like (strangely enough) the most efficient way is to just not group vertices and iterate through them every time. I've tried practically everything that I could find (lists of lists, multidimensional arrays, jagged arrays, arrays of arrays), but none of these options run anywhere near as fast according to the profiler.
Your answer
Follow this Question
Related Questions
Alternative Ways of Finding Vertices 2 Answers
mask one gameObject mesh by another mesh vertex transparency 1 Answer
Mirror vertices procedurally 2 Answers