Search Unity

Removing Duplicate Polygons at Runtime

Discussion in 'Scripting' started by QuantumCD, Mar 29, 2013.

  1. QuantumCD

    QuantumCD

    Joined:
    Dec 15, 2012
    Posts:
    10
    In my project I have a substantially large, dynamic mesh that will potentially have thousands of faces that could be removed. As a result, I'm looking to detect faces that occupy the same space or nearly the same space and delete them. Initially, I treated the problem in such a way where faces are representative of Vectors--the same way you might detect a duplicate vertex. Apparently after doing some more research into working with faces in Unity, they are integer arrays built up of 3 vertices. This makes the problem much tougher to approach. Currently, before making this realization, I had all the faces in a List and was going to search for duplicates and upon encountering them, delete both of them.

    What would be the best way to go about removing all these duplicate faces? Is there perhaps a feature of the Unity API I'm overlooking? Thanks for any help.
     
  2. Flavelius

    Flavelius

    Joined:
    Jul 8, 2012
    Posts:
    945
    Sorry to be somewhat off topic, but this looks like something you might not want to do realtime, as i think it will be quite resource heavy with thousands of faces.
    Either remove these in the modelling app or if you build the model during runtime, make sure you're not drawing faces twice in the first place.
    Also, as far as i remember even Blender can not remove duplicate faces, only vertices
     
  3. QuantumCD

    QuantumCD

    Joined:
    Dec 15, 2012
    Posts:
    10
    Performance really isn't that much of an issue. If there is an algorithm that exists, it can wait. The optimization will probably be done on a dedicated server machine anyway, so unless it will take 5 minutes for a thousand faces or so, I think the performance aspect is negligible. However, with all algorithms, speed is always appreciated.