public void Deform(Vector3 impactVector, Vector3 simplifiedVector)
    {
        Deform_local(impactVector, simplifiedVector, mFilter.sharedMesh);
        ThreadTools.WaitForThreads(ref threads);
        threads.Clear();

        mFilter.sharedMesh.vertices = thread_vertices;
        mFilter.sharedMesh.RecalculateBounds();

        Deform_local(impactVector, simplifiedVector, simplifiedMesh);
        ThreadTools.WaitForThreads(ref threads);
        threads.Clear();

        simplifiedMesh.vertices = thread_vertices;
        UpdateMeshCollider();
    }
Beispiel #2
0
    public void Deform(int meshIndex)
    {
        if (meshIndex > bMeshes.Length - 1)
        {
            return;
        }

        thread_pts = new Vector3[bMeshes[meshIndex].origVerts.Length];

        BendParameters bp = new BendParameters();

        bp.N       = ts_transform.TransformDirection(1, 0, 0);
        bp.BiN     = ts_transform.TransformDirection(0, 0, -1);
        bp.T       = ts_transform.TransformDirection(0, 1, 0);
        bp.bendEnd = ts_targetTransform.TransformPoint(0, length, 0);

        int start = (direction) ? 0 : bMeshes[meshIndex].seperatingIndex;
        int end   = (direction) ? bMeshes[meshIndex].seperatingIndex : bMeshes[meshIndex].origVerts.Length;

        for (int i = start; i < end; i += maxWorkGroupSize)
        {
            int workgroupSize = (i + maxWorkGroupSize < bMeshes[meshIndex].origVerts.Length) ? maxWorkGroupSize : bMeshes[meshIndex].origVerts.Length - i;
            threads.Add(StartThread(i, i + workgroupSize, ts_transform, ts_targetTransform, bp, meshIndex));
        }

        start = (direction) ? bMeshes[meshIndex].seperatingIndex : 0;
        end   = (direction) ? bMeshes[meshIndex].origVerts.Length : bMeshes[meshIndex].seperatingIndex;

        for (int i = start; i < end; i++)
        {
            thread_pts[i] = bMeshes[meshIndex].origVerts[i];
        }

        ThreadTools.WaitForThreads(ref threads);
        bMeshes[meshIndex].mesh.vertices = thread_pts;
    }