Exemplo n.º 1
0
    static void Process(SAMeshCollider meshCollider)
    {
        if (meshCollider == null)
        {
            Debug.LogError("");
            return;
        }

        Cleanup(meshCollider);

        MeshCache meshCache = null;

        if (meshCollider.splitMode == SplitMode.None ||
            meshCollider.splitMode == SplitMode.Material ||
            meshCollider.splitMode == SplitMode.Primitive)
        {
            meshCache = SAMeshColliderEditorCommon.GetParentMeshCache(meshCollider);

            if (meshCache == null)
            {
                Debug.LogError("Mesh not found:" + meshCollider.name);
                return;
            }
        }

        List <ReducerTask> reducerTasks = new List <ReducerTask>();

        switch (meshCollider.splitMode)
        {
        case SplitMode.None:
            ProcessRoot(reducerTasks, meshCache, meshCollider);
            break;

        case SplitMode.Material:
            ProcessMaterial(reducerTasks, meshCache, meshCollider);
            break;

        case SplitMode.Primitive:
            ProcessPrimitive(reducerTasks, meshCache, meshCollider);
            break;

        case SplitMode.Polygon:
            ProcessPolygon(reducerTasks, meshCollider);
            break;
        }

        SAMeshColliderEditorCommon.Reduce(reducerTasks, meshCollider.isDebug);
    }